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
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/TableUtil.java
// Path: src/main/java/com/chncwang/easy2db/table/TableDef.java // public class TableDef { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyDef mPrimaryKeyDef; // private final ColumnDef mUniqueKeyDef; // private final List<ForeignKeyDef> mForeignKeyDefs; // private final List<ColumnDef> mColumnDefs; // // public TableDef(final Class<?> clazz, final String tableName, // final PrimaryKeyDef primaryKeyDef, // final ColumnDef uniqueKeyDef, // final List<ForeignKeyDef> foreignKeyDefs, // final List<ColumnDef> columnDefs) { // PreconditionsUtil.checkNotNull(tableName, "tableName"); // PreconditionsUtil.checkNotNull(primaryKeyDef, "primaryKeyDef"); // PreconditionsUtil.checkNotNull(uniqueKeyDef, "uniqueKeyDef"); // // mClass = clazz; // mTableName = tableName; // mPrimaryKeyDef = primaryKeyDef; // mUniqueKeyDef = uniqueKeyDef; // mForeignKeyDefs = Collections.unmodifiableList(foreignKeyDefs); // mColumnDefs = Collections.unmodifiableList(columnDefs); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public ColumnDef getUniqueKeyDef() { // return mUniqueKeyDef; // } // // public List<ForeignKeyDef> getForeignKeyDefs() { // return mForeignKeyDefs; // } // // public List<ColumnDef> getColumnDefs() { // return mColumnDefs; // } // }
import com.chncwang.easy2db.table.TableDef;
package com.chncwang.easy2db.table.util; public class TableUtil { private TableUtil() {}
// Path: src/main/java/com/chncwang/easy2db/table/TableDef.java // public class TableDef { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyDef mPrimaryKeyDef; // private final ColumnDef mUniqueKeyDef; // private final List<ForeignKeyDef> mForeignKeyDefs; // private final List<ColumnDef> mColumnDefs; // // public TableDef(final Class<?> clazz, final String tableName, // final PrimaryKeyDef primaryKeyDef, // final ColumnDef uniqueKeyDef, // final List<ForeignKeyDef> foreignKeyDefs, // final List<ColumnDef> columnDefs) { // PreconditionsUtil.checkNotNull(tableName, "tableName"); // PreconditionsUtil.checkNotNull(primaryKeyDef, "primaryKeyDef"); // PreconditionsUtil.checkNotNull(uniqueKeyDef, "uniqueKeyDef"); // // mClass = clazz; // mTableName = tableName; // mPrimaryKeyDef = primaryKeyDef; // mUniqueKeyDef = uniqueKeyDef; // mForeignKeyDefs = Collections.unmodifiableList(foreignKeyDefs); // mColumnDefs = Collections.unmodifiableList(columnDefs); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public ColumnDef getUniqueKeyDef() { // return mUniqueKeyDef; // } // // public List<ForeignKeyDef> getForeignKeyDefs() { // return mForeignKeyDefs; // } // // public List<ColumnDef> getColumnDefs() { // return mColumnDefs; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/TableUtil.java import com.chncwang.easy2db.table.TableDef; package com.chncwang.easy2db.table.util; public class TableUtil { private TableUtil() {}
public static String getPrimaryKeyName(final TableDef tableDef) {
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/TableDef.java
// Path: src/main/java/com/chncwang/easy2db/PreconditionsUtil.java // public class PreconditionsUtil { // private PreconditionsUtil() {} // // public static void checkNotNull(final Object arg, final String argName) { // Preconditions.checkNotNull(arg, Constants.NULL_POINTER_ERROR_TEMPLATE, // argName); // } // }
import java.util.Collections; import java.util.List; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.chncwang.easy2db.PreconditionsUtil;
package com.chncwang.easy2db.table; public class TableDef { private final Class<?> mClass; private final String mTableName; private final PrimaryKeyDef mPrimaryKeyDef; private final ColumnDef mUniqueKeyDef; private final List<ForeignKeyDef> mForeignKeyDefs; private final List<ColumnDef> mColumnDefs; public TableDef(final Class<?> clazz, final String tableName, final PrimaryKeyDef primaryKeyDef, final ColumnDef uniqueKeyDef, final List<ForeignKeyDef> foreignKeyDefs, final List<ColumnDef> columnDefs) {
// Path: src/main/java/com/chncwang/easy2db/PreconditionsUtil.java // public class PreconditionsUtil { // private PreconditionsUtil() {} // // public static void checkNotNull(final Object arg, final String argName) { // Preconditions.checkNotNull(arg, Constants.NULL_POINTER_ERROR_TEMPLATE, // argName); // } // } // Path: src/main/java/com/chncwang/easy2db/table/TableDef.java import java.util.Collections; import java.util.List; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.chncwang.easy2db.PreconditionsUtil; package com.chncwang.easy2db.table; public class TableDef { private final Class<?> mClass; private final String mTableName; private final PrimaryKeyDef mPrimaryKeyDef; private final ColumnDef mUniqueKeyDef; private final List<ForeignKeyDef> mForeignKeyDefs; private final List<ColumnDef> mColumnDefs; public TableDef(final Class<?> clazz, final String tableName, final PrimaryKeyDef primaryKeyDef, final ColumnDef uniqueKeyDef, final List<ForeignKeyDef> foreignKeyDefs, final List<ColumnDef> columnDefs) {
PreconditionsUtil.checkNotNull(tableName, "tableName");
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // }
import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists;
package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {}
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists; package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {}
public static String getColumnValueString(final ColumnWithValue columnValue) {
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // }
import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists;
package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {} public static String getColumnValueString(final ColumnWithValue columnValue) {
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists; package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {} public static String getColumnValueString(final ColumnWithValue columnValue) {
return NumericTypes
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // }
import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists;
package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {} public static String getColumnValueString(final ColumnWithValue columnValue) { return NumericTypes .isNumericType(columnValue.getColumnDef().getClazz()) ? columnValue
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists; package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {} public static String getColumnValueString(final ColumnWithValue columnValue) { return NumericTypes .isNumericType(columnValue.getColumnDef().getClazz()) ? columnValue
.getValue().toString() : Constants.QUOTATION
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // }
import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists;
package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {} public static String getColumnValueString(final ColumnWithValue columnValue) { return NumericTypes .isNumericType(columnValue.getColumnDef().getClazz()) ? columnValue .getValue().toString() : Constants.QUOTATION + columnValue.getValue() + Constants.QUOTATION; } public static String joinNamesWithCommaWithColumnDefs(
// Path: src/main/java/com/chncwang/easy2db/Constants.java // public class Constants { // private Constants() {} // // public static final String COMMA = ", "; // public static final String FROM = " FROM "; // public static final String WHERE = " WHERE "; // public static final String EQUAL = " = "; // public static final String QUOTATION = "\""; // public static final String LEFT_PARENTHESES = " ("; // public static final String RIGHT_PARENTHESES = ") "; // public static final String VALUES = " VALUES "; // public static final String SET = " SET "; // // public static final String NULL_POINTER_ERROR_TEMPLATE = "%s should not be null!"; // } // // Path: src/main/java/com/chncwang/easy2db/sql/NumericTypes.java // public class NumericTypes { // private static final Set<Class<?>> sNumericClasses = Sets.newHashSet(); // // static { // sNumericClasses.add(Byte.class); // sNumericClasses.add(Short.class); // sNumericClasses.add(Integer.class); // sNumericClasses.add(Long.class); // sNumericClasses.add(Float.class); // sNumericClasses.add(Double.class); // sNumericClasses.add(Boolean.class); // } // // public static boolean isNumericType(final Class<?> clazz) { // return sNumericClasses.contains(clazz); // } // } // // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ColumnUtil.java import java.util.List; import org.apache.commons.lang3.StringUtils; import com.chncwang.easy2db.Constants; import com.chncwang.easy2db.sql.NumericTypes; import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.google.common.collect.Lists; package com.chncwang.easy2db.table.util; public class ColumnUtil { private ColumnUtil() {} public static String getColumnValueString(final ColumnWithValue columnValue) { return NumericTypes .isNumericType(columnValue.getColumnDef().getClazz()) ? columnValue .getValue().toString() : Constants.QUOTATION + columnValue.getValue() + Constants.QUOTATION; } public static String joinNamesWithCommaWithColumnDefs(
final List<ColumnDef> columnDefs) {
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // }
import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row;
package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue(
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row; package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue(
final ForeignKeyWithValue foreignKeyWithValue, final Object value) {
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // }
import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row;
package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); }
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row; package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); }
public static PrimaryKeyWithValue getPrimayKeyWithValue(
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // }
import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row;
package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); } public static PrimaryKeyWithValue getPrimayKeyWithValue( final ForeignKeyWithValue foreignKeyValue) { return foreignKeyValue.getForeignRow().getPrimaryKeyValue(); } public static Class<?> getType(final ForeignKeyWithValue foreignKeyWithValue) {
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row; package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); } public static PrimaryKeyWithValue getPrimayKeyWithValue( final ForeignKeyWithValue foreignKeyValue) { return foreignKeyValue.getForeignRow().getPrimaryKeyValue(); } public static Class<?> getType(final ForeignKeyWithValue foreignKeyWithValue) {
final Row row = foreignKeyWithValue.getForeignRow();
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // }
import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row;
package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); } public static PrimaryKeyWithValue getPrimayKeyWithValue( final ForeignKeyWithValue foreignKeyValue) { return foreignKeyValue.getForeignRow().getPrimaryKeyValue(); } public static Class<?> getType(final ForeignKeyWithValue foreignKeyWithValue) { final Row row = foreignKeyWithValue.getForeignRow(); return RowUtil.getPrimaryKeyType(row); }
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row; package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); } public static PrimaryKeyWithValue getPrimayKeyWithValue( final ForeignKeyWithValue foreignKeyValue) { return foreignKeyValue.getForeignRow().getPrimaryKeyValue(); } public static Class<?> getType(final ForeignKeyWithValue foreignKeyWithValue) { final Row row = foreignKeyWithValue.getForeignRow(); return RowUtil.getPrimaryKeyType(row); }
public static ColumnWithValue toColumnWithValue(
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // }
import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row;
package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); } public static PrimaryKeyWithValue getPrimayKeyWithValue( final ForeignKeyWithValue foreignKeyValue) { return foreignKeyValue.getForeignRow().getPrimaryKeyValue(); } public static Class<?> getType(final ForeignKeyWithValue foreignKeyWithValue) { final Row row = foreignKeyWithValue.getForeignRow(); return RowUtil.getPrimaryKeyType(row); } public static ColumnWithValue toColumnWithValue( final ForeignKeyWithValue foreignKeyWithValue) { final Class<?> type = getType(foreignKeyWithValue);
// Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java // public class ColumnDef { // private final Class<?> mClass; // private final String mName; // // public ColumnDef(final Class<?> clazz, final String name) { // PreconditionsUtil.checkNotNull(name, "name"); // // mClass = clazz; // mName = name; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getName() { // return mName; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ColumnWithValue.java // public class ColumnWithValue { // private final ColumnDef mColumnDef; // private final Object mValue; // // public ColumnWithValue(final ColumnDef columnDef, final Object value) { // mColumnDef = columnDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public ColumnDef getColumnDef() { // return mColumnDef; // } // // public Object getValue() { // return mValue; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/ForeignKeyWithValue.java // public class ForeignKeyWithValue { // private final String mColumnName; // private final Row mForeignRow; // // public ForeignKeyWithValue(final String columnName, final Row foreignRow) { // mColumnName = columnName; // mForeignRow = foreignRow; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public String getColumnName() { // return mColumnName; // } // // public Row getForeignRow() { // return mForeignRow; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/PrimaryKeyWithValue.java // public class PrimaryKeyWithValue { // private final PrimaryKeyDef mPrimaryKeyDef; // private Object mValue; // // public PrimaryKeyWithValue(final PrimaryKeyDef primaryKeyDef, final Object value) { // mPrimaryKeyDef = primaryKeyDef; // mValue = value; // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public PrimaryKeyDef getPrimaryKeyDef() { // return mPrimaryKeyDef; // } // // public Object getValue() { // return mValue; // } // // public void setValue(final Object value) { // mValue = value; // } // } // // Path: src/main/java/com/chncwang/easy2db/table/value/Row.java // public class Row { // private final Class<?> mClass; // private final String mTableName; // private final PrimaryKeyWithValue mPrimaryKeyWithValue; // private final ColumnWithValue mUniqueKeyWithValue; // private final List<ForeignKeyWithValue> mForeignKeyWithValueList; // private final List<ColumnWithValue> mColumnWithValueList; // // public Row(final Class<?> clazz, // final String tableName, // final PrimaryKeyWithValue primaryKeyValue, // final ColumnWithValue uniqueKeyValue, // final List<ForeignKeyWithValue> foreignKeyValues, // final List<ColumnWithValue> columnValues) { // mClass = clazz; // mTableName = tableName; // mPrimaryKeyWithValue = primaryKeyValue; // mUniqueKeyWithValue = uniqueKeyValue; // mForeignKeyWithValueList = Collections // .unmodifiableList(foreignKeyValues); // mColumnWithValueList = Collections.unmodifiableList(columnValues); // } // // @Override // public String toString() { // return ToStringBuilder.reflectionToString(this, // ToStringStyle.MULTI_LINE_STYLE); // } // // public Class<?> getClazz() { // return mClass; // } // // public String getTableName() { // return mTableName; // } // // public PrimaryKeyWithValue getPrimaryKeyValue() { // return mPrimaryKeyWithValue; // } // // public ColumnWithValue getUniqueKeyValue() { // return mUniqueKeyWithValue; // } // // public List<ForeignKeyWithValue> getForeignKeyWithValueList() { // return mForeignKeyWithValueList; // } // // public List<ColumnWithValue> getColumnWithValueList() { // return mColumnWithValueList; // } // } // Path: src/main/java/com/chncwang/easy2db/table/util/ForeignKeyUtil.java import com.chncwang.easy2db.table.ColumnDef; import com.chncwang.easy2db.table.value.ColumnWithValue; import com.chncwang.easy2db.table.value.ForeignKeyWithValue; import com.chncwang.easy2db.table.value.PrimaryKeyWithValue; import com.chncwang.easy2db.table.value.Row; package com.chncwang.easy2db.table.util; public class ForeignKeyUtil { private ForeignKeyUtil() {} public static void setForeignKeyPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue, final Object value) { getPrimayKeyWithValue(foreignKeyWithValue).setValue(value); } public static Object getPrimaryKeyValue( final ForeignKeyWithValue foreignKeyWithValue) { return getPrimayKeyWithValue(foreignKeyWithValue).getValue(); } public static PrimaryKeyWithValue getPrimayKeyWithValue( final ForeignKeyWithValue foreignKeyValue) { return foreignKeyValue.getForeignRow().getPrimaryKeyValue(); } public static Class<?> getType(final ForeignKeyWithValue foreignKeyWithValue) { final Row row = foreignKeyWithValue.getForeignRow(); return RowUtil.getPrimaryKeyType(row); } public static ColumnWithValue toColumnWithValue( final ForeignKeyWithValue foreignKeyWithValue) { final Class<?> type = getType(foreignKeyWithValue);
final ColumnDef columnDef = new ColumnDef(type,
chncwang/easy2db
src/main/java/com/chncwang/easy2db/table/ColumnDef.java
// Path: src/main/java/com/chncwang/easy2db/PreconditionsUtil.java // public class PreconditionsUtil { // private PreconditionsUtil() {} // // public static void checkNotNull(final Object arg, final String argName) { // Preconditions.checkNotNull(arg, Constants.NULL_POINTER_ERROR_TEMPLATE, // argName); // } // }
import org.apache.commons.lang3.builder.ToStringBuilder; import com.chncwang.easy2db.PreconditionsUtil;
package com.chncwang.easy2db.table; public class ColumnDef { private final Class<?> mClass; private final String mName; public ColumnDef(final Class<?> clazz, final String name) {
// Path: src/main/java/com/chncwang/easy2db/PreconditionsUtil.java // public class PreconditionsUtil { // private PreconditionsUtil() {} // // public static void checkNotNull(final Object arg, final String argName) { // Preconditions.checkNotNull(arg, Constants.NULL_POINTER_ERROR_TEMPLATE, // argName); // } // } // Path: src/main/java/com/chncwang/easy2db/table/ColumnDef.java import org.apache.commons.lang3.builder.ToStringBuilder; import com.chncwang.easy2db.PreconditionsUtil; package com.chncwang.easy2db.table; public class ColumnDef { private final Class<?> mClass; private final String mName; public ColumnDef(final Class<?> clazz, final String name) {
PreconditionsUtil.checkNotNull(name, "name");
jaak-s/extraTrees
src/test/java/org/extratrees/BenchmarkTests.java
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // }
import static org.junit.Assert.assertEquals; import org.extratrees.data.Matrix; import org.junit.Test;
package org.extratrees; public class BenchmarkTests { public static FactorExtraTrees getSampleData(int ndata, int ndim) { int[] output = new int[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); }
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // Path: src/test/java/org/extratrees/BenchmarkTests.java import static org.junit.Assert.assertEquals; import org.extratrees.data.Matrix; import org.junit.Test; package org.extratrees; public class BenchmarkTests { public static FactorExtraTrees getSampleData(int ndata, int ndim) { int[] output = new int[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); }
Matrix m = new Matrix(v, ndata, ndim);
jaak-s/extraTrees
src/main/java/org/extratrees/AbstractTrees.java
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // // Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // // Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // }
import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.extratrees.data.Array2D; import org.extratrees.data.Matrix; import org.extratrees.data.Row;
package org.extratrees; public abstract class AbstractTrees<E extends AbstractBinaryTree<E,D>, D> implements Serializable { private static final long serialVersionUID = -7981888649599586067L;
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // // Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // // Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // } // Path: src/main/java/org/extratrees/AbstractTrees.java import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.extratrees.data.Array2D; import org.extratrees.data.Matrix; import org.extratrees.data.Row; package org.extratrees; public abstract class AbstractTrees<E extends AbstractBinaryTree<E,D>, D> implements Serializable { private static final long serialVersionUID = -7981888649599586067L;
transient Array2D input;
jaak-s/extraTrees
src/main/java/org/extratrees/AbstractTrees.java
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // // Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // // Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // }
import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.extratrees.data.Array2D; import org.extratrees.data.Matrix; import org.extratrees.data.Row;
// single-threading: for (int t=0; t<nTrees; t++) { trees.add( this.buildTree(nmin, K, t) ); } return trees; } public void setupRandoms(int nTrees) { this.treeRandoms = new Random[nTrees]; for (int i = 0; i < nTrees; i++) { treeRandoms[i] = new Random( this.random.nextLong() ); } } /** * stores trees with the AbstractTrees object. * Uses multiple threads if set. * @param nmin * @param K * @param nTrees */ public void learnTrees(int nmin, int K, int nTrees) { setupRandoms(nTrees); if (numThreads <= 1) { this.trees = buildTrees(nmin, K, nTrees); } else { this.trees = buildTreesParallel(nmin, K, nTrees); } }
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // // Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // // Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // } // Path: src/main/java/org/extratrees/AbstractTrees.java import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Random; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.extratrees.data.Array2D; import org.extratrees.data.Matrix; import org.extratrees.data.Row; // single-threading: for (int t=0; t<nTrees; t++) { trees.add( this.buildTree(nmin, K, t) ); } return trees; } public void setupRandoms(int nTrees) { this.treeRandoms = new Random[nTrees]; for (int i = 0; i < nTrees; i++) { treeRandoms[i] = new Random( this.random.nextLong() ); } } /** * stores trees with the AbstractTrees object. * Uses multiple threads if set. * @param nmin * @param K * @param nTrees */ public void learnTrees(int nmin, int K, int nTrees) { setupRandoms(nTrees); if (numThreads <= 1) { this.trees = buildTrees(nmin, K, nTrees); } else { this.trees = buildTreesParallel(nmin, K, nTrees); } }
public D getValue(Row input) {
jaak-s/extraTrees
src/test/java/org/extratrees/NATests.java
// Path: src/main/java/org/extratrees/AbstractTrees.java // static protected class CutResult { // double score; // boolean leftConst; // boolean rightConst; // int countLeft; // int countRight; // double nanWeigth; // // public CutResult() {} // // public int getCountLeft() { // return countLeft; // } // public void setCountLeft(int countLeft) { // this.countLeft = countLeft; // } // public int getCountRight() { // return countRight; // } // public void setCountRight(int countRight) { // this.countRight = countRight; // } // // public boolean isLeftConstant() { // return leftConst; // } // public void setLeftConstant(boolean leftConstant) { // this.leftConst = leftConstant; // } // // public boolean isRightConstant() { // return rightConst; // } // public void setRightConstant(boolean rightConstant) { // this.rightConst = rightConstant; // } // // public double getScore() { // return score; // } // public void setScore(double score) { // this.score = score; // } // // } // // Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.extratrees.AbstractTrees.CutResult; import org.extratrees.data.Matrix; import org.junit.Test;
package org.extratrees; public class NATests { /** * @param ndata * @param ndim */ public static FactorExtraTrees getFET(int ndata, int ndim, boolean useWeights) { int[] output = new int[ndata];
// Path: src/main/java/org/extratrees/AbstractTrees.java // static protected class CutResult { // double score; // boolean leftConst; // boolean rightConst; // int countLeft; // int countRight; // double nanWeigth; // // public CutResult() {} // // public int getCountLeft() { // return countLeft; // } // public void setCountLeft(int countLeft) { // this.countLeft = countLeft; // } // public int getCountRight() { // return countRight; // } // public void setCountRight(int countRight) { // this.countRight = countRight; // } // // public boolean isLeftConstant() { // return leftConst; // } // public void setLeftConstant(boolean leftConstant) { // this.leftConst = leftConstant; // } // // public boolean isRightConstant() { // return rightConst; // } // public void setRightConstant(boolean rightConstant) { // this.rightConst = rightConstant; // } // // public double getScore() { // return score; // } // public void setScore(double score) { // this.score = score; // } // // } // // Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // Path: src/test/java/org/extratrees/NATests.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.extratrees.AbstractTrees.CutResult; import org.extratrees.data.Matrix; import org.junit.Test; package org.extratrees; public class NATests { /** * @param ndata * @param ndim */ public static FactorExtraTrees getFET(int ndata, int ndim, boolean useWeights) { int[] output = new int[ndata];
Matrix m = new Matrix(ndata, ndim);
jaak-s/extraTrees
src/test/java/org/extratrees/QuantileTests.java
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // }
import static org.junit.Assert.*; import java.util.Arrays; import org.extratrees.data.Matrix; import org.junit.Test;
package org.extratrees; public class QuantileTests { public static QuantileExtraTrees getSampleData(int ndata, int ndim) { double[] output = new double[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); }
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // Path: src/test/java/org/extratrees/QuantileTests.java import static org.junit.Assert.*; import java.util.Arrays; import org.extratrees.data.Matrix; import org.junit.Test; package org.extratrees; public class QuantileTests { public static QuantileExtraTrees getSampleData(int ndata, int ndim) { double[] output = new double[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); }
Matrix m = new Matrix(v, ndata, ndim);
jaak-s/extraTrees
src/main/java/org/extratrees/AbstractBinaryTree.java
// Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // }
import java.io.Serializable; import java.util.Set; import org.extratrees.data.Row;
package org.extratrees; /** * All subclasses should have their generic argument equal to itself, * i.e. X extends AbstractBinaryTree<X>. * Otherwise getItself() will break. * * @author Jaak Simm * * @param <T> class that extends ABT * @param <D> class of value */ public abstract class AbstractBinaryTree <T extends AbstractBinaryTree<T, D>, D> implements Serializable { private static final long serialVersionUID = 5530548509407016040L; /** tree for elements below threshold. * if left==null, it is a leaf node * if left!=null, not a leaf * */ public T left; /** tree for elements equal or above threshold. */ public T right; /** number of elements in the tree */ public int nSuccessors; /** feature ID used for cutting */ public int column=-1; /** threshold of cutting */ public double threshold; /** value of the node (estimated by its samples). * Non-leaf nodes (may) also store value, allowing to change size of final nodes on-the-fly. */ public D value; /** tasks that are active in this thread */ Set<Integer> tasks; public abstract D getNA(); /** @return value of current node */ public D getValue() { return value; } /** * @param input the vector of input values * @return the leaf node (BinaryTree) for the input */
// Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // } // Path: src/main/java/org/extratrees/AbstractBinaryTree.java import java.io.Serializable; import java.util.Set; import org.extratrees.data.Row; package org.extratrees; /** * All subclasses should have their generic argument equal to itself, * i.e. X extends AbstractBinaryTree<X>. * Otherwise getItself() will break. * * @author Jaak Simm * * @param <T> class that extends ABT * @param <D> class of value */ public abstract class AbstractBinaryTree <T extends AbstractBinaryTree<T, D>, D> implements Serializable { private static final long serialVersionUID = 5530548509407016040L; /** tree for elements below threshold. * if left==null, it is a leaf node * if left!=null, not a leaf * */ public T left; /** tree for elements equal or above threshold. */ public T right; /** number of elements in the tree */ public int nSuccessors; /** feature ID used for cutting */ public int column=-1; /** threshold of cutting */ public double threshold; /** value of the node (estimated by its samples). * Non-leaf nodes (may) also store value, allowing to change size of final nodes on-the-fly. */ public D value; /** tasks that are active in this thread */ Set<Integer> tasks; public abstract D getNA(); /** @return value of current node */ public D getValue() { return value; } /** * @param input the vector of input values * @return the leaf node (BinaryTree) for the input */
public T getLeaf(Row input) {
jaak-s/extraTrees
src/main/java/org/extratrees/QuantileExtraTrees.java
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // // Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // }
import java.util.ArrayList; import java.util.Set; import org.extratrees.data.Array2D; import org.extratrees.data.Row;
package org.extratrees; public class QuantileExtraTrees extends ExtraTrees { public QuantileExtraTrees(Array2D input, double[] output) { super(input, output); } /** * * @param input * @param quantile a value between 0.0 and 1.0. For median use 0.5 * @return return quantiles for each input row. */ public double[] getQuantiles(Array2D input, double k) { double[] quantileValues = new double[input.nrows()]; ArrayList<Double> leafValues = new ArrayList<Double>(this.trees.size()); for (int row=0; row<input.nrows(); row++) { getLeafValues(input.getRow(row), leafValues); // doing quickselect: quantileValues[row] = QuickSelect.quickSelect(leafValues, k); } return quantileValues; } /** * Clears ArrayList {@code values} and adds leaf values of {@code input} to it. * @param input * @param values */
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // // Path: src/main/java/org/extratrees/data/Row.java // public interface Row { // public double get(int col); // } // Path: src/main/java/org/extratrees/QuantileExtraTrees.java import java.util.ArrayList; import java.util.Set; import org.extratrees.data.Array2D; import org.extratrees.data.Row; package org.extratrees; public class QuantileExtraTrees extends ExtraTrees { public QuantileExtraTrees(Array2D input, double[] output) { super(input, output); } /** * * @param input * @param quantile a value between 0.0 and 1.0. For median use 0.5 * @return return quantiles for each input row. */ public double[] getQuantiles(Array2D input, double k) { double[] quantileValues = new double[input.nrows()]; ArrayList<Double> leafValues = new ArrayList<Double>(this.trees.size()); for (int row=0; row<input.nrows(); row++) { getLeafValues(input.getRow(row), leafValues); // doing quickselect: quantileValues[row] = QuickSelect.quickSelect(leafValues, k); } return quantileValues; } /** * Clears ArrayList {@code values} and adds leaf values of {@code input} to it. * @param input * @param values */
public void getLeafValues(Row input, ArrayList<Double> values) {
jaak-s/extraTrees
src/main/java/org/extratrees/ExtraTrees.java
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // }
import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import org.extratrees.data.Array2D;
package org.extratrees; public class ExtraTrees extends AbstractTrees<BinaryTree, Double> implements Serializable { private static final long serialVersionUID = -8164290318411068380L; transient double[] output; transient double[] outputSq; public ExtraTrees() { }
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // Path: src/main/java/org/extratrees/ExtraTrees.java import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import org.extratrees.data.Array2D; package org.extratrees; public class ExtraTrees extends AbstractTrees<BinaryTree, Double> implements Serializable { private static final long serialVersionUID = -8164290318411068380L; transient double[] output; transient double[] outputSq; public ExtraTrees() { }
public ExtraTrees(Array2D input, double[] output) {
jaak-s/extraTrees
src/test/java/org/extratrees/SubsetTests.java
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // }
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; import java.util.Random; import org.extratrees.data.Matrix; import org.junit.Test;
package org.extratrees; public class SubsetTests { public static ExtraTrees getSampleData(int ndata, int ndim) { double[] output = new double[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); }
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // Path: src/test/java/org/extratrees/SubsetTests.java import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; import java.util.Random; import org.extratrees.data.Matrix; import org.junit.Test; package org.extratrees; public class SubsetTests { public static ExtraTrees getSampleData(int ndata, int ndim) { double[] output = new double[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); }
Matrix m = new Matrix(v, ndata, ndim);
jaak-s/extraTrees
src/test/java/org/extratrees/MultitaskTests.java
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // }
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import java.util.HashSet; import java.util.Set; import org.extratrees.data.Matrix; import org.junit.Test;
package org.extratrees; public class MultitaskTests { public static FactorExtraTrees getData1(int ndata, int ndim) { int[] output = new int[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); } for (int i=0; i<ndata; i++) { output[i] = (i%2==0 ?0 :1); }
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // Path: src/test/java/org/extratrees/MultitaskTests.java import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import java.util.HashSet; import java.util.Set; import org.extratrees.data.Matrix; import org.junit.Test; package org.extratrees; public class MultitaskTests { public static FactorExtraTrees getData1(int ndata, int ndim) { int[] output = new int[ndata]; double[] v = new double[ndata*ndim]; for (int i=0; i<v.length; i++) { v[i] = Math.random(); } for (int i=0; i<ndata; i++) { output[i] = (i%2==0 ?0 :1); }
Matrix m = new Matrix(v, ndata, ndim);
jaak-s/extraTrees
src/test/java/org/extratrees/SerializationTests.java
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.extratrees.data.Matrix; import org.junit.Test;
package org.extratrees; public class SerializationTests { public static ExtraTrees getSampleData(int ndata, int ndim) { double[] output = new double[ndata]; double[] v = new double[ndata * ndim]; for (int i = 0; i < v.length; i++) { v[i] = Math.random(); }
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // Path: src/test/java/org/extratrees/SerializationTests.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.extratrees.data.Matrix; import org.junit.Test; package org.extratrees; public class SerializationTests { public static ExtraTrees getSampleData(int ndata, int ndim) { double[] output = new double[ndata]; double[] v = new double[ndata * ndim]; for (int i = 0; i < v.length; i++) { v[i] = Math.random(); }
Matrix m = new Matrix(v, ndata, ndim);
jaak-s/extraTrees
src/test/java/org/extratrees/BenchmarkRange.java
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // }
import java.util.ArrayList; import java.util.Random; import org.extratrees.data.Matrix; import org.junit.Test;
package org.extratrees; public class BenchmarkRange { @Test public void testRange() { int N = 10*1000*1000; int col = 1;
// Path: src/main/java/org/extratrees/data/Matrix.java // public class Matrix implements Array2D { // public double[] v; // public int ncols, nrows; // // /** Matrix filled with 0s. */ // public Matrix(int nrows, int ncols) { // this(new double[nrows*ncols], nrows, ncols); // } // // /** Matrix filled with v. */ // public Matrix(double[] v, int nrows, int ncols) { // if (v.length != nrows*ncols) { // throw( new IllegalArgumentException( // "Length of v ("+v.length+") is not equal to nrows*ncols ("+ // nrows+"*"+ncols+")")); // } // this.v = v; // this.nrows = nrows; // this.ncols = ncols; // } // // /** row is from 0 to (nrow-1) // * col is from 0 to (ncol-1) // * */ // public void set(int row, int col, double value) { // this.v[row + col*nrows] = value; // } // // @Override // public double get(int row, int col) { // return this.v[row + col*nrows]; // } // // @Override // public int ncols() { // return ncols; // } // // @Override // public int nrows() { // return nrows; // } // // @Override // public Row getRow(int row) { // return new MRow(row); // } // // /** // * Provide access to rows of the matrix without copy-pasting // */ // public class MRow implements Row { // int row; // public MRow(int row) { // this.row = row; // } // @Override // public double get(int col) { // return Matrix.this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public void copyRow(int row, double[] vector) { // for (int col=0; col < this.ncols; col++) { // vector[col] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param col // * @param vector // */ // public void copyCol(int col, double[] vector) { // for (int row=0; row < this.nrows; row++) { // vector[row] = this.get(row, col); // } // } // // /** // * Copies values from given row to the vector. // * @param row // * @param vector // */ // public double[] getCol(int col) { // double[] colValues = new double[ nrows ]; // copyCol( col, colValues ); // return colValues; // } // // public void square() { // for (int i=0; i<v.length; i++) { // v[i] *= v[i]; // } // } // // public String toString() { // StringBuilder out = new StringBuilder(); // for (int row=0; row < nrows; row++) { // for (int col=0; col < ncols; col++) { // out.append( String.format("%1.4f", get(row,col) ) ); // out.append( " " ); // } // out.append("\n"); // } // return out.toString(); // } // // public boolean hasNaN() { // for (int i = 0; i < v.length; i++) { // if ( Double.isNaN(v[i]) ) { // return true; // } // } // return false; // } // // public static void main(String[] args) { // double[] v = new double[40]; // for (int i=0; i < v.length; i++) { // v[i] = i+1; // } // Matrix m = new Matrix(v, 10, 4); // System.out.println(m); // } // } // Path: src/test/java/org/extratrees/BenchmarkRange.java import java.util.ArrayList; import java.util.Random; import org.extratrees.data.Matrix; import org.junit.Test; package org.extratrees; public class BenchmarkRange { @Test public void testRange() { int N = 10*1000*1000; int col = 1;
Matrix m = new Matrix(N, 2);
jaak-s/extraTrees
src/main/java/org/extratrees/FactorExtraTrees.java
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // }
import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import org.extratrees.data.Array2D;
package org.extratrees; public class FactorExtraTrees extends AbstractTrees<FactorBinaryTree, Integer> implements Serializable { private static final long serialVersionUID = 3625952360819832098L; transient int[] output; /** number of factors: */ int nFactors; public FactorExtraTrees(int nFactors) { this.nFactors = nFactors; }
// Path: src/main/java/org/extratrees/data/Array2D.java // public interface Array2D { // public double get(int row, int col); // public int ncols(); // public int nrows(); // public Row getRow(int row); // } // Path: src/main/java/org/extratrees/FactorExtraTrees.java import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import org.extratrees.data.Array2D; package org.extratrees; public class FactorExtraTrees extends AbstractTrees<FactorBinaryTree, Integer> implements Serializable { private static final long serialVersionUID = 3625952360819832098L; transient int[] output; /** number of factors: */ int nFactors; public FactorExtraTrees(int nFactors) { this.nFactors = nFactors; }
public FactorExtraTrees(Array2D input, int[] output) {
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/pluginService/ApplicationServerInfo.java
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/ServerInfo.java // public interface ServerInfo { // // public String getWebappPath(); // public String getDocumentsPath(); // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/PropertyConstants.java // public class PropertyConstants { // public static final String NETTY_PORT = "no.haagensoftware.netty.port"; // public static final String WEBAPP_DIR = "no.haagensoftware.netty.webappDir"; // public static final String SCRIPTS_CACHE_SECONDS = "no.haagensoftware.netty.scriptsCacheSeconds"; // public static final String RIAK_HOST = "no.haagensoftware.riak.host"; // public static final String RIAK_PORT = "no.haagensoftware.riak.port"; // }
import no.haagensoftware.netty.webserver.ServerInfo; import org.haagensoftware.netty.webserver.spi.PropertyConstants;
package no.haagensoftware.pluginService; public class ApplicationServerInfo implements ServerInfo { private String webappdir; private String documentsdir; public ApplicationServerInfo() {
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/ServerInfo.java // public interface ServerInfo { // // public String getWebappPath(); // public String getDocumentsPath(); // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/PropertyConstants.java // public class PropertyConstants { // public static final String NETTY_PORT = "no.haagensoftware.netty.port"; // public static final String WEBAPP_DIR = "no.haagensoftware.netty.webappDir"; // public static final String SCRIPTS_CACHE_SECONDS = "no.haagensoftware.netty.scriptsCacheSeconds"; // public static final String RIAK_HOST = "no.haagensoftware.riak.host"; // public static final String RIAK_PORT = "no.haagensoftware.riak.port"; // } // Path: backend/src/main/java/no/haagensoftware/pluginService/ApplicationServerInfo.java import no.haagensoftware.netty.webserver.ServerInfo; import org.haagensoftware.netty.webserver.spi.PropertyConstants; package no.haagensoftware.pluginService; public class ApplicationServerInfo implements ServerInfo { private String webappdir; private String documentsdir; public ApplicationServerInfo() {
webappdir = System.getProperty(PropertyConstants.WEBAPP_DIR);
joachimhs/Embriak
backend/src/main/java/org/haagensoftware/netty/webserver/spi/NettyWebserverRouterPlugin.java
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/ServerInfo.java // public interface ServerInfo { // // public String getWebappPath(); // public String getDocumentsPath(); // }
import java.util.LinkedHashMap; import java.util.List; import no.haagensoftware.netty.webserver.ServerInfo; import org.jboss.netty.channel.ChannelHandler; import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
package org.haagensoftware.netty.webserver.spi; public abstract class NettyWebserverRouterPlugin { public abstract LinkedHashMap<String, SimpleChannelUpstreamHandler> getRoutes(); public abstract ChannelHandler getHandlerForRoute(String route);
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/ServerInfo.java // public interface ServerInfo { // // public String getWebappPath(); // public String getDocumentsPath(); // } // Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/NettyWebserverRouterPlugin.java import java.util.LinkedHashMap; import java.util.List; import no.haagensoftware.netty.webserver.ServerInfo; import org.jboss.netty.channel.ChannelHandler; import org.jboss.netty.channel.SimpleChannelUpstreamHandler; package org.haagensoftware.netty.webserver.spi; public abstract class NettyWebserverRouterPlugin { public abstract LinkedHashMap<String, SimpleChannelUpstreamHandler> getRoutes(); public abstract ChannelHandler getHandlerForRoute(String route);
public abstract void setServerInfo(ServerInfo serverInfo);
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/netty/webserver/handler/FileServerHandler.java
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // }
import static org.jboss.netty.handler.codec.http.HttpHeaders.*; import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*; import static org.jboss.netty.handler.codec.http.HttpMethod.*; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.*; import static org.jboss.netty.handler.codec.http.HttpVersion.*; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.*; import org.jboss.netty.handler.codec.frame.TooLongFrameException; import org.jboss.netty.handler.codec.http.Cookie; import org.jboss.netty.handler.codec.http.CookieDecoder; import org.jboss.netty.handler.codec.http.DefaultHttpResponse; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.QueryStringDecoder; import org.jboss.netty.util.CharsetUtil; import javax.activation.MimetypesFileTypeMap; import java.io.*; import java.net.*; import java.util.Set;
return requestContent; } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); if (request.getMethod() != GET) { sendError(ctx, METHOD_NOT_ALLOWED); return; } String uri = request.getUri(); String path = sanitizeUri(uri); if (path == null) { sendError(ctx, FORBIDDEN); return; } if (path.startsWith("/document")) { path = path.substring(9); } ChannelBuffer content = getFileContent(path); if (content == null) { logger.info("Unable to find file at path: " + path); sendError(ctx, NOT_FOUND); return; }
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // } // Path: backend/src/main/java/no/haagensoftware/netty/webserver/handler/FileServerHandler.java import static org.jboss.netty.handler.codec.http.HttpHeaders.*; import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*; import static org.jboss.netty.handler.codec.http.HttpMethod.*; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.*; import static org.jboss.netty.handler.codec.http.HttpVersion.*; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.*; import org.jboss.netty.handler.codec.frame.TooLongFrameException; import org.jboss.netty.handler.codec.http.Cookie; import org.jboss.netty.handler.codec.http.CookieDecoder; import org.jboss.netty.handler.codec.http.DefaultHttpResponse; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.QueryStringDecoder; import org.jboss.netty.util.CharsetUtil; import javax.activation.MimetypesFileTypeMap; import java.io.*; import java.net.*; import java.util.Set; return requestContent; } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); if (request.getMethod() != GET) { sendError(ctx, METHOD_NOT_ALLOWED); return; } String uri = request.getUri(); String path = sanitizeUri(uri); if (path == null) { sendError(ctx, FORBIDDEN); return; } if (path.startsWith("/document")) { path = path.substring(9); } ChannelBuffer content = getFileContent(path); if (content == null) { logger.info("Unable to find file at path: " + path); sendError(ctx, NOT_FOUND); return; }
String contentType = ContentTypeUtil.getContentType(path);
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/netty/webserver/handler/RouterHandler.java
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/Matcher.java // public interface Matcher { // public boolean match(String uri); // }
import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.Matcher; import org.jboss.netty.channel.*; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.execution.ExecutionHandler; import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor; import java.util.LinkedHashMap; import java.util.Map;
package no.haagensoftware.netty.webserver.handler; public class RouterHandler extends SimpleChannelUpstreamHandler { private Logger logger = Logger.getLogger(RouterHandler.class.getName());
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/Matcher.java // public interface Matcher { // public boolean match(String uri); // } // Path: backend/src/main/java/no/haagensoftware/netty/webserver/handler/RouterHandler.java import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.Matcher; import org.jboss.netty.channel.*; import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.execution.ExecutionHandler; import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor; import java.util.LinkedHashMap; import java.util.Map; package no.haagensoftware.netty.webserver.handler; public class RouterHandler extends SimpleChannelUpstreamHandler { private Logger logger = Logger.getLogger(RouterHandler.class.getName());
private Map<Matcher, ChannelHandler> routes = new LinkedHashMap<Matcher, ChannelHandler>();
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/riak/RiakEnv.java
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/PropertyConstants.java // public class PropertyConstants { // public static final String NETTY_PORT = "no.haagensoftware.netty.port"; // public static final String WEBAPP_DIR = "no.haagensoftware.netty.webappDir"; // public static final String SCRIPTS_CACHE_SECONDS = "no.haagensoftware.netty.scriptsCacheSeconds"; // public static final String RIAK_HOST = "no.haagensoftware.riak.host"; // public static final String RIAK_PORT = "no.haagensoftware.riak.port"; // } // // Path: backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java // public class RiakBucketDao { // private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); // // private IRiakClient riakClient; // // public RiakBucketDao(IRiakClient riakClient) { // this.riakClient = riakClient; // } // // public List<BucketData> getBuckets() { // List<BucketData> bucketList = new ArrayList<>(); // try { // for (String bucket : riakClient.listBuckets()) { // BucketData bd = new BucketData(bucket); // List<String> keyIds = new ArrayList<>(); // // for (KeyData kd : getKeysForBucket(bucket)) { // keyIds.add(bucket + "___" + kd.getId()); // } // Collections.sort(keyIds); // bd.setKeyIds(keyIds); // bucketList.add(bd); // } // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // // return bucketList; // } // // public List<KeyData> getKeysForBucket(String bucketName) { // List<KeyData> keyList = new ArrayList<>(); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // // for (String key : bucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) { // keyList.add(new KeyData(key)); // } // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // e.printStackTrace(); // } // // return keyList; // } // // public KeyValue getKeyValue(String bucketName, String key) { // KeyValue keyValue = new KeyValue(); // keyValue.setId(bucketName + "___" + key); // keyValue.setKeyName(key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // keyValue.setValue(bucket.fetch(key).execute().getValueAsString()); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // // return keyValue; // } // // public void persistKeyValue(String bucketName, String key, KeyValue keyValue) { // logger.info("Persisint KeyValue for bucket: " + bucketName + " key: " + key + " JSON: " + keyValue.getValue()); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.store(key, keyValue.getValue()).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // } // // public void deleteKeyValue(String bucketName, String key) { // logger.info("Deleting keyVlaue for bucket: " + bucketName + " key: " + key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.delete(key).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } // }
import org.haagensoftware.netty.webserver.spi.PropertyConstants; import no.haagensoftware.riak.dao.RiakBucketDao; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakFactory; import com.basho.riak.client.raw.pbc.PBClientConfig; import com.basho.riak.client.raw.pbc.PBClusterConfig;
package no.haagensoftware.riak; public class RiakEnv { private IRiakClient riakClient;
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/PropertyConstants.java // public class PropertyConstants { // public static final String NETTY_PORT = "no.haagensoftware.netty.port"; // public static final String WEBAPP_DIR = "no.haagensoftware.netty.webappDir"; // public static final String SCRIPTS_CACHE_SECONDS = "no.haagensoftware.netty.scriptsCacheSeconds"; // public static final String RIAK_HOST = "no.haagensoftware.riak.host"; // public static final String RIAK_PORT = "no.haagensoftware.riak.port"; // } // // Path: backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java // public class RiakBucketDao { // private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); // // private IRiakClient riakClient; // // public RiakBucketDao(IRiakClient riakClient) { // this.riakClient = riakClient; // } // // public List<BucketData> getBuckets() { // List<BucketData> bucketList = new ArrayList<>(); // try { // for (String bucket : riakClient.listBuckets()) { // BucketData bd = new BucketData(bucket); // List<String> keyIds = new ArrayList<>(); // // for (KeyData kd : getKeysForBucket(bucket)) { // keyIds.add(bucket + "___" + kd.getId()); // } // Collections.sort(keyIds); // bd.setKeyIds(keyIds); // bucketList.add(bd); // } // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // // return bucketList; // } // // public List<KeyData> getKeysForBucket(String bucketName) { // List<KeyData> keyList = new ArrayList<>(); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // // for (String key : bucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) { // keyList.add(new KeyData(key)); // } // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // e.printStackTrace(); // } // // return keyList; // } // // public KeyValue getKeyValue(String bucketName, String key) { // KeyValue keyValue = new KeyValue(); // keyValue.setId(bucketName + "___" + key); // keyValue.setKeyName(key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // keyValue.setValue(bucket.fetch(key).execute().getValueAsString()); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // // return keyValue; // } // // public void persistKeyValue(String bucketName, String key, KeyValue keyValue) { // logger.info("Persisint KeyValue for bucket: " + bucketName + " key: " + key + " JSON: " + keyValue.getValue()); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.store(key, keyValue.getValue()).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // } // // public void deleteKeyValue(String bucketName, String key) { // logger.info("Deleting keyVlaue for bucket: " + bucketName + " key: " + key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.delete(key).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } // } // Path: backend/src/main/java/no/haagensoftware/riak/RiakEnv.java import org.haagensoftware.netty.webserver.spi.PropertyConstants; import no.haagensoftware.riak.dao.RiakBucketDao; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakFactory; import com.basho.riak.client.raw.pbc.PBClientConfig; import com.basho.riak.client.raw.pbc.PBClusterConfig; package no.haagensoftware.riak; public class RiakEnv { private IRiakClient riakClient;
private RiakBucketDao riakBucketDao;
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/riak/RiakEnv.java
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/PropertyConstants.java // public class PropertyConstants { // public static final String NETTY_PORT = "no.haagensoftware.netty.port"; // public static final String WEBAPP_DIR = "no.haagensoftware.netty.webappDir"; // public static final String SCRIPTS_CACHE_SECONDS = "no.haagensoftware.netty.scriptsCacheSeconds"; // public static final String RIAK_HOST = "no.haagensoftware.riak.host"; // public static final String RIAK_PORT = "no.haagensoftware.riak.port"; // } // // Path: backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java // public class RiakBucketDao { // private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); // // private IRiakClient riakClient; // // public RiakBucketDao(IRiakClient riakClient) { // this.riakClient = riakClient; // } // // public List<BucketData> getBuckets() { // List<BucketData> bucketList = new ArrayList<>(); // try { // for (String bucket : riakClient.listBuckets()) { // BucketData bd = new BucketData(bucket); // List<String> keyIds = new ArrayList<>(); // // for (KeyData kd : getKeysForBucket(bucket)) { // keyIds.add(bucket + "___" + kd.getId()); // } // Collections.sort(keyIds); // bd.setKeyIds(keyIds); // bucketList.add(bd); // } // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // // return bucketList; // } // // public List<KeyData> getKeysForBucket(String bucketName) { // List<KeyData> keyList = new ArrayList<>(); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // // for (String key : bucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) { // keyList.add(new KeyData(key)); // } // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // e.printStackTrace(); // } // // return keyList; // } // // public KeyValue getKeyValue(String bucketName, String key) { // KeyValue keyValue = new KeyValue(); // keyValue.setId(bucketName + "___" + key); // keyValue.setKeyName(key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // keyValue.setValue(bucket.fetch(key).execute().getValueAsString()); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // // return keyValue; // } // // public void persistKeyValue(String bucketName, String key, KeyValue keyValue) { // logger.info("Persisint KeyValue for bucket: " + bucketName + " key: " + key + " JSON: " + keyValue.getValue()); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.store(key, keyValue.getValue()).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // } // // public void deleteKeyValue(String bucketName, String key) { // logger.info("Deleting keyVlaue for bucket: " + bucketName + " key: " + key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.delete(key).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } // }
import org.haagensoftware.netty.webserver.spi.PropertyConstants; import no.haagensoftware.riak.dao.RiakBucketDao; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakFactory; import com.basho.riak.client.raw.pbc.PBClientConfig; import com.basho.riak.client.raw.pbc.PBClusterConfig;
package no.haagensoftware.riak; public class RiakEnv { private IRiakClient riakClient; private RiakBucketDao riakBucketDao; public RiakEnv() { } public void setup() throws RiakException { // Riak Protocol Buffers client with supplied IP and Port PBClusterConfig riakClusterConfig = new PBClusterConfig(20); // See above examples for client config options PBClientConfig riakClientConfig = PBClientConfig.defaults();
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/PropertyConstants.java // public class PropertyConstants { // public static final String NETTY_PORT = "no.haagensoftware.netty.port"; // public static final String WEBAPP_DIR = "no.haagensoftware.netty.webappDir"; // public static final String SCRIPTS_CACHE_SECONDS = "no.haagensoftware.netty.scriptsCacheSeconds"; // public static final String RIAK_HOST = "no.haagensoftware.riak.host"; // public static final String RIAK_PORT = "no.haagensoftware.riak.port"; // } // // Path: backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java // public class RiakBucketDao { // private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); // // private IRiakClient riakClient; // // public RiakBucketDao(IRiakClient riakClient) { // this.riakClient = riakClient; // } // // public List<BucketData> getBuckets() { // List<BucketData> bucketList = new ArrayList<>(); // try { // for (String bucket : riakClient.listBuckets()) { // BucketData bd = new BucketData(bucket); // List<String> keyIds = new ArrayList<>(); // // for (KeyData kd : getKeysForBucket(bucket)) { // keyIds.add(bucket + "___" + kd.getId()); // } // Collections.sort(keyIds); // bd.setKeyIds(keyIds); // bucketList.add(bd); // } // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // // return bucketList; // } // // public List<KeyData> getKeysForBucket(String bucketName) { // List<KeyData> keyList = new ArrayList<>(); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // // for (String key : bucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) { // keyList.add(new KeyData(key)); // } // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // e.printStackTrace(); // } // // return keyList; // } // // public KeyValue getKeyValue(String bucketName, String key) { // KeyValue keyValue = new KeyValue(); // keyValue.setId(bucketName + "___" + key); // keyValue.setKeyName(key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // keyValue.setValue(bucket.fetch(key).execute().getValueAsString()); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // // return keyValue; // } // // public void persistKeyValue(String bucketName, String key, KeyValue keyValue) { // logger.info("Persisint KeyValue for bucket: " + bucketName + " key: " + key + " JSON: " + keyValue.getValue()); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.store(key, keyValue.getValue()).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } // } // // public void deleteKeyValue(String bucketName, String key) { // logger.info("Deleting keyVlaue for bucket: " + bucketName + " key: " + key); // // Bucket bucket = null; // try { // bucket = riakClient.fetchBucket(bucketName).execute(); // bucket.delete(key).execute(); // } catch (RiakRetryFailedException rrfe) { // rrfe.printStackTrace(); // } catch (RiakException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } // } // Path: backend/src/main/java/no/haagensoftware/riak/RiakEnv.java import org.haagensoftware.netty.webserver.spi.PropertyConstants; import no.haagensoftware.riak.dao.RiakBucketDao; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakFactory; import com.basho.riak.client.raw.pbc.PBClientConfig; import com.basho.riak.client.raw.pbc.PBClusterConfig; package no.haagensoftware.riak; public class RiakEnv { private IRiakClient riakClient; private RiakBucketDao riakBucketDao; public RiakEnv() { } public void setup() throws RiakException { // Riak Protocol Buffers client with supplied IP and Port PBClusterConfig riakClusterConfig = new PBClusterConfig(20); // See above examples for client config options PBClientConfig riakClientConfig = PBClientConfig.defaults();
riakClusterConfig.addHosts(riakClientConfig, System.getProperty(PropertyConstants.RIAK_HOST));
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java
// Path: backend/src/main/java/no/akvaplan/postsense/datatypes/BucketData.java // public class BucketData { // private String id; // private String bucketName; // private List<String> keyIds; // // public BucketData() { // keyIds = new ArrayList<>(); // } // // public BucketData(String id) { // this(); // this.id = id; // this.bucketName = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getBucketName() { // return bucketName; // } // // public void setBucketName(String bucketName) { // this.bucketName = bucketName; // } // // public List<String> getKeyIds() { // return keyIds; // } // // public void setKeyIds(List<String> keyIds) { // this.keyIds = keyIds; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyData.java // public class KeyData { // private String id; // private String keyName; // // public KeyData() { // // TODO Auto-generated constructor stub // } // // public KeyData(String id) { // this.id = id; // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyValue.java // public class KeyValue { // String id; // String keyName; // String value; // // public KeyValue() { // // TODO Auto-generated constructor stub // } // // public KeyValue(String id, String value) { // this.id = id; // this.value = value; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // }
import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Logger; import no.akvaplan.postsense.datatypes.BucketData; import no.akvaplan.postsense.datatypes.KeyData; import no.akvaplan.postsense.datatypes.KeyValue; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakRetryFailedException; import com.basho.riak.client.bucket.Bucket; import com.basho.riak.client.query.indexes.BucketIndex; import com.google.gson.Gson;
package no.haagensoftware.riak.dao; public class RiakBucketDao { private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); private IRiakClient riakClient; public RiakBucketDao(IRiakClient riakClient) { this.riakClient = riakClient; }
// Path: backend/src/main/java/no/akvaplan/postsense/datatypes/BucketData.java // public class BucketData { // private String id; // private String bucketName; // private List<String> keyIds; // // public BucketData() { // keyIds = new ArrayList<>(); // } // // public BucketData(String id) { // this(); // this.id = id; // this.bucketName = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getBucketName() { // return bucketName; // } // // public void setBucketName(String bucketName) { // this.bucketName = bucketName; // } // // public List<String> getKeyIds() { // return keyIds; // } // // public void setKeyIds(List<String> keyIds) { // this.keyIds = keyIds; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyData.java // public class KeyData { // private String id; // private String keyName; // // public KeyData() { // // TODO Auto-generated constructor stub // } // // public KeyData(String id) { // this.id = id; // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyValue.java // public class KeyValue { // String id; // String keyName; // String value; // // public KeyValue() { // // TODO Auto-generated constructor stub // } // // public KeyValue(String id, String value) { // this.id = id; // this.value = value; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // Path: backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Logger; import no.akvaplan.postsense.datatypes.BucketData; import no.akvaplan.postsense.datatypes.KeyData; import no.akvaplan.postsense.datatypes.KeyValue; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakRetryFailedException; import com.basho.riak.client.bucket.Bucket; import com.basho.riak.client.query.indexes.BucketIndex; import com.google.gson.Gson; package no.haagensoftware.riak.dao; public class RiakBucketDao { private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); private IRiakClient riakClient; public RiakBucketDao(IRiakClient riakClient) { this.riakClient = riakClient; }
public List<BucketData> getBuckets() {
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java
// Path: backend/src/main/java/no/akvaplan/postsense/datatypes/BucketData.java // public class BucketData { // private String id; // private String bucketName; // private List<String> keyIds; // // public BucketData() { // keyIds = new ArrayList<>(); // } // // public BucketData(String id) { // this(); // this.id = id; // this.bucketName = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getBucketName() { // return bucketName; // } // // public void setBucketName(String bucketName) { // this.bucketName = bucketName; // } // // public List<String> getKeyIds() { // return keyIds; // } // // public void setKeyIds(List<String> keyIds) { // this.keyIds = keyIds; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyData.java // public class KeyData { // private String id; // private String keyName; // // public KeyData() { // // TODO Auto-generated constructor stub // } // // public KeyData(String id) { // this.id = id; // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyValue.java // public class KeyValue { // String id; // String keyName; // String value; // // public KeyValue() { // // TODO Auto-generated constructor stub // } // // public KeyValue(String id, String value) { // this.id = id; // this.value = value; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // }
import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Logger; import no.akvaplan.postsense.datatypes.BucketData; import no.akvaplan.postsense.datatypes.KeyData; import no.akvaplan.postsense.datatypes.KeyValue; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakRetryFailedException; import com.basho.riak.client.bucket.Bucket; import com.basho.riak.client.query.indexes.BucketIndex; import com.google.gson.Gson;
package no.haagensoftware.riak.dao; public class RiakBucketDao { private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); private IRiakClient riakClient; public RiakBucketDao(IRiakClient riakClient) { this.riakClient = riakClient; } public List<BucketData> getBuckets() { List<BucketData> bucketList = new ArrayList<>(); try { for (String bucket : riakClient.listBuckets()) { BucketData bd = new BucketData(bucket); List<String> keyIds = new ArrayList<>();
// Path: backend/src/main/java/no/akvaplan/postsense/datatypes/BucketData.java // public class BucketData { // private String id; // private String bucketName; // private List<String> keyIds; // // public BucketData() { // keyIds = new ArrayList<>(); // } // // public BucketData(String id) { // this(); // this.id = id; // this.bucketName = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getBucketName() { // return bucketName; // } // // public void setBucketName(String bucketName) { // this.bucketName = bucketName; // } // // public List<String> getKeyIds() { // return keyIds; // } // // public void setKeyIds(List<String> keyIds) { // this.keyIds = keyIds; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyData.java // public class KeyData { // private String id; // private String keyName; // // public KeyData() { // // TODO Auto-generated constructor stub // } // // public KeyData(String id) { // this.id = id; // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyValue.java // public class KeyValue { // String id; // String keyName; // String value; // // public KeyValue() { // // TODO Auto-generated constructor stub // } // // public KeyValue(String id, String value) { // this.id = id; // this.value = value; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // Path: backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Logger; import no.akvaplan.postsense.datatypes.BucketData; import no.akvaplan.postsense.datatypes.KeyData; import no.akvaplan.postsense.datatypes.KeyValue; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakRetryFailedException; import com.basho.riak.client.bucket.Bucket; import com.basho.riak.client.query.indexes.BucketIndex; import com.google.gson.Gson; package no.haagensoftware.riak.dao; public class RiakBucketDao { private static Logger logger = Logger.getLogger(RiakBucketDao.class.getName()); private IRiakClient riakClient; public RiakBucketDao(IRiakClient riakClient) { this.riakClient = riakClient; } public List<BucketData> getBuckets() { List<BucketData> bucketList = new ArrayList<>(); try { for (String bucket : riakClient.listBuckets()) { BucketData bd = new BucketData(bucket); List<String> keyIds = new ArrayList<>();
for (KeyData kd : getKeysForBucket(bucket)) {
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java
// Path: backend/src/main/java/no/akvaplan/postsense/datatypes/BucketData.java // public class BucketData { // private String id; // private String bucketName; // private List<String> keyIds; // // public BucketData() { // keyIds = new ArrayList<>(); // } // // public BucketData(String id) { // this(); // this.id = id; // this.bucketName = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getBucketName() { // return bucketName; // } // // public void setBucketName(String bucketName) { // this.bucketName = bucketName; // } // // public List<String> getKeyIds() { // return keyIds; // } // // public void setKeyIds(List<String> keyIds) { // this.keyIds = keyIds; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyData.java // public class KeyData { // private String id; // private String keyName; // // public KeyData() { // // TODO Auto-generated constructor stub // } // // public KeyData(String id) { // this.id = id; // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyValue.java // public class KeyValue { // String id; // String keyName; // String value; // // public KeyValue() { // // TODO Auto-generated constructor stub // } // // public KeyValue(String id, String value) { // this.id = id; // this.value = value; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // }
import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Logger; import no.akvaplan.postsense.datatypes.BucketData; import no.akvaplan.postsense.datatypes.KeyData; import no.akvaplan.postsense.datatypes.KeyValue; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakRetryFailedException; import com.basho.riak.client.bucket.Bucket; import com.basho.riak.client.query.indexes.BucketIndex; import com.google.gson.Gson;
bd.setKeyIds(keyIds); bucketList.add(bd); } } catch (RiakException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bucketList; } public List<KeyData> getKeysForBucket(String bucketName) { List<KeyData> keyList = new ArrayList<>(); Bucket bucket = null; try { bucket = riakClient.fetchBucket(bucketName).execute(); for (String key : bucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) { keyList.add(new KeyData(key)); } } catch (RiakRetryFailedException rrfe) { rrfe.printStackTrace(); } catch (RiakException e) { e.printStackTrace(); } return keyList; }
// Path: backend/src/main/java/no/akvaplan/postsense/datatypes/BucketData.java // public class BucketData { // private String id; // private String bucketName; // private List<String> keyIds; // // public BucketData() { // keyIds = new ArrayList<>(); // } // // public BucketData(String id) { // this(); // this.id = id; // this.bucketName = id; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getBucketName() { // return bucketName; // } // // public void setBucketName(String bucketName) { // this.bucketName = bucketName; // } // // public List<String> getKeyIds() { // return keyIds; // } // // public void setKeyIds(List<String> keyIds) { // this.keyIds = keyIds; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyData.java // public class KeyData { // private String id; // private String keyName; // // public KeyData() { // // TODO Auto-generated constructor stub // } // // public KeyData(String id) { // this.id = id; // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // } // // Path: backend/src/main/java/no/akvaplan/postsense/datatypes/KeyValue.java // public class KeyValue { // String id; // String keyName; // String value; // // public KeyValue() { // // TODO Auto-generated constructor stub // } // // public KeyValue(String id, String value) { // this.id = id; // this.value = value; // } // // public String getKeyName() { // return keyName; // } // // public void setKeyName(String keyName) { // this.keyName = keyName; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // Path: backend/src/main/java/no/haagensoftware/riak/dao/RiakBucketDao.java import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.log4j.Logger; import no.akvaplan.postsense.datatypes.BucketData; import no.akvaplan.postsense.datatypes.KeyData; import no.akvaplan.postsense.datatypes.KeyValue; import com.basho.riak.client.IRiakClient; import com.basho.riak.client.RiakException; import com.basho.riak.client.RiakRetryFailedException; import com.basho.riak.client.bucket.Bucket; import com.basho.riak.client.query.indexes.BucketIndex; import com.google.gson.Gson; bd.setKeyIds(keyIds); bucketList.add(bd); } } catch (RiakException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bucketList; } public List<KeyData> getKeysForBucket(String bucketName) { List<KeyData> keyList = new ArrayList<>(); Bucket bucket = null; try { bucket = riakClient.fetchBucket(bucketName).execute(); for (String key : bucket.fetchIndex(BucketIndex.index).withValue("$key").execute()) { keyList.add(new KeyData(key)); } } catch (RiakRetryFailedException rrfe) { rrfe.printStackTrace(); } catch (RiakException e) { e.printStackTrace(); } return keyList; }
public KeyValue getKeyValue(String bucketName, String key) {
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/pluginService/ApplicationRouterPluginService.java
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/NettyWebserverRouterPlugin.java // public abstract class NettyWebserverRouterPlugin { // // public abstract LinkedHashMap<String, SimpleChannelUpstreamHandler> getRoutes(); // // public abstract ChannelHandler getHandlerForRoute(String route); // // public abstract void setServerInfo(ServerInfo serverInfo); // }
import java.util.ArrayList; import java.util.List; import java.util.ServiceLoader; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.spi.NettyWebserverRouterPlugin;
package no.haagensoftware.pluginService; public class ApplicationRouterPluginService { private static Logger logger = Logger.getLogger(ApplicationRouterPluginService.class.getName()); private static ApplicationRouterPluginService pluginService = null;
// Path: backend/src/main/java/org/haagensoftware/netty/webserver/spi/NettyWebserverRouterPlugin.java // public abstract class NettyWebserverRouterPlugin { // // public abstract LinkedHashMap<String, SimpleChannelUpstreamHandler> getRoutes(); // // public abstract ChannelHandler getHandlerForRoute(String route); // // public abstract void setServerInfo(ServerInfo serverInfo); // } // Path: backend/src/main/java/no/haagensoftware/pluginService/ApplicationRouterPluginService.java import java.util.ArrayList; import java.util.List; import java.util.ServiceLoader; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.spi.NettyWebserverRouterPlugin; package no.haagensoftware.pluginService; public class ApplicationRouterPluginService { private static Logger logger = Logger.getLogger(ApplicationRouterPluginService.class.getName()); private static ApplicationRouterPluginService pluginService = null;
private ServiceLoader<NettyWebserverRouterPlugin> loader;
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/netty/webserver/handler/CacheableFileServerHandler.java
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachableHttpResponse.java // public class CachableHttpResponse extends DefaultHttpResponse { // private String requestUri; // private int cacheMaxAge; // // public CachableHttpResponse(HttpVersion version, HttpResponseStatus status) { // super(version, status); // } // // public String getRequestUri() { // return requestUri; // } // // public void setRequestUri(String requestUri) { // this.requestUri = requestUri; // } // // public int getCacheMaxAge() { // return cacheMaxAge; // } // // public void setCacheMaxAge(int cacheMaxAge) { // this.cacheMaxAge = cacheMaxAge; // } // } // // Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachedChannelBuffer.java // public class CachedChannelBuffer { // private ChannelBuffer channelBuffer; // private long expires; // // public CachedChannelBuffer(ChannelBuffer channelBuffer, long expires) { // this.channelBuffer = channelBuffer; // this.expires = expires; // } // // public ChannelBuffer getChannelBuffer() { // return channelBuffer; // } // // public long getExpires() { // return expires; // } // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // }
import static org.jboss.netty.handler.codec.http.HttpHeaders.isKeepAlive; import static org.jboss.netty.handler.codec.http.HttpHeaders.setContentLength; import static org.jboss.netty.handler.codec.http.HttpMethod.GET; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK; import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.concurrent.ConcurrentHashMap; import no.haagensoftware.netty.webserver.response.CachableHttpResponse; import no.haagensoftware.netty.webserver.response.CachedChannelBuffer; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpRequest;
package no.haagensoftware.netty.webserver.handler; public class CacheableFileServerHandler extends FileServerHandler { private static Logger logger = Logger.getLogger(CacheableFileServerHandler.class.getName());
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachableHttpResponse.java // public class CachableHttpResponse extends DefaultHttpResponse { // private String requestUri; // private int cacheMaxAge; // // public CachableHttpResponse(HttpVersion version, HttpResponseStatus status) { // super(version, status); // } // // public String getRequestUri() { // return requestUri; // } // // public void setRequestUri(String requestUri) { // this.requestUri = requestUri; // } // // public int getCacheMaxAge() { // return cacheMaxAge; // } // // public void setCacheMaxAge(int cacheMaxAge) { // this.cacheMaxAge = cacheMaxAge; // } // } // // Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachedChannelBuffer.java // public class CachedChannelBuffer { // private ChannelBuffer channelBuffer; // private long expires; // // public CachedChannelBuffer(ChannelBuffer channelBuffer, long expires) { // this.channelBuffer = channelBuffer; // this.expires = expires; // } // // public ChannelBuffer getChannelBuffer() { // return channelBuffer; // } // // public long getExpires() { // return expires; // } // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // } // Path: backend/src/main/java/no/haagensoftware/netty/webserver/handler/CacheableFileServerHandler.java import static org.jboss.netty.handler.codec.http.HttpHeaders.isKeepAlive; import static org.jboss.netty.handler.codec.http.HttpHeaders.setContentLength; import static org.jboss.netty.handler.codec.http.HttpMethod.GET; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK; import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.concurrent.ConcurrentHashMap; import no.haagensoftware.netty.webserver.response.CachableHttpResponse; import no.haagensoftware.netty.webserver.response.CachedChannelBuffer; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpRequest; package no.haagensoftware.netty.webserver.handler; public class CacheableFileServerHandler extends FileServerHandler { private static Logger logger = Logger.getLogger(CacheableFileServerHandler.class.getName());
private static ConcurrentHashMap<String, CachedChannelBuffer> cache = new ConcurrentHashMap<String, CachedChannelBuffer>();
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/netty/webserver/handler/CacheableFileServerHandler.java
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachableHttpResponse.java // public class CachableHttpResponse extends DefaultHttpResponse { // private String requestUri; // private int cacheMaxAge; // // public CachableHttpResponse(HttpVersion version, HttpResponseStatus status) { // super(version, status); // } // // public String getRequestUri() { // return requestUri; // } // // public void setRequestUri(String requestUri) { // this.requestUri = requestUri; // } // // public int getCacheMaxAge() { // return cacheMaxAge; // } // // public void setCacheMaxAge(int cacheMaxAge) { // this.cacheMaxAge = cacheMaxAge; // } // } // // Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachedChannelBuffer.java // public class CachedChannelBuffer { // private ChannelBuffer channelBuffer; // private long expires; // // public CachedChannelBuffer(ChannelBuffer channelBuffer, long expires) { // this.channelBuffer = channelBuffer; // this.expires = expires; // } // // public ChannelBuffer getChannelBuffer() { // return channelBuffer; // } // // public long getExpires() { // return expires; // } // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // }
import static org.jboss.netty.handler.codec.http.HttpHeaders.isKeepAlive; import static org.jboss.netty.handler.codec.http.HttpHeaders.setContentLength; import static org.jboss.netty.handler.codec.http.HttpMethod.GET; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK; import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.concurrent.ConcurrentHashMap; import no.haagensoftware.netty.webserver.response.CachableHttpResponse; import no.haagensoftware.netty.webserver.response.CachedChannelBuffer; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpRequest;
package no.haagensoftware.netty.webserver.handler; public class CacheableFileServerHandler extends FileServerHandler { private static Logger logger = Logger.getLogger(CacheableFileServerHandler.class.getName()); private static ConcurrentHashMap<String, CachedChannelBuffer> cache = new ConcurrentHashMap<String, CachedChannelBuffer>(); public CacheableFileServerHandler(String rootPath, int cacheMaxAge) { super(rootPath, cacheMaxAge); } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); if (request.getMethod() != GET) { sendError(ctx, METHOD_NOT_ALLOWED); return; } String uri = request.getUri(); final String path = sanitizeUri(uri); if (path == null) { sendError(ctx, FORBIDDEN); return; } ChannelBuffer content = getFileContent(path); if (content == null) { sendError(ctx, NOT_FOUND); return; }
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachableHttpResponse.java // public class CachableHttpResponse extends DefaultHttpResponse { // private String requestUri; // private int cacheMaxAge; // // public CachableHttpResponse(HttpVersion version, HttpResponseStatus status) { // super(version, status); // } // // public String getRequestUri() { // return requestUri; // } // // public void setRequestUri(String requestUri) { // this.requestUri = requestUri; // } // // public int getCacheMaxAge() { // return cacheMaxAge; // } // // public void setCacheMaxAge(int cacheMaxAge) { // this.cacheMaxAge = cacheMaxAge; // } // } // // Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachedChannelBuffer.java // public class CachedChannelBuffer { // private ChannelBuffer channelBuffer; // private long expires; // // public CachedChannelBuffer(ChannelBuffer channelBuffer, long expires) { // this.channelBuffer = channelBuffer; // this.expires = expires; // } // // public ChannelBuffer getChannelBuffer() { // return channelBuffer; // } // // public long getExpires() { // return expires; // } // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // } // Path: backend/src/main/java/no/haagensoftware/netty/webserver/handler/CacheableFileServerHandler.java import static org.jboss.netty.handler.codec.http.HttpHeaders.isKeepAlive; import static org.jboss.netty.handler.codec.http.HttpHeaders.setContentLength; import static org.jboss.netty.handler.codec.http.HttpMethod.GET; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK; import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.concurrent.ConcurrentHashMap; import no.haagensoftware.netty.webserver.response.CachableHttpResponse; import no.haagensoftware.netty.webserver.response.CachedChannelBuffer; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpRequest; package no.haagensoftware.netty.webserver.handler; public class CacheableFileServerHandler extends FileServerHandler { private static Logger logger = Logger.getLogger(CacheableFileServerHandler.class.getName()); private static ConcurrentHashMap<String, CachedChannelBuffer> cache = new ConcurrentHashMap<String, CachedChannelBuffer>(); public CacheableFileServerHandler(String rootPath, int cacheMaxAge) { super(rootPath, cacheMaxAge); } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); if (request.getMethod() != GET) { sendError(ctx, METHOD_NOT_ALLOWED); return; } String uri = request.getUri(); final String path = sanitizeUri(uri); if (path == null) { sendError(ctx, FORBIDDEN); return; } ChannelBuffer content = getFileContent(path); if (content == null) { sendError(ctx, NOT_FOUND); return; }
String contentType = ContentTypeUtil.getContentType(path);
joachimhs/Embriak
backend/src/main/java/no/haagensoftware/netty/webserver/handler/CacheableFileServerHandler.java
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachableHttpResponse.java // public class CachableHttpResponse extends DefaultHttpResponse { // private String requestUri; // private int cacheMaxAge; // // public CachableHttpResponse(HttpVersion version, HttpResponseStatus status) { // super(version, status); // } // // public String getRequestUri() { // return requestUri; // } // // public void setRequestUri(String requestUri) { // this.requestUri = requestUri; // } // // public int getCacheMaxAge() { // return cacheMaxAge; // } // // public void setCacheMaxAge(int cacheMaxAge) { // this.cacheMaxAge = cacheMaxAge; // } // } // // Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachedChannelBuffer.java // public class CachedChannelBuffer { // private ChannelBuffer channelBuffer; // private long expires; // // public CachedChannelBuffer(ChannelBuffer channelBuffer, long expires) { // this.channelBuffer = channelBuffer; // this.expires = expires; // } // // public ChannelBuffer getChannelBuffer() { // return channelBuffer; // } // // public long getExpires() { // return expires; // } // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // }
import static org.jboss.netty.handler.codec.http.HttpHeaders.isKeepAlive; import static org.jboss.netty.handler.codec.http.HttpHeaders.setContentLength; import static org.jboss.netty.handler.codec.http.HttpMethod.GET; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK; import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.concurrent.ConcurrentHashMap; import no.haagensoftware.netty.webserver.response.CachableHttpResponse; import no.haagensoftware.netty.webserver.response.CachedChannelBuffer; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpRequest;
package no.haagensoftware.netty.webserver.handler; public class CacheableFileServerHandler extends FileServerHandler { private static Logger logger = Logger.getLogger(CacheableFileServerHandler.class.getName()); private static ConcurrentHashMap<String, CachedChannelBuffer> cache = new ConcurrentHashMap<String, CachedChannelBuffer>(); public CacheableFileServerHandler(String rootPath, int cacheMaxAge) { super(rootPath, cacheMaxAge); } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); if (request.getMethod() != GET) { sendError(ctx, METHOD_NOT_ALLOWED); return; } String uri = request.getUri(); final String path = sanitizeUri(uri); if (path == null) { sendError(ctx, FORBIDDEN); return; } ChannelBuffer content = getFileContent(path); if (content == null) { sendError(ctx, NOT_FOUND); return; } String contentType = ContentTypeUtil.getContentType(path); logger.info("contentType: " + contentType + " for path: " + path);
// Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachableHttpResponse.java // public class CachableHttpResponse extends DefaultHttpResponse { // private String requestUri; // private int cacheMaxAge; // // public CachableHttpResponse(HttpVersion version, HttpResponseStatus status) { // super(version, status); // } // // public String getRequestUri() { // return requestUri; // } // // public void setRequestUri(String requestUri) { // this.requestUri = requestUri; // } // // public int getCacheMaxAge() { // return cacheMaxAge; // } // // public void setCacheMaxAge(int cacheMaxAge) { // this.cacheMaxAge = cacheMaxAge; // } // } // // Path: backend/src/main/java/no/haagensoftware/netty/webserver/response/CachedChannelBuffer.java // public class CachedChannelBuffer { // private ChannelBuffer channelBuffer; // private long expires; // // public CachedChannelBuffer(ChannelBuffer channelBuffer, long expires) { // this.channelBuffer = channelBuffer; // this.expires = expires; // } // // public ChannelBuffer getChannelBuffer() { // return channelBuffer; // } // // public long getExpires() { // return expires; // } // } // // Path: backend/src/main/java/org/haagensoftware/netty/webserver/util/ContentTypeUtil.java // public class ContentTypeUtil { // private static Hashtable<String, String> contentTypeHash = new Hashtable<String, String>(); // // static { // contentTypeHash.put("png", "image/png"); // contentTypeHash.put("PNG", "image/png"); // contentTypeHash.put("txt", "text/plain"); // contentTypeHash.put("text", "text/plain"); // contentTypeHash.put("TXT", "text/plain"); // contentTypeHash.put("js", "application/javascript"); // contentTypeHash.put("jpg", "image/jpeg"); // contentTypeHash.put("jpeg", "image/jpeg"); // contentTypeHash.put("JPG", "image/jpeg"); // contentTypeHash.put("JPEG", "image/jpeg"); // contentTypeHash.put("css", "text/css"); // contentTypeHash.put("CSS", "text/css"); // contentTypeHash.put("json", "text/json"); // contentTypeHash.put("html", "text/html"); // contentTypeHash.put("htm", "text/html"); // } // // public static String getContentType(String filename) { // String fileEnding = filename.substring(filename.lastIndexOf(".")+1); // System.out.println(fileEnding); // if (contentTypeHash.get(fileEnding) != null) { // return contentTypeHash.get(fileEnding); // } // // return "text/plain"; // } // } // Path: backend/src/main/java/no/haagensoftware/netty/webserver/handler/CacheableFileServerHandler.java import static org.jboss.netty.handler.codec.http.HttpHeaders.isKeepAlive; import static org.jboss.netty.handler.codec.http.HttpHeaders.setContentLength; import static org.jboss.netty.handler.codec.http.HttpMethod.GET; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK; import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; import java.util.concurrent.ConcurrentHashMap; import no.haagensoftware.netty.webserver.response.CachableHttpResponse; import no.haagensoftware.netty.webserver.response.CachedChannelBuffer; import org.apache.log4j.Logger; import org.haagensoftware.netty.webserver.util.ContentTypeUtil; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.jboss.netty.handler.codec.http.HttpRequest; package no.haagensoftware.netty.webserver.handler; public class CacheableFileServerHandler extends FileServerHandler { private static Logger logger = Logger.getLogger(CacheableFileServerHandler.class.getName()); private static ConcurrentHashMap<String, CachedChannelBuffer> cache = new ConcurrentHashMap<String, CachedChannelBuffer>(); public CacheableFileServerHandler(String rootPath, int cacheMaxAge) { super(rootPath, cacheMaxAge); } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { HttpRequest request = (HttpRequest) e.getMessage(); if (request.getMethod() != GET) { sendError(ctx, METHOD_NOT_ALLOWED); return; } String uri = request.getUri(); final String path = sanitizeUri(uri); if (path == null) { sendError(ctx, FORBIDDEN); return; } ChannelBuffer content = getFileContent(path); if (content == null) { sendError(ctx, NOT_FOUND); return; } String contentType = ContentTypeUtil.getContentType(path); logger.info("contentType: " + contentType + " for path: " + path);
CachableHttpResponse response = new CachableHttpResponse(HTTP_1_1, OK);
pxb1988/dex2jar
dex-translator/src/main/java/com/googlecode/d2j/dex/ExDex2Asm.java
// Path: dex-translator/src/main/java/org/objectweb/asm/AsmBridge.java // public class AsmBridge { // public static MethodVisitor searchMethodWriter(MethodVisitor mv) { // while (mv != null && !(mv instanceof MethodWriter)) { // mv = mv.mv; // } // return mv; // } // // public static int sizeOfMethodWriter(MethodVisitor mv) { // MethodWriter mw = (MethodWriter) mv; // return mw.getSize(); // } // // private static void removeMethodWriter(MethodWriter mw) { // // mv must be the last element // ClassWriter cw = mw.cw; // MethodWriter p = cw.firstMethod; // if (p == mw) { // cw.firstMethod = null; // if (cw.lastMethod == mw) { // cw.lastMethod = null; // } // } else { // while (p != null) { // if (p.mv == mw) { // p.mv = mw.mv; // if (cw.lastMethod == mw) { // cw.lastMethod = p; // } // break; // } else { // p = (MethodWriter) p.mv; // } // } // } // } // // public static void replaceMethodWriter(MethodVisitor mv, MethodNode mn) { // MethodWriter mw = (MethodWriter) mv; // ClassWriter cw = mw.cw; // mn.accept(cw); // removeMethodWriter(mw); // } // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexMethodNode.java // public class DexMethodNode extends DexMethodVisitor { // public int access; // public List<DexAnnotationNode> anns; // public DexCodeNode codeNode; // public Method method; // public List<DexAnnotationNode> parameterAnns[]; // // public DexMethodNode(DexMethodVisitor mv, int access, Method method) { // super(mv); // this.access = access; // this.method = method; // } // // public DexMethodNode(int access, Method method) { // super(); // this.access = access; // this.method = method; // } // // public void accept(DexClassVisitor dcv) { // DexMethodVisitor mv = dcv.visitMethod(access, method); // if (mv != null) { // accept(mv); // mv.visitEnd(); // } // // } // // public void accept(DexMethodVisitor mv) { // if (anns != null) { // for (DexAnnotationNode ann : anns) { // ann.accept(mv); // } // } // // if (parameterAnns != null) { // for (int i = 0; i < parameterAnns.length; i++) { // List<DexAnnotationNode> ps = parameterAnns[i]; // if (ps != null) { // DexAnnotationAble av = mv.visitParameterAnnotation(i); // if (av != null) { // for (DexAnnotationNode p : ps) { // p.accept(av); // } // } // } // } // } // if (codeNode != null) { // codeNode.accept(mv); // } // } // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // if (anns == null) { // anns = new ArrayList<DexAnnotationNode>(5); // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // anns.add(annotation); // return annotation; // } // // @Override // public DexCodeVisitor visitCode() { // DexCodeNode codeNode = new DexCodeNode(super.visitCode()); // this.codeNode = codeNode; // return codeNode; // } // // @SuppressWarnings("unchecked") // @Override // public DexAnnotationAble visitParameterAnnotation(final int index) { // if (parameterAnns == null) { // parameterAnns = new List[method.getParameterTypes().length]; // } // // // // https://github.com/pxb1988/dex2jar/issues/485 // // skip param annotation if out of range // if (index >= parameterAnns.length) { // System.err.println("WARN: parameter out-of-range in " + method); // return null; // } // // return new DexAnnotationAble() { // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // List<DexAnnotationNode> pas = parameterAnns[index]; // if (pas == null) { // pas = new ArrayList<DexAnnotationNode>(5); // parameterAnns[index] = pas; // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // pas.add(annotation); // return annotation; // } // }; // } // // }
import org.objectweb.asm.AsmBridge; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.MethodNode; import com.googlecode.d2j.DexException; import com.googlecode.d2j.node.DexMethodNode;
/* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2014 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.dex; public class ExDex2Asm extends Dex2Asm { final protected DexExceptionHandler exceptionHandler; public ExDex2Asm(DexExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } @Override
// Path: dex-translator/src/main/java/org/objectweb/asm/AsmBridge.java // public class AsmBridge { // public static MethodVisitor searchMethodWriter(MethodVisitor mv) { // while (mv != null && !(mv instanceof MethodWriter)) { // mv = mv.mv; // } // return mv; // } // // public static int sizeOfMethodWriter(MethodVisitor mv) { // MethodWriter mw = (MethodWriter) mv; // return mw.getSize(); // } // // private static void removeMethodWriter(MethodWriter mw) { // // mv must be the last element // ClassWriter cw = mw.cw; // MethodWriter p = cw.firstMethod; // if (p == mw) { // cw.firstMethod = null; // if (cw.lastMethod == mw) { // cw.lastMethod = null; // } // } else { // while (p != null) { // if (p.mv == mw) { // p.mv = mw.mv; // if (cw.lastMethod == mw) { // cw.lastMethod = p; // } // break; // } else { // p = (MethodWriter) p.mv; // } // } // } // } // // public static void replaceMethodWriter(MethodVisitor mv, MethodNode mn) { // MethodWriter mw = (MethodWriter) mv; // ClassWriter cw = mw.cw; // mn.accept(cw); // removeMethodWriter(mw); // } // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexMethodNode.java // public class DexMethodNode extends DexMethodVisitor { // public int access; // public List<DexAnnotationNode> anns; // public DexCodeNode codeNode; // public Method method; // public List<DexAnnotationNode> parameterAnns[]; // // public DexMethodNode(DexMethodVisitor mv, int access, Method method) { // super(mv); // this.access = access; // this.method = method; // } // // public DexMethodNode(int access, Method method) { // super(); // this.access = access; // this.method = method; // } // // public void accept(DexClassVisitor dcv) { // DexMethodVisitor mv = dcv.visitMethod(access, method); // if (mv != null) { // accept(mv); // mv.visitEnd(); // } // // } // // public void accept(DexMethodVisitor mv) { // if (anns != null) { // for (DexAnnotationNode ann : anns) { // ann.accept(mv); // } // } // // if (parameterAnns != null) { // for (int i = 0; i < parameterAnns.length; i++) { // List<DexAnnotationNode> ps = parameterAnns[i]; // if (ps != null) { // DexAnnotationAble av = mv.visitParameterAnnotation(i); // if (av != null) { // for (DexAnnotationNode p : ps) { // p.accept(av); // } // } // } // } // } // if (codeNode != null) { // codeNode.accept(mv); // } // } // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // if (anns == null) { // anns = new ArrayList<DexAnnotationNode>(5); // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // anns.add(annotation); // return annotation; // } // // @Override // public DexCodeVisitor visitCode() { // DexCodeNode codeNode = new DexCodeNode(super.visitCode()); // this.codeNode = codeNode; // return codeNode; // } // // @SuppressWarnings("unchecked") // @Override // public DexAnnotationAble visitParameterAnnotation(final int index) { // if (parameterAnns == null) { // parameterAnns = new List[method.getParameterTypes().length]; // } // // // // https://github.com/pxb1988/dex2jar/issues/485 // // skip param annotation if out of range // if (index >= parameterAnns.length) { // System.err.println("WARN: parameter out-of-range in " + method); // return null; // } // // return new DexAnnotationAble() { // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // List<DexAnnotationNode> pas = parameterAnns[index]; // if (pas == null) { // pas = new ArrayList<DexAnnotationNode>(5); // parameterAnns[index] = pas; // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // pas.add(annotation); // return annotation; // } // }; // } // // } // Path: dex-translator/src/main/java/com/googlecode/d2j/dex/ExDex2Asm.java import org.objectweb.asm.AsmBridge; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.MethodNode; import com.googlecode.d2j.DexException; import com.googlecode.d2j.node.DexMethodNode; /* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2014 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.dex; public class ExDex2Asm extends Dex2Asm { final protected DexExceptionHandler exceptionHandler; public ExDex2Asm(DexExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } @Override
public void convertCode(DexMethodNode methodNode, MethodVisitor mv, ClzCtx clzCtx) {
pxb1988/dex2jar
dex-translator/src/main/java/com/googlecode/d2j/dex/ExDex2Asm.java
// Path: dex-translator/src/main/java/org/objectweb/asm/AsmBridge.java // public class AsmBridge { // public static MethodVisitor searchMethodWriter(MethodVisitor mv) { // while (mv != null && !(mv instanceof MethodWriter)) { // mv = mv.mv; // } // return mv; // } // // public static int sizeOfMethodWriter(MethodVisitor mv) { // MethodWriter mw = (MethodWriter) mv; // return mw.getSize(); // } // // private static void removeMethodWriter(MethodWriter mw) { // // mv must be the last element // ClassWriter cw = mw.cw; // MethodWriter p = cw.firstMethod; // if (p == mw) { // cw.firstMethod = null; // if (cw.lastMethod == mw) { // cw.lastMethod = null; // } // } else { // while (p != null) { // if (p.mv == mw) { // p.mv = mw.mv; // if (cw.lastMethod == mw) { // cw.lastMethod = p; // } // break; // } else { // p = (MethodWriter) p.mv; // } // } // } // } // // public static void replaceMethodWriter(MethodVisitor mv, MethodNode mn) { // MethodWriter mw = (MethodWriter) mv; // ClassWriter cw = mw.cw; // mn.accept(cw); // removeMethodWriter(mw); // } // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexMethodNode.java // public class DexMethodNode extends DexMethodVisitor { // public int access; // public List<DexAnnotationNode> anns; // public DexCodeNode codeNode; // public Method method; // public List<DexAnnotationNode> parameterAnns[]; // // public DexMethodNode(DexMethodVisitor mv, int access, Method method) { // super(mv); // this.access = access; // this.method = method; // } // // public DexMethodNode(int access, Method method) { // super(); // this.access = access; // this.method = method; // } // // public void accept(DexClassVisitor dcv) { // DexMethodVisitor mv = dcv.visitMethod(access, method); // if (mv != null) { // accept(mv); // mv.visitEnd(); // } // // } // // public void accept(DexMethodVisitor mv) { // if (anns != null) { // for (DexAnnotationNode ann : anns) { // ann.accept(mv); // } // } // // if (parameterAnns != null) { // for (int i = 0; i < parameterAnns.length; i++) { // List<DexAnnotationNode> ps = parameterAnns[i]; // if (ps != null) { // DexAnnotationAble av = mv.visitParameterAnnotation(i); // if (av != null) { // for (DexAnnotationNode p : ps) { // p.accept(av); // } // } // } // } // } // if (codeNode != null) { // codeNode.accept(mv); // } // } // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // if (anns == null) { // anns = new ArrayList<DexAnnotationNode>(5); // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // anns.add(annotation); // return annotation; // } // // @Override // public DexCodeVisitor visitCode() { // DexCodeNode codeNode = new DexCodeNode(super.visitCode()); // this.codeNode = codeNode; // return codeNode; // } // // @SuppressWarnings("unchecked") // @Override // public DexAnnotationAble visitParameterAnnotation(final int index) { // if (parameterAnns == null) { // parameterAnns = new List[method.getParameterTypes().length]; // } // // // // https://github.com/pxb1988/dex2jar/issues/485 // // skip param annotation if out of range // if (index >= parameterAnns.length) { // System.err.println("WARN: parameter out-of-range in " + method); // return null; // } // // return new DexAnnotationAble() { // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // List<DexAnnotationNode> pas = parameterAnns[index]; // if (pas == null) { // pas = new ArrayList<DexAnnotationNode>(5); // parameterAnns[index] = pas; // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // pas.add(annotation); // return annotation; // } // }; // } // // }
import org.objectweb.asm.AsmBridge; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.MethodNode; import com.googlecode.d2j.DexException; import com.googlecode.d2j.node.DexMethodNode;
/* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2014 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.dex; public class ExDex2Asm extends Dex2Asm { final protected DexExceptionHandler exceptionHandler; public ExDex2Asm(DexExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } @Override public void convertCode(DexMethodNode methodNode, MethodVisitor mv, ClzCtx clzCtx) {
// Path: dex-translator/src/main/java/org/objectweb/asm/AsmBridge.java // public class AsmBridge { // public static MethodVisitor searchMethodWriter(MethodVisitor mv) { // while (mv != null && !(mv instanceof MethodWriter)) { // mv = mv.mv; // } // return mv; // } // // public static int sizeOfMethodWriter(MethodVisitor mv) { // MethodWriter mw = (MethodWriter) mv; // return mw.getSize(); // } // // private static void removeMethodWriter(MethodWriter mw) { // // mv must be the last element // ClassWriter cw = mw.cw; // MethodWriter p = cw.firstMethod; // if (p == mw) { // cw.firstMethod = null; // if (cw.lastMethod == mw) { // cw.lastMethod = null; // } // } else { // while (p != null) { // if (p.mv == mw) { // p.mv = mw.mv; // if (cw.lastMethod == mw) { // cw.lastMethod = p; // } // break; // } else { // p = (MethodWriter) p.mv; // } // } // } // } // // public static void replaceMethodWriter(MethodVisitor mv, MethodNode mn) { // MethodWriter mw = (MethodWriter) mv; // ClassWriter cw = mw.cw; // mn.accept(cw); // removeMethodWriter(mw); // } // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexMethodNode.java // public class DexMethodNode extends DexMethodVisitor { // public int access; // public List<DexAnnotationNode> anns; // public DexCodeNode codeNode; // public Method method; // public List<DexAnnotationNode> parameterAnns[]; // // public DexMethodNode(DexMethodVisitor mv, int access, Method method) { // super(mv); // this.access = access; // this.method = method; // } // // public DexMethodNode(int access, Method method) { // super(); // this.access = access; // this.method = method; // } // // public void accept(DexClassVisitor dcv) { // DexMethodVisitor mv = dcv.visitMethod(access, method); // if (mv != null) { // accept(mv); // mv.visitEnd(); // } // // } // // public void accept(DexMethodVisitor mv) { // if (anns != null) { // for (DexAnnotationNode ann : anns) { // ann.accept(mv); // } // } // // if (parameterAnns != null) { // for (int i = 0; i < parameterAnns.length; i++) { // List<DexAnnotationNode> ps = parameterAnns[i]; // if (ps != null) { // DexAnnotationAble av = mv.visitParameterAnnotation(i); // if (av != null) { // for (DexAnnotationNode p : ps) { // p.accept(av); // } // } // } // } // } // if (codeNode != null) { // codeNode.accept(mv); // } // } // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // if (anns == null) { // anns = new ArrayList<DexAnnotationNode>(5); // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // anns.add(annotation); // return annotation; // } // // @Override // public DexCodeVisitor visitCode() { // DexCodeNode codeNode = new DexCodeNode(super.visitCode()); // this.codeNode = codeNode; // return codeNode; // } // // @SuppressWarnings("unchecked") // @Override // public DexAnnotationAble visitParameterAnnotation(final int index) { // if (parameterAnns == null) { // parameterAnns = new List[method.getParameterTypes().length]; // } // // // // https://github.com/pxb1988/dex2jar/issues/485 // // skip param annotation if out of range // if (index >= parameterAnns.length) { // System.err.println("WARN: parameter out-of-range in " + method); // return null; // } // // return new DexAnnotationAble() { // // @Override // public DexAnnotationVisitor visitAnnotation(String name, Visibility visibility) { // List<DexAnnotationNode> pas = parameterAnns[index]; // if (pas == null) { // pas = new ArrayList<DexAnnotationNode>(5); // parameterAnns[index] = pas; // } // DexAnnotationNode annotation = new DexAnnotationNode(name, visibility); // pas.add(annotation); // return annotation; // } // }; // } // // } // Path: dex-translator/src/main/java/com/googlecode/d2j/dex/ExDex2Asm.java import org.objectweb.asm.AsmBridge; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.MethodNode; import com.googlecode.d2j.DexException; import com.googlecode.d2j.node.DexMethodNode; /* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2014 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.dex; public class ExDex2Asm extends Dex2Asm { final protected DexExceptionHandler exceptionHandler; public ExDex2Asm(DexExceptionHandler exceptionHandler) { this.exceptionHandler = exceptionHandler; } @Override public void convertCode(DexMethodNode methodNode, MethodVisitor mv, ClzCtx clzCtx) {
MethodVisitor mw = AsmBridge.searchMethodWriter(mv);
pxb1988/dex2jar
dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/InvokePolymorphicExpr.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/Method.java // public class Method { // /** // * name of the method. // */ // private String name; // /** // * owner class of the method, in TypeDescriptor format. // */ // private String owner; // /** // * parameter types of the method, in TypeDescriptor format. // */ // private Proto proto; // // public Proto getProto() { // return proto; // } // // public Method(String owner, String name, String[] parameterTypes, String returnType) { // this.owner = owner; // this.name = name; // this.proto = new Proto(parameterTypes, returnType); // } // public Method(String owner, String name, Proto proto) { // this.owner = owner; // this.name = name; // this.proto = proto; // } // public String getDesc() { // return proto.getDesc(); // } // // /** // * @return the name // */ // public String getName() { // return name; // } // // /** // * @return the owner // */ // public String getOwner() { // return owner; // } // // /** // * @return the parameterTypes // */ // public String[] getParameterTypes() { // return proto.getParameterTypes(); // } // // public String getReturnType() { // return proto.getReturnType(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Method method = (Method) o; // // if (name != null ? !name.equals(method.name) : method.name != null) return false; // if (owner != null ? !owner.equals(method.owner) : method.owner != null) return false; // return proto.equals(method.proto); // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (owner != null ? owner.hashCode() : 0); // result = 31 * result + proto.hashCode(); // return result; // } // // /* // * (non-Javadoc) // * // * @see java.lang.Object#toString() // */ // @Override // public String toString() { // return this.getOwner() + "->" + this.getName() + this.getDesc(); // } // }
import com.googlecode.d2j.Method; import com.googlecode.d2j.Proto; import com.googlecode.dex2jar.ir.LabelAndLocalMapper; import com.googlecode.dex2jar.ir.Util;
/* * Copyright (c) 2009-2017 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.dex2jar.ir.expr; public class InvokePolymorphicExpr extends AbstractInvokeExpr { public Proto proto;
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/Method.java // public class Method { // /** // * name of the method. // */ // private String name; // /** // * owner class of the method, in TypeDescriptor format. // */ // private String owner; // /** // * parameter types of the method, in TypeDescriptor format. // */ // private Proto proto; // // public Proto getProto() { // return proto; // } // // public Method(String owner, String name, String[] parameterTypes, String returnType) { // this.owner = owner; // this.name = name; // this.proto = new Proto(parameterTypes, returnType); // } // public Method(String owner, String name, Proto proto) { // this.owner = owner; // this.name = name; // this.proto = proto; // } // public String getDesc() { // return proto.getDesc(); // } // // /** // * @return the name // */ // public String getName() { // return name; // } // // /** // * @return the owner // */ // public String getOwner() { // return owner; // } // // /** // * @return the parameterTypes // */ // public String[] getParameterTypes() { // return proto.getParameterTypes(); // } // // public String getReturnType() { // return proto.getReturnType(); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // Method method = (Method) o; // // if (name != null ? !name.equals(method.name) : method.name != null) return false; // if (owner != null ? !owner.equals(method.owner) : method.owner != null) return false; // return proto.equals(method.proto); // } // // @Override // public int hashCode() { // int result = name != null ? name.hashCode() : 0; // result = 31 * result + (owner != null ? owner.hashCode() : 0); // result = 31 * result + proto.hashCode(); // return result; // } // // /* // * (non-Javadoc) // * // * @see java.lang.Object#toString() // */ // @Override // public String toString() { // return this.getOwner() + "->" + this.getName() + this.getDesc(); // } // } // Path: dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/InvokePolymorphicExpr.java import com.googlecode.d2j.Method; import com.googlecode.d2j.Proto; import com.googlecode.dex2jar.ir.LabelAndLocalMapper; import com.googlecode.dex2jar.ir.Util; /* * Copyright (c) 2009-2017 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.dex2jar.ir.expr; public class InvokePolymorphicExpr extends AbstractInvokeExpr { public Proto proto;
public Method method;
pxb1988/dex2jar
d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java // public class DexFileNode extends DexFileVisitor { // public List<DexClassNode> clzs = new ArrayList<>(); // public int dexVersion = DexConstants.DEX_035; // // @Override // public void visitDexFileVersion(int version) { // this.dexVersion = version; // super.visitDexFileVersion(version); // } // // @Override // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames); // clzs.add(cn); // return cn; // } // // public void accept(DexClassVisitor dcv) { // for (DexClassNode cn : clzs) { // cn.accept(dcv); // } // } // // public void accept(DexFileVisitor dfv) { // for (DexClassNode cn : clzs) { // cn.accept(dfv); // } // } // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java // public class DexFileVisitor { // protected DexFileVisitor visitor; // // public DexFileVisitor() { // super(); // } // // public DexFileVisitor(DexFileVisitor visitor) { // super(); // this.visitor = visitor; // } // // public void visitDexFileVersion(int version) { // if (visitor != null) { // visitor.visitDexFileVersion(version); // } // } // // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // if (visitor == null) { // return null; // } // return visitor.visit(access_flags, className, superClass, interfaceNames); // } // // public void visitEnd() { // if (visitor == null) { // return; // } // visitor.visitEnd(); // } // // }
import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import com.googlecode.d2j.node.DexClassNode; import com.googlecode.d2j.node.DexFileNode; import com.googlecode.d2j.smali.antlr4.SmaliLexer; import com.googlecode.d2j.smali.antlr4.SmaliParser; import com.googlecode.d2j.visitors.DexFileVisitor; import org.antlr.v4.runtime.*; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; import java.nio.file.FileVisitResult; import java.nio.file.Files;
/* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2013 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.smali; public class Smali { public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException { try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { ANTLRInputStream is = new ANTLRInputStream(reader); is.name = path.toString(); smali0(dcv, is); } } public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException { ANTLRInputStream is = new ANTLRInputStream(buff); is.name = name; smali0(dcv, is); } public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException { try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { ANTLRInputStream is = new ANTLRInputStream(reader); is.name = name; smali0(dcv, is); } } public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException {
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java // public class DexFileNode extends DexFileVisitor { // public List<DexClassNode> clzs = new ArrayList<>(); // public int dexVersion = DexConstants.DEX_035; // // @Override // public void visitDexFileVersion(int version) { // this.dexVersion = version; // super.visitDexFileVersion(version); // } // // @Override // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames); // clzs.add(cn); // return cn; // } // // public void accept(DexClassVisitor dcv) { // for (DexClassNode cn : clzs) { // cn.accept(dcv); // } // } // // public void accept(DexFileVisitor dfv) { // for (DexClassNode cn : clzs) { // cn.accept(dfv); // } // } // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java // public class DexFileVisitor { // protected DexFileVisitor visitor; // // public DexFileVisitor() { // super(); // } // // public DexFileVisitor(DexFileVisitor visitor) { // super(); // this.visitor = visitor; // } // // public void visitDexFileVersion(int version) { // if (visitor != null) { // visitor.visitDexFileVersion(version); // } // } // // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // if (visitor == null) { // return null; // } // return visitor.visit(access_flags, className, superClass, interfaceNames); // } // // public void visitEnd() { // if (visitor == null) { // return; // } // visitor.visitEnd(); // } // // } // Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import com.googlecode.d2j.node.DexClassNode; import com.googlecode.d2j.node.DexFileNode; import com.googlecode.d2j.smali.antlr4.SmaliLexer; import com.googlecode.d2j.smali.antlr4.SmaliParser; import com.googlecode.d2j.visitors.DexFileVisitor; import org.antlr.v4.runtime.*; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.StandardCharsets; import java.nio.file.FileVisitResult; import java.nio.file.Files; /* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2013 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.smali; public class Smali { public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException { try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { ANTLRInputStream is = new ANTLRInputStream(reader); is.name = path.toString(); smali0(dcv, is); } } public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException { ANTLRInputStream is = new ANTLRInputStream(buff); is.name = name; smali0(dcv, is); } public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException { try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { ANTLRInputStream is = new ANTLRInputStream(reader); is.name = name; smali0(dcv, is); } } public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException {
DexFileNode dfn = new DexFileNode();
pxb1988/dex2jar
dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/DexConstants.java // public abstract interface DexConstants { // // int ACC_PUBLIC = 0x0001; // class, field, method // int ACC_PRIVATE = 0x0002; // class, field, method // int ACC_PROTECTED = 0x0004; // class, field, method // int ACC_STATIC = 0x0008; // field, method // int ACC_FINAL = 0x0010; // class, field, method // // int ACC_SUPER = 0x0020; // class // int ACC_SYNCHRONIZED = 0x0020; // method // int ACC_VOLATILE = 0x0040; // field // int ACC_BRIDGE = 0x0040; // method // int ACC_VARARGS = 0x0080; // method // int ACC_TRANSIENT = 0x0080; // field // int ACC_NATIVE = 0x0100; // method // int ACC_INTERFACE = 0x0200; // class // int ACC_ABSTRACT = 0x0400; // class, method // int ACC_STRICT = 0x0800; // method // int ACC_SYNTHETIC = 0x1000; // class, field, method // int ACC_ANNOTATION = 0x2000; // class // int ACC_ENUM = 0x4000; // class(?) field inner // int ACC_CONSTRUCTOR = 0x10000;// constructor method (class or instance initializer) // int ACC_DECLARED_SYNCHRONIZED = 0x20000; // // String ANNOTATION_DEFAULT_TYPE = "Ldalvik/annotation/AnnotationDefault;"; // String ANNOTATION_SIGNATURE_TYPE = "Ldalvik/annotation/Signature;"; // String ANNOTATION_THROWS_TYPE = "Ldalvik/annotation/Throws;"; // String ANNOTATION_ENCLOSING_CLASS_TYPE = "Ldalvik/annotation/EnclosingClass;"; // String ANNOTATION_ENCLOSING_METHOD_TYPE = "Ldalvik/annotation/EnclosingMethod;"; // String ANNOTATION_INNER_CLASS_TYPE = "Ldalvik/annotation/InnerClass;"; // String ANNOTATION_MEMBER_CLASSES_TYPE = "Ldalvik/annotation/MemberClasses;"; // // int DEX_035 = 0x00303335; // int DEX_036 = 0x00303336; // int DEX_037 = 0x00303337; // int DEX_038 = 0x00303338; // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java // public class DexFileVisitor { // protected DexFileVisitor visitor; // // public DexFileVisitor() { // super(); // } // // public DexFileVisitor(DexFileVisitor visitor) { // super(); // this.visitor = visitor; // } // // public void visitDexFileVersion(int version) { // if (visitor != null) { // visitor.visitDexFileVersion(version); // } // } // // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // if (visitor == null) { // return null; // } // return visitor.visit(access_flags, className, superClass, interfaceNames); // } // // public void visitEnd() { // if (visitor == null) { // return; // } // visitor.visitEnd(); // } // // }
import com.googlecode.d2j.DexConstants; import com.googlecode.d2j.visitors.DexClassVisitor; import com.googlecode.d2j.visitors.DexFileVisitor; import java.util.ArrayList; import java.util.List;
/* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2013 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.node; public class DexFileNode extends DexFileVisitor { public List<DexClassNode> clzs = new ArrayList<>();
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/DexConstants.java // public abstract interface DexConstants { // // int ACC_PUBLIC = 0x0001; // class, field, method // int ACC_PRIVATE = 0x0002; // class, field, method // int ACC_PROTECTED = 0x0004; // class, field, method // int ACC_STATIC = 0x0008; // field, method // int ACC_FINAL = 0x0010; // class, field, method // // int ACC_SUPER = 0x0020; // class // int ACC_SYNCHRONIZED = 0x0020; // method // int ACC_VOLATILE = 0x0040; // field // int ACC_BRIDGE = 0x0040; // method // int ACC_VARARGS = 0x0080; // method // int ACC_TRANSIENT = 0x0080; // field // int ACC_NATIVE = 0x0100; // method // int ACC_INTERFACE = 0x0200; // class // int ACC_ABSTRACT = 0x0400; // class, method // int ACC_STRICT = 0x0800; // method // int ACC_SYNTHETIC = 0x1000; // class, field, method // int ACC_ANNOTATION = 0x2000; // class // int ACC_ENUM = 0x4000; // class(?) field inner // int ACC_CONSTRUCTOR = 0x10000;// constructor method (class or instance initializer) // int ACC_DECLARED_SYNCHRONIZED = 0x20000; // // String ANNOTATION_DEFAULT_TYPE = "Ldalvik/annotation/AnnotationDefault;"; // String ANNOTATION_SIGNATURE_TYPE = "Ldalvik/annotation/Signature;"; // String ANNOTATION_THROWS_TYPE = "Ldalvik/annotation/Throws;"; // String ANNOTATION_ENCLOSING_CLASS_TYPE = "Ldalvik/annotation/EnclosingClass;"; // String ANNOTATION_ENCLOSING_METHOD_TYPE = "Ldalvik/annotation/EnclosingMethod;"; // String ANNOTATION_INNER_CLASS_TYPE = "Ldalvik/annotation/InnerClass;"; // String ANNOTATION_MEMBER_CLASSES_TYPE = "Ldalvik/annotation/MemberClasses;"; // // int DEX_035 = 0x00303335; // int DEX_036 = 0x00303336; // int DEX_037 = 0x00303337; // int DEX_038 = 0x00303338; // } // // Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java // public class DexFileVisitor { // protected DexFileVisitor visitor; // // public DexFileVisitor() { // super(); // } // // public DexFileVisitor(DexFileVisitor visitor) { // super(); // this.visitor = visitor; // } // // public void visitDexFileVersion(int version) { // if (visitor != null) { // visitor.visitDexFileVersion(version); // } // } // // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // if (visitor == null) { // return null; // } // return visitor.visit(access_flags, className, superClass, interfaceNames); // } // // public void visitEnd() { // if (visitor == null) { // return; // } // visitor.visitEnd(); // } // // } // Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java import com.googlecode.d2j.DexConstants; import com.googlecode.d2j.visitors.DexClassVisitor; import com.googlecode.d2j.visitors.DexFileVisitor; import java.util.ArrayList; import java.util.List; /* * dex2jar - Tools to work with android .dex and java .class files * Copyright (c) 2009-2013 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.d2j.node; public class DexFileNode extends DexFileVisitor { public List<DexClassNode> clzs = new ArrayList<>();
public int dexVersion = DexConstants.DEX_035;
pxb1988/dex2jar
dex-reader/src/main/java/com/googlecode/d2j/reader/BaseDexFileReader.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java // public class DexFileVisitor { // protected DexFileVisitor visitor; // // public DexFileVisitor() { // super(); // } // // public DexFileVisitor(DexFileVisitor visitor) { // super(); // this.visitor = visitor; // } // // public void visitDexFileVersion(int version) { // if (visitor != null) { // visitor.visitDexFileVersion(version); // } // } // // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // if (visitor == null) { // return null; // } // return visitor.visit(access_flags, className, superClass, interfaceNames); // } // // public void visitEnd() { // if (visitor == null) { // return; // } // visitor.visitEnd(); // } // // }
import com.googlecode.d2j.visitors.DexFileVisitor; import java.util.List;
package com.googlecode.d2j.reader; public interface BaseDexFileReader { int getDexVersion();
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/visitors/DexFileVisitor.java // public class DexFileVisitor { // protected DexFileVisitor visitor; // // public DexFileVisitor() { // super(); // } // // public DexFileVisitor(DexFileVisitor visitor) { // super(); // this.visitor = visitor; // } // // public void visitDexFileVersion(int version) { // if (visitor != null) { // visitor.visitDexFileVersion(version); // } // } // // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // if (visitor == null) { // return null; // } // return visitor.visit(access_flags, className, superClass, interfaceNames); // } // // public void visitEnd() { // if (visitor == null) { // return; // } // visitor.visitEnd(); // } // // } // Path: dex-reader/src/main/java/com/googlecode/d2j/reader/BaseDexFileReader.java import com.googlecode.d2j.visitors.DexFileVisitor; import java.util.List; package com.googlecode.d2j.reader; public interface BaseDexFileReader { int getDexVersion();
void accept(DexFileVisitor dv);
pxb1988/dex2jar
dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/InvokeCustomExpr.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/MethodHandle.java // public class MethodHandle { // public static final int STATIC_PUT = 0x00; // public static final int STATIC_GET = 0x01; // public static final int INSTANCE_PUT = 0x02; // public static final int INSTANCE_GET = 0x03; // public static final int INVOKE_STATIC = 0x04; // public static final int INVOKE_INSTANCE = 0x05; // public static final int INVOKE_CONSTRUCTOR = 0x06; // public static final int INVOKE_DIRECT = 0x07; // public static final int INVOKE_INTERFACE = 0x08; // // private int type; // private Field field; // private Method method; // // public MethodHandle(int type, Field field) { // this.type = type; // this.field = field; // } // // public MethodHandle(int type, Method method) { // this.type = type; // this.method = method; // } // // public MethodHandle(int type, Field field, Method method) { // this.type = type; // this.field = field; // this.method = method; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // MethodHandle that = (MethodHandle) o; // // if (type != that.type) return false; // if (field != null ? !field.equals(that.field) : that.field != null) return false; // return method != null ? method.equals(that.method) : that.method == null; // } // // @Override // public int hashCode() { // int result = type; // result = 31 * result + (field != null ? field.hashCode() : 0); // result = 31 * result + (method != null ? method.hashCode() : 0); // return result; // } // // public int getType() { // return type; // } // // public Field getField() { // return field; // } // // public Method getMethod() { // return method; // } // }
import com.googlecode.d2j.MethodHandle; import com.googlecode.d2j.Proto; import com.googlecode.dex2jar.ir.LabelAndLocalMapper;
/* * Copyright (c) 2009-2017 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.dex2jar.ir.expr; public class InvokeCustomExpr extends AbstractInvokeExpr { public String name; public Proto proto;
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/MethodHandle.java // public class MethodHandle { // public static final int STATIC_PUT = 0x00; // public static final int STATIC_GET = 0x01; // public static final int INSTANCE_PUT = 0x02; // public static final int INSTANCE_GET = 0x03; // public static final int INVOKE_STATIC = 0x04; // public static final int INVOKE_INSTANCE = 0x05; // public static final int INVOKE_CONSTRUCTOR = 0x06; // public static final int INVOKE_DIRECT = 0x07; // public static final int INVOKE_INTERFACE = 0x08; // // private int type; // private Field field; // private Method method; // // public MethodHandle(int type, Field field) { // this.type = type; // this.field = field; // } // // public MethodHandle(int type, Method method) { // this.type = type; // this.method = method; // } // // public MethodHandle(int type, Field field, Method method) { // this.type = type; // this.field = field; // this.method = method; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // MethodHandle that = (MethodHandle) o; // // if (type != that.type) return false; // if (field != null ? !field.equals(that.field) : that.field != null) return false; // return method != null ? method.equals(that.method) : that.method == null; // } // // @Override // public int hashCode() { // int result = type; // result = 31 * result + (field != null ? field.hashCode() : 0); // result = 31 * result + (method != null ? method.hashCode() : 0); // return result; // } // // public int getType() { // return type; // } // // public Field getField() { // return field; // } // // public Method getMethod() { // return method; // } // } // Path: dex-ir/src/main/java/com/googlecode/dex2jar/ir/expr/InvokeCustomExpr.java import com.googlecode.d2j.MethodHandle; import com.googlecode.d2j.Proto; import com.googlecode.dex2jar.ir.LabelAndLocalMapper; /* * Copyright (c) 2009-2017 Panxiaobo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.googlecode.dex2jar.ir.expr; public class InvokeCustomExpr extends AbstractInvokeExpr { public String name; public Proto proto;
public MethodHandle handle;
pxb1988/dex2jar
dex-translator/src/test/java/com/googlecode/dex2jar/test/Smali2jTest.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java // public class DexFileNode extends DexFileVisitor { // public List<DexClassNode> clzs = new ArrayList<>(); // public int dexVersion = DexConstants.DEX_035; // // @Override // public void visitDexFileVersion(int version) { // this.dexVersion = version; // super.visitDexFileVersion(version); // } // // @Override // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames); // clzs.add(cn); // return cn; // } // // public void accept(DexClassVisitor dcv) { // for (DexClassNode cn : clzs) { // cn.accept(dcv); // } // } // // public void accept(DexFileVisitor dfv) { // for (DexClassNode cn : clzs) { // cn.accept(dfv); // } // } // } // // Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java // public class Smali { // public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException { // try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = path.toString(); // smali0(dcv, is); // } // } // // public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException { // ANTLRInputStream is = new ANTLRInputStream(buff); // is.name = name; // smali0(dcv, is); // } // // public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException { // try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = name; // smali0(dcv, is); // } // } // // public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, in, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // public static DexClassNode smaliFile2Node(String name, String buff) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, buff, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // private static void smali0(DexFileVisitor dcv, CharStream is) throws IOException { // SmaliLexer lexer = new SmaliLexer(is); // CommonTokenStream ts = new CommonTokenStream(lexer); // SmaliParser parser = new SmaliParser(ts); // // for (SmaliParser.SFileContext ctx : parser.sFiles().sFile()) { // AntlrSmaliUtil.acceptFile(ctx, dcv); // } // } // // public static void smaliFile(String fileName, char[] data, DexFileVisitor dcv) throws IOException { // // System.err.println("parsing " + f.getAbsoluteFile()); // ANTLRInputStream is = new ANTLRInputStream(data, data.length); // is.name = fileName; // smali0(dcv, is); // } // // public static void smali(Path base, final DexFileVisitor dfv) throws IOException { // if (Files.isDirectory(base)) { // Files.walkFileTree(base, new SimpleFileVisitor<Path>() { // @Override // public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { // Path fn = dir.getFileName(); // if (fn != null && fn.toString().startsWith(".")) { // return FileVisitResult.SKIP_SUBTREE; // } // return super.preVisitDirectory(dir, attrs); // } // // @Override // public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { // smaliFile(file, dfv); // return super.visitFile(file, attrs); // } // }); // } else if (Files.isRegularFile(base)) { // smaliFile(base, dfv); // } // } // }
import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.TreeSet; import org.junit.Assert; import org.junit.runner.Description; import org.junit.runner.RunWith; import org.junit.runner.Runner; import org.junit.runner.notification.RunNotifier; import org.junit.runners.ParentRunner; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import com.googlecode.d2j.node.DexClassNode; import com.googlecode.d2j.node.DexFileNode; import com.googlecode.d2j.smali.Smali;
public void init(final Class<?> testClass) throws InitializationError { URL url = testClass.getResource("/smalis/writeString.smali"); System.out.println("url is " + url); Assert.assertNotNull(url); final String file = url.getFile(); Assert.assertNotNull(file); Path dirxpath = new File(file).toPath(); final Path basePath = dirxpath.getParent(); final Set<Path> files = new TreeSet<>(); try { Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.getFileName().toString().endsWith(".smali")) { files.add(file); } return super.visitFile(file, attrs); } }); } catch (IOException e) { throw new RuntimeException(e); } List<Runner> runners = new ArrayList<>(); for (final Path p : files) {
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java // public class DexFileNode extends DexFileVisitor { // public List<DexClassNode> clzs = new ArrayList<>(); // public int dexVersion = DexConstants.DEX_035; // // @Override // public void visitDexFileVersion(int version) { // this.dexVersion = version; // super.visitDexFileVersion(version); // } // // @Override // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames); // clzs.add(cn); // return cn; // } // // public void accept(DexClassVisitor dcv) { // for (DexClassNode cn : clzs) { // cn.accept(dcv); // } // } // // public void accept(DexFileVisitor dfv) { // for (DexClassNode cn : clzs) { // cn.accept(dfv); // } // } // } // // Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java // public class Smali { // public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException { // try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = path.toString(); // smali0(dcv, is); // } // } // // public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException { // ANTLRInputStream is = new ANTLRInputStream(buff); // is.name = name; // smali0(dcv, is); // } // // public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException { // try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = name; // smali0(dcv, is); // } // } // // public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, in, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // public static DexClassNode smaliFile2Node(String name, String buff) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, buff, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // private static void smali0(DexFileVisitor dcv, CharStream is) throws IOException { // SmaliLexer lexer = new SmaliLexer(is); // CommonTokenStream ts = new CommonTokenStream(lexer); // SmaliParser parser = new SmaliParser(ts); // // for (SmaliParser.SFileContext ctx : parser.sFiles().sFile()) { // AntlrSmaliUtil.acceptFile(ctx, dcv); // } // } // // public static void smaliFile(String fileName, char[] data, DexFileVisitor dcv) throws IOException { // // System.err.println("parsing " + f.getAbsoluteFile()); // ANTLRInputStream is = new ANTLRInputStream(data, data.length); // is.name = fileName; // smali0(dcv, is); // } // // public static void smali(Path base, final DexFileVisitor dfv) throws IOException { // if (Files.isDirectory(base)) { // Files.walkFileTree(base, new SimpleFileVisitor<Path>() { // @Override // public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { // Path fn = dir.getFileName(); // if (fn != null && fn.toString().startsWith(".")) { // return FileVisitResult.SKIP_SUBTREE; // } // return super.preVisitDirectory(dir, attrs); // } // // @Override // public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { // smaliFile(file, dfv); // return super.visitFile(file, attrs); // } // }); // } else if (Files.isRegularFile(base)) { // smaliFile(base, dfv); // } // } // } // Path: dex-translator/src/test/java/com/googlecode/dex2jar/test/Smali2jTest.java import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.TreeSet; import org.junit.Assert; import org.junit.runner.Description; import org.junit.runner.RunWith; import org.junit.runner.Runner; import org.junit.runner.notification.RunNotifier; import org.junit.runners.ParentRunner; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import com.googlecode.d2j.node.DexClassNode; import com.googlecode.d2j.node.DexFileNode; import com.googlecode.d2j.smali.Smali; public void init(final Class<?> testClass) throws InitializationError { URL url = testClass.getResource("/smalis/writeString.smali"); System.out.println("url is " + url); Assert.assertNotNull(url); final String file = url.getFile(); Assert.assertNotNull(file); Path dirxpath = new File(file).toPath(); final Path basePath = dirxpath.getParent(); final Set<Path> files = new TreeSet<>(); try { Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.getFileName().toString().endsWith(".smali")) { files.add(file); } return super.visitFile(file, attrs); } }); } catch (IOException e) { throw new RuntimeException(e); } List<Runner> runners = new ArrayList<>(); for (final Path p : files) {
Smali smali = new Smali();
pxb1988/dex2jar
dex-translator/src/test/java/com/googlecode/dex2jar/test/Smali2jTest.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java // public class DexFileNode extends DexFileVisitor { // public List<DexClassNode> clzs = new ArrayList<>(); // public int dexVersion = DexConstants.DEX_035; // // @Override // public void visitDexFileVersion(int version) { // this.dexVersion = version; // super.visitDexFileVersion(version); // } // // @Override // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames); // clzs.add(cn); // return cn; // } // // public void accept(DexClassVisitor dcv) { // for (DexClassNode cn : clzs) { // cn.accept(dcv); // } // } // // public void accept(DexFileVisitor dfv) { // for (DexClassNode cn : clzs) { // cn.accept(dfv); // } // } // } // // Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java // public class Smali { // public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException { // try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = path.toString(); // smali0(dcv, is); // } // } // // public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException { // ANTLRInputStream is = new ANTLRInputStream(buff); // is.name = name; // smali0(dcv, is); // } // // public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException { // try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = name; // smali0(dcv, is); // } // } // // public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, in, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // public static DexClassNode smaliFile2Node(String name, String buff) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, buff, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // private static void smali0(DexFileVisitor dcv, CharStream is) throws IOException { // SmaliLexer lexer = new SmaliLexer(is); // CommonTokenStream ts = new CommonTokenStream(lexer); // SmaliParser parser = new SmaliParser(ts); // // for (SmaliParser.SFileContext ctx : parser.sFiles().sFile()) { // AntlrSmaliUtil.acceptFile(ctx, dcv); // } // } // // public static void smaliFile(String fileName, char[] data, DexFileVisitor dcv) throws IOException { // // System.err.println("parsing " + f.getAbsoluteFile()); // ANTLRInputStream is = new ANTLRInputStream(data, data.length); // is.name = fileName; // smali0(dcv, is); // } // // public static void smali(Path base, final DexFileVisitor dfv) throws IOException { // if (Files.isDirectory(base)) { // Files.walkFileTree(base, new SimpleFileVisitor<Path>() { // @Override // public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { // Path fn = dir.getFileName(); // if (fn != null && fn.toString().startsWith(".")) { // return FileVisitResult.SKIP_SUBTREE; // } // return super.preVisitDirectory(dir, attrs); // } // // @Override // public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { // smaliFile(file, dfv); // return super.visitFile(file, attrs); // } // }); // } else if (Files.isRegularFile(base)) { // smaliFile(base, dfv); // } // } // }
import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.TreeSet; import org.junit.Assert; import org.junit.runner.Description; import org.junit.runner.RunWith; import org.junit.runner.Runner; import org.junit.runner.notification.RunNotifier; import org.junit.runners.ParentRunner; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import com.googlecode.d2j.node.DexClassNode; import com.googlecode.d2j.node.DexFileNode; import com.googlecode.d2j.smali.Smali;
URL url = testClass.getResource("/smalis/writeString.smali"); System.out.println("url is " + url); Assert.assertNotNull(url); final String file = url.getFile(); Assert.assertNotNull(file); Path dirxpath = new File(file).toPath(); final Path basePath = dirxpath.getParent(); final Set<Path> files = new TreeSet<>(); try { Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.getFileName().toString().endsWith(".smali")) { files.add(file); } return super.visitFile(file, attrs); } }); } catch (IOException e) { throw new RuntimeException(e); } List<Runner> runners = new ArrayList<>(); for (final Path p : files) { Smali smali = new Smali();
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/node/DexFileNode.java // public class DexFileNode extends DexFileVisitor { // public List<DexClassNode> clzs = new ArrayList<>(); // public int dexVersion = DexConstants.DEX_035; // // @Override // public void visitDexFileVersion(int version) { // this.dexVersion = version; // super.visitDexFileVersion(version); // } // // @Override // public DexClassVisitor visit(int access_flags, String className, String superClass, String[] interfaceNames) { // DexClassNode cn = new DexClassNode(access_flags, className, superClass, interfaceNames); // clzs.add(cn); // return cn; // } // // public void accept(DexClassVisitor dcv) { // for (DexClassNode cn : clzs) { // cn.accept(dcv); // } // } // // public void accept(DexFileVisitor dfv) { // for (DexClassNode cn : clzs) { // cn.accept(dfv); // } // } // } // // Path: d2j-smali/src/main/java/com/googlecode/d2j/smali/Smali.java // public class Smali { // public static void smaliFile(Path path, DexFileVisitor dcv) throws IOException { // try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = path.toString(); // smali0(dcv, is); // } // } // // public static void smaliFile(String name, String buff, DexFileVisitor dcv) throws IOException { // ANTLRInputStream is = new ANTLRInputStream(buff); // is.name = name; // smali0(dcv, is); // } // // public static void smaliFile(String name, InputStream in, DexFileVisitor dcv) throws IOException { // try (InputStreamReader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { // ANTLRInputStream is = new ANTLRInputStream(reader); // is.name = name; // smali0(dcv, is); // } // } // // public static DexClassNode smaliFile2Node(String name, InputStream in) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, in, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // public static DexClassNode smaliFile2Node(String name, String buff) throws IOException { // DexFileNode dfn = new DexFileNode(); // smaliFile(name, buff, dfn); // return dfn.clzs.size() > 0 ? dfn.clzs.get(0) : null; // } // // private static void smali0(DexFileVisitor dcv, CharStream is) throws IOException { // SmaliLexer lexer = new SmaliLexer(is); // CommonTokenStream ts = new CommonTokenStream(lexer); // SmaliParser parser = new SmaliParser(ts); // // for (SmaliParser.SFileContext ctx : parser.sFiles().sFile()) { // AntlrSmaliUtil.acceptFile(ctx, dcv); // } // } // // public static void smaliFile(String fileName, char[] data, DexFileVisitor dcv) throws IOException { // // System.err.println("parsing " + f.getAbsoluteFile()); // ANTLRInputStream is = new ANTLRInputStream(data, data.length); // is.name = fileName; // smali0(dcv, is); // } // // public static void smali(Path base, final DexFileVisitor dfv) throws IOException { // if (Files.isDirectory(base)) { // Files.walkFileTree(base, new SimpleFileVisitor<Path>() { // @Override // public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { // Path fn = dir.getFileName(); // if (fn != null && fn.toString().startsWith(".")) { // return FileVisitResult.SKIP_SUBTREE; // } // return super.preVisitDirectory(dir, attrs); // } // // @Override // public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { // smaliFile(file, dfv); // return super.visitFile(file, attrs); // } // }); // } else if (Files.isRegularFile(base)) { // smaliFile(base, dfv); // } // } // } // Path: dex-translator/src/test/java/com/googlecode/dex2jar/test/Smali2jTest.java import java.io.File; import java.io.IOException; import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.TreeSet; import org.junit.Assert; import org.junit.runner.Description; import org.junit.runner.RunWith; import org.junit.runner.Runner; import org.junit.runner.notification.RunNotifier; import org.junit.runners.ParentRunner; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import com.googlecode.d2j.node.DexClassNode; import com.googlecode.d2j.node.DexFileNode; import com.googlecode.d2j.smali.Smali; URL url = testClass.getResource("/smalis/writeString.smali"); System.out.println("url is " + url); Assert.assertNotNull(url); final String file = url.getFile(); Assert.assertNotNull(file); Path dirxpath = new File(file).toPath(); final Path basePath = dirxpath.getParent(); final Set<Path> files = new TreeSet<>(); try { Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.getFileName().toString().endsWith(".smali")) { files.add(file); } return super.visitFile(file, attrs); } }); } catch (IOException e) { throw new RuntimeException(e); } List<Runner> runners = new ArrayList<>(); for (final Path p : files) { Smali smali = new Smali();
final DexFileNode fileNode = new DexFileNode();
pxb1988/dex2jar
dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/DexConstants.java // public abstract interface DexConstants { // // int ACC_PUBLIC = 0x0001; // class, field, method // int ACC_PRIVATE = 0x0002; // class, field, method // int ACC_PROTECTED = 0x0004; // class, field, method // int ACC_STATIC = 0x0008; // field, method // int ACC_FINAL = 0x0010; // class, field, method // // int ACC_SUPER = 0x0020; // class // int ACC_SYNCHRONIZED = 0x0020; // method // int ACC_VOLATILE = 0x0040; // field // int ACC_BRIDGE = 0x0040; // method // int ACC_VARARGS = 0x0080; // method // int ACC_TRANSIENT = 0x0080; // field // int ACC_NATIVE = 0x0100; // method // int ACC_INTERFACE = 0x0200; // class // int ACC_ABSTRACT = 0x0400; // class, method // int ACC_STRICT = 0x0800; // method // int ACC_SYNTHETIC = 0x1000; // class, field, method // int ACC_ANNOTATION = 0x2000; // class // int ACC_ENUM = 0x4000; // class(?) field inner // int ACC_CONSTRUCTOR = 0x10000;// constructor method (class or instance initializer) // int ACC_DECLARED_SYNCHRONIZED = 0x20000; // // String ANNOTATION_DEFAULT_TYPE = "Ldalvik/annotation/AnnotationDefault;"; // String ANNOTATION_SIGNATURE_TYPE = "Ldalvik/annotation/Signature;"; // String ANNOTATION_THROWS_TYPE = "Ldalvik/annotation/Throws;"; // String ANNOTATION_ENCLOSING_CLASS_TYPE = "Ldalvik/annotation/EnclosingClass;"; // String ANNOTATION_ENCLOSING_METHOD_TYPE = "Ldalvik/annotation/EnclosingMethod;"; // String ANNOTATION_INNER_CLASS_TYPE = "Ldalvik/annotation/InnerClass;"; // String ANNOTATION_MEMBER_CLASSES_TYPE = "Ldalvik/annotation/MemberClasses;"; // // int DEX_035 = 0x00303335; // int DEX_036 = 0x00303336; // int DEX_037 = 0x00303337; // int DEX_038 = 0x00303338; // }
import java.io.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import com.googlecode.d2j.*; import com.googlecode.d2j.node.DexAnnotationNode; import com.googlecode.d2j.util.Mutf8; import com.googlecode.d2j.visitors.*; import static com.googlecode.d2j.DexConstants.*;
} catch (Exception e) { throw new DexException(e, "while accept annotation in field:%s.", field.toString()); } } } dfv.visitEnd(); } // ////////////////////////////////////////////////////////////// return field_id; } private int acceptMethod(ByteBuffer in, int lastIndex, DexClassVisitor cv, Map<Integer, Integer> methodAnnos, Map<Integer, Integer> parameterAnnos, int config, boolean firstMethod) { int offset = in.position(); int diff = (int) readULeb128i(in); int method_access_flags = (int) readULeb128i(in); int code_off = (int) readULeb128i(in); int method_id = lastIndex + diff; Method method = getMethod(method_id); // issue 200, methods may have same signature, we only need to keep the first one if (!firstMethod && diff == 0) { // detect a duplicated method WARN("GLITCH: duplicated method %s @%08x", method.toString(), offset); if ((config & KEEP_ALL_METHODS) == 0) { WARN("WARN: skip method %s @%08x", method.toString(), offset); return method_id; } } // issue 195, a <clinit> or <init> but not marked as ACC_CONSTRUCTOR,
// Path: dex-reader-api/src/main/java/com/googlecode/d2j/DexConstants.java // public abstract interface DexConstants { // // int ACC_PUBLIC = 0x0001; // class, field, method // int ACC_PRIVATE = 0x0002; // class, field, method // int ACC_PROTECTED = 0x0004; // class, field, method // int ACC_STATIC = 0x0008; // field, method // int ACC_FINAL = 0x0010; // class, field, method // // int ACC_SUPER = 0x0020; // class // int ACC_SYNCHRONIZED = 0x0020; // method // int ACC_VOLATILE = 0x0040; // field // int ACC_BRIDGE = 0x0040; // method // int ACC_VARARGS = 0x0080; // method // int ACC_TRANSIENT = 0x0080; // field // int ACC_NATIVE = 0x0100; // method // int ACC_INTERFACE = 0x0200; // class // int ACC_ABSTRACT = 0x0400; // class, method // int ACC_STRICT = 0x0800; // method // int ACC_SYNTHETIC = 0x1000; // class, field, method // int ACC_ANNOTATION = 0x2000; // class // int ACC_ENUM = 0x4000; // class(?) field inner // int ACC_CONSTRUCTOR = 0x10000;// constructor method (class or instance initializer) // int ACC_DECLARED_SYNCHRONIZED = 0x20000; // // String ANNOTATION_DEFAULT_TYPE = "Ldalvik/annotation/AnnotationDefault;"; // String ANNOTATION_SIGNATURE_TYPE = "Ldalvik/annotation/Signature;"; // String ANNOTATION_THROWS_TYPE = "Ldalvik/annotation/Throws;"; // String ANNOTATION_ENCLOSING_CLASS_TYPE = "Ldalvik/annotation/EnclosingClass;"; // String ANNOTATION_ENCLOSING_METHOD_TYPE = "Ldalvik/annotation/EnclosingMethod;"; // String ANNOTATION_INNER_CLASS_TYPE = "Ldalvik/annotation/InnerClass;"; // String ANNOTATION_MEMBER_CLASSES_TYPE = "Ldalvik/annotation/MemberClasses;"; // // int DEX_035 = 0x00303335; // int DEX_036 = 0x00303336; // int DEX_037 = 0x00303337; // int DEX_038 = 0x00303338; // } // Path: dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java import java.io.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.file.Files; import java.nio.file.Path; import java.util.*; import com.googlecode.d2j.*; import com.googlecode.d2j.node.DexAnnotationNode; import com.googlecode.d2j.util.Mutf8; import com.googlecode.d2j.visitors.*; import static com.googlecode.d2j.DexConstants.*; } catch (Exception e) { throw new DexException(e, "while accept annotation in field:%s.", field.toString()); } } } dfv.visitEnd(); } // ////////////////////////////////////////////////////////////// return field_id; } private int acceptMethod(ByteBuffer in, int lastIndex, DexClassVisitor cv, Map<Integer, Integer> methodAnnos, Map<Integer, Integer> parameterAnnos, int config, boolean firstMethod) { int offset = in.position(); int diff = (int) readULeb128i(in); int method_access_flags = (int) readULeb128i(in); int code_off = (int) readULeb128i(in); int method_id = lastIndex + diff; Method method = getMethod(method_id); // issue 200, methods may have same signature, we only need to keep the first one if (!firstMethod && diff == 0) { // detect a duplicated method WARN("GLITCH: duplicated method %s @%08x", method.toString(), offset); if ((config & KEEP_ALL_METHODS) == 0) { WARN("WARN: skip method %s @%08x", method.toString(), offset); return method_id; } } // issue 195, a <clinit> or <init> but not marked as ACC_CONSTRUCTOR,
if (0 == (method_access_flags & DexConstants.ACC_CONSTRUCTOR)
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/TagDetectionHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // }
import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Super class of detection handlers register listener and invoke appropriate method when * onFire method is invoked */ public abstract class TagDetectionHandler { private final DeviceFootprint footprint; private volatile OnTriggerFiredListener listener; protected TagDetectionHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { this.footprint = footprint; this.listener = listener; }
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/TagDetectionHandler.java import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Super class of detection handlers register listener and invoke appropriate method when * onFire method is invoked */ public abstract class TagDetectionHandler { private final DeviceFootprint footprint; private volatile OnTriggerFiredListener listener; protected TagDetectionHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { this.footprint = footprint; this.listener = listener; }
public void onDetect(IBeaconDetect detection) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/model/BeaconSettings.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // }
import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import java.util.Arrays; import java.util.List;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.model; /** * Contains all information about tag for detection. */ public class BeaconSettings { private static final int MAX_SLEEP_DELAY = 65535; private static final float MIN_ACCELERATION = 0.1569064f; private static final float MAX_ACCELERATION = 156.9064f; private static final List<Byte> TX_POWERS = Arrays.asList(new Byte[]{-62, -52, -48, -44, -40, -36, -32, -30, -20, -16, -12, -8, -4, 0, 4}); private static final int MIN_ADVERTISING_INTERVAL = 160; private static final int MAX_ADVERTISING_INTERVAL = 16000;
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/model/BeaconSettings.java import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import java.util.Arrays; import java.util.List; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.model; /** * Contains all information about tag for detection. */ public class BeaconSettings { private static final int MAX_SLEEP_DELAY = 65535; private static final float MIN_ACCELERATION = 0.1569064f; private static final float MAX_ACCELERATION = 156.9064f; private static final List<Byte> TX_POWERS = Arrays.asList(new Byte[]{-62, -52, -48, -44, -40, -36, -32, -30, -20, -16, -12, -8, -4, 0, 4}); private static final int MIN_ADVERTISING_INTERVAL = 160; private static final int MAX_ADVERTISING_INTERVAL = 16000;
private final DeviceFootprint footprint;
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/control/BeaconTagDeviceUpdater.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BeaconTagDevice.java // public class BeaconTagDevice { // // public static final UUID UUID_SERVICE_UUID // = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); // private static final UUID UUID_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a00-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MAJOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a02-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MINOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a01-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TX_POWER_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ADV_INTERVAL_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a04-0b1e-4063-8b16-b00b50aa3a7e"); // // public static final UUID WAKE_UP_SERVICE_UUID // = UUID.fromString("59EC0802-0B1E-4063-8B16-B00B50AA3A7E"); // public static final UUID SLEEP_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a07-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TEMPERATURE_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a08-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ACCELERATION_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a0b-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ANGULAR_SPEED_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a09-0b1e-4063-8b16-b00b50aa3a7e"); // // private BluetoothDevice bleDevice; // private DeviceFootprint footprint; // // public BeaconTagDevice(BluetoothDevice device, DeviceFootprint footprint) { // bleDevice = device; // this.footprint = footprint; // } // // public BluetoothDevice getBleDevice() { // return bleDevice; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/WriteCharacteristicCommand.java // public class WriteCharacteristicCommand { // private UUID serviceUUID; // private UUID characteristicUUID; // private SwitchState switchState = SwitchState.NONE; // private byte[] bytesToUpload; // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, boolean enable) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.switchState = enable ? SwitchState.ENABLE : SwitchState.DISABLE; // } // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, byte[] bytesToUpload) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.bytesToUpload = bytesToUpload; // } // // public UUID getServiceUUID() { // return serviceUUID; // } // // public UUID getCharacteristicUUID() { // return characteristicUUID; // } // // public SwitchState getSwitchState() { // return switchState; // } // // public byte[] getBytesToUpload() { // return bytesToUpload; // } // // public enum SwitchState { // ENABLE, DISABLE, NONE // } // }
import java.util.List; import java.util.Map; import java.util.UUID; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCallback; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import com.orange.beaconme_sdk.ble.model.BeaconTagDevice; import com.orange.beaconme_sdk.ble.model.WriteCharacteristicCommand; import java.util.Arrays; import java.util.HashMap;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.control; /** * */ public class BeaconTagDeviceUpdater extends BLEDeviceGattController { private final String TAG = this.getClass().getSimpleName(); public static final UUID UUID_SERVICE_UUID = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); public static final UUID TX_POWER_CHARACTERISTIC_UUID = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e");
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BeaconTagDevice.java // public class BeaconTagDevice { // // public static final UUID UUID_SERVICE_UUID // = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); // private static final UUID UUID_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a00-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MAJOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a02-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MINOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a01-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TX_POWER_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ADV_INTERVAL_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a04-0b1e-4063-8b16-b00b50aa3a7e"); // // public static final UUID WAKE_UP_SERVICE_UUID // = UUID.fromString("59EC0802-0B1E-4063-8B16-B00B50AA3A7E"); // public static final UUID SLEEP_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a07-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TEMPERATURE_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a08-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ACCELERATION_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a0b-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ANGULAR_SPEED_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a09-0b1e-4063-8b16-b00b50aa3a7e"); // // private BluetoothDevice bleDevice; // private DeviceFootprint footprint; // // public BeaconTagDevice(BluetoothDevice device, DeviceFootprint footprint) { // bleDevice = device; // this.footprint = footprint; // } // // public BluetoothDevice getBleDevice() { // return bleDevice; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/WriteCharacteristicCommand.java // public class WriteCharacteristicCommand { // private UUID serviceUUID; // private UUID characteristicUUID; // private SwitchState switchState = SwitchState.NONE; // private byte[] bytesToUpload; // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, boolean enable) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.switchState = enable ? SwitchState.ENABLE : SwitchState.DISABLE; // } // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, byte[] bytesToUpload) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.bytesToUpload = bytesToUpload; // } // // public UUID getServiceUUID() { // return serviceUUID; // } // // public UUID getCharacteristicUUID() { // return characteristicUUID; // } // // public SwitchState getSwitchState() { // return switchState; // } // // public byte[] getBytesToUpload() { // return bytesToUpload; // } // // public enum SwitchState { // ENABLE, DISABLE, NONE // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/control/BeaconTagDeviceUpdater.java import java.util.List; import java.util.Map; import java.util.UUID; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCallback; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import com.orange.beaconme_sdk.ble.model.BeaconTagDevice; import com.orange.beaconme_sdk.ble.model.WriteCharacteristicCommand; import java.util.Arrays; import java.util.HashMap; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.control; /** * */ public class BeaconTagDeviceUpdater extends BLEDeviceGattController { private final String TAG = this.getClass().getSimpleName(); public static final UUID UUID_SERVICE_UUID = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); public static final UUID TX_POWER_CHARACTERISTIC_UUID = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e");
private List<UUID> charUUIDs = Arrays.asList(BeaconTagDevice.SLEEP_CHARACTERISTIC_UUID,
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/control/BeaconTagDeviceUpdater.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BeaconTagDevice.java // public class BeaconTagDevice { // // public static final UUID UUID_SERVICE_UUID // = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); // private static final UUID UUID_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a00-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MAJOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a02-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MINOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a01-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TX_POWER_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ADV_INTERVAL_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a04-0b1e-4063-8b16-b00b50aa3a7e"); // // public static final UUID WAKE_UP_SERVICE_UUID // = UUID.fromString("59EC0802-0B1E-4063-8B16-B00B50AA3A7E"); // public static final UUID SLEEP_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a07-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TEMPERATURE_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a08-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ACCELERATION_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a0b-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ANGULAR_SPEED_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a09-0b1e-4063-8b16-b00b50aa3a7e"); // // private BluetoothDevice bleDevice; // private DeviceFootprint footprint; // // public BeaconTagDevice(BluetoothDevice device, DeviceFootprint footprint) { // bleDevice = device; // this.footprint = footprint; // } // // public BluetoothDevice getBleDevice() { // return bleDevice; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/WriteCharacteristicCommand.java // public class WriteCharacteristicCommand { // private UUID serviceUUID; // private UUID characteristicUUID; // private SwitchState switchState = SwitchState.NONE; // private byte[] bytesToUpload; // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, boolean enable) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.switchState = enable ? SwitchState.ENABLE : SwitchState.DISABLE; // } // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, byte[] bytesToUpload) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.bytesToUpload = bytesToUpload; // } // // public UUID getServiceUUID() { // return serviceUUID; // } // // public UUID getCharacteristicUUID() { // return characteristicUUID; // } // // public SwitchState getSwitchState() { // return switchState; // } // // public byte[] getBytesToUpload() { // return bytesToUpload; // } // // public enum SwitchState { // ENABLE, DISABLE, NONE // } // }
import java.util.List; import java.util.Map; import java.util.UUID; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCallback; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import com.orange.beaconme_sdk.ble.model.BeaconTagDevice; import com.orange.beaconme_sdk.ble.model.WriteCharacteristicCommand; import java.util.Arrays; import java.util.HashMap;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.control; /** * */ public class BeaconTagDeviceUpdater extends BLEDeviceGattController { private final String TAG = this.getClass().getSimpleName(); public static final UUID UUID_SERVICE_UUID = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); public static final UUID TX_POWER_CHARACTERISTIC_UUID = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e"); private List<UUID> charUUIDs = Arrays.asList(BeaconTagDevice.SLEEP_CHARACTERISTIC_UUID, BeaconTagDevice.TEMPERATURE_CHARACTERISTIC_UUID, BeaconTagDevice.ACCELERATION_CHARACTERISTIC_UUID, BeaconTagDevice.ANGULAR_SPEED_CHARACTERISTIC_UUID); private Map<UUID, Boolean> uploadingCompletion;
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BeaconTagDevice.java // public class BeaconTagDevice { // // public static final UUID UUID_SERVICE_UUID // = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); // private static final UUID UUID_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a00-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MAJOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a02-0b1e-4063-8b16-b00b50aa3a7e"); // private static final UUID MINOR_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a01-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TX_POWER_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ADV_INTERVAL_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a04-0b1e-4063-8b16-b00b50aa3a7e"); // // public static final UUID WAKE_UP_SERVICE_UUID // = UUID.fromString("59EC0802-0B1E-4063-8B16-B00B50AA3A7E"); // public static final UUID SLEEP_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a07-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID TEMPERATURE_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a08-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ACCELERATION_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a0b-0b1e-4063-8b16-b00b50aa3a7e"); // public static final UUID ANGULAR_SPEED_CHARACTERISTIC_UUID // = UUID.fromString("59ec0a09-0b1e-4063-8b16-b00b50aa3a7e"); // // private BluetoothDevice bleDevice; // private DeviceFootprint footprint; // // public BeaconTagDevice(BluetoothDevice device, DeviceFootprint footprint) { // bleDevice = device; // this.footprint = footprint; // } // // public BluetoothDevice getBleDevice() { // return bleDevice; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/WriteCharacteristicCommand.java // public class WriteCharacteristicCommand { // private UUID serviceUUID; // private UUID characteristicUUID; // private SwitchState switchState = SwitchState.NONE; // private byte[] bytesToUpload; // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, boolean enable) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.switchState = enable ? SwitchState.ENABLE : SwitchState.DISABLE; // } // // public WriteCharacteristicCommand(UUID serviceUUID, UUID characteristicUUID, byte[] bytesToUpload) { // this.serviceUUID = serviceUUID; // this.characteristicUUID = characteristicUUID; // this.bytesToUpload = bytesToUpload; // } // // public UUID getServiceUUID() { // return serviceUUID; // } // // public UUID getCharacteristicUUID() { // return characteristicUUID; // } // // public SwitchState getSwitchState() { // return switchState; // } // // public byte[] getBytesToUpload() { // return bytesToUpload; // } // // public enum SwitchState { // ENABLE, DISABLE, NONE // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/control/BeaconTagDeviceUpdater.java import java.util.List; import java.util.Map; import java.util.UUID; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCallback; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattService; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import com.orange.beaconme_sdk.ble.model.BeaconTagDevice; import com.orange.beaconme_sdk.ble.model.WriteCharacteristicCommand; import java.util.Arrays; import java.util.HashMap; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.control; /** * */ public class BeaconTagDeviceUpdater extends BLEDeviceGattController { private final String TAG = this.getClass().getSimpleName(); public static final UUID UUID_SERVICE_UUID = UUID.fromString("59EC0800-0B1E-4063-8B16-B00B50AA3A7E"); public static final UUID TX_POWER_CHARACTERISTIC_UUID = UUID.fromString("59ec0a05-0b1e-4063-8b16-b00b50aa3a7e"); private List<UUID> charUUIDs = Arrays.asList(BeaconTagDevice.SLEEP_CHARACTERISTIC_UUID, BeaconTagDevice.TEMPERATURE_CHARACTERISTIC_UUID, BeaconTagDevice.ACCELERATION_CHARACTERISTIC_UUID, BeaconTagDevice.ANGULAR_SPEED_CHARACTERISTIC_UUID); private Map<UUID, Boolean> uploadingCompletion;
private List<WriteCharacteristicCommand> commands;
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // }
import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000;
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000;
private BLERange range = null;
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // }
import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000; private BLERange range = null;
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000; private BLERange range = null;
private List<BLERangeChange> rangeChangesStack = new ArrayList<>();
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // }
import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000; private BLERange range = null; private List<BLERangeChange> rangeChangesStack = new ArrayList<>(); private TimerTask makeInvisibleTask; private Timer timer = new Timer();
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000; private BLERange range = null; private List<BLERangeChange> rangeChangesStack = new ArrayList<>(); private TimerTask makeInvisibleTask; private Timer timer = new Timer();
protected AreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // }
import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000; private BLERange range = null; private List<BLERangeChange> rangeChangesStack = new ArrayList<>(); private TimerTask makeInvisibleTask; private Timer timer = new Timer(); protected AreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } private void rescheduleInvisibilityTask() { if (makeInvisibleTask != null) { makeInvisibleTask.cancel(); } timer.purge(); makeInvisibleTask = getMakeInvisibleTask(); timer.schedule(makeInvisibleTask, VISIBILITY_DELAY); } @Override
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERangeChange.java // public class BLERangeChange { // private final BLERange range; // private final long timestamp; // // public BLERangeChange(BLERange range, long timestamp) { // this.range = range; // this.timestamp = timestamp; // } // // public BLERange getRange() { // return range; // } // // public long getTimestamp() { // return timestamp; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/IBeaconDetect.java // public class IBeaconDetect { // // private final DeviceFootprint footprint; // private final int rssi; // private final Date detectTime; // private final int txPower; // // public IBeaconDetect(String uuid, int major, int minor, int rssi, int txPower) { // footprint = new DeviceFootprint(uuid.toLowerCase(), major, minor); // this.rssi = rssi; // this.detectTime = new Date(); // this.txPower = txPower; // } // // public DeviceFootprint getFootprint() { // return footprint; // } // // public int getRssi() { // return rssi; // } // // public Date getDetectTime() { // return detectTime; // } // // public double getDistance() { // return Math.sqrt(Math.pow(10, (txPower - rssi) / 10.0)); // } // // public BLERange getRange(){ // return BLERange.getRange(getDistance()); // // } // // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/AreaHandler.java import android.util.Log; import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.BLERangeChange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.ble.model.IBeaconDetect; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * Superclass of all handlers which works with areas, like enter, exit area or proximity zone. */ public abstract class AreaHandler extends TagDetectionHandler { private static final int SAFE_INTERVAL = 2*1000; private static final int VISIBILITY_DELAY = 30*1000; private BLERange range = null; private List<BLERangeChange> rangeChangesStack = new ArrayList<>(); private TimerTask makeInvisibleTask; private Timer timer = new Timer(); protected AreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } private void rescheduleInvisibilityTask() { if (makeInvisibleTask != null) { makeInvisibleTask.cancel(); } timer.purge(); makeInvisibleTask = getMakeInvisibleTask(); timer.schedule(makeInvisibleTask, VISIBILITY_DELAY); } @Override
protected void handleDetection(IBeaconDetect detection) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/DetectionHandlerFactory.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/model/AreaSettings.java // public enum AreaSettings { // /** // * ENTER - event will occur within a few seconds after phone enters beacon area, // * EXIT - event will occur after 30 seconds after phone has left the beacon area, // * APPROACHING - event will occur within a few seconds after phone enters Immidiate and/or Near beacon area, // * LEAVING - event will occur after phone leave Immidiate and/or Near beacon area within a few // * seconds if phone in Far area, or after 30 seconds, if beacon no longer visible to the phone, // * ENTER_AND_EXIT - event will occur for conditions described either in ENTER or EXIT, // * APPROACHING_AND_LEAVING - event will occur for conditions described either in APPROACHING or LEAVING. // */ // ENTER, // EXIT, // ENTER_AND_EXIT, // APPROACHING, // LEAVING, // APPROACHING_AND_LEAVING; // }
import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.control.model.AreaSettings;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public final class DetectionHandlerFactory { private DetectionHandlerFactory() {}
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/model/AreaSettings.java // public enum AreaSettings { // /** // * ENTER - event will occur within a few seconds after phone enters beacon area, // * EXIT - event will occur after 30 seconds after phone has left the beacon area, // * APPROACHING - event will occur within a few seconds after phone enters Immidiate and/or Near beacon area, // * LEAVING - event will occur after phone leave Immidiate and/or Near beacon area within a few // * seconds if phone in Far area, or after 30 seconds, if beacon no longer visible to the phone, // * ENTER_AND_EXIT - event will occur for conditions described either in ENTER or EXIT, // * APPROACHING_AND_LEAVING - event will occur for conditions described either in APPROACHING or LEAVING. // */ // ENTER, // EXIT, // ENTER_AND_EXIT, // APPROACHING, // LEAVING, // APPROACHING_AND_LEAVING; // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/DetectionHandlerFactory.java import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.control.model.AreaSettings; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public final class DetectionHandlerFactory { private DetectionHandlerFactory() {}
public static TagDetectionHandler getHandler(DeviceFootprint footprint,
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/DetectionHandlerFactory.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/model/AreaSettings.java // public enum AreaSettings { // /** // * ENTER - event will occur within a few seconds after phone enters beacon area, // * EXIT - event will occur after 30 seconds after phone has left the beacon area, // * APPROACHING - event will occur within a few seconds after phone enters Immidiate and/or Near beacon area, // * LEAVING - event will occur after phone leave Immidiate and/or Near beacon area within a few // * seconds if phone in Far area, or after 30 seconds, if beacon no longer visible to the phone, // * ENTER_AND_EXIT - event will occur for conditions described either in ENTER or EXIT, // * APPROACHING_AND_LEAVING - event will occur for conditions described either in APPROACHING or LEAVING. // */ // ENTER, // EXIT, // ENTER_AND_EXIT, // APPROACHING, // LEAVING, // APPROACHING_AND_LEAVING; // }
import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.control.model.AreaSettings;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public final class DetectionHandlerFactory { private DetectionHandlerFactory() {} public static TagDetectionHandler getHandler(DeviceFootprint footprint, TagDetectionHandler.OnTriggerFiredListener triggerFiredListener,
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/model/AreaSettings.java // public enum AreaSettings { // /** // * ENTER - event will occur within a few seconds after phone enters beacon area, // * EXIT - event will occur after 30 seconds after phone has left the beacon area, // * APPROACHING - event will occur within a few seconds after phone enters Immidiate and/or Near beacon area, // * LEAVING - event will occur after phone leave Immidiate and/or Near beacon area within a few // * seconds if phone in Far area, or after 30 seconds, if beacon no longer visible to the phone, // * ENTER_AND_EXIT - event will occur for conditions described either in ENTER or EXIT, // * APPROACHING_AND_LEAVING - event will occur for conditions described either in APPROACHING or LEAVING. // */ // ENTER, // EXIT, // ENTER_AND_EXIT, // APPROACHING, // LEAVING, // APPROACHING_AND_LEAVING; // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/DetectionHandlerFactory.java import com.orange.beaconme_sdk.ble.model.DeviceFootprint; import com.orange.beaconme_sdk.control.model.AreaSettings; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public final class DetectionHandlerFactory { private DetectionHandlerFactory() {} public static TagDetectionHandler getHandler(DeviceFootprint footprint, TagDetectionHandler.OnTriggerFiredListener triggerFiredListener,
AreaSettings areaSettings) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/GATTOperation.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/GATTCharacteristicListener.java // public class GATTCharacteristicListener { // public void read(int status, BluetoothGattCharacteristic c) { // // } // // public void written(int status, BluetoothGattCharacteristic c) { // // } // // public void changed(int status, BluetoothGattCharacteristic c) { // // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/IGATTDescriptorListener.java // public interface IGATTDescriptorListener { // void read(int status, BluetoothGattDescriptor d); // // void written(int status, BluetoothGattDescriptor d); // }
import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import com.orange.beaconme_sdk.ble.listeners.GATTCharacteristicListener; import com.orange.beaconme_sdk.ble.listeners.IGATTDescriptorListener;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.model; public class GATTOperation { public enum OperationType { READ_CHARACTERISTIC, WRITE_CHARACTERISTIC, READ_DESCRIPTOR, WRITE_DESCRIPTOR, NOTIFY_START, NOTIFY_END, } protected OperationType mType; protected BluetoothGattCharacteristic mCharacteristic; protected BluetoothGattDescriptor mDescriptor;
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/GATTCharacteristicListener.java // public class GATTCharacteristicListener { // public void read(int status, BluetoothGattCharacteristic c) { // // } // // public void written(int status, BluetoothGattCharacteristic c) { // // } // // public void changed(int status, BluetoothGattCharacteristic c) { // // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/IGATTDescriptorListener.java // public interface IGATTDescriptorListener { // void read(int status, BluetoothGattDescriptor d); // // void written(int status, BluetoothGattDescriptor d); // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/GATTOperation.java import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import com.orange.beaconme_sdk.ble.listeners.GATTCharacteristicListener; import com.orange.beaconme_sdk.ble.listeners.IGATTDescriptorListener; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.model; public class GATTOperation { public enum OperationType { READ_CHARACTERISTIC, WRITE_CHARACTERISTIC, READ_DESCRIPTOR, WRITE_DESCRIPTOR, NOTIFY_START, NOTIFY_END, } protected OperationType mType; protected BluetoothGattCharacteristic mCharacteristic; protected BluetoothGattDescriptor mDescriptor;
protected GATTCharacteristicListener mCharListener;
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/GATTOperation.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/GATTCharacteristicListener.java // public class GATTCharacteristicListener { // public void read(int status, BluetoothGattCharacteristic c) { // // } // // public void written(int status, BluetoothGattCharacteristic c) { // // } // // public void changed(int status, BluetoothGattCharacteristic c) { // // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/IGATTDescriptorListener.java // public interface IGATTDescriptorListener { // void read(int status, BluetoothGattDescriptor d); // // void written(int status, BluetoothGattDescriptor d); // }
import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import com.orange.beaconme_sdk.ble.listeners.GATTCharacteristicListener; import com.orange.beaconme_sdk.ble.listeners.IGATTDescriptorListener;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.model; public class GATTOperation { public enum OperationType { READ_CHARACTERISTIC, WRITE_CHARACTERISTIC, READ_DESCRIPTOR, WRITE_DESCRIPTOR, NOTIFY_START, NOTIFY_END, } protected OperationType mType; protected BluetoothGattCharacteristic mCharacteristic; protected BluetoothGattDescriptor mDescriptor; protected GATTCharacteristicListener mCharListener;
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/GATTCharacteristicListener.java // public class GATTCharacteristicListener { // public void read(int status, BluetoothGattCharacteristic c) { // // } // // public void written(int status, BluetoothGattCharacteristic c) { // // } // // public void changed(int status, BluetoothGattCharacteristic c) { // // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/listeners/IGATTDescriptorListener.java // public interface IGATTDescriptorListener { // void read(int status, BluetoothGattDescriptor d); // // void written(int status, BluetoothGattDescriptor d); // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/GATTOperation.java import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import com.orange.beaconme_sdk.ble.listeners.GATTCharacteristicListener; import com.orange.beaconme_sdk.ble.listeners.IGATTDescriptorListener; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.ble.model; public class GATTOperation { public enum OperationType { READ_CHARACTERISTIC, WRITE_CHARACTERISTIC, READ_DESCRIPTOR, WRITE_DESCRIPTOR, NOTIFY_START, NOTIFY_END, } protected OperationType mType; protected BluetoothGattCharacteristic mCharacteristic; protected BluetoothGattDescriptor mDescriptor; protected GATTCharacteristicListener mCharListener;
protected IGATTDescriptorListener mDescListener;
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterAndExitAreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // }
import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterAndExitAreaHandler extends AreaHandler { public EnterAndExitAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterAndExitAreaHandler.java import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterAndExitAreaHandler extends AreaHandler { public EnterAndExitAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
protected void onRangeChanged(BLERange oldRange, BLERange newRange) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/ExitAreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // }
import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class ExitAreaHandler extends AreaHandler { public ExitAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/ExitAreaHandler.java import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class ExitAreaHandler extends AreaHandler { public ExitAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
protected void onRangeChanged(BLERange oldRange, BLERange newRange) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterNearAreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // }
import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterNearAreaHandler extends AreaHandler { public EnterNearAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterNearAreaHandler.java import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterNearAreaHandler extends AreaHandler { public EnterNearAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
protected void onRangeChanged(BLERange oldRange, BLERange newRange) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterAreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // }
import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterAreaHandler extends AreaHandler { public EnterAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterAreaHandler.java import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterAreaHandler extends AreaHandler { public EnterAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
protected void onRangeChanged(BLERange oldRange, BLERange newRange) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/ExitNearAreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // }
import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class ExitNearAreaHandler extends AreaHandler { public ExitNearAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/ExitNearAreaHandler.java import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class ExitNearAreaHandler extends AreaHandler { public ExitNearAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
protected void onRangeChanged(BLERange oldRange, BLERange newRange) {
Orange-OpenSource/BeaconTag-Android-SDK
beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterNearAndExitNearAreaHandler.java
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // }
import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint;
/* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterNearAndExitNearAreaHandler extends AreaHandler { public EnterNearAndExitNearAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
// Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/BLERange.java // public enum BLERange { // IMMIDIATE(0, 1), NEAR(1, 10), FAR(10, Double.MAX_VALUE); // // public static BLERange getRange(double distance) { // for (BLERange range: BLERange.values()) { // if (range.isWithinRange(distance)) return range; // } // return FAR; // } // // BLERange(double bottomThreshold, double topThreshold) { // this.topThreshold = topThreshold; // this.bottomThreshold = bottomThreshold; // } // // private final double topThreshold; // private final double bottomThreshold; // // public boolean isWithinRange(double distance) { // return (distance <= topThreshold) && (distance > bottomThreshold); // } // } // // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/ble/model/DeviceFootprint.java // public class DeviceFootprint implements Serializable { // // private String uuid; // // private int major; // // private int minor; // // public DeviceFootprint() {} // // /** // * Create new footprint // * @param uuid uuid of the device // * @param major major of the device // * @param minor minor of the device // */ // public DeviceFootprint(String uuid, int major, int minor) { // this.uuid = uuid; // this.major = major; // this.minor = minor; // } // // public String getUuid() { // return uuid; // } // // public int getMajor() { // return major; // } // // public int getMinor() { // return minor; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // DeviceFootprint that = (DeviceFootprint) o; // // if (major != that.major) return false; // if (minor != that.minor) return false; // if (!uuid.equals(that.uuid)) return false; // // return true; // } // // @Override // public int hashCode() { // int result = uuid.hashCode(); // result = 31 * result + major; // result = 31 * result + minor; // return result; // } // } // Path: beacontag_sdk/src/main/java/com/orange/beaconme_sdk/control/detection_handlers/EnterNearAndExitNearAreaHandler.java import com.orange.beaconme_sdk.ble.model.BLERange; import com.orange.beaconme_sdk.ble.model.DeviceFootprint; /* * Copyright (c) 2015 Orange. * * This library is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License, which can be found in the file 'LICENSE.txt' in * this package distribution or at 'http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html' * for more details. * * Created by Orange Beacon on 08/6/15. */ package com.orange.beaconme_sdk.control.detection_handlers; /** * */ public class EnterNearAndExitNearAreaHandler extends AreaHandler { public EnterNearAndExitNearAreaHandler(DeviceFootprint footprint, OnTriggerFiredListener listener) { super(footprint, listener); } @Override
protected void onRangeChanged(BLERange oldRange, BLERange newRange) {
lwfwind/smart-api-framework
src/com/qa/framework/core/GlobalConvertor.java
// Path: src/com/qa/framework/InstanceFactory.java // public class InstanceFactory { // // /** // * 用于缓存对应的实例 // */ // private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); // // // /** // * 获取 ClassScanner // * // * @return the class scanner // */ // public static ClassScanner getClassScanner() { // return getInstance("class_scanner", DefaultClassScanner.class); // } // // public static Global getGlobal() { // return getInstance("Global", Global.class); // } // // // /** // * Gets instance. // * // * @param <T> the type parameter // * @param cacheKey the cache key // * @param defaultImplClass the default impl class // * @return the instance // */ // @SuppressWarnings("unchecked") // public static <T> T getInstance(String cacheKey, Class<T> defaultImplClass) { // // 若缓存中存在对应的实例,则返回该实例 // if (cache.containsKey(cacheKey)) { // return (T) cache.get(cacheKey); // } // // 通过反射创建该实现类对应的实例 // T instance = ReflectHelper.newInstance(defaultImplClass.getName()); // // 若该实例不为空,则将其放入缓存 // if (instance != null) { // cache.put(cacheKey, instance); // } // // 返回该实例 // return instance; // } // } // // Path: src/com/qa/framework/bean/Function.java // public class Function { // private String name; // private String clsName; // private String methodName; // private Object value; // private String arguments; // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // public String getArguments() { // return arguments; // } // // public void setArguments(String arguments) { // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // /** // * Gets cls name. // * // * @return the cls name // */ // public String getClsName() { // return clsName; // } // // /** // * Sets cls name. // * // * @param clsName the cls name // */ // public void setClsName(String clsName) { // this.clsName = clsName; // } // // /** // * Gets method name. // * // * @return the method name // */ // public String getMethodName() { // return methodName; // } // // /** // * Sets method name. // * // * @param methodName the method name // */ // public void setMethodName(String methodName) { // this.methodName = methodName; // } // } // // Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // }
import com.library.common.IOHelper; import com.library.common.ReflectHelper; import com.library.common.XmlHelper; import com.qa.framework.InstanceFactory; import com.qa.framework.bean.Function; import com.qa.framework.bean.Global; import org.apache.log4j.Logger; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Element; import java.lang.reflect.Field; import java.util.List;
package com.qa.framework.core; /** * 将xml中的数据转化成对应的bean类 */ public class GlobalConvertor { private static final Logger logger = Logger.getLogger(GlobalConvertor.class); public GlobalConvertor() { List<String> files = IOHelper.listFilesInDirectoryRecursive(System.getProperty("user.dir"), "global.xml"); if (files.size() > 0) { String filePath = files.get(0); logger.info("convert data from xml-" + filePath); XmlHelper xmlHelper = new XmlHelper(); Document document = xmlHelper.readXMLFile(filePath);
// Path: src/com/qa/framework/InstanceFactory.java // public class InstanceFactory { // // /** // * 用于缓存对应的实例 // */ // private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); // // // /** // * 获取 ClassScanner // * // * @return the class scanner // */ // public static ClassScanner getClassScanner() { // return getInstance("class_scanner", DefaultClassScanner.class); // } // // public static Global getGlobal() { // return getInstance("Global", Global.class); // } // // // /** // * Gets instance. // * // * @param <T> the type parameter // * @param cacheKey the cache key // * @param defaultImplClass the default impl class // * @return the instance // */ // @SuppressWarnings("unchecked") // public static <T> T getInstance(String cacheKey, Class<T> defaultImplClass) { // // 若缓存中存在对应的实例,则返回该实例 // if (cache.containsKey(cacheKey)) { // return (T) cache.get(cacheKey); // } // // 通过反射创建该实现类对应的实例 // T instance = ReflectHelper.newInstance(defaultImplClass.getName()); // // 若该实例不为空,则将其放入缓存 // if (instance != null) { // cache.put(cacheKey, instance); // } // // 返回该实例 // return instance; // } // } // // Path: src/com/qa/framework/bean/Function.java // public class Function { // private String name; // private String clsName; // private String methodName; // private Object value; // private String arguments; // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // public String getArguments() { // return arguments; // } // // public void setArguments(String arguments) { // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // /** // * Gets cls name. // * // * @return the cls name // */ // public String getClsName() { // return clsName; // } // // /** // * Sets cls name. // * // * @param clsName the cls name // */ // public void setClsName(String clsName) { // this.clsName = clsName; // } // // /** // * Gets method name. // * // * @return the method name // */ // public String getMethodName() { // return methodName; // } // // /** // * Sets method name. // * // * @param methodName the method name // */ // public void setMethodName(String methodName) { // this.methodName = methodName; // } // } // // Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // Path: src/com/qa/framework/core/GlobalConvertor.java import com.library.common.IOHelper; import com.library.common.ReflectHelper; import com.library.common.XmlHelper; import com.qa.framework.InstanceFactory; import com.qa.framework.bean.Function; import com.qa.framework.bean.Global; import org.apache.log4j.Logger; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Element; import java.lang.reflect.Field; import java.util.List; package com.qa.framework.core; /** * 将xml中的数据转化成对应的bean类 */ public class GlobalConvertor { private static final Logger logger = Logger.getLogger(GlobalConvertor.class); public GlobalConvertor() { List<String> files = IOHelper.listFilesInDirectoryRecursive(System.getProperty("user.dir"), "global.xml"); if (files.size() > 0) { String filePath = files.get(0); logger.info("convert data from xml-" + filePath); XmlHelper xmlHelper = new XmlHelper(); Document document = xmlHelper.readXMLFile(filePath);
Global global = InstanceFactory.getGlobal();
lwfwind/smart-api-framework
src/com/qa/framework/core/GlobalConvertor.java
// Path: src/com/qa/framework/InstanceFactory.java // public class InstanceFactory { // // /** // * 用于缓存对应的实例 // */ // private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); // // // /** // * 获取 ClassScanner // * // * @return the class scanner // */ // public static ClassScanner getClassScanner() { // return getInstance("class_scanner", DefaultClassScanner.class); // } // // public static Global getGlobal() { // return getInstance("Global", Global.class); // } // // // /** // * Gets instance. // * // * @param <T> the type parameter // * @param cacheKey the cache key // * @param defaultImplClass the default impl class // * @return the instance // */ // @SuppressWarnings("unchecked") // public static <T> T getInstance(String cacheKey, Class<T> defaultImplClass) { // // 若缓存中存在对应的实例,则返回该实例 // if (cache.containsKey(cacheKey)) { // return (T) cache.get(cacheKey); // } // // 通过反射创建该实现类对应的实例 // T instance = ReflectHelper.newInstance(defaultImplClass.getName()); // // 若该实例不为空,则将其放入缓存 // if (instance != null) { // cache.put(cacheKey, instance); // } // // 返回该实例 // return instance; // } // } // // Path: src/com/qa/framework/bean/Function.java // public class Function { // private String name; // private String clsName; // private String methodName; // private Object value; // private String arguments; // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // public String getArguments() { // return arguments; // } // // public void setArguments(String arguments) { // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // /** // * Gets cls name. // * // * @return the cls name // */ // public String getClsName() { // return clsName; // } // // /** // * Sets cls name. // * // * @param clsName the cls name // */ // public void setClsName(String clsName) { // this.clsName = clsName; // } // // /** // * Gets method name. // * // * @return the method name // */ // public String getMethodName() { // return methodName; // } // // /** // * Sets method name. // * // * @param methodName the method name // */ // public void setMethodName(String methodName) { // this.methodName = methodName; // } // } // // Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // }
import com.library.common.IOHelper; import com.library.common.ReflectHelper; import com.library.common.XmlHelper; import com.qa.framework.InstanceFactory; import com.qa.framework.bean.Function; import com.qa.framework.bean.Global; import org.apache.log4j.Logger; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Element; import java.lang.reflect.Field; import java.util.List;
package com.qa.framework.core; /** * 将xml中的数据转化成对应的bean类 */ public class GlobalConvertor { private static final Logger logger = Logger.getLogger(GlobalConvertor.class); public GlobalConvertor() { List<String> files = IOHelper.listFilesInDirectoryRecursive(System.getProperty("user.dir"), "global.xml"); if (files.size() > 0) { String filePath = files.get(0); logger.info("convert data from xml-" + filePath); XmlHelper xmlHelper = new XmlHelper(); Document document = xmlHelper.readXMLFile(filePath);
// Path: src/com/qa/framework/InstanceFactory.java // public class InstanceFactory { // // /** // * 用于缓存对应的实例 // */ // private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); // // // /** // * 获取 ClassScanner // * // * @return the class scanner // */ // public static ClassScanner getClassScanner() { // return getInstance("class_scanner", DefaultClassScanner.class); // } // // public static Global getGlobal() { // return getInstance("Global", Global.class); // } // // // /** // * Gets instance. // * // * @param <T> the type parameter // * @param cacheKey the cache key // * @param defaultImplClass the default impl class // * @return the instance // */ // @SuppressWarnings("unchecked") // public static <T> T getInstance(String cacheKey, Class<T> defaultImplClass) { // // 若缓存中存在对应的实例,则返回该实例 // if (cache.containsKey(cacheKey)) { // return (T) cache.get(cacheKey); // } // // 通过反射创建该实现类对应的实例 // T instance = ReflectHelper.newInstance(defaultImplClass.getName()); // // 若该实例不为空,则将其放入缓存 // if (instance != null) { // cache.put(cacheKey, instance); // } // // 返回该实例 // return instance; // } // } // // Path: src/com/qa/framework/bean/Function.java // public class Function { // private String name; // private String clsName; // private String methodName; // private Object value; // private String arguments; // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // public String getArguments() { // return arguments; // } // // public void setArguments(String arguments) { // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // /** // * Gets cls name. // * // * @return the cls name // */ // public String getClsName() { // return clsName; // } // // /** // * Sets cls name. // * // * @param clsName the cls name // */ // public void setClsName(String clsName) { // this.clsName = clsName; // } // // /** // * Gets method name. // * // * @return the method name // */ // public String getMethodName() { // return methodName; // } // // /** // * Sets method name. // * // * @param methodName the method name // */ // public void setMethodName(String methodName) { // this.methodName = methodName; // } // } // // Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // Path: src/com/qa/framework/core/GlobalConvertor.java import com.library.common.IOHelper; import com.library.common.ReflectHelper; import com.library.common.XmlHelper; import com.qa.framework.InstanceFactory; import com.qa.framework.bean.Function; import com.qa.framework.bean.Global; import org.apache.log4j.Logger; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Element; import java.lang.reflect.Field; import java.util.List; package com.qa.framework.core; /** * 将xml中的数据转化成对应的bean类 */ public class GlobalConvertor { private static final Logger logger = Logger.getLogger(GlobalConvertor.class); public GlobalConvertor() { List<String> files = IOHelper.listFilesInDirectoryRecursive(System.getProperty("user.dir"), "global.xml"); if (files.size() > 0) { String filePath = files.get(0); logger.info("convert data from xml-" + filePath); XmlHelper xmlHelper = new XmlHelper(); Document document = xmlHelper.readXMLFile(filePath);
Global global = InstanceFactory.getGlobal();
lwfwind/smart-api-framework
src/com/qa/framework/core/GlobalConvertor.java
// Path: src/com/qa/framework/InstanceFactory.java // public class InstanceFactory { // // /** // * 用于缓存对应的实例 // */ // private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); // // // /** // * 获取 ClassScanner // * // * @return the class scanner // */ // public static ClassScanner getClassScanner() { // return getInstance("class_scanner", DefaultClassScanner.class); // } // // public static Global getGlobal() { // return getInstance("Global", Global.class); // } // // // /** // * Gets instance. // * // * @param <T> the type parameter // * @param cacheKey the cache key // * @param defaultImplClass the default impl class // * @return the instance // */ // @SuppressWarnings("unchecked") // public static <T> T getInstance(String cacheKey, Class<T> defaultImplClass) { // // 若缓存中存在对应的实例,则返回该实例 // if (cache.containsKey(cacheKey)) { // return (T) cache.get(cacheKey); // } // // 通过反射创建该实现类对应的实例 // T instance = ReflectHelper.newInstance(defaultImplClass.getName()); // // 若该实例不为空,则将其放入缓存 // if (instance != null) { // cache.put(cacheKey, instance); // } // // 返回该实例 // return instance; // } // } // // Path: src/com/qa/framework/bean/Function.java // public class Function { // private String name; // private String clsName; // private String methodName; // private Object value; // private String arguments; // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // public String getArguments() { // return arguments; // } // // public void setArguments(String arguments) { // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // /** // * Gets cls name. // * // * @return the cls name // */ // public String getClsName() { // return clsName; // } // // /** // * Sets cls name. // * // * @param clsName the cls name // */ // public void setClsName(String clsName) { // this.clsName = clsName; // } // // /** // * Gets method name. // * // * @return the method name // */ // public String getMethodName() { // return methodName; // } // // /** // * Sets method name. // * // * @param methodName the method name // */ // public void setMethodName(String methodName) { // this.methodName = methodName; // } // } // // Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // }
import com.library.common.IOHelper; import com.library.common.ReflectHelper; import com.library.common.XmlHelper; import com.qa.framework.InstanceFactory; import com.qa.framework.bean.Function; import com.qa.framework.bean.Global; import org.apache.log4j.Logger; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Element; import java.lang.reflect.Field; import java.util.List;
package com.qa.framework.core; /** * 将xml中的数据转化成对应的bean类 */ public class GlobalConvertor { private static final Logger logger = Logger.getLogger(GlobalConvertor.class); public GlobalConvertor() { List<String> files = IOHelper.listFilesInDirectoryRecursive(System.getProperty("user.dir"), "global.xml"); if (files.size() > 0) { String filePath = files.get(0); logger.info("convert data from xml-" + filePath); XmlHelper xmlHelper = new XmlHelper(); Document document = xmlHelper.readXMLFile(filePath); Global global = InstanceFactory.getGlobal(); List elements = document.getRootElement().elements(); for (Object element : elements) { convert(global, (Element) element); } if(InstanceFactory.getGlobal().getBefore() != null && InstanceFactory.getGlobal().getBefore().getFunctions() != null) {
// Path: src/com/qa/framework/InstanceFactory.java // public class InstanceFactory { // // /** // * 用于缓存对应的实例 // */ // private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); // // // /** // * 获取 ClassScanner // * // * @return the class scanner // */ // public static ClassScanner getClassScanner() { // return getInstance("class_scanner", DefaultClassScanner.class); // } // // public static Global getGlobal() { // return getInstance("Global", Global.class); // } // // // /** // * Gets instance. // * // * @param <T> the type parameter // * @param cacheKey the cache key // * @param defaultImplClass the default impl class // * @return the instance // */ // @SuppressWarnings("unchecked") // public static <T> T getInstance(String cacheKey, Class<T> defaultImplClass) { // // 若缓存中存在对应的实例,则返回该实例 // if (cache.containsKey(cacheKey)) { // return (T) cache.get(cacheKey); // } // // 通过反射创建该实现类对应的实例 // T instance = ReflectHelper.newInstance(defaultImplClass.getName()); // // 若该实例不为空,则将其放入缓存 // if (instance != null) { // cache.put(cacheKey, instance); // } // // 返回该实例 // return instance; // } // } // // Path: src/com/qa/framework/bean/Function.java // public class Function { // private String name; // private String clsName; // private String methodName; // private Object value; // private String arguments; // // public Object getValue() { // return value; // } // // public void setValue(Object value) { // this.value = value; // } // // public String getArguments() { // return arguments; // } // // public void setArguments(String arguments) { // this.arguments = arguments; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // /** // * Gets cls name. // * // * @return the cls name // */ // public String getClsName() { // return clsName; // } // // /** // * Sets cls name. // * // * @param clsName the cls name // */ // public void setClsName(String clsName) { // this.clsName = clsName; // } // // /** // * Gets method name. // * // * @return the method name // */ // public String getMethodName() { // return methodName; // } // // /** // * Sets method name. // * // * @param methodName the method name // */ // public void setMethodName(String methodName) { // this.methodName = methodName; // } // } // // Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // Path: src/com/qa/framework/core/GlobalConvertor.java import com.library.common.IOHelper; import com.library.common.ReflectHelper; import com.library.common.XmlHelper; import com.qa.framework.InstanceFactory; import com.qa.framework.bean.Function; import com.qa.framework.bean.Global; import org.apache.log4j.Logger; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Element; import java.lang.reflect.Field; import java.util.List; package com.qa.framework.core; /** * 将xml中的数据转化成对应的bean类 */ public class GlobalConvertor { private static final Logger logger = Logger.getLogger(GlobalConvertor.class); public GlobalConvertor() { List<String> files = IOHelper.listFilesInDirectoryRecursive(System.getProperty("user.dir"), "global.xml"); if (files.size() > 0) { String filePath = files.get(0); logger.info("convert data from xml-" + filePath); XmlHelper xmlHelper = new XmlHelper(); Document document = xmlHelper.readXMLFile(filePath); Global global = InstanceFactory.getGlobal(); List elements = document.getRootElement().elements(); for (Object element : elements) { convert(global, (Element) element); } if(InstanceFactory.getGlobal().getBefore() != null && InstanceFactory.getGlobal().getBefore().getFunctions() != null) {
for (Function function : InstanceFactory.getGlobal().getBefore().getFunctions()) {
lwfwind/smart-api-framework
src/com/qa/framework/bean/ExpectResults.java
// Path: src/com/qa/framework/verify/IExpectResult.java // public interface IExpectResult { // // /** // * Compare real. // * // * @param content the content // */ // void compareReal(String content); // // }
import com.qa.framework.verify.IExpectResult; import org.apache.log4j.Logger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
package com.qa.framework.bean; public class ExpectResults { /** * The constant logger. */ protected static final Logger logger = Logger.getLogger(ExpectResults.class);
// Path: src/com/qa/framework/verify/IExpectResult.java // public interface IExpectResult { // // /** // * Compare real. // * // * @param content the content // */ // void compareReal(String content); // // } // Path: src/com/qa/framework/bean/ExpectResults.java import com.qa.framework.verify.IExpectResult; import org.apache.log4j.Logger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; package com.qa.framework.bean; public class ExpectResults { /** * The constant logger. */ protected static final Logger logger = Logger.getLogger(ExpectResults.class);
private List<IExpectResult> expectResults;
lwfwind/smart-api-framework
src/com/qa/framework/verify/PairExpectResult.java
// Path: src/com/qa/framework/bean/Pair.java // public class Pair { // private String key; // private String value; // private boolean sort; // private boolean patternMatch = true; // // /** // * Instantiates a new Pair. // * // * @param key the key // * @param value the value // */ // public Pair(String key, String value) { // this.key = key; // this.value = value; // } // // /** // * Instantiates a new Pair. // */ // public Pair() { // } // // /** // * Gets pattern match. // * // * @return the pattern match // */ // public Boolean getPatternMatch() { // return patternMatch; // } // // /** // * Sets pattern match. // * // * @param patter the patter // */ // public void setPatternMatch(String patter) { // this.patternMatch = StringHelper.changeString2boolean(patter); // } // // /** // * Sets pattern match. // * // * @param patter the patter // */ // public void setPatternMatch(boolean patter) { // this.patternMatch = patter; // } // // /** // * Gets key. // * // * @return the key // */ // public String getKey() { // return key; // } // // /** // * Sets key. // * // * @param key the key // */ // public void setKey(String key) { // this.key = key; // } // // /** // * Gets value. // * // * @return the value // */ // public String getValue() { // return value; // } // // /** // * Sets value. // * // * @param value the value // */ // public void setValue(String value) { // this.value = value; // } // // /** // * Sets sort. // * // * @param sortStr the sort str // */ // public void setSort(String sortStr) { // sort = StringHelper.changeString2boolean(sortStr); // } // // /** // * Is sort boolean. // * // * @return the boolean // */ // public boolean isSort() { // return sort; // } // // /** // * Sets sort. // * // * @param sort the sort // */ // public void setSort(boolean sort) { // this.sort = sort; // } // // // /** // * Sets map statement. // * // * @param mapStatement the map statement // */ // public void setMapStatement(String mapStatement) { // if (mapStatement != null && !"".equalsIgnoreCase(mapStatement)) { // if (!mapStatement.contains(":")) { // throw new IllegalArgumentException("请重新设值,参照格式key:value"); // } // String[] statements = mapStatement.split(":"); // if (statements.length == 1) { // setKey(statements[0].trim()); // setValue(""); // } else if (statements.length == 2) { // setKey(statements[0].trim()); // setValue(statements[1].trim()); // } else { // setKey(statements[0].trim()); // String[] newStatementsValue = Arrays.copyOfRange(statements, 1, statements.length); // setValue(StringHelper.join(newStatementsValue, ":")); // } // } // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // if (obj instanceof Pair) { // Pair pair = (Pair) obj; // if (this.getValue().equalsIgnoreCase(pair.getValue()) && this.getKey().equalsIgnoreCase(pair.getKey())) { // return true; // } // } // return false; // } // // // @Override // public String toString() { // return key + ":=" + value; // } // // }
import com.library.common.JsonHelper; import com.qa.framework.bean.Pair; import org.apache.log4j.Logger; import org.testng.Assert; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern;
package com.qa.framework.verify; /** * Created by apple on 15/11/20. */ public class PairExpectResult implements IExpectResult { /** * The constant logger. */ protected static final Logger logger = Logger.getLogger(PairExpectResult.class); private String pairStatement;
// Path: src/com/qa/framework/bean/Pair.java // public class Pair { // private String key; // private String value; // private boolean sort; // private boolean patternMatch = true; // // /** // * Instantiates a new Pair. // * // * @param key the key // * @param value the value // */ // public Pair(String key, String value) { // this.key = key; // this.value = value; // } // // /** // * Instantiates a new Pair. // */ // public Pair() { // } // // /** // * Gets pattern match. // * // * @return the pattern match // */ // public Boolean getPatternMatch() { // return patternMatch; // } // // /** // * Sets pattern match. // * // * @param patter the patter // */ // public void setPatternMatch(String patter) { // this.patternMatch = StringHelper.changeString2boolean(patter); // } // // /** // * Sets pattern match. // * // * @param patter the patter // */ // public void setPatternMatch(boolean patter) { // this.patternMatch = patter; // } // // /** // * Gets key. // * // * @return the key // */ // public String getKey() { // return key; // } // // /** // * Sets key. // * // * @param key the key // */ // public void setKey(String key) { // this.key = key; // } // // /** // * Gets value. // * // * @return the value // */ // public String getValue() { // return value; // } // // /** // * Sets value. // * // * @param value the value // */ // public void setValue(String value) { // this.value = value; // } // // /** // * Sets sort. // * // * @param sortStr the sort str // */ // public void setSort(String sortStr) { // sort = StringHelper.changeString2boolean(sortStr); // } // // /** // * Is sort boolean. // * // * @return the boolean // */ // public boolean isSort() { // return sort; // } // // /** // * Sets sort. // * // * @param sort the sort // */ // public void setSort(boolean sort) { // this.sort = sort; // } // // // /** // * Sets map statement. // * // * @param mapStatement the map statement // */ // public void setMapStatement(String mapStatement) { // if (mapStatement != null && !"".equalsIgnoreCase(mapStatement)) { // if (!mapStatement.contains(":")) { // throw new IllegalArgumentException("请重新设值,参照格式key:value"); // } // String[] statements = mapStatement.split(":"); // if (statements.length == 1) { // setKey(statements[0].trim()); // setValue(""); // } else if (statements.length == 2) { // setKey(statements[0].trim()); // setValue(statements[1].trim()); // } else { // setKey(statements[0].trim()); // String[] newStatementsValue = Arrays.copyOfRange(statements, 1, statements.length); // setValue(StringHelper.join(newStatementsValue, ":")); // } // } // } // // @Override // public boolean equals(Object obj) { // if (obj == null) { // return false; // } // if (obj instanceof Pair) { // Pair pair = (Pair) obj; // if (this.getValue().equalsIgnoreCase(pair.getValue()) && this.getKey().equalsIgnoreCase(pair.getKey())) { // return true; // } // } // return false; // } // // // @Override // public String toString() { // return key + ":=" + value; // } // // } // Path: src/com/qa/framework/verify/PairExpectResult.java import com.library.common.JsonHelper; import com.qa.framework.bean.Pair; import org.apache.log4j.Logger; import org.testng.Assert; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; package com.qa.framework.verify; /** * Created by apple on 15/11/20. */ public class PairExpectResult implements IExpectResult { /** * The constant logger. */ protected static final Logger logger = Logger.getLogger(PairExpectResult.class); private String pairStatement;
private Pair pair;
lwfwind/smart-api-framework
src/com/qa/framework/library/httpclient/HttpConnectionImp.java
// Path: src/com/qa/framework/bean/Cookie.java // public class Cookie { // private String name; // private String value; // private String domain; // private String path; // private Date expiry; // // private static Date getExpiryDate() { // Calendar calendar = Calendar.getInstance(); // Date date = new Date(); // calendar.setTime(date); // calendar.add(Calendar.YEAR, 1); // date = calendar.getTime(); // return date; // } // // /** // * Gets value. // * // * @return the value // */ // public String getValue() { // return value; // } // // /** // * Sets value. // * // * @param value the value // */ // public void setValue(String value) { // this.value = value; // } // // /** // * Gets name. // * // * @return the name // */ // public String getName() { // return name; // } // // /** // * Sets name. // * // * @param name the name // */ // public void setName(String name) { // this.name = name; // } // // /** // * Gets domain. // * // * @return the domain // */ // public String getDomain() { // if (domain == null) { // String webPath = PropConfig.getWebPath(); // if (StringHelper.startsWithIgnoreCase(webPath, "http://")) { // if (webPath.substring(7).contains("/")) { // domain = StringHelper.getTokensList(webPath.substring(7), "/").get(0); // } else { // domain = webPath.substring(7); // } // } // if (domain.contains(":")) { // domain = domain.split(":")[0].trim(); // } // } // return domain; // } // // /** // * Sets domain. // * // * @param domain the domain // */ // public void setDomain(String domain) { // this.domain = domain; // } // // /** // * Gets path. // * // * @return the path // */ // public String getPath() { // if (path == null) { // path = "/"; // } // return path; // } // // /** // * Sets path. // * // * @param path the path // */ // public void setPath(String path) { // this.path = path; // } // // /** // * Gets expiry. // * // * @return the expiry // */ // public Date getExpiry() { // if (expiry == null) { // expiry = getExpiryDate(); // } // return expiry; // } // // /** // * Sets expiry. // * // * @param expiry the expiry // */ // public void setExpiry(Date expiry) { // this.expiry = expiry; // } // }
import com.qa.framework.bean.Cookie; import org.apache.commons.io.input.BOMInputStream; import org.apache.http.HttpEntity; import org.apache.http.client.CookieStore; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.util.EntityUtils; import org.apache.log4j.Logger; import java.io.*; import java.util.List;
package com.qa.framework.library.httpclient; /** * The type Http connection imp. */ public class HttpConnectionImp { private final Logger logger = Logger .getLogger(this.getClass()); private HttpRequestBase baseRequest;
// Path: src/com/qa/framework/bean/Cookie.java // public class Cookie { // private String name; // private String value; // private String domain; // private String path; // private Date expiry; // // private static Date getExpiryDate() { // Calendar calendar = Calendar.getInstance(); // Date date = new Date(); // calendar.setTime(date); // calendar.add(Calendar.YEAR, 1); // date = calendar.getTime(); // return date; // } // // /** // * Gets value. // * // * @return the value // */ // public String getValue() { // return value; // } // // /** // * Sets value. // * // * @param value the value // */ // public void setValue(String value) { // this.value = value; // } // // /** // * Gets name. // * // * @return the name // */ // public String getName() { // return name; // } // // /** // * Sets name. // * // * @param name the name // */ // public void setName(String name) { // this.name = name; // } // // /** // * Gets domain. // * // * @return the domain // */ // public String getDomain() { // if (domain == null) { // String webPath = PropConfig.getWebPath(); // if (StringHelper.startsWithIgnoreCase(webPath, "http://")) { // if (webPath.substring(7).contains("/")) { // domain = StringHelper.getTokensList(webPath.substring(7), "/").get(0); // } else { // domain = webPath.substring(7); // } // } // if (domain.contains(":")) { // domain = domain.split(":")[0].trim(); // } // } // return domain; // } // // /** // * Sets domain. // * // * @param domain the domain // */ // public void setDomain(String domain) { // this.domain = domain; // } // // /** // * Gets path. // * // * @return the path // */ // public String getPath() { // if (path == null) { // path = "/"; // } // return path; // } // // /** // * Sets path. // * // * @param path the path // */ // public void setPath(String path) { // this.path = path; // } // // /** // * Gets expiry. // * // * @return the expiry // */ // public Date getExpiry() { // if (expiry == null) { // expiry = getExpiryDate(); // } // return expiry; // } // // /** // * Sets expiry. // * // * @param expiry the expiry // */ // public void setExpiry(Date expiry) { // this.expiry = expiry; // } // } // Path: src/com/qa/framework/library/httpclient/HttpConnectionImp.java import com.qa.framework.bean.Cookie; import org.apache.commons.io.input.BOMInputStream; import org.apache.http.HttpEntity; import org.apache.http.client.CookieStore; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.util.EntityUtils; import org.apache.log4j.Logger; import java.io.*; import java.util.List; package com.qa.framework.library.httpclient; /** * The type Http connection imp. */ public class HttpConnectionImp { private final Logger logger = Logger .getLogger(this.getClass()); private HttpRequestBase baseRequest;
private List<Cookie> cookieList;
lwfwind/smart-api-framework
src/com/qa/framework/InstanceFactory.java
// Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // // Path: src/com/qa/framework/classfinder/ClassScanner.java // public interface ClassScanner { // // /** // * 获取指定包名中的所有类 // * // * @param packageName the package name // * @return the class list // */ // List<Class<?>> getClassList(String packageName); // // /** // * 获取指定包名中指定注解的相关类 // * // * @param packageName the package name // * @param annotationClass the annotation class // * @return the class list by annotation // */ // List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass); // // /** // * 获取指定包名中指定父类或接口的相关类 // * // * @param packageName the package name // * @param superClass the super class // * @return the class list by super // */ // List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass); // } // // Path: src/com/qa/framework/classfinder/impl/DefaultClassScanner.java // public class DefaultClassScanner implements ClassScanner { // // @Override // public List<Class<?>> getClassList(String packageName) { // return new ClassTemplate(packageName) { // @Override // public boolean checkAddClass(Class<?> cls) { // String className = cls.getName(); // String pkgName = className.substring(0, className.lastIndexOf(".")); // return pkgName.startsWith(packageName); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass) { // return new AnnotationClassTemplate(packageName, annotationClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return cls.isAnnotationPresent(annotationClass); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass) { // return new SupperClassTemplate(packageName, superClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return superClass.isAssignableFrom(cls) && !superClass.equals(cls); // } // }.getClassList(); // } // }
import com.library.common.ReflectHelper; import com.qa.framework.bean.Global; import com.qa.framework.classfinder.ClassScanner; import com.qa.framework.classfinder.impl.DefaultClassScanner; import java.util.Map; import java.util.concurrent.ConcurrentHashMap;
package com.qa.framework; /** * 实例工厂 */ public class InstanceFactory { /** * 用于缓存对应的实例 */ private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); /** * 获取 ClassScanner * * @return the class scanner */
// Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // // Path: src/com/qa/framework/classfinder/ClassScanner.java // public interface ClassScanner { // // /** // * 获取指定包名中的所有类 // * // * @param packageName the package name // * @return the class list // */ // List<Class<?>> getClassList(String packageName); // // /** // * 获取指定包名中指定注解的相关类 // * // * @param packageName the package name // * @param annotationClass the annotation class // * @return the class list by annotation // */ // List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass); // // /** // * 获取指定包名中指定父类或接口的相关类 // * // * @param packageName the package name // * @param superClass the super class // * @return the class list by super // */ // List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass); // } // // Path: src/com/qa/framework/classfinder/impl/DefaultClassScanner.java // public class DefaultClassScanner implements ClassScanner { // // @Override // public List<Class<?>> getClassList(String packageName) { // return new ClassTemplate(packageName) { // @Override // public boolean checkAddClass(Class<?> cls) { // String className = cls.getName(); // String pkgName = className.substring(0, className.lastIndexOf(".")); // return pkgName.startsWith(packageName); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass) { // return new AnnotationClassTemplate(packageName, annotationClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return cls.isAnnotationPresent(annotationClass); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass) { // return new SupperClassTemplate(packageName, superClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return superClass.isAssignableFrom(cls) && !superClass.equals(cls); // } // }.getClassList(); // } // } // Path: src/com/qa/framework/InstanceFactory.java import com.library.common.ReflectHelper; import com.qa.framework.bean.Global; import com.qa.framework.classfinder.ClassScanner; import com.qa.framework.classfinder.impl.DefaultClassScanner; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; package com.qa.framework; /** * 实例工厂 */ public class InstanceFactory { /** * 用于缓存对应的实例 */ private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); /** * 获取 ClassScanner * * @return the class scanner */
public static ClassScanner getClassScanner() {
lwfwind/smart-api-framework
src/com/qa/framework/InstanceFactory.java
// Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // // Path: src/com/qa/framework/classfinder/ClassScanner.java // public interface ClassScanner { // // /** // * 获取指定包名中的所有类 // * // * @param packageName the package name // * @return the class list // */ // List<Class<?>> getClassList(String packageName); // // /** // * 获取指定包名中指定注解的相关类 // * // * @param packageName the package name // * @param annotationClass the annotation class // * @return the class list by annotation // */ // List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass); // // /** // * 获取指定包名中指定父类或接口的相关类 // * // * @param packageName the package name // * @param superClass the super class // * @return the class list by super // */ // List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass); // } // // Path: src/com/qa/framework/classfinder/impl/DefaultClassScanner.java // public class DefaultClassScanner implements ClassScanner { // // @Override // public List<Class<?>> getClassList(String packageName) { // return new ClassTemplate(packageName) { // @Override // public boolean checkAddClass(Class<?> cls) { // String className = cls.getName(); // String pkgName = className.substring(0, className.lastIndexOf(".")); // return pkgName.startsWith(packageName); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass) { // return new AnnotationClassTemplate(packageName, annotationClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return cls.isAnnotationPresent(annotationClass); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass) { // return new SupperClassTemplate(packageName, superClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return superClass.isAssignableFrom(cls) && !superClass.equals(cls); // } // }.getClassList(); // } // }
import com.library.common.ReflectHelper; import com.qa.framework.bean.Global; import com.qa.framework.classfinder.ClassScanner; import com.qa.framework.classfinder.impl.DefaultClassScanner; import java.util.Map; import java.util.concurrent.ConcurrentHashMap;
package com.qa.framework; /** * 实例工厂 */ public class InstanceFactory { /** * 用于缓存对应的实例 */ private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); /** * 获取 ClassScanner * * @return the class scanner */ public static ClassScanner getClassScanner() {
// Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // // Path: src/com/qa/framework/classfinder/ClassScanner.java // public interface ClassScanner { // // /** // * 获取指定包名中的所有类 // * // * @param packageName the package name // * @return the class list // */ // List<Class<?>> getClassList(String packageName); // // /** // * 获取指定包名中指定注解的相关类 // * // * @param packageName the package name // * @param annotationClass the annotation class // * @return the class list by annotation // */ // List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass); // // /** // * 获取指定包名中指定父类或接口的相关类 // * // * @param packageName the package name // * @param superClass the super class // * @return the class list by super // */ // List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass); // } // // Path: src/com/qa/framework/classfinder/impl/DefaultClassScanner.java // public class DefaultClassScanner implements ClassScanner { // // @Override // public List<Class<?>> getClassList(String packageName) { // return new ClassTemplate(packageName) { // @Override // public boolean checkAddClass(Class<?> cls) { // String className = cls.getName(); // String pkgName = className.substring(0, className.lastIndexOf(".")); // return pkgName.startsWith(packageName); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass) { // return new AnnotationClassTemplate(packageName, annotationClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return cls.isAnnotationPresent(annotationClass); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass) { // return new SupperClassTemplate(packageName, superClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return superClass.isAssignableFrom(cls) && !superClass.equals(cls); // } // }.getClassList(); // } // } // Path: src/com/qa/framework/InstanceFactory.java import com.library.common.ReflectHelper; import com.qa.framework.bean.Global; import com.qa.framework.classfinder.ClassScanner; import com.qa.framework.classfinder.impl.DefaultClassScanner; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; package com.qa.framework; /** * 实例工厂 */ public class InstanceFactory { /** * 用于缓存对应的实例 */ private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); /** * 获取 ClassScanner * * @return the class scanner */ public static ClassScanner getClassScanner() {
return getInstance("class_scanner", DefaultClassScanner.class);
lwfwind/smart-api-framework
src/com/qa/framework/InstanceFactory.java
// Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // // Path: src/com/qa/framework/classfinder/ClassScanner.java // public interface ClassScanner { // // /** // * 获取指定包名中的所有类 // * // * @param packageName the package name // * @return the class list // */ // List<Class<?>> getClassList(String packageName); // // /** // * 获取指定包名中指定注解的相关类 // * // * @param packageName the package name // * @param annotationClass the annotation class // * @return the class list by annotation // */ // List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass); // // /** // * 获取指定包名中指定父类或接口的相关类 // * // * @param packageName the package name // * @param superClass the super class // * @return the class list by super // */ // List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass); // } // // Path: src/com/qa/framework/classfinder/impl/DefaultClassScanner.java // public class DefaultClassScanner implements ClassScanner { // // @Override // public List<Class<?>> getClassList(String packageName) { // return new ClassTemplate(packageName) { // @Override // public boolean checkAddClass(Class<?> cls) { // String className = cls.getName(); // String pkgName = className.substring(0, className.lastIndexOf(".")); // return pkgName.startsWith(packageName); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass) { // return new AnnotationClassTemplate(packageName, annotationClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return cls.isAnnotationPresent(annotationClass); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass) { // return new SupperClassTemplate(packageName, superClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return superClass.isAssignableFrom(cls) && !superClass.equals(cls); // } // }.getClassList(); // } // }
import com.library.common.ReflectHelper; import com.qa.framework.bean.Global; import com.qa.framework.classfinder.ClassScanner; import com.qa.framework.classfinder.impl.DefaultClassScanner; import java.util.Map; import java.util.concurrent.ConcurrentHashMap;
package com.qa.framework; /** * 实例工厂 */ public class InstanceFactory { /** * 用于缓存对应的实例 */ private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); /** * 获取 ClassScanner * * @return the class scanner */ public static ClassScanner getClassScanner() { return getInstance("class_scanner", DefaultClassScanner.class); }
// Path: src/com/qa/framework/bean/Global.java // public class Global { // private List<Sql> sqlList; // private List<Function> functionList; // // private Before before; // private After after; // // public Global() { // } // // public Before getBefore() { // return before; // } // // public void setBefore(Before before) { // this.before = before; // } // // public After getAfter() { // return after; // } // // public void setAfter(After after) { // this.after = after; // } // // public List<Sql> getSqlList() { // return sqlList; // } // // public List<Function> getFunctionList() { // return functionList; // } // // // public void addSql(Sql sql) { // if (sqlList == null) { // sqlList = new ArrayList<Sql>(); // } // sqlList.add(sql); // } // // public void addFunction(Function function) { // if (functionList == null) { // functionList = new ArrayList<Function>(); // } // functionList.add(function); // } // // } // // Path: src/com/qa/framework/classfinder/ClassScanner.java // public interface ClassScanner { // // /** // * 获取指定包名中的所有类 // * // * @param packageName the package name // * @return the class list // */ // List<Class<?>> getClassList(String packageName); // // /** // * 获取指定包名中指定注解的相关类 // * // * @param packageName the package name // * @param annotationClass the annotation class // * @return the class list by annotation // */ // List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass); // // /** // * 获取指定包名中指定父类或接口的相关类 // * // * @param packageName the package name // * @param superClass the super class // * @return the class list by super // */ // List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass); // } // // Path: src/com/qa/framework/classfinder/impl/DefaultClassScanner.java // public class DefaultClassScanner implements ClassScanner { // // @Override // public List<Class<?>> getClassList(String packageName) { // return new ClassTemplate(packageName) { // @Override // public boolean checkAddClass(Class<?> cls) { // String className = cls.getName(); // String pkgName = className.substring(0, className.lastIndexOf(".")); // return pkgName.startsWith(packageName); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListByAnnotation(String packageName, Class<? extends Annotation> annotationClass) { // return new AnnotationClassTemplate(packageName, annotationClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return cls.isAnnotationPresent(annotationClass); // } // }.getClassList(); // } // // @Override // public List<Class<?>> getClassListBySuper(String packageName, Class<?> superClass) { // return new SupperClassTemplate(packageName, superClass) { // @Override // public boolean checkAddClass(Class<?> cls) { // return superClass.isAssignableFrom(cls) && !superClass.equals(cls); // } // }.getClassList(); // } // } // Path: src/com/qa/framework/InstanceFactory.java import com.library.common.ReflectHelper; import com.qa.framework.bean.Global; import com.qa.framework.classfinder.ClassScanner; import com.qa.framework.classfinder.impl.DefaultClassScanner; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; package com.qa.framework; /** * 实例工厂 */ public class InstanceFactory { /** * 用于缓存对应的实例 */ private static final Map<String, Object> cache = new ConcurrentHashMap<String, Object>(); /** * 获取 ClassScanner * * @return the class scanner */ public static ClassScanner getClassScanner() { return getInstance("class_scanner", DefaultClassScanner.class); }
public static Global getGlobal() {
lwfwind/smart-api-framework
src/com/qa/framework/library/database/XmlToBean.java
// Path: src/com/qa/framework/config/ProjectEnvironment.java // public class ProjectEnvironment { // // private static final String SRC = "src"; // // private static String basePath; // // static { // basePath = System.getProperty("user.dir") + File.separator; // } // // /** // * Resource path string. // * // * @return the string // */ // public static String resourcePath() { // return basePath + "res" + File.separator; // } // // /** // * Src path string. // * // * @return the string // */ // public static String srcPath() { // return basePath + SRC + File.separator; // } // // /** // * Lib path string. // * // * @return the string // */ // public static String libPath() { // return resourcePath() + "lib" + File.separator; // } // // /** // * Config path string. // * // * @return the string // */ // public static String configPath() { // return basePath + "config" + File.separator; // // } // // /** // * Db config file string. // * // * @return the string // */ // public static String dbConfigFile() { // return configPath() + "DBConfig.xml"; // } // // /** // * Admin config file string. // * // * @return the string // */ // public static String adminConfigFile() { // return configPath() + "AdminConfig.xml"; // } // // /** // * Data files path string. // * // * @return the string // */ // public static String dataFilesPath() { // return basePath + "dataFiles" + File.separator; // } // // /** // * Test suites path string. // * // * @return the string // */ // public static String testSuitesPath() { // return dataFilesPath() + "testSuites" + File.separator; // } // // /** // * Test cases path string. // * // * @return the string // */ // public static String testCasesPath() { // return dataFilesPath() + "testCases" + File.separator; // } // // /** // * Reports path string. // * // * @return the string // */ // public static String reportsPath() { // return basePath + "reports" + File.separator; // } // // /** // * Ui objects map path string. // * // * @return the string // */ // public static String uiObjectsMapPath() { // return basePath + "uimaps" + File.separator; // } // // /** // * Reports link to file path string. // * // * @return the string // */ // public static String reportsLinkToFilePath() { // return reportsPath() + "_filepath" + File.separator; // } // // /** // * Reports screenshot path string. // * // * @return the string // */ // public static String reportsScreenshotPath() { // return reportsPath() + "_Screenshots" + File.separator; // } // // /** // * Auto it x file string. // * // * @return the string // */ // public static String autoItXFile() { // return libPath() + "AutoItX3" + File.separator + "AutoItX3.dll"; // } // // /** // * Auto it x 64 file string. // * // * @return the string // */ // public static String autoItX64File() { // return libPath() + "AutoItX3" + File.separator + "AutoItX3_x64.dll"; // } // // /** // * Pw matrix path string. // * // * @return the string // */ // public static String pwMatrixPath() { // return libPath() + "PWMatrix"; // } // // /** // * Ftp config file string. // * // * @return the string // */ // public static String ftpConfigFile() { // return configPath() + "FTPConfig.xml"; // } // // /** // * Gets chrome driver location. // * // * @return the chrome driver location // */ // public static String getChromeDriverLocation() { // Properties sysProp = System.getProperties(); // String os = sysProp.getProperty("os.name"); // if (os.startsWith("Win")) { // return resourcePath() + "chromedriver" + File.separator + "chromedriver_for_win.exe"; // } else { // return resourcePath() + "chromedriver" + File.separator + "chromedriver"; // } // } // // /** // * Gets ie driver location. // * // * @return the ie driver location // */ // public static String getIEDriverLocation() { // Properties sysProp = System.getProperties(); // String arch = sysProp.getProperty("os.arch"); // if (arch.contains("64")) { // return resourcePath() + "IEDriver" + File.separator + "64" + File.separator + "IEDriverServer.exe"; // } // return resourcePath() + "IEDriver" + File.separator + "32" + File.separator + "IEDriverServer.exe"; // } // // }
import com.library.common.XmlHelper; import com.qa.framework.config.ProjectEnvironment; import org.dom4j.Element; import java.util.ArrayList; import java.util.Iterator; import java.util.List;
package com.qa.framework.library.database; /** * The type Xml to bean. */ public class XmlToBean { /** * Read list. * * @return the list */ public static List<BaseConnBean> read() {
// Path: src/com/qa/framework/config/ProjectEnvironment.java // public class ProjectEnvironment { // // private static final String SRC = "src"; // // private static String basePath; // // static { // basePath = System.getProperty("user.dir") + File.separator; // } // // /** // * Resource path string. // * // * @return the string // */ // public static String resourcePath() { // return basePath + "res" + File.separator; // } // // /** // * Src path string. // * // * @return the string // */ // public static String srcPath() { // return basePath + SRC + File.separator; // } // // /** // * Lib path string. // * // * @return the string // */ // public static String libPath() { // return resourcePath() + "lib" + File.separator; // } // // /** // * Config path string. // * // * @return the string // */ // public static String configPath() { // return basePath + "config" + File.separator; // // } // // /** // * Db config file string. // * // * @return the string // */ // public static String dbConfigFile() { // return configPath() + "DBConfig.xml"; // } // // /** // * Admin config file string. // * // * @return the string // */ // public static String adminConfigFile() { // return configPath() + "AdminConfig.xml"; // } // // /** // * Data files path string. // * // * @return the string // */ // public static String dataFilesPath() { // return basePath + "dataFiles" + File.separator; // } // // /** // * Test suites path string. // * // * @return the string // */ // public static String testSuitesPath() { // return dataFilesPath() + "testSuites" + File.separator; // } // // /** // * Test cases path string. // * // * @return the string // */ // public static String testCasesPath() { // return dataFilesPath() + "testCases" + File.separator; // } // // /** // * Reports path string. // * // * @return the string // */ // public static String reportsPath() { // return basePath + "reports" + File.separator; // } // // /** // * Ui objects map path string. // * // * @return the string // */ // public static String uiObjectsMapPath() { // return basePath + "uimaps" + File.separator; // } // // /** // * Reports link to file path string. // * // * @return the string // */ // public static String reportsLinkToFilePath() { // return reportsPath() + "_filepath" + File.separator; // } // // /** // * Reports screenshot path string. // * // * @return the string // */ // public static String reportsScreenshotPath() { // return reportsPath() + "_Screenshots" + File.separator; // } // // /** // * Auto it x file string. // * // * @return the string // */ // public static String autoItXFile() { // return libPath() + "AutoItX3" + File.separator + "AutoItX3.dll"; // } // // /** // * Auto it x 64 file string. // * // * @return the string // */ // public static String autoItX64File() { // return libPath() + "AutoItX3" + File.separator + "AutoItX3_x64.dll"; // } // // /** // * Pw matrix path string. // * // * @return the string // */ // public static String pwMatrixPath() { // return libPath() + "PWMatrix"; // } // // /** // * Ftp config file string. // * // * @return the string // */ // public static String ftpConfigFile() { // return configPath() + "FTPConfig.xml"; // } // // /** // * Gets chrome driver location. // * // * @return the chrome driver location // */ // public static String getChromeDriverLocation() { // Properties sysProp = System.getProperties(); // String os = sysProp.getProperty("os.name"); // if (os.startsWith("Win")) { // return resourcePath() + "chromedriver" + File.separator + "chromedriver_for_win.exe"; // } else { // return resourcePath() + "chromedriver" + File.separator + "chromedriver"; // } // } // // /** // * Gets ie driver location. // * // * @return the ie driver location // */ // public static String getIEDriverLocation() { // Properties sysProp = System.getProperties(); // String arch = sysProp.getProperty("os.arch"); // if (arch.contains("64")) { // return resourcePath() + "IEDriver" + File.separator + "64" + File.separator + "IEDriverServer.exe"; // } // return resourcePath() + "IEDriver" + File.separator + "32" + File.separator + "IEDriverServer.exe"; // } // // } // Path: src/com/qa/framework/library/database/XmlToBean.java import com.library.common.XmlHelper; import com.qa.framework.config.ProjectEnvironment; import org.dom4j.Element; import java.util.ArrayList; import java.util.Iterator; import java.util.List; package com.qa.framework.library.database; /** * The type Xml to bean. */ public class XmlToBean { /** * Read list. * * @return the list */ public static List<BaseConnBean> read() {
return read(ProjectEnvironment.dbConfigFile());
RCasatta/EternityWallAndroid
src/main/java/it/eternitywall/eternitywall/fragments/AccountFragment.java
// Path: src/main/java/it/eternitywall/eternitywall/Preferences.java // public class Preferences { // // public static final String NODES = "nodes"; // public static final String PASSPHRASE = "passphrase"; // public static final String PIN = "pin"; // public static final String EMAIL = "email"; // public static final String CHK_ONE = "ckone"; // public static final String CHK_TWO = "cktwo"; // public static final String DONATION = "donation"; // public static final String TO_NOTIFY = "tonotify"; // public static final String ALIAS_NAME = "aliasname"; // }
import android.app.Activity; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import it.eternitywall.eternitywall.Preferences; import it.eternitywall.eternitywall.R;
AccountFragment fragment = new AccountFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } public AccountFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v= inflater.inflate(R.layout.fragment_account, container, false); FragmentTransaction transaction = getFragmentManager() .beginTransaction(); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
// Path: src/main/java/it/eternitywall/eternitywall/Preferences.java // public class Preferences { // // public static final String NODES = "nodes"; // public static final String PASSPHRASE = "passphrase"; // public static final String PIN = "pin"; // public static final String EMAIL = "email"; // public static final String CHK_ONE = "ckone"; // public static final String CHK_TWO = "cktwo"; // public static final String DONATION = "donation"; // public static final String TO_NOTIFY = "tonotify"; // public static final String ALIAS_NAME = "aliasname"; // } // Path: src/main/java/it/eternitywall/eternitywall/fragments/AccountFragment.java import android.app.Activity; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import it.eternitywall.eternitywall.Preferences; import it.eternitywall.eternitywall.R; AccountFragment fragment = new AccountFragment(); Bundle args = new Bundle(); args.putString(ARG_PARAM1, param1); args.putString(ARG_PARAM2, param2); fragment.setArguments(args); return fragment; } public AccountFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v= inflater.inflate(R.layout.fragment_account, container, false); FragmentTransaction transaction = getFragmentManager() .beginTransaction(); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
String passphrase=sharedPref.getString(Preferences.PASSPHRASE,null);
RCasatta/EternityWallAndroid
src/main/java/it/eternitywall/eternitywall/dialogfragments/PersonalNodeDialogFragment.java
// Path: src/main/java/it/eternitywall/eternitywall/Preferences.java // public class Preferences { // // public static final String NODES = "nodes"; // public static final String PASSPHRASE = "passphrase"; // public static final String PIN = "pin"; // public static final String EMAIL = "email"; // public static final String CHK_ONE = "ckone"; // public static final String CHK_TWO = "cktwo"; // public static final String DONATION = "donation"; // public static final String TO_NOTIFY = "tonotify"; // public static final String ALIAS_NAME = "aliasname"; // }
import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.google.common.net.InetAddresses; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import it.eternitywall.eternitywall.Preferences; import it.eternitywall.eternitywall.R;
package it.eternitywall.eternitywall.dialogfragments; /** * Created by Riccardo Casatta @RCasatta on 18/12/15. */ public class PersonalNodeDialogFragment extends DialogFragment { private static final String TAG = "PersonalNodeDlg"; private EditText txtNode; private ListView lstNodes; private TextView advise; private View view; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { view = getActivity().getLayoutInflater().inflate(R.layout.dlg_personalnodes, null); lstNodes = (ListView) view.findViewById(R.id.lstNodes); txtNode = (EditText) view.findViewById(R.id.txtNode); advise = (TextView) view.findViewById(R.id.advise); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
// Path: src/main/java/it/eternitywall/eternitywall/Preferences.java // public class Preferences { // // public static final String NODES = "nodes"; // public static final String PASSPHRASE = "passphrase"; // public static final String PIN = "pin"; // public static final String EMAIL = "email"; // public static final String CHK_ONE = "ckone"; // public static final String CHK_TWO = "cktwo"; // public static final String DONATION = "donation"; // public static final String TO_NOTIFY = "tonotify"; // public static final String ALIAS_NAME = "aliasname"; // } // Path: src/main/java/it/eternitywall/eternitywall/dialogfragments/PersonalNodeDialogFragment.java import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.google.common.net.InetAddresses; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import it.eternitywall.eternitywall.Preferences; import it.eternitywall.eternitywall.R; package it.eternitywall.eternitywall.dialogfragments; /** * Created by Riccardo Casatta @RCasatta on 18/12/15. */ public class PersonalNodeDialogFragment extends DialogFragment { private static final String TAG = "PersonalNodeDlg"; private EditText txtNode; private ListView lstNodes; private TextView advise; private View view; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { view = getActivity().getLayoutInflater().inflate(R.layout.dlg_personalnodes, null); lstNodes = (ListView) view.findViewById(R.id.lstNodes); txtNode = (EditText) view.findViewById(R.id.txtNode); advise = (TextView) view.findViewById(R.id.advise); final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
final Set<String> stringSet = sharedPref.getStringSet(Preferences.NODES, new HashSet<String>());
RCasatta/EternityWallAndroid
src/main/java/it/eternitywall/eternitywall/wallet/WalletObserver.java
// Path: src/main/java/it/eternitywall/eternitywall/IdenticonGenerator.java // public class IdenticonGenerator { // private static final String TAG = "IdenticonGenerator"; // // public static int SIDE = 7; // public static int MUL = 9; // // public static Bitmap generate(String string, int side, int mul) { // return generate(Sha256Hash.create(string.getBytes()).getBytes(), side, mul); // } // // public static Bitmap generate(String string) { // return generate(Sha256Hash.create(string.getBytes()).getBytes(), SIDE, MUL); // } // // public static Bitmap generate(byte[] hash, int side, int mul) { // final Bitmap identicon = Bitmap.createBitmap(side*mul, side*mul, Bitmap.Config.ARGB_8888); // // //get byte values as unsigned ints // int r = hash[0] & 255; // int g = hash[1] & 255; // int b = hash[2] & 255; // Log.i(TAG, "r " + r + " g " + g + " b " + b); // // int background = Color.argb(0,255,255,255); // int foreground = Color.argb(255,r,g,b); // // for(int x=0 ; x < side ; x++) { // int i = x < side/2 ? x : side - 1 - x; // final int i1 = x * mul; // for(int y=0 ; y < side; y++) { // final int i2 = y * mul; // int currentColor; // // if((hash[i] >> y & 1) == 1) // currentColor=foreground; // else // currentColor=background; // // for (int a = 0; a < mul; a++) { // final int x1 = i1 + a; // for (int c = 0; c < mul; c++) { // final int y1 = i2 + c; // identicon.setPixel(x1, y1, currentColor); // } // } // } // } // // return identicon; // } // // }
import android.graphics.Bitmap; import android.util.Log; import org.bitcoinj.core.Address; import java.util.Observable; import java.util.Observer; import it.eternitywall.eternitywall.IdenticonGenerator;
package it.eternitywall.eternitywall.wallet; /** * Created by Riccardo Casatta @RCasatta on 30/11/15. */ public class WalletObserver implements Observer { private static final String TAG = "WalletObserver"; private EWWalletService ewWalletService; private WalletObservable.State was; public WalletObserver(EWWalletService ewWalletService) { this.ewWalletService = ewWalletService; was= WalletObservable.State.STARTED; } @Override public void update(Observable observable, Object data) { final WalletObservable walletObservable= (WalletObservable) observable; Log.i(TAG, android.os.Process.myTid() + " TID :" + walletObservable+ " was: " + was); final String alias = walletObservable.getAlias(); if (alias != null && !alias.equals(walletObservable.getCurrentIdenticonSource())) { Log.i(TAG, "CreateOrRefreshingIdenticon");
// Path: src/main/java/it/eternitywall/eternitywall/IdenticonGenerator.java // public class IdenticonGenerator { // private static final String TAG = "IdenticonGenerator"; // // public static int SIDE = 7; // public static int MUL = 9; // // public static Bitmap generate(String string, int side, int mul) { // return generate(Sha256Hash.create(string.getBytes()).getBytes(), side, mul); // } // // public static Bitmap generate(String string) { // return generate(Sha256Hash.create(string.getBytes()).getBytes(), SIDE, MUL); // } // // public static Bitmap generate(byte[] hash, int side, int mul) { // final Bitmap identicon = Bitmap.createBitmap(side*mul, side*mul, Bitmap.Config.ARGB_8888); // // //get byte values as unsigned ints // int r = hash[0] & 255; // int g = hash[1] & 255; // int b = hash[2] & 255; // Log.i(TAG, "r " + r + " g " + g + " b " + b); // // int background = Color.argb(0,255,255,255); // int foreground = Color.argb(255,r,g,b); // // for(int x=0 ; x < side ; x++) { // int i = x < side/2 ? x : side - 1 - x; // final int i1 = x * mul; // for(int y=0 ; y < side; y++) { // final int i2 = y * mul; // int currentColor; // // if((hash[i] >> y & 1) == 1) // currentColor=foreground; // else // currentColor=background; // // for (int a = 0; a < mul; a++) { // final int x1 = i1 + a; // for (int c = 0; c < mul; c++) { // final int y1 = i2 + c; // identicon.setPixel(x1, y1, currentColor); // } // } // } // } // // return identicon; // } // // } // Path: src/main/java/it/eternitywall/eternitywall/wallet/WalletObserver.java import android.graphics.Bitmap; import android.util.Log; import org.bitcoinj.core.Address; import java.util.Observable; import java.util.Observer; import it.eternitywall.eternitywall.IdenticonGenerator; package it.eternitywall.eternitywall.wallet; /** * Created by Riccardo Casatta @RCasatta on 30/11/15. */ public class WalletObserver implements Observer { private static final String TAG = "WalletObserver"; private EWWalletService ewWalletService; private WalletObservable.State was; public WalletObserver(EWWalletService ewWalletService) { this.ewWalletService = ewWalletService; was= WalletObservable.State.STARTED; } @Override public void update(Observable observable, Object data) { final WalletObservable walletObservable= (WalletObservable) observable; Log.i(TAG, android.os.Process.myTid() + " TID :" + walletObservable+ " was: " + was); final String alias = walletObservable.getAlias(); if (alias != null && !alias.equals(walletObservable.getCurrentIdenticonSource())) { Log.i(TAG, "CreateOrRefreshingIdenticon");
Bitmap identicon = IdenticonGenerator.generate(alias);
RCasatta/EternityWallAndroid
src/main/java/it/eternitywall/eternitywall/dialogfragments/PinAlertDialogFragment.java
// Path: src/main/java/it/eternitywall/eternitywall/Preferences.java // public class Preferences { // // public static final String NODES = "nodes"; // public static final String PASSPHRASE = "passphrase"; // public static final String PIN = "pin"; // public static final String EMAIL = "email"; // public static final String CHK_ONE = "ckone"; // public static final String CHK_TWO = "cktwo"; // public static final String DONATION = "donation"; // public static final String TO_NOTIFY = "tonotify"; // public static final String ALIAS_NAME = "aliasname"; // }
import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.google.common.net.InetAddresses; import com.google.common.util.concurrent.Runnables; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import it.eternitywall.eternitywall.Preferences; import it.eternitywall.eternitywall.R;
package it.eternitywall.eternitywall.dialogfragments; /** * Created by Riccardo Casatta @RCasatta on 18/12/15. */ public class PinAlertDialogFragment extends DialogFragment { public static PinAlertDialogFragment newInstance(int title) { PinAlertDialogFragment frag = new PinAlertDialogFragment(); Bundle args = new Bundle(); args.putInt("title", title); frag.setArguments(args); return frag; } //View view; Runnable mRunnable=null; View view=null; public void setPositive(Runnable runnable){ this.mRunnable=runnable; } public String getPin(){ if(view==null) return null; else return ((EditText)view.findViewById(R.id.editText)).getText().toString(); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { int title = getArguments().getInt("title"); view = getActivity().getLayoutInflater().inflate(R.layout.dlg_pin, null); return new AlertDialog.Builder(getActivity()) // Set Dialog Title .setTitle(title) // Set Dialog Message : custom view .setView(view) // Positive button .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do something final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
// Path: src/main/java/it/eternitywall/eternitywall/Preferences.java // public class Preferences { // // public static final String NODES = "nodes"; // public static final String PASSPHRASE = "passphrase"; // public static final String PIN = "pin"; // public static final String EMAIL = "email"; // public static final String CHK_ONE = "ckone"; // public static final String CHK_TWO = "cktwo"; // public static final String DONATION = "donation"; // public static final String TO_NOTIFY = "tonotify"; // public static final String ALIAS_NAME = "aliasname"; // } // Path: src/main/java/it/eternitywall/eternitywall/dialogfragments/PinAlertDialogFragment.java import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.google.common.net.InetAddresses; import com.google.common.util.concurrent.Runnables; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import it.eternitywall.eternitywall.Preferences; import it.eternitywall.eternitywall.R; package it.eternitywall.eternitywall.dialogfragments; /** * Created by Riccardo Casatta @RCasatta on 18/12/15. */ public class PinAlertDialogFragment extends DialogFragment { public static PinAlertDialogFragment newInstance(int title) { PinAlertDialogFragment frag = new PinAlertDialogFragment(); Bundle args = new Bundle(); args.putInt("title", title); frag.setArguments(args); return frag; } //View view; Runnable mRunnable=null; View view=null; public void setPositive(Runnable runnable){ this.mRunnable=runnable; } public String getPin(){ if(view==null) return null; else return ((EditText)view.findViewById(R.id.editText)).getText().toString(); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { int title = getArguments().getInt("title"); view = getActivity().getLayoutInflater().inflate(R.layout.dlg_pin, null); return new AlertDialog.Builder(getActivity()) // Set Dialog Title .setTitle(title) // Set Dialog Message : custom view .setView(view) // Positive button .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do something final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
String pin = sharedPref.getString(Preferences.PIN,null);
necr0potenc3/uosl
slclient/src/org/solhost/folko/uosl/slclient/models/TextureAtlas.java
// Path: slclient/src/org/solhost/folko/uosl/slclient/views/util/Texture.java // public class Texture { // private final int id, width, height; // private final boolean useMipMapping = false; // // public Texture(BufferedImage image) { // this.width = image.getWidth(); // this.height = image.getHeight(); // ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4); // if(image.getType() != BufferedImage.TYPE_INT_ARGB) { // throw new RuntimeException("Can only open INT_ARGB images"); // } // // for(int y = 0; y < height; y++) { // for(int x = 0; x < width; x++) { // int argb = image.getRGB(x, y); // buffer.put((byte) ((argb >> 16) & 0xFF)); // buffer.put((byte) ((argb >> 8) & 0xFF)); // buffer.put((byte) ((argb >> 0) & 0xFF)); // buffer.put((byte) ((argb >> 24) & 0xFF)); // } // } // buffer.rewind(); // // id = glGenTextures(); // glBindTexture(GL_TEXTURE_2D, id); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // if(useMipMapping) { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); // glGenerateMipmap(GL_TEXTURE_2D); // } else { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_BASE_LEVEL, 0); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); // } // } // // public void bind(int textureUnit) { // glActiveTexture(GL_TEXTURE0 + textureUnit); // glBindTexture(GL_TEXTURE_2D, id); // } // // public void dispose() { // glDeleteTextures(id); // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public int getTextureId() { // return id; // } // }
import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.imageio.ImageIO; import org.solhost.folko.uosl.slclient.views.util.Texture;
package org.solhost.folko.uosl.slclient.models; public class TextureAtlas { private static final int DISTANCE = 5; private final int maxWidth, maxHeight; private final Map<Integer, Rectangle> idMap; private int curX, curY, curLineHeight; private BufferedImage atlasImage;
// Path: slclient/src/org/solhost/folko/uosl/slclient/views/util/Texture.java // public class Texture { // private final int id, width, height; // private final boolean useMipMapping = false; // // public Texture(BufferedImage image) { // this.width = image.getWidth(); // this.height = image.getHeight(); // ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4); // if(image.getType() != BufferedImage.TYPE_INT_ARGB) { // throw new RuntimeException("Can only open INT_ARGB images"); // } // // for(int y = 0; y < height; y++) { // for(int x = 0; x < width; x++) { // int argb = image.getRGB(x, y); // buffer.put((byte) ((argb >> 16) & 0xFF)); // buffer.put((byte) ((argb >> 8) & 0xFF)); // buffer.put((byte) ((argb >> 0) & 0xFF)); // buffer.put((byte) ((argb >> 24) & 0xFF)); // } // } // buffer.rewind(); // // id = glGenTextures(); // glBindTexture(GL_TEXTURE_2D, id); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // if(useMipMapping) { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); // glGenerateMipmap(GL_TEXTURE_2D); // } else { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_BASE_LEVEL, 0); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); // } // } // // public void bind(int textureUnit) { // glActiveTexture(GL_TEXTURE0 + textureUnit); // glBindTexture(GL_TEXTURE_2D, id); // } // // public void dispose() { // glDeleteTextures(id); // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public int getTextureId() { // return id; // } // } // Path: slclient/src/org/solhost/folko/uosl/slclient/models/TextureAtlas.java import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.imageio.ImageIO; import org.solhost.folko.uosl.slclient.views.util.Texture; package org.solhost.folko.uosl.slclient.models; public class TextureAtlas { private static final int DISTANCE = 5; private final int maxWidth, maxHeight; private final Map<Integer, Rectangle> idMap; private int curX, curY, curLineHeight; private BufferedImage atlasImage;
private Texture texture;
necr0potenc3/uosl
jphex/src/org/solhost/folko/uosl/jphex/types/Mobile.java
// Path: slclient/src/org/solhost/folko/uosl/common/RandUtil.java // public class RandUtil { // // [minimum, maximum) // public static int random(int min, int max) { // Random rng = ThreadLocalRandom.current(); // return rng.nextInt(max - min) + min; // } // // public static <T extends Object> T randomElement(T[] array) { // if(array.length == 0) return null; // int index = random(0, array.length); // return array[index]; // } // // public static boolean tryChance(double chance) { // Random rng = ThreadLocalRandom.current(); // return rng.nextDouble() <= chance; // } // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // }
import org.solhost.folko.uosl.libuosl.network.SendableMobile; import org.solhost.folko.uosl.libuosl.types.Attribute; import org.solhost.folko.uosl.libuosl.types.Direction; import org.solhost.folko.uosl.libuosl.types.Items; import org.solhost.folko.uosl.libuosl.types.Mobiles; import java.io.IOException; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Logger; import org.solhost.folko.uosl.common.RandUtil; import org.solhost.folko.uosl.libuosl.data.SLTiles; import org.solhost.folko.uosl.libuosl.data.SLTiles.StaticTile;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.jphex.types; public abstract class Mobile extends SLObject implements SendableMobile { private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger("jphex.mobile"); protected transient Set<Item> equipped; protected transient Map<Mobile, Integer> damagers; protected boolean refreshRunning;
// Path: slclient/src/org/solhost/folko/uosl/common/RandUtil.java // public class RandUtil { // // [minimum, maximum) // public static int random(int min, int max) { // Random rng = ThreadLocalRandom.current(); // return rng.nextInt(max - min) + min; // } // // public static <T extends Object> T randomElement(T[] array) { // if(array.length == 0) return null; // int index = random(0, array.length); // return array[index]; // } // // public static boolean tryChance(double chance) { // Random rng = ThreadLocalRandom.current(); // return rng.nextDouble() <= chance; // } // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // } // Path: jphex/src/org/solhost/folko/uosl/jphex/types/Mobile.java import org.solhost.folko.uosl.libuosl.network.SendableMobile; import org.solhost.folko.uosl.libuosl.types.Attribute; import org.solhost.folko.uosl.libuosl.types.Direction; import org.solhost.folko.uosl.libuosl.types.Items; import org.solhost.folko.uosl.libuosl.types.Mobiles; import java.io.IOException; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Logger; import org.solhost.folko.uosl.common.RandUtil; import org.solhost.folko.uosl.libuosl.data.SLTiles; import org.solhost.folko.uosl.libuosl.data.SLTiles.StaticTile; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.jphex.types; public abstract class Mobile extends SLObject implements SendableMobile { private static final long serialVersionUID = 1L; private static final Logger log = Logger.getLogger("jphex.mobile"); protected transient Set<Item> equipped; protected transient Map<Mobile, Integer> damagers; protected boolean refreshRunning;
protected Direction facing;
necr0potenc3/uosl
jphex/src/org/solhost/folko/uosl/jphex/types/Mobile.java
// Path: slclient/src/org/solhost/folko/uosl/common/RandUtil.java // public class RandUtil { // // [minimum, maximum) // public static int random(int min, int max) { // Random rng = ThreadLocalRandom.current(); // return rng.nextInt(max - min) + min; // } // // public static <T extends Object> T randomElement(T[] array) { // if(array.length == 0) return null; // int index = random(0, array.length); // return array[index]; // } // // public static boolean tryChance(double chance) { // Random rng = ThreadLocalRandom.current(); // return rng.nextDouble() <= chance; // } // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // }
import org.solhost.folko.uosl.libuosl.network.SendableMobile; import org.solhost.folko.uosl.libuosl.types.Attribute; import org.solhost.folko.uosl.libuosl.types.Direction; import org.solhost.folko.uosl.libuosl.types.Items; import org.solhost.folko.uosl.libuosl.types.Mobiles; import java.io.IOException; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Logger; import org.solhost.folko.uosl.common.RandUtil; import org.solhost.folko.uosl.libuosl.data.SLTiles; import org.solhost.folko.uosl.libuosl.data.SLTiles.StaticTile;
} return null; } public void unequipItem(Item item) { item.setParent(null); equipped.remove(item); } // changes won't be reflected public Set<Item> getEquippedItems() { Set<Item> res = new HashSet<Item>(); for(Item equip : equipped) { res.add(equip); } return res; } public boolean checkSkill(Attribute skill, long minRequired, long maxUntilNoGain) { long value = getAttribute(skill); if(value < minRequired) { log.fine(String.format("%s: Checking %s for %d -> failure due to no chance", getName(), skill, minRequired)); return false; } else if(value >= maxUntilNoGain) { log.fine(String.format("%s: Checking %s for %d -> success due to high chance", getName(), skill, minRequired)); return true; } // Interesting range where gains happen double successChance = (double) (value - minRequired) / (double) (maxUntilNoGain - minRequired);
// Path: slclient/src/org/solhost/folko/uosl/common/RandUtil.java // public class RandUtil { // // [minimum, maximum) // public static int random(int min, int max) { // Random rng = ThreadLocalRandom.current(); // return rng.nextInt(max - min) + min; // } // // public static <T extends Object> T randomElement(T[] array) { // if(array.length == 0) return null; // int index = random(0, array.length); // return array[index]; // } // // public static boolean tryChance(double chance) { // Random rng = ThreadLocalRandom.current(); // return rng.nextDouble() <= chance; // } // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // } // Path: jphex/src/org/solhost/folko/uosl/jphex/types/Mobile.java import org.solhost.folko.uosl.libuosl.network.SendableMobile; import org.solhost.folko.uosl.libuosl.types.Attribute; import org.solhost.folko.uosl.libuosl.types.Direction; import org.solhost.folko.uosl.libuosl.types.Items; import org.solhost.folko.uosl.libuosl.types.Mobiles; import java.io.IOException; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Logger; import org.solhost.folko.uosl.common.RandUtil; import org.solhost.folko.uosl.libuosl.data.SLTiles; import org.solhost.folko.uosl.libuosl.data.SLTiles.StaticTile; } return null; } public void unequipItem(Item item) { item.setParent(null); equipped.remove(item); } // changes won't be reflected public Set<Item> getEquippedItems() { Set<Item> res = new HashSet<Item>(); for(Item equip : equipped) { res.add(equip); } return res; } public boolean checkSkill(Attribute skill, long minRequired, long maxUntilNoGain) { long value = getAttribute(skill); if(value < minRequired) { log.fine(String.format("%s: Checking %s for %d -> failure due to no chance", getName(), skill, minRequired)); return false; } else if(value >= maxUntilNoGain) { log.fine(String.format("%s: Checking %s for %d -> success due to high chance", getName(), skill, minRequired)); return true; } // Interesting range where gains happen double successChance = (double) (value - minRequired) / (double) (maxUntilNoGain - minRequired);
boolean success = RandUtil.tryChance(successChance);
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/MoveRequestPacket.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // }
import java.nio.ByteBuffer; import org.solhost.folko.uosl.libuosl.types.Direction;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class MoveRequestPacket extends SLPacket { public static final short ID = 0x04;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/MoveRequestPacket.java import java.nio.ByteBuffer; import org.solhost.folko.uosl.libuosl.types.Direction; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class MoveRequestPacket extends SLPacket { public static final short ID = 0x04;
private Direction direction;
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/data/SLStatics.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // }
import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; import org.solhost.folko.uosl.libuosl.types.Point2D; import org.solhost.folko.uosl.libuosl.types.Point3D;
} cached = true; } private List<SLStatic> getStatics(int cell) { if(cached) { return staticCells[cell]; } synchronized(this) { int idxOffset = cell * 12; staticsIndex.seek(idxOffset); long staticsOffset = staticsIndex.readUDWord(); int staticsCount = (int) staticsIndex.readUDWord() / 11; List<SLStatic> res = new ArrayList<SLStatic>(staticsCount); if(staticsOffset == -1) { // no statics return res; } staticsFile.seek((int) staticsOffset); for(int i = 0; i < staticsCount; i++) { long serial = staticsFile.readUDWord(); int staticID = staticsFile.readUWord(); byte xOffset = staticsFile.readSByte(); byte yOffset = staticsFile.readSByte(); byte z = staticsFile.readSByte(); int hue = staticsFile.readUWord();
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLStatics.java import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; import org.solhost.folko.uosl.libuosl.types.Point2D; import org.solhost.folko.uosl.libuosl.types.Point3D; } cached = true; } private List<SLStatic> getStatics(int cell) { if(cached) { return staticCells[cell]; } synchronized(this) { int idxOffset = cell * 12; staticsIndex.seek(idxOffset); long staticsOffset = staticsIndex.readUDWord(); int staticsCount = (int) staticsIndex.readUDWord() / 11; List<SLStatic> res = new ArrayList<SLStatic>(staticsCount); if(staticsOffset == -1) { // no statics return res; } staticsFile.seek((int) staticsOffset); for(int i = 0; i < staticsCount; i++) { long serial = staticsFile.readUDWord(); int staticID = staticsFile.readUWord(); byte xOffset = staticsFile.readSByte(); byte yOffset = staticsFile.readSByte(); byte z = staticsFile.readSByte(); int hue = staticsFile.readUWord();
Point3D location = new Point3D(Point2D.fromCell(cell, xOffset, yOffset), z);
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/DropPacket.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // }
import java.nio.ByteBuffer; import org.solhost.folko.uosl.libuosl.types.Point3D;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class DropPacket extends SLPacket { public static final short ID = 0x0F; public static final long CONTAINER_GROUND = 0xFFFFFFFF; private long serial, container;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/DropPacket.java import java.nio.ByteBuffer; import org.solhost.folko.uosl.libuosl.types.Point3D; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class DropPacket extends SLPacket { public static final short ID = 0x0F; public static final long CONTAINER_GROUND = 0xFFFFFFFF; private long serial, container;
private Point3D location;
necr0potenc3/uosl
viewsl/src/org/solhost/folko/uosl/viewsl/SoundView.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SLSound { // private final SLDataFile sound, soundIdx; // // public SLSound(String soundPath, String soundIdxPath) throws IOException { // this.sound = new SLDataFile(soundPath, false); // this.soundIdx = new SLDataFile(soundIdxPath, true); // } // // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // } // // public int getNumEntries() { // return soundIdx.getLength() / 12; // } // // public synchronized SoundEntry getEntry(int index) { // int idxOffset = index * 12; // soundIdx.seek(idxOffset); // // SoundEntry entry = new SoundEntry(); // // long offset = soundIdx.readUDWord(); // long length = soundIdx.readUDWord(); // if(offset == -1 || length == -1) { // return null; // } // // entry.id = index; // entry.unknown = soundIdx.readUDWord(); // sound.seek((int) offset); // entry.fileName = sound.readString(16); // sound.skip(24); // entry.pcmData = sound.readRaw((int) (length - 16 - 24)); // // return entry; // } // // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // }
import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.DataLine; import javax.swing.AbstractListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.solhost.folko.uosl.libuosl.data.SLSound; import org.solhost.folko.uosl.libuosl.data.SLSound.SoundEntry;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.viewsl; public class SoundView extends JPanel { private static final long serialVersionUID = 534689691557745487L;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SLSound { // private final SLDataFile sound, soundIdx; // // public SLSound(String soundPath, String soundIdxPath) throws IOException { // this.sound = new SLDataFile(soundPath, false); // this.soundIdx = new SLDataFile(soundIdxPath, true); // } // // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // } // // public int getNumEntries() { // return soundIdx.getLength() / 12; // } // // public synchronized SoundEntry getEntry(int index) { // int idxOffset = index * 12; // soundIdx.seek(idxOffset); // // SoundEntry entry = new SoundEntry(); // // long offset = soundIdx.readUDWord(); // long length = soundIdx.readUDWord(); // if(offset == -1 || length == -1) { // return null; // } // // entry.id = index; // entry.unknown = soundIdx.readUDWord(); // sound.seek((int) offset); // entry.fileName = sound.readString(16); // sound.skip(24); // entry.pcmData = sound.readRaw((int) (length - 16 - 24)); // // return entry; // } // // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // } // Path: viewsl/src/org/solhost/folko/uosl/viewsl/SoundView.java import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.DataLine; import javax.swing.AbstractListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.solhost.folko.uosl.libuosl.data.SLSound; import org.solhost.folko.uosl.libuosl.data.SLSound.SoundEntry; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.viewsl; public class SoundView extends JPanel { private static final long serialVersionUID = 534689691557745487L;
private SLSound sound;
necr0potenc3/uosl
viewsl/src/org/solhost/folko/uosl/viewsl/SoundView.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SLSound { // private final SLDataFile sound, soundIdx; // // public SLSound(String soundPath, String soundIdxPath) throws IOException { // this.sound = new SLDataFile(soundPath, false); // this.soundIdx = new SLDataFile(soundIdxPath, true); // } // // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // } // // public int getNumEntries() { // return soundIdx.getLength() / 12; // } // // public synchronized SoundEntry getEntry(int index) { // int idxOffset = index * 12; // soundIdx.seek(idxOffset); // // SoundEntry entry = new SoundEntry(); // // long offset = soundIdx.readUDWord(); // long length = soundIdx.readUDWord(); // if(offset == -1 || length == -1) { // return null; // } // // entry.id = index; // entry.unknown = soundIdx.readUDWord(); // sound.seek((int) offset); // entry.fileName = sound.readString(16); // sound.skip(24); // entry.pcmData = sound.readRaw((int) (length - 16 - 24)); // // return entry; // } // // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // }
import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.DataLine; import javax.swing.AbstractListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.solhost.folko.uosl.libuosl.data.SLSound; import org.solhost.folko.uosl.libuosl.data.SLSound.SoundEntry;
JPanel soundInfoPanel = new JPanel(); soundInfoPanel.setLayout(new FlowLayout()); soundLabel = new JLabel("0x0000"); soundButton = new JButton("Play"); soundInfoPanel.add(soundLabel); soundInfoPanel.add(soundButton); soundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { playSound(soundList.getSelectedIndex()); } }); soundList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); soundList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()) return; selectSound(soundList.getSelectedIndex()); } }); soundList.setSelectedIndex(0); add(new JScrollPane(soundList), BorderLayout.WEST); add(soundInfoPanel, BorderLayout.CENTER); } private void selectSound(int listIndex) { int id = soundList.getModel().getElementAt(listIndex).id;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SLSound { // private final SLDataFile sound, soundIdx; // // public SLSound(String soundPath, String soundIdxPath) throws IOException { // this.sound = new SLDataFile(soundPath, false); // this.soundIdx = new SLDataFile(soundIdxPath, true); // } // // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // } // // public int getNumEntries() { // return soundIdx.getLength() / 12; // } // // public synchronized SoundEntry getEntry(int index) { // int idxOffset = index * 12; // soundIdx.seek(idxOffset); // // SoundEntry entry = new SoundEntry(); // // long offset = soundIdx.readUDWord(); // long length = soundIdx.readUDWord(); // if(offset == -1 || length == -1) { // return null; // } // // entry.id = index; // entry.unknown = soundIdx.readUDWord(); // sound.seek((int) offset); // entry.fileName = sound.readString(16); // sound.skip(24); // entry.pcmData = sound.readRaw((int) (length - 16 - 24)); // // return entry; // } // // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLSound.java // public class SoundEntry { // public long id; // public long unknown; // public String fileName; // public byte[] pcmData; // } // Path: viewsl/src/org/solhost/folko/uosl/viewsl/SoundView.java import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.DataLine; import javax.swing.AbstractListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.solhost.folko.uosl.libuosl.data.SLSound; import org.solhost.folko.uosl.libuosl.data.SLSound.SoundEntry; JPanel soundInfoPanel = new JPanel(); soundInfoPanel.setLayout(new FlowLayout()); soundLabel = new JLabel("0x0000"); soundButton = new JButton("Play"); soundInfoPanel.add(soundLabel); soundInfoPanel.add(soundButton); soundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { playSound(soundList.getSelectedIndex()); } }); soundList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); soundList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if(e.getValueIsAdjusting()) return; selectSound(soundList.getSelectedIndex()); } }); soundList.setSelectedIndex(0); add(new JScrollPane(soundList), BorderLayout.WEST); add(soundInfoPanel, BorderLayout.CENTER); } private void selectSound(int listIndex) { int id = soundList.getModel().getElementAt(listIndex).id;
SoundEntry entry = sound.getEntry(id);
necr0potenc3/uosl
slclient/src/org/solhost/folko/uosl/slclient/models/SLMobile.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // }
import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.solhost.folko.uosl.libuosl.network.SendableMobile; import org.solhost.folko.uosl.libuosl.types.Attribute; import org.solhost.folko.uosl.libuosl.types.Direction;
package org.solhost.folko.uosl.slclient.models; public class SLMobile extends SLObject implements SendableMobile { private final Map<Attribute, Long> attributes; private final Map<Short, SLItem> equipment;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // } // Path: slclient/src/org/solhost/folko/uosl/slclient/models/SLMobile.java import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.solhost.folko.uosl.libuosl.network.SendableMobile; import org.solhost.folko.uosl.libuosl.types.Attribute; import org.solhost.folko.uosl.libuosl.types.Direction; package org.solhost.folko.uosl.slclient.models; public class SLMobile extends SLObject implements SendableMobile { private final Map<Attribute, Long> attributes; private final Map<Short, SLItem> equipment;
private Direction facing;
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/OpenGumpPacket.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java // public interface SendableObject { // public long getSerial(); // public String getName(); // public int getGraphic(); // public int getHue(); // public Point3D getLocation(); // }
import java.nio.ByteBuffer; import org.solhost.folko.uosl.libuosl.network.SendableObject;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class OpenGumpPacket extends SLPacket { public static final short ID = 0x42; private long serial; private int gumpID; private OpenGumpPacket() { } public static OpenGumpPacket read(ByteBuffer b, int len) { OpenGumpPacket res = new OpenGumpPacket(); res.serial = readUDWord(b); res.gumpID = readUWord(b); return res; }
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java // public interface SendableObject { // public long getSerial(); // public String getName(); // public int getGraphic(); // public int getHue(); // public Point3D getLocation(); // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/OpenGumpPacket.java import java.nio.ByteBuffer; import org.solhost.folko.uosl.libuosl.network.SendableObject; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class OpenGumpPacket extends SLPacket { public static final short ID = 0x42; private long serial; private int gumpID; private OpenGumpPacket() { } public static OpenGumpPacket read(ByteBuffer b, int len) { OpenGumpPacket res = new OpenGumpPacket(); res.serial = readUDWord(b); res.gumpID = readUWord(b); return res; }
public OpenGumpPacket(SendableObject obj, int gumpID) {
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/LightLevelPacket.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java // public interface SendableObject { // public long getSerial(); // public String getName(); // public int getGraphic(); // public int getHue(); // public Point3D getLocation(); // }
import org.solhost.folko.uosl.libuosl.network.SendableObject;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class LightLevelPacket extends SLPacket { public static final short ID = 0xA8;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java // public interface SendableObject { // public long getSerial(); // public String getName(); // public int getGraphic(); // public int getHue(); // public Point3D getLocation(); // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/LightLevelPacket.java import org.solhost.folko.uosl.libuosl.network.SendableObject; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class LightLevelPacket extends SLPacket { public static final short ID = 0xA8;
public LightLevelPacket(SendableObject obj, byte level) {
necr0potenc3/uosl
viewsl/src/org/solhost/folko/uosl/viewsl/AnimationView.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // }
import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedList; import java.util.List; import javax.swing.AbstractListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.Timer; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.solhost.folko.uosl.libuosl.data.SLArt; import org.solhost.folko.uosl.libuosl.data.SLArt.ArtEntry; import org.solhost.folko.uosl.libuosl.data.SLArt.MobileAnimation; import org.solhost.folko.uosl.libuosl.types.Direction;
add(artInfoPanel, BorderLayout.CENTER); } private void selectArt(int idx) { if(timer != null) { animationButton.setText("Start"); timer.stop(); timer = null; } ArtListEntry entry = artList.getModel().getElementAt(idx); currentAnimation = art.getAnimationEntry(entry.id, entry.dir, entry.fighting); currentFrame = 0; artLabel.setText(String.format("0x%04X: %d frames", currentAnimation.id, currentAnimation.frames.size())); updateFrame(); } private void updateFrame() { int staticID = currentAnimation.frames.get(currentFrame); ArtEntry entry = art.getStaticArt(staticID, false); entry.mirror(currentAnimation.needMirror); imagePanel.setImage(entry.image); currentFrame++; if(currentFrame == currentAnimation.frames.size()) { currentFrame = 0; } } } class ArtListEntry { public int id;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java // public enum Direction { // NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST; // // public static Direction parse(short b) { // switch(b) { // case 0: return NORTH; // case 1: return NORTH_EAST; // case 2: return EAST; // case 3: return SOUTH_EAST; // case 4: return SOUTH; // case 5: return SOUTH_WEST; // case 6: return WEST; // case 7: return NORTH_WEST; // default: return NORTH; // } // } // // public short toByte() { // switch(this) { // case NORTH: return 0; // case NORTH_EAST: return 1; // case EAST: return 2; // case SOUTH_EAST: return 3; // case SOUTH: return 4; // case SOUTH_WEST: return 5; // case WEST: return 6; // case NORTH_WEST: return 7; // default: return 0; // } // } // // // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise // public static Direction fromAngle(double angle) { // double r = 360 / 16.0; // if(angle < 45 - r) { // return Direction.NORTH_WEST; // } else if(angle < 90 - r) { // return Direction.NORTH; // } else if(angle < 135 - r) { // return Direction.NORTH_EAST; // } else if(angle < 180 - r) { // return Direction.EAST; // } else if(angle < 225 - r) { // return Direction.SOUTH_EAST; // } else if(angle < 270 - r) { // return Direction.SOUTH; // } else if(angle < 315 - r) { // return Direction.SOUTH_WEST; // } else if(angle < 360 - r) { // return Direction.WEST; // } else { // return Direction.NORTH_WEST; // } // } // // public int getFrameIndex() { // switch(this) { // case NORTH: return 3; // case NORTH_EAST: return 2; // case EAST: return 1; // case SOUTH_EAST: return 0; // case SOUTH: return 1; // case SOUTH_WEST: return 2; // case WEST: return 3; // case NORTH_WEST: return 4; // default: return -1; // } // } // // public Direction getOpposingDirection() { // switch(this) { // case NORTH: return SOUTH; // case NORTH_EAST: return SOUTH_WEST; // case EAST: return WEST; // case SOUTH_EAST: return NORTH_WEST; // case SOUTH: return NORTH; // case SOUTH_WEST: return NORTH_EAST; // case WEST: return EAST; // case NORTH_WEST: return SOUTH_EAST; // default: return SOUTH; // } // } // } // Path: viewsl/src/org/solhost/folko/uosl/viewsl/AnimationView.java import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedList; import java.util.List; import javax.swing.AbstractListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.Timer; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.solhost.folko.uosl.libuosl.data.SLArt; import org.solhost.folko.uosl.libuosl.data.SLArt.ArtEntry; import org.solhost.folko.uosl.libuosl.data.SLArt.MobileAnimation; import org.solhost.folko.uosl.libuosl.types.Direction; add(artInfoPanel, BorderLayout.CENTER); } private void selectArt(int idx) { if(timer != null) { animationButton.setText("Start"); timer.stop(); timer = null; } ArtListEntry entry = artList.getModel().getElementAt(idx); currentAnimation = art.getAnimationEntry(entry.id, entry.dir, entry.fighting); currentFrame = 0; artLabel.setText(String.format("0x%04X: %d frames", currentAnimation.id, currentAnimation.frames.size())); updateFrame(); } private void updateFrame() { int staticID = currentAnimation.frames.get(currentFrame); ArtEntry entry = art.getStaticArt(staticID, false); entry.mirror(currentAnimation.needMirror); imagePanel.setImage(entry.image); currentFrame++; if(currentFrame == currentAnimation.frames.size()) { currentFrame = 0; } } } class ArtListEntry { public int id;
public Direction dir;
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // }
import org.solhost.folko.uosl.libuosl.types.Point3D;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network; public interface SendableObject { public long getSerial(); public String getName(); public int getGraphic(); public int getHue();
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java import org.solhost.folko.uosl.libuosl.types.Point3D; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network; public interface SendableObject { public long getSerial(); public String getName(); public int getGraphic(); public int getHue();
public Point3D getLocation();
necr0potenc3/uosl
slclient/src/org/solhost/folko/uosl/slclient/views/gumps/BaseGump.java
// Path: slclient/src/org/solhost/folko/uosl/slclient/models/SLObject.java // public abstract class SLObject implements SendableObject { // protected long serial; // protected Point3D location; // protected int graphic, hue; // protected String name; // protected boolean registered; // // public SLObject(long serial, int graphic) { // setSerial(serial); // setGraphic(graphic); // registered = false; // } // // public void register() { // registered = true; // } // // public void unregister() { // registered = false; // } // // public long getSerial() { // return serial; // } // // public void setSerial(long serial) { // this.serial = serial; // } // // public Point3D getLocation() { // return location; // } // // public void setLocation(Point3D location) { // this.location = location; // } // // public int getGraphic() { // return graphic; // } // // public void setGraphic(int graphic) { // this.graphic = graphic; // } // // public int getHue() { // return hue; // } // // public void setHue(int hue) { // this.hue = hue; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: slclient/src/org/solhost/folko/uosl/slclient/views/util/Texture.java // public class Texture { // private final int id, width, height; // private final boolean useMipMapping = false; // // public Texture(BufferedImage image) { // this.width = image.getWidth(); // this.height = image.getHeight(); // ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4); // if(image.getType() != BufferedImage.TYPE_INT_ARGB) { // throw new RuntimeException("Can only open INT_ARGB images"); // } // // for(int y = 0; y < height; y++) { // for(int x = 0; x < width; x++) { // int argb = image.getRGB(x, y); // buffer.put((byte) ((argb >> 16) & 0xFF)); // buffer.put((byte) ((argb >> 8) & 0xFF)); // buffer.put((byte) ((argb >> 0) & 0xFF)); // buffer.put((byte) ((argb >> 24) & 0xFF)); // } // } // buffer.rewind(); // // id = glGenTextures(); // glBindTexture(GL_TEXTURE_2D, id); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // if(useMipMapping) { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); // glGenerateMipmap(GL_TEXTURE_2D); // } else { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_BASE_LEVEL, 0); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); // } // } // // public void bind(int textureUnit) { // glActiveTexture(GL_TEXTURE0 + textureUnit); // glBindTexture(GL_TEXTURE_2D, id); // } // // public void dispose() { // glDeleteTextures(id); // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public int getTextureId() { // return id; // } // }
import java.awt.Point; import java.util.List; import org.solhost.folko.uosl.slclient.models.SLObject; import org.solhost.folko.uosl.slclient.views.util.Texture;
package org.solhost.folko.uosl.slclient.views.gumps; public abstract class BaseGump { private final int gumpID;
// Path: slclient/src/org/solhost/folko/uosl/slclient/models/SLObject.java // public abstract class SLObject implements SendableObject { // protected long serial; // protected Point3D location; // protected int graphic, hue; // protected String name; // protected boolean registered; // // public SLObject(long serial, int graphic) { // setSerial(serial); // setGraphic(graphic); // registered = false; // } // // public void register() { // registered = true; // } // // public void unregister() { // registered = false; // } // // public long getSerial() { // return serial; // } // // public void setSerial(long serial) { // this.serial = serial; // } // // public Point3D getLocation() { // return location; // } // // public void setLocation(Point3D location) { // this.location = location; // } // // public int getGraphic() { // return graphic; // } // // public void setGraphic(int graphic) { // this.graphic = graphic; // } // // public int getHue() { // return hue; // } // // public void setHue(int hue) { // this.hue = hue; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: slclient/src/org/solhost/folko/uosl/slclient/views/util/Texture.java // public class Texture { // private final int id, width, height; // private final boolean useMipMapping = false; // // public Texture(BufferedImage image) { // this.width = image.getWidth(); // this.height = image.getHeight(); // ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4); // if(image.getType() != BufferedImage.TYPE_INT_ARGB) { // throw new RuntimeException("Can only open INT_ARGB images"); // } // // for(int y = 0; y < height; y++) { // for(int x = 0; x < width; x++) { // int argb = image.getRGB(x, y); // buffer.put((byte) ((argb >> 16) & 0xFF)); // buffer.put((byte) ((argb >> 8) & 0xFF)); // buffer.put((byte) ((argb >> 0) & 0xFF)); // buffer.put((byte) ((argb >> 24) & 0xFF)); // } // } // buffer.rewind(); // // id = glGenTextures(); // glBindTexture(GL_TEXTURE_2D, id); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // if(useMipMapping) { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); // glGenerateMipmap(GL_TEXTURE_2D); // } else { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_BASE_LEVEL, 0); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); // } // } // // public void bind(int textureUnit) { // glActiveTexture(GL_TEXTURE0 + textureUnit); // glBindTexture(GL_TEXTURE_2D, id); // } // // public void dispose() { // glDeleteTextures(id); // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public int getTextureId() { // return id; // } // } // Path: slclient/src/org/solhost/folko/uosl/slclient/views/gumps/BaseGump.java import java.awt.Point; import java.util.List; import org.solhost.folko.uosl.slclient.models.SLObject; import org.solhost.folko.uosl.slclient.views.util.Texture; package org.solhost.folko.uosl.slclient.views.gumps; public abstract class BaseGump { private final int gumpID;
private final SLObject object;
necr0potenc3/uosl
slclient/src/org/solhost/folko/uosl/slclient/views/gumps/BaseGump.java
// Path: slclient/src/org/solhost/folko/uosl/slclient/models/SLObject.java // public abstract class SLObject implements SendableObject { // protected long serial; // protected Point3D location; // protected int graphic, hue; // protected String name; // protected boolean registered; // // public SLObject(long serial, int graphic) { // setSerial(serial); // setGraphic(graphic); // registered = false; // } // // public void register() { // registered = true; // } // // public void unregister() { // registered = false; // } // // public long getSerial() { // return serial; // } // // public void setSerial(long serial) { // this.serial = serial; // } // // public Point3D getLocation() { // return location; // } // // public void setLocation(Point3D location) { // this.location = location; // } // // public int getGraphic() { // return graphic; // } // // public void setGraphic(int graphic) { // this.graphic = graphic; // } // // public int getHue() { // return hue; // } // // public void setHue(int hue) { // this.hue = hue; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: slclient/src/org/solhost/folko/uosl/slclient/views/util/Texture.java // public class Texture { // private final int id, width, height; // private final boolean useMipMapping = false; // // public Texture(BufferedImage image) { // this.width = image.getWidth(); // this.height = image.getHeight(); // ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4); // if(image.getType() != BufferedImage.TYPE_INT_ARGB) { // throw new RuntimeException("Can only open INT_ARGB images"); // } // // for(int y = 0; y < height; y++) { // for(int x = 0; x < width; x++) { // int argb = image.getRGB(x, y); // buffer.put((byte) ((argb >> 16) & 0xFF)); // buffer.put((byte) ((argb >> 8) & 0xFF)); // buffer.put((byte) ((argb >> 0) & 0xFF)); // buffer.put((byte) ((argb >> 24) & 0xFF)); // } // } // buffer.rewind(); // // id = glGenTextures(); // glBindTexture(GL_TEXTURE_2D, id); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // if(useMipMapping) { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); // glGenerateMipmap(GL_TEXTURE_2D); // } else { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_BASE_LEVEL, 0); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); // } // } // // public void bind(int textureUnit) { // glActiveTexture(GL_TEXTURE0 + textureUnit); // glBindTexture(GL_TEXTURE_2D, id); // } // // public void dispose() { // glDeleteTextures(id); // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public int getTextureId() { // return id; // } // }
import java.awt.Point; import java.util.List; import org.solhost.folko.uosl.slclient.models.SLObject; import org.solhost.folko.uosl.slclient.views.util.Texture;
package org.solhost.folko.uosl.slclient.views.gumps; public abstract class BaseGump { private final int gumpID; private final SLObject object; private boolean wantsClose; private Point position; public class GumpPart { public BaseGump owner;
// Path: slclient/src/org/solhost/folko/uosl/slclient/models/SLObject.java // public abstract class SLObject implements SendableObject { // protected long serial; // protected Point3D location; // protected int graphic, hue; // protected String name; // protected boolean registered; // // public SLObject(long serial, int graphic) { // setSerial(serial); // setGraphic(graphic); // registered = false; // } // // public void register() { // registered = true; // } // // public void unregister() { // registered = false; // } // // public long getSerial() { // return serial; // } // // public void setSerial(long serial) { // this.serial = serial; // } // // public Point3D getLocation() { // return location; // } // // public void setLocation(Point3D location) { // this.location = location; // } // // public int getGraphic() { // return graphic; // } // // public void setGraphic(int graphic) { // this.graphic = graphic; // } // // public int getHue() { // return hue; // } // // public void setHue(int hue) { // this.hue = hue; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: slclient/src/org/solhost/folko/uosl/slclient/views/util/Texture.java // public class Texture { // private final int id, width, height; // private final boolean useMipMapping = false; // // public Texture(BufferedImage image) { // this.width = image.getWidth(); // this.height = image.getHeight(); // ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4); // if(image.getType() != BufferedImage.TYPE_INT_ARGB) { // throw new RuntimeException("Can only open INT_ARGB images"); // } // // for(int y = 0; y < height; y++) { // for(int x = 0; x < width; x++) { // int argb = image.getRGB(x, y); // buffer.put((byte) ((argb >> 16) & 0xFF)); // buffer.put((byte) ((argb >> 8) & 0xFF)); // buffer.put((byte) ((argb >> 0) & 0xFF)); // buffer.put((byte) ((argb >> 24) & 0xFF)); // } // } // buffer.rewind(); // // id = glGenTextures(); // glBindTexture(GL_TEXTURE_2D, id); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); // if(useMipMapping) { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); // glGenerateMipmap(GL_TEXTURE_2D); // } else { // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_BASE_LEVEL, 0); // glTexParameteri(GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); // } // } // // public void bind(int textureUnit) { // glActiveTexture(GL_TEXTURE0 + textureUnit); // glBindTexture(GL_TEXTURE_2D, id); // } // // public void dispose() { // glDeleteTextures(id); // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public int getTextureId() { // return id; // } // } // Path: slclient/src/org/solhost/folko/uosl/slclient/views/gumps/BaseGump.java import java.awt.Point; import java.util.List; import org.solhost.folko.uosl.slclient.models.SLObject; import org.solhost.folko.uosl.slclient.views.util.Texture; package org.solhost.folko.uosl.slclient.views.gumps; public abstract class BaseGump { private final int gumpID; private final SLObject object; private boolean wantsClose; private Point position; public class GumpPart { public BaseGump owner;
public Texture texture;
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/data/SLStatic.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // }
import org.solhost.folko.uosl.libuosl.types.Point3D;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.data; public class SLStatic { private final long serial; private final int staticID; private final int hue;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/data/SLStatic.java import org.solhost.folko.uosl.libuosl.types.Point3D; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.data; public class SLStatic { private final long serial; private final int staticID; private final int hue;
private final Point3D location;
necr0potenc3/uosl
libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/FullItemsContainerPacket.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // }
import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import org.solhost.folko.uosl.libuosl.network.ItemStub; import org.solhost.folko.uosl.libuosl.network.SendableItem; import org.solhost.folko.uosl.libuosl.types.Point3D;
/******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class FullItemsContainerPacket extends SLPacket { public static final short ID = 0x71; private List<SendableItem> items; private long containerSerial; private FullItemsContainerPacket() { items = new ArrayList<SendableItem>(); } public static FullItemsContainerPacket read(ByteBuffer b, int len) { FullItemsContainerPacket res = new FullItemsContainerPacket(); int itemCount = readUWord(b); for(int i = 0; i < itemCount; i++) { ItemStub itm = new ItemStub(); itm.setSerial(readUDWord(b)); itm.setGraphic(readUWord(b)); readUByte(b); itm.setAmount(readUWord(b)); int x = readUWord(b); int y = readUWord(b);
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // } // Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/packets/FullItemsContainerPacket.java import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import org.solhost.folko.uosl.libuosl.network.ItemStub; import org.solhost.folko.uosl.libuosl.network.SendableItem; import org.solhost.folko.uosl.libuosl.types.Point3D; /******************************************************************************* * Copyright (c) 2013 Folke Will <folke.will@gmail.com> * * This file is part of JPhex. * * JPhex 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 * (at your option) any later version. * * JPhex 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, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package org.solhost.folko.uosl.libuosl.network.packets; public class FullItemsContainerPacket extends SLPacket { public static final short ID = 0x71; private List<SendableItem> items; private long containerSerial; private FullItemsContainerPacket() { items = new ArrayList<SendableItem>(); } public static FullItemsContainerPacket read(ByteBuffer b, int len) { FullItemsContainerPacket res = new FullItemsContainerPacket(); int itemCount = readUWord(b); for(int i = 0; i < itemCount; i++) { ItemStub itm = new ItemStub(); itm.setSerial(readUDWord(b)); itm.setGraphic(readUWord(b)); readUByte(b); itm.setAmount(readUWord(b)); int x = readUWord(b); int y = readUWord(b);
itm.setLocation(new Point3D(x, y));
necr0potenc3/uosl
slclient/src/org/solhost/folko/uosl/slclient/models/SLObject.java
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java // public interface SendableObject { // public long getSerial(); // public String getName(); // public int getGraphic(); // public int getHue(); // public Point3D getLocation(); // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // }
import org.solhost.folko.uosl.libuosl.network.SendableObject; import org.solhost.folko.uosl.libuosl.types.Point3D;
package org.solhost.folko.uosl.slclient.models; public abstract class SLObject implements SendableObject { protected long serial;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/network/SendableObject.java // public interface SendableObject { // public long getSerial(); // public String getName(); // public int getGraphic(); // public int getHue(); // public Point3D getLocation(); // } // // Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Point3D.java // public class Point3D extends Point2D { // private static final long serialVersionUID = 1L; // public static final int MIN_ELEVATION = -128; // public static final int MAX_ELEVATION = 127; // protected final int z; // // public Point3D(int x, int y) { // super(x, y); // this.z = 0; // } // // public Point3D(int x, int y, int z) { // super(x, y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public Point3D(Point2D d2, int z) { // super(d2.x, d2.y); // if(z < MIN_ELEVATION || z > MAX_ELEVATION) { // throw new IllegalArgumentException("invalid z coordinate: " + z); // } // this.z = z; // } // // public int getZ() { // return z; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = super.hashCode(); // result = prime * result + z; // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (!super.equals(obj)) // return false; // if (!(obj instanceof Point3D)) // return false; // Point3D other = (Point3D) obj; // if (z != other.z) // return false; // return true; // } // // @Override // public String toString() { // return String.format("<Point3D: x = %d, y = %d, z = %d>", x, y, z); // } // } // Path: slclient/src/org/solhost/folko/uosl/slclient/models/SLObject.java import org.solhost.folko.uosl.libuosl.network.SendableObject; import org.solhost.folko.uosl.libuosl.types.Point3D; package org.solhost.folko.uosl.slclient.models; public abstract class SLObject implements SendableObject { protected long serial;
protected Point3D location;
wseemann/ServeStream
app/src/main/java/net/sourceforge/servestream/activity/SetAlarmActivity.java
// Path: app/src/main/java/net/sourceforge/servestream/preference/UserPreferences.java // public class UserPreferences implements // SharedPreferences.OnSharedPreferenceChangeListener { // private static UserPreferences instance; // private final Context mContext; // // // Preferences // private int mTheme; // // private UserPreferences(Context context) { // mContext = context; // loadPreferences(); // } // // /** // * Sets up the UserPreferences class. // * // * @throws IllegalArgumentException // * if context is null // * */ // public static void createInstance(Context context) { // if (context == null) // throw new IllegalArgumentException("Context must not be null"); // instance = new UserPreferences(context); // // PreferenceManager.getDefaultSharedPreferences(context) // .registerOnSharedPreferenceChangeListener(instance); // // } // // private void loadPreferences() { // SharedPreferences sp = PreferenceManager // .getDefaultSharedPreferences(mContext); // //mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "0")); // mTheme = R.style.Theme_ServeStream_DarkActionBar;; // } // // private int readThemeValue(String valueFromPrefs) { // switch (Integer.parseInt(valueFromPrefs)) { // case 0: // return R.style.Theme_ServeStream_DarkActionBar; // case 1: // return R.style.Theme_ServeStream_Dark; // default: // return R.style.Theme_ServeStream_DarkActionBar; // } // } // // private static void instanceAvailable() { // if (instance == null) { // throw new IllegalStateException( // "UserPreferences was used before being set up"); // } // } // // public static int getTheme() { // instanceAvailable(); // return instance.mTheme; // } // // @Override // public void onSharedPreferenceChanged(SharedPreferences sp, String key) { // if (key.equals(PreferenceConstants.THEME)) { // mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "")); // } // } // }
import net.sourceforge.servestream.fragment.SetAlarmFragment; import net.sourceforge.servestream.preference.UserPreferences; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBar; import android.view.MenuItem;
/* * ServeStream: A HTTP stream browser/player for Android * Copyright 2014 William Seemann * * 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 net.sourceforge.servestream.activity; public class SetAlarmActivity extends ActionBarActivity { @Override public void onCreate(Bundle savedInstanceState) {
// Path: app/src/main/java/net/sourceforge/servestream/preference/UserPreferences.java // public class UserPreferences implements // SharedPreferences.OnSharedPreferenceChangeListener { // private static UserPreferences instance; // private final Context mContext; // // // Preferences // private int mTheme; // // private UserPreferences(Context context) { // mContext = context; // loadPreferences(); // } // // /** // * Sets up the UserPreferences class. // * // * @throws IllegalArgumentException // * if context is null // * */ // public static void createInstance(Context context) { // if (context == null) // throw new IllegalArgumentException("Context must not be null"); // instance = new UserPreferences(context); // // PreferenceManager.getDefaultSharedPreferences(context) // .registerOnSharedPreferenceChangeListener(instance); // // } // // private void loadPreferences() { // SharedPreferences sp = PreferenceManager // .getDefaultSharedPreferences(mContext); // //mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "0")); // mTheme = R.style.Theme_ServeStream_DarkActionBar;; // } // // private int readThemeValue(String valueFromPrefs) { // switch (Integer.parseInt(valueFromPrefs)) { // case 0: // return R.style.Theme_ServeStream_DarkActionBar; // case 1: // return R.style.Theme_ServeStream_Dark; // default: // return R.style.Theme_ServeStream_DarkActionBar; // } // } // // private static void instanceAvailable() { // if (instance == null) { // throw new IllegalStateException( // "UserPreferences was used before being set up"); // } // } // // public static int getTheme() { // instanceAvailable(); // return instance.mTheme; // } // // @Override // public void onSharedPreferenceChanged(SharedPreferences sp, String key) { // if (key.equals(PreferenceConstants.THEME)) { // mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "")); // } // } // } // Path: app/src/main/java/net/sourceforge/servestream/activity/SetAlarmActivity.java import net.sourceforge.servestream.fragment.SetAlarmFragment; import net.sourceforge.servestream.preference.UserPreferences; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBar; import android.view.MenuItem; /* * ServeStream: A HTTP stream browser/player for Android * Copyright 2014 William Seemann * * 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 net.sourceforge.servestream.activity; public class SetAlarmActivity extends ActionBarActivity { @Override public void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());
wseemann/ServeStream
app/src/main/java/net/sourceforge/servestream/activity/AddUrlActivity.java
// Path: app/src/main/java/net/sourceforge/servestream/preference/UserPreferences.java // public class UserPreferences implements // SharedPreferences.OnSharedPreferenceChangeListener { // private static UserPreferences instance; // private final Context mContext; // // // Preferences // private int mTheme; // // private UserPreferences(Context context) { // mContext = context; // loadPreferences(); // } // // /** // * Sets up the UserPreferences class. // * // * @throws IllegalArgumentException // * if context is null // * */ // public static void createInstance(Context context) { // if (context == null) // throw new IllegalArgumentException("Context must not be null"); // instance = new UserPreferences(context); // // PreferenceManager.getDefaultSharedPreferences(context) // .registerOnSharedPreferenceChangeListener(instance); // // } // // private void loadPreferences() { // SharedPreferences sp = PreferenceManager // .getDefaultSharedPreferences(mContext); // //mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "0")); // mTheme = R.style.Theme_ServeStream_DarkActionBar;; // } // // private int readThemeValue(String valueFromPrefs) { // switch (Integer.parseInt(valueFromPrefs)) { // case 0: // return R.style.Theme_ServeStream_DarkActionBar; // case 1: // return R.style.Theme_ServeStream_Dark; // default: // return R.style.Theme_ServeStream_DarkActionBar; // } // } // // private static void instanceAvailable() { // if (instance == null) { // throw new IllegalStateException( // "UserPreferences was used before being set up"); // } // } // // public static int getTheme() { // instanceAvailable(); // return instance.mTheme; // } // // @Override // public void onSharedPreferenceChanged(SharedPreferences sp, String key) { // if (key.equals(PreferenceConstants.THEME)) { // mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "")); // } // } // }
import net.sourceforge.servestream.fragment.AddUrlFragment; import net.sourceforge.servestream.preference.UserPreferences; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.view.MenuItem;
/* * ServeStream: A HTTP stream browser/player for Android * Copyright 2014 William Seemann * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this.getActivity() 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 net.sourceforge.servestream.activity; public class AddUrlActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) {
// Path: app/src/main/java/net/sourceforge/servestream/preference/UserPreferences.java // public class UserPreferences implements // SharedPreferences.OnSharedPreferenceChangeListener { // private static UserPreferences instance; // private final Context mContext; // // // Preferences // private int mTheme; // // private UserPreferences(Context context) { // mContext = context; // loadPreferences(); // } // // /** // * Sets up the UserPreferences class. // * // * @throws IllegalArgumentException // * if context is null // * */ // public static void createInstance(Context context) { // if (context == null) // throw new IllegalArgumentException("Context must not be null"); // instance = new UserPreferences(context); // // PreferenceManager.getDefaultSharedPreferences(context) // .registerOnSharedPreferenceChangeListener(instance); // // } // // private void loadPreferences() { // SharedPreferences sp = PreferenceManager // .getDefaultSharedPreferences(mContext); // //mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "0")); // mTheme = R.style.Theme_ServeStream_DarkActionBar;; // } // // private int readThemeValue(String valueFromPrefs) { // switch (Integer.parseInt(valueFromPrefs)) { // case 0: // return R.style.Theme_ServeStream_DarkActionBar; // case 1: // return R.style.Theme_ServeStream_Dark; // default: // return R.style.Theme_ServeStream_DarkActionBar; // } // } // // private static void instanceAvailable() { // if (instance == null) { // throw new IllegalStateException( // "UserPreferences was used before being set up"); // } // } // // public static int getTheme() { // instanceAvailable(); // return instance.mTheme; // } // // @Override // public void onSharedPreferenceChanged(SharedPreferences sp, String key) { // if (key.equals(PreferenceConstants.THEME)) { // mTheme = readThemeValue(sp.getString(PreferenceConstants.THEME, "")); // } // } // } // Path: app/src/main/java/net/sourceforge/servestream/activity/AddUrlActivity.java import net.sourceforge.servestream.fragment.AddUrlFragment; import net.sourceforge.servestream.preference.UserPreferences; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.view.MenuItem; /* * ServeStream: A HTTP stream browser/player for Android * Copyright 2014 William Seemann * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this.getActivity() 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 net.sourceforge.servestream.activity; public class AddUrlActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());