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 |
|---|---|---|---|---|---|---|
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-28.
*/
public abstract class Matcher {
protected String column;
| // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-28.
*/
public abstract class Matcher {
protected String column;
| public abstract MatchType getMatchType(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/QueryBuilder.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class QueryBuilder extends ActionBuilder {
public QueryBuilder(ActionTable table) {
this.table = table;
}
@Override
public Query build() {
Query query = new Query();
query.table = this.table;
return query;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/QueryBuilder.java
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class QueryBuilder extends ActionBuilder {
public QueryBuilder(ActionTable table) {
this.table = table;
}
@Override
public Query build() {
Query query = new Query();
query.table = this.table;
return query;
}
@Override | public ActionMode getActionMode() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016/4/30.
*/
public abstract class ConditionalAction extends Action {
private Collection<Matcher> conditions = new ArrayList<Matcher>();
private String conSql = null;
private List<Object> conParams = null;
private String realTableName = null;
public <T extends ConditionalAction>T addConditions(Collection<Matcher> matcheres) {
conditions.addAll(matcheres);
return (T) this;
}
public <T extends ConditionalAction>T addCondition(Matcher matcher) {
conditions.add(matcher);
return (T) this;
}
protected List<Object> getConParams() {
if(null == this.conParams) {
analysisConditions();
}
return this.conParams != null ? this.conParams : new ArrayList<Object>(0);
}
protected String getConSql() {
if(null == this.conSql) {
analysisConditions();
}
return this.conSql != null ? this.conSql : "";
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016/4/30.
*/
public abstract class ConditionalAction extends Action {
private Collection<Matcher> conditions = new ArrayList<Matcher>();
private String conSql = null;
private List<Object> conParams = null;
private String realTableName = null;
public <T extends ConditionalAction>T addConditions(Collection<Matcher> matcheres) {
conditions.addAll(matcheres);
return (T) this;
}
public <T extends ConditionalAction>T addCondition(Matcher matcher) {
conditions.add(matcher);
return (T) this;
}
protected List<Object> getConParams() {
if(null == this.conParams) {
analysisConditions();
}
return this.conParams != null ? this.conParams : new ArrayList<Object>(0);
}
protected String getConSql() {
if(null == this.conSql) {
analysisConditions();
}
return this.conSql != null ? this.conSql : "";
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist | TableShardStrategy tableShardStrategy = table.getTableShardStrategy(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016/4/30.
*/
public abstract class ConditionalAction extends Action {
private Collection<Matcher> conditions = new ArrayList<Matcher>();
private String conSql = null;
private List<Object> conParams = null;
private String realTableName = null;
public <T extends ConditionalAction>T addConditions(Collection<Matcher> matcheres) {
conditions.addAll(matcheres);
return (T) this;
}
public <T extends ConditionalAction>T addCondition(Matcher matcher) {
conditions.add(matcher);
return (T) this;
}
protected List<Object> getConParams() {
if(null == this.conParams) {
analysisConditions();
}
return this.conParams != null ? this.conParams : new ArrayList<Object>(0);
}
protected String getConSql() {
if(null == this.conSql) {
analysisConditions();
}
return this.conSql != null ? this.conSql : "";
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist
TableShardStrategy tableShardStrategy = table.getTableShardStrategy(); | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016/4/30.
*/
public abstract class ConditionalAction extends Action {
private Collection<Matcher> conditions = new ArrayList<Matcher>();
private String conSql = null;
private List<Object> conParams = null;
private String realTableName = null;
public <T extends ConditionalAction>T addConditions(Collection<Matcher> matcheres) {
conditions.addAll(matcheres);
return (T) this;
}
public <T extends ConditionalAction>T addCondition(Matcher matcher) {
conditions.add(matcher);
return (T) this;
}
protected List<Object> getConParams() {
if(null == this.conParams) {
analysisConditions();
}
return this.conParams != null ? this.conParams : new ArrayList<Object>(0);
}
protected String getConSql() {
if(null == this.conSql) {
analysisConditions();
}
return this.conSql != null ? this.conSql : "";
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist
TableShardStrategy tableShardStrategy = table.getTableShardStrategy(); | TableShardHandler tableShardHandler = table.getTableShardHandler(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*; | conditions.add(matcher);
return (T) this;
}
protected List<Object> getConParams() {
if(null == this.conParams) {
analysisConditions();
}
return this.conParams != null ? this.conParams : new ArrayList<Object>(0);
}
protected String getConSql() {
if(null == this.conSql) {
analysisConditions();
}
return this.conSql != null ? this.conSql : "";
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist
TableShardStrategy tableShardStrategy = table.getTableShardStrategy();
TableShardHandler tableShardHandler = table.getTableShardHandler();
if(null != tableShardHandler && null != tableShardStrategy) {
String[] shardColumns = tableShardStrategy.getShardColumns();
List<String> shardColumnList = Arrays.asList(shardColumns);
List<Object> shardColumnValueList = new ArrayList<Object>();
for(Matcher matcher : conditions) { | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*;
conditions.add(matcher);
return (T) this;
}
protected List<Object> getConParams() {
if(null == this.conParams) {
analysisConditions();
}
return this.conParams != null ? this.conParams : new ArrayList<Object>(0);
}
protected String getConSql() {
if(null == this.conSql) {
analysisConditions();
}
return this.conSql != null ? this.conSql : "";
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist
TableShardStrategy tableShardStrategy = table.getTableShardStrategy();
TableShardHandler tableShardHandler = table.getTableShardHandler();
if(null != tableShardHandler && null != tableShardStrategy) {
String[] shardColumns = tableShardStrategy.getShardColumns();
List<String> shardColumnList = Arrays.asList(shardColumns);
List<Object> shardColumnValueList = new ArrayList<Object>();
for(Matcher matcher : conditions) { | if(MatchType.EQUALS == matcher.getMatchType() && shardColumnList.contains(matcher.getColumn())) { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*; | for(Matcher matcher : conditions) {
if(MatchType.EQUALS == matcher.getMatchType() && shardColumnList.contains(matcher.getColumn())) {
shardColumnValueList.add(matcher.getValues()[0]);
}
}
realTableName = tableShardHandler.getRealTableName(tableShardStrategy,shardColumnValueList.toArray());
if(tableShardStrategy != null && this.realTableName == null) {
throw new RuntimeException("Failed to get real name of shard table!");
}
}else {
realTableName = table.getTableName();
}
}
return realTableName;
}
private void analysisConditions() {
StringBuilder conditionSqlBuilder = new StringBuilder();
if(CollectionUtils.isEmpty(conditions)){
this.conSql = null;
}else {
conditionSqlBuilder.append("WHERE ");
List<Object> conParamsList = new ArrayList<Object>(conditions.size());
for(Matcher matcher : conditions) { | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ConditionType.java
// public enum ConditionType {
//
// AND, OR
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/ConditionalAction.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ConditionType;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.*;
for(Matcher matcher : conditions) {
if(MatchType.EQUALS == matcher.getMatchType() && shardColumnList.contains(matcher.getColumn())) {
shardColumnValueList.add(matcher.getValues()[0]);
}
}
realTableName = tableShardHandler.getRealTableName(tableShardStrategy,shardColumnValueList.toArray());
if(tableShardStrategy != null && this.realTableName == null) {
throw new RuntimeException("Failed to get real name of shard table!");
}
}else {
realTableName = table.getTableName();
}
}
return realTableName;
}
private void analysisConditions() {
StringBuilder conditionSqlBuilder = new StringBuilder();
if(CollectionUtils.isEmpty(conditions)){
this.conSql = null;
}else {
conditionSqlBuilder.append("WHERE ");
List<Object> conParamsList = new ArrayList<Object>(conditions.size());
for(Matcher matcher : conditions) { | conditionSqlBuilder.append(ConditionType.AND).append(" ") |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/GreaterMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class GreaterMatcher extends Matcher {
private Object value;
public GreaterMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/GreaterMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class GreaterMatcher extends Matcher {
private Object value;
public GreaterMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | public MatchType getMatchType() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
| import pers.zr.opensource.magic.dao.constants.DataSourceType; | package pers.zr.opensource.magic.dao.runtime;
/**
* Created by zhurong on 2016-8-2.
*/
public class RuntimeQueryDataSource {
public static ThreadLocal<String> alias = new ThreadLocal<String>();
| // Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java
import pers.zr.opensource.magic.dao.constants.DataSourceType;
package pers.zr.opensource.magic.dao.runtime;
/**
* Created by zhurong on 2016-8-2.
*/
public class RuntimeQueryDataSource {
public static ThreadLocal<String> alias = new ThreadLocal<String>();
| public static ThreadLocal<DataSourceType> type = new ThreadLocal<DataSourceType>(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/ActionBuilder.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy; | package pers.zr.opensource.magic.dao.action;
/**
*
* Created by zhurong on 2016-4-28.
*/
public abstract class ActionBuilder {
protected ActionTable table;
public abstract <T extends Action> T build();
public ActionTable getTable() {
return this.table;
}
| // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/ActionBuilder.java
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
package pers.zr.opensource.magic.dao.action;
/**
*
* Created by zhurong on 2016-4-28.
*/
public abstract class ActionBuilder {
protected ActionTable table;
public abstract <T extends Action> T build();
public ActionTable getTable() {
return this.table;
}
| public abstract ActionMode getActionMode(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/MagicSingleDataSource.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import javax.sql.DataSource; | package pers.zr.opensource.magic.dao;
/**
*
* Single DataSource
*
* Created by zhurong on 2016-4-28.
*/
public class MagicSingleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicSingleDataSource.class);
private DataSource dataSource;
private JdbcTemplate jdbcTemplate;
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/MagicSingleDataSource.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import javax.sql.DataSource;
package pers.zr.opensource.magic.dao;
/**
*
* Single DataSource
*
* Created by zhurong on 2016-4-28.
*/
public class MagicSingleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicSingleDataSource.class);
private DataSource dataSource;
private JdbcTemplate jdbcTemplate;
@Override | public JdbcTemplate getJdbcTemplate(ActionMode actionMode) { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/ActionBuilderContainer.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
| import pers.zr.opensource.magic.dao.constants.ActionMode;
import java.util.HashMap;
import java.util.Map; | package pers.zr.opensource.magic.dao.action;
/**
* ActionBuilderContainer
*
* ActionBuilder cache
*
* Created by zhurong on 2016-4-29.
*/
public class ActionBuilderContainer {
private static Map<ActionTable, QueryBuilder> queryBuilderMap = new HashMap<ActionTable, QueryBuilder>();
private static Map<ActionTable, DeleteBuilder> deleteBuilderMap = new HashMap<ActionTable, DeleteBuilder>();
private static Map<ActionTable, InsertBuilder> insertBuilderMap = new HashMap<ActionTable, InsertBuilder>();
private static Map<ActionTable, UpdateBuilder> updateBuilderMap = new HashMap<ActionTable, UpdateBuilder>();
| // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/ActionBuilderContainer.java
import pers.zr.opensource.magic.dao.constants.ActionMode;
import java.util.HashMap;
import java.util.Map;
package pers.zr.opensource.magic.dao.action;
/**
* ActionBuilderContainer
*
* ActionBuilder cache
*
* Created by zhurong on 2016-4-29.
*/
public class ActionBuilderContainer {
private static Map<ActionTable, QueryBuilder> queryBuilderMap = new HashMap<ActionTable, QueryBuilder>();
private static Map<ActionTable, DeleteBuilder> deleteBuilderMap = new HashMap<ActionTable, DeleteBuilder>();
private static Map<ActionTable, InsertBuilder> insertBuilderMap = new HashMap<ActionTable, InsertBuilder>();
private static Map<ActionTable, UpdateBuilder> updateBuilderMap = new HashMap<ActionTable, UpdateBuilder>();
| public static <T extends ActionBuilder> T getActionBuilder(ActionTable table, ActionMode mode) { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/UpdateBuilder.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class UpdateBuilder extends ActionBuilder {
public UpdateBuilder(ActionTable table) {
this.table = table;
}
@Override
public Update build() {
Update update = new Update();
update.table = this.table;
return update;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/UpdateBuilder.java
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class UpdateBuilder extends ActionBuilder {
public UpdateBuilder(ActionTable table) {
this.table = table;
}
@Override
public Update build() {
Update update = new Update();
update.table = this.table;
return update;
}
@Override | public ActionMode getActionMode() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/Delete.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
| import pers.zr.opensource.magic.dao.constants.ActionMode; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Delete extends ConditionalAction {
@Override
public String getSql() {
if(null == this.sql) {
this.sql = (new StringBuilder()).append("DELETE FROM ").append(getRealTableName())
.append(" ").append(getConSql()).toString();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
this.params = getConParams().toArray();
return this.params;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/Delete.java
import pers.zr.opensource.magic.dao.constants.ActionMode;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Delete extends ConditionalAction {
@Override
public String getSql() {
if(null == this.sql) {
this.sql = (new StringBuilder()).append("DELETE FROM ").append(getRealTableName())
.append(" ").append(getConSql()).toString();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
this.params = getConParams().toArray();
return this.params;
}
@Override | public ActionMode getActionMode() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSourceAop.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import pers.zr.opensource.magic.dao.annotation.QueryDataSource;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import java.lang.reflect.Method; | package pers.zr.opensource.magic.dao.runtime;
/**
*
* Aop to analysis @QueryDataSource annotation, and determine the reading dataSource type: master or slave
* Created by zhurong on 2016-5-23.
*/
public class RuntimeQueryDataSourceAop {
private Log log = LogFactory.getLog(RuntimeQueryDataSourceAop.class);
public Object determine(ProceedingJoinPoint pjp) {
try {
QueryDataSource queryDataSourceAnnotation = null;
Object target = pjp.getTarget();
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
//method in class
Method methodImpl = target.getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
//method in interface
Method methodInterface = methodSignature.getMethod();
//current class
Class<?> clazzImpl = pjp.getTarget().getClass();
//current interface
Class<?> clazzInterface = methodInterface.getDeclaringClass();
//get annotation of method
queryDataSourceAnnotation = methodImpl.getAnnotation(QueryDataSource.class) != null
? methodImpl.getAnnotation(QueryDataSource.class)
: methodInterface.getAnnotation(QueryDataSource.class);
if(null == queryDataSourceAnnotation) {
//get annotation of class or interface
queryDataSourceAnnotation = clazzImpl.getAnnotation(QueryDataSource.class) != null
? clazzImpl.getAnnotation(QueryDataSource.class)
: clazzInterface.getAnnotation(QueryDataSource.class);
}
//set alias of current thread query datasource
String currentDataSourceAlias = queryDataSourceAnnotation.alias();
if(null == currentDataSourceAlias || "".equals(currentDataSourceAlias)) {
//set type of current thread query dataSource | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSourceAop.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import pers.zr.opensource.magic.dao.annotation.QueryDataSource;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import java.lang.reflect.Method;
package pers.zr.opensource.magic.dao.runtime;
/**
*
* Aop to analysis @QueryDataSource annotation, and determine the reading dataSource type: master or slave
* Created by zhurong on 2016-5-23.
*/
public class RuntimeQueryDataSourceAop {
private Log log = LogFactory.getLog(RuntimeQueryDataSourceAop.class);
public Object determine(ProceedingJoinPoint pjp) {
try {
QueryDataSource queryDataSourceAnnotation = null;
Object target = pjp.getTarget();
MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
//method in class
Method methodImpl = target.getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
//method in interface
Method methodInterface = methodSignature.getMethod();
//current class
Class<?> clazzImpl = pjp.getTarget().getClass();
//current interface
Class<?> clazzInterface = methodInterface.getDeclaringClass();
//get annotation of method
queryDataSourceAnnotation = methodImpl.getAnnotation(QueryDataSource.class) != null
? methodImpl.getAnnotation(QueryDataSource.class)
: methodInterface.getAnnotation(QueryDataSource.class);
if(null == queryDataSourceAnnotation) {
//get annotation of class or interface
queryDataSourceAnnotation = clazzImpl.getAnnotation(QueryDataSource.class) != null
? clazzImpl.getAnnotation(QueryDataSource.class)
: clazzInterface.getAnnotation(QueryDataSource.class);
}
//set alias of current thread query datasource
String currentDataSourceAlias = queryDataSourceAnnotation.alias();
if(null == currentDataSourceAlias || "".equals(currentDataSourceAlias)) {
//set type of current thread query dataSource | DataSourceType currentDataSourceType = (null != queryDataSourceAnnotation) ? queryDataSourceAnnotation.type() : DataSourceType.SLAVE; |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/EqualsMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class EqualsMatcher extends Matcher {
private Object value;
public EqualsMatcher(String column, Object value) {
this.value = value;
this.column = column;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/EqualsMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class EqualsMatcher extends Matcher {
private Object value;
public EqualsMatcher(String column, Object value) {
this.value = value;
this.column = column;
}
@Override | public MatchType getMatchType() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/LeftLikeMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-5-5.
*/
public class LeftLikeMatcher extends Matcher {
private String value;
public LeftLikeMatcher(String column, String value) {
this.column = column; | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/LeftLikeMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-5-5.
*/
public class LeftLikeMatcher extends Matcher {
private String value;
public LeftLikeMatcher(String column, String value) {
this.column = column; | this.value = convertSpecialChar(value, MatchType.LIKE) + "%"; |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/NotEqualsMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class NotEqualsMatcher extends Matcher {
private Object value;
public NotEqualsMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/NotEqualsMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class NotEqualsMatcher extends Matcher {
private Object value;
public NotEqualsMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | public MatchType getMatchType() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/GreaterOrEqualsMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class GreaterOrEqualsMatcher extends Matcher {
private Object value;
public GreaterOrEqualsMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/GreaterOrEqualsMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class GreaterOrEqualsMatcher extends Matcher {
private Object value;
public GreaterOrEqualsMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | public MatchType getMatchType() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/InsertBuilder.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class InsertBuilder extends ActionBuilder {
public InsertBuilder(ActionTable table) {
this.table = table;
}
@Override
public Insert build() {
Insert insert = new Insert();
insert.table = this.table;
return insert;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/InsertBuilder.java
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class InsertBuilder extends ActionBuilder {
public InsertBuilder(ActionTable table) {
this.table = table;
}
@Override
public Insert build() {
Insert insert = new Insert();
insert.table = this.table;
return insert;
}
@Override | public ActionMode getActionMode() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/DeleteBuilder.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy; | package pers.zr.opensource.magic.dao.action;
/**
*
* Created by zhurong on 2016-4-28.
*/
public class DeleteBuilder extends ActionBuilder {
public DeleteBuilder(ActionTable table) {
this.table = table;
}
@Override
public Delete build() {
Delete delete = new Delete();
delete.table = this.table;
return delete;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/DeleteBuilder.java
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
package pers.zr.opensource.magic.dao.action;
/**
*
* Created by zhurong on 2016-4-28.
*/
public class DeleteBuilder extends ActionBuilder {
public DeleteBuilder(ActionTable table) {
this.table = table;
}
@Override
public Delete build() {
Delete delete = new Delete();
delete.table = this.table;
return delete;
}
@Override | public ActionMode getActionMode() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/annotation/QueryDataSource.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
| import pers.zr.opensource.magic.dao.constants.DataSourceType;
import java.lang.annotation.*; | package pers.zr.opensource.magic.dao.annotation;
/**
* Created by zhurong on 2016-5-5.
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface QueryDataSource {
String alias() default "";
| // Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/annotation/QueryDataSource.java
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import java.lang.annotation.*;
package pers.zr.opensource.magic.dao.annotation;
/**
* Created by zhurong on 2016-5-5.
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface QueryDataSource {
String alias() default "";
| DataSourceType type() default DataSourceType.SLAVE; |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/BetweenAndMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class BetweenAndMatcher extends Matcher {
private Object minValue;
private Object maxValue;
public BetweenAndMatcher(String column, Object minValue, Object maxValue) {
this.column = column;
this.minValue = minValue;
this.maxValue = maxValue;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/BetweenAndMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class BetweenAndMatcher extends Matcher {
private Object minValue;
private Object maxValue;
public BetweenAndMatcher(String column, Object minValue, Object maxValue) {
this.column = column;
this.minValue = minValue;
this.maxValue = maxValue;
}
@Override | public MatchType getMatchType() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/LessMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class LessMatcher extends Matcher {
private Object value;
public LessMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/LessMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class LessMatcher extends Matcher {
private Object value;
public LessMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | public MatchType getMatchType() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/Update.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Update extends ConditionalAction {
private Map<String, Object> updateFields;
public void setUpdateFields(Map<String, Object> updateFields) {
this.updateFields = updateFields;
}
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/Update.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Update extends ConditionalAction {
private Map<String, Object> updateFields;
public void setUpdateFields(Map<String, Object> updateFields) {
this.updateFields = updateFields;
}
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override | public ActionMode getActionMode() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/MagicDao.java | // Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/order/Order.java
// public class Order {
//
// private String column;
//
// private OrderType type;
//
// public Order(String column, OrderType type) {
// this.column = column;
// this.type = type;
// }
//
// public String getColumn() {
// return column;
// }
//
// public OrderType getType() {
// return type;
// }
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/page/Page.java
// public class Page {
//
// private int pageNo;
//
// private int pageSize;
//
// public Page(int pageNo, int pageSize) {
// this.pageNo = pageNo;
// this.pageSize = pageSize;
// }
//
// public int getPageNo() {
// return pageNo;
// }
//
// public void setPageNo(int pageNo) {
// this.pageNo = pageNo;
// }
//
// public int getPageSize() {
// return pageSize;
// }
//
// public void setPageSize(int pageSize) {
// this.pageSize = pageSize;
// }
// }
| import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.order.Order;
import pers.zr.opensource.magic.dao.page.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map; | package pers.zr.opensource.magic.dao;
/**
* MagicDao interface
*
* Created by zhurong on 2016-4-29.
*/
public interface MagicDao<KEY extends Serializable, ENTITY extends Serializable> {
public ENTITY get(KEY key);
public void insert(ENTITY entity);
public Long insertForId(ENTITY entity);
public void update(ENTITY entity);
public void delete(KEY key);
| // Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/order/Order.java
// public class Order {
//
// private String column;
//
// private OrderType type;
//
// public Order(String column, OrderType type) {
// this.column = column;
// this.type = type;
// }
//
// public String getColumn() {
// return column;
// }
//
// public OrderType getType() {
// return type;
// }
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/page/Page.java
// public class Page {
//
// private int pageNo;
//
// private int pageSize;
//
// public Page(int pageNo, int pageSize) {
// this.pageNo = pageNo;
// this.pageSize = pageSize;
// }
//
// public int getPageNo() {
// return pageNo;
// }
//
// public void setPageNo(int pageNo) {
// this.pageNo = pageNo;
// }
//
// public int getPageSize() {
// return pageSize;
// }
//
// public void setPageSize(int pageSize) {
// this.pageSize = pageSize;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/MagicDao.java
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.order.Order;
import pers.zr.opensource.magic.dao.page.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
package pers.zr.opensource.magic.dao;
/**
* MagicDao interface
*
* Created by zhurong on 2016-4-29.
*/
public interface MagicDao<KEY extends Serializable, ENTITY extends Serializable> {
public ENTITY get(KEY key);
public void insert(ENTITY entity);
public Long insertForId(ENTITY entity);
public void update(ENTITY entity);
public void delete(KEY key);
| public List<ENTITY> query(Matcher...conditions); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/MagicDao.java | // Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/order/Order.java
// public class Order {
//
// private String column;
//
// private OrderType type;
//
// public Order(String column, OrderType type) {
// this.column = column;
// this.type = type;
// }
//
// public String getColumn() {
// return column;
// }
//
// public OrderType getType() {
// return type;
// }
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/page/Page.java
// public class Page {
//
// private int pageNo;
//
// private int pageSize;
//
// public Page(int pageNo, int pageSize) {
// this.pageNo = pageNo;
// this.pageSize = pageSize;
// }
//
// public int getPageNo() {
// return pageNo;
// }
//
// public void setPageNo(int pageNo) {
// this.pageNo = pageNo;
// }
//
// public int getPageSize() {
// return pageSize;
// }
//
// public void setPageSize(int pageSize) {
// this.pageSize = pageSize;
// }
// }
| import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.order.Order;
import pers.zr.opensource.magic.dao.page.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map; | package pers.zr.opensource.magic.dao;
/**
* MagicDao interface
*
* Created by zhurong on 2016-4-29.
*/
public interface MagicDao<KEY extends Serializable, ENTITY extends Serializable> {
public ENTITY get(KEY key);
public void insert(ENTITY entity);
public Long insertForId(ENTITY entity);
public void update(ENTITY entity);
public void delete(KEY key);
public List<ENTITY> query(Matcher...conditions);
| // Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/order/Order.java
// public class Order {
//
// private String column;
//
// private OrderType type;
//
// public Order(String column, OrderType type) {
// this.column = column;
// this.type = type;
// }
//
// public String getColumn() {
// return column;
// }
//
// public OrderType getType() {
// return type;
// }
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/page/Page.java
// public class Page {
//
// private int pageNo;
//
// private int pageSize;
//
// public Page(int pageNo, int pageSize) {
// this.pageNo = pageNo;
// this.pageSize = pageSize;
// }
//
// public int getPageNo() {
// return pageNo;
// }
//
// public void setPageNo(int pageNo) {
// this.pageNo = pageNo;
// }
//
// public int getPageSize() {
// return pageSize;
// }
//
// public void setPageSize(int pageSize) {
// this.pageSize = pageSize;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/MagicDao.java
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.order.Order;
import pers.zr.opensource.magic.dao.page.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
package pers.zr.opensource.magic.dao;
/**
* MagicDao interface
*
* Created by zhurong on 2016-4-29.
*/
public interface MagicDao<KEY extends Serializable, ENTITY extends Serializable> {
public ENTITY get(KEY key);
public void insert(ENTITY entity);
public Long insertForId(ENTITY entity);
public void update(ENTITY entity);
public void delete(KEY key);
public List<ENTITY> query(Matcher...conditions);
| public List<ENTITY> query(List<Order> orders, Matcher...conditions); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/MagicDao.java | // Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/order/Order.java
// public class Order {
//
// private String column;
//
// private OrderType type;
//
// public Order(String column, OrderType type) {
// this.column = column;
// this.type = type;
// }
//
// public String getColumn() {
// return column;
// }
//
// public OrderType getType() {
// return type;
// }
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/page/Page.java
// public class Page {
//
// private int pageNo;
//
// private int pageSize;
//
// public Page(int pageNo, int pageSize) {
// this.pageNo = pageNo;
// this.pageSize = pageSize;
// }
//
// public int getPageNo() {
// return pageNo;
// }
//
// public void setPageNo(int pageNo) {
// this.pageNo = pageNo;
// }
//
// public int getPageSize() {
// return pageSize;
// }
//
// public void setPageSize(int pageSize) {
// this.pageSize = pageSize;
// }
// }
| import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.order.Order;
import pers.zr.opensource.magic.dao.page.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map; | package pers.zr.opensource.magic.dao;
/**
* MagicDao interface
*
* Created by zhurong on 2016-4-29.
*/
public interface MagicDao<KEY extends Serializable, ENTITY extends Serializable> {
public ENTITY get(KEY key);
public void insert(ENTITY entity);
public Long insertForId(ENTITY entity);
public void update(ENTITY entity);
public void delete(KEY key);
public List<ENTITY> query(Matcher...conditions);
public List<ENTITY> query(List<Order> orders, Matcher...conditions);
| // Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/order/Order.java
// public class Order {
//
// private String column;
//
// private OrderType type;
//
// public Order(String column, OrderType type) {
// this.column = column;
// this.type = type;
// }
//
// public String getColumn() {
// return column;
// }
//
// public OrderType getType() {
// return type;
// }
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/page/Page.java
// public class Page {
//
// private int pageNo;
//
// private int pageSize;
//
// public Page(int pageNo, int pageSize) {
// this.pageNo = pageNo;
// this.pageSize = pageSize;
// }
//
// public int getPageNo() {
// return pageNo;
// }
//
// public void setPageNo(int pageNo) {
// this.pageNo = pageNo;
// }
//
// public int getPageSize() {
// return pageSize;
// }
//
// public void setPageSize(int pageSize) {
// this.pageSize = pageSize;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/MagicDao.java
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.order.Order;
import pers.zr.opensource.magic.dao.page.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
package pers.zr.opensource.magic.dao;
/**
* MagicDao interface
*
* Created by zhurong on 2016-4-29.
*/
public interface MagicDao<KEY extends Serializable, ENTITY extends Serializable> {
public ENTITY get(KEY key);
public void insert(ENTITY entity);
public Long insertForId(ENTITY entity);
public void update(ENTITY entity);
public void delete(KEY key);
public List<ENTITY> query(Matcher...conditions);
public List<ENTITY> query(List<Order> orders, Matcher...conditions);
| public List<ENTITY> query(Page page, Matcher...conditions); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/MagicMultipleDataSource.java | // Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java
// public class RuntimeQueryDataSource {
//
// public static ThreadLocal<String> alias = new ThreadLocal<String>();
//
// public static ThreadLocal<DataSourceType> type = new ThreadLocal<DataSourceType>();
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.runtime.RuntimeQueryDataSource;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import javax.sql.DataSource;
import java.util.*; | package pers.zr.opensource.magic.dao;
/**
* Multiple DataSource
*
* For Reading and writing separation
*
* Created by zhurong on 2016-4-28.
*/
public class MagicMultipleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicMultipleDataSource.class);
private DataSource master;
private Map<String, DataSource> slaves;
private JdbcTemplate masterJdbcTemplate;
private Map<String, JdbcTemplate> slaveJdbcTemplates;
private List<String> dataSourceNameList;
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java
// public class RuntimeQueryDataSource {
//
// public static ThreadLocal<String> alias = new ThreadLocal<String>();
//
// public static ThreadLocal<DataSourceType> type = new ThreadLocal<DataSourceType>();
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/MagicMultipleDataSource.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.runtime.RuntimeQueryDataSource;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import javax.sql.DataSource;
import java.util.*;
package pers.zr.opensource.magic.dao;
/**
* Multiple DataSource
*
* For Reading and writing separation
*
* Created by zhurong on 2016-4-28.
*/
public class MagicMultipleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicMultipleDataSource.class);
private DataSource master;
private Map<String, DataSource> slaves;
private JdbcTemplate masterJdbcTemplate;
private Map<String, JdbcTemplate> slaveJdbcTemplates;
private List<String> dataSourceNameList;
@Override | public JdbcTemplate getJdbcTemplate(ActionMode actionMode) { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/MagicMultipleDataSource.java | // Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java
// public class RuntimeQueryDataSource {
//
// public static ThreadLocal<String> alias = new ThreadLocal<String>();
//
// public static ThreadLocal<DataSourceType> type = new ThreadLocal<DataSourceType>();
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.runtime.RuntimeQueryDataSource;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import javax.sql.DataSource;
import java.util.*; | package pers.zr.opensource.magic.dao;
/**
* Multiple DataSource
*
* For Reading and writing separation
*
* Created by zhurong on 2016-4-28.
*/
public class MagicMultipleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicMultipleDataSource.class);
private DataSource master;
private Map<String, DataSource> slaves;
private JdbcTemplate masterJdbcTemplate;
private Map<String, JdbcTemplate> slaveJdbcTemplates;
private List<String> dataSourceNameList;
@Override
public JdbcTemplate getJdbcTemplate(ActionMode actionMode) {
if(CollectionUtils.isEmpty(this.slaves)) {
throw new RuntimeException("MagicMultipleDataSource must has at least one slave DataSource!");
}
boolean isMasterDataSource; | // Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java
// public class RuntimeQueryDataSource {
//
// public static ThreadLocal<String> alias = new ThreadLocal<String>();
//
// public static ThreadLocal<DataSourceType> type = new ThreadLocal<DataSourceType>();
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/MagicMultipleDataSource.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.runtime.RuntimeQueryDataSource;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import javax.sql.DataSource;
import java.util.*;
package pers.zr.opensource.magic.dao;
/**
* Multiple DataSource
*
* For Reading and writing separation
*
* Created by zhurong on 2016-4-28.
*/
public class MagicMultipleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicMultipleDataSource.class);
private DataSource master;
private Map<String, DataSource> slaves;
private JdbcTemplate masterJdbcTemplate;
private Map<String, JdbcTemplate> slaveJdbcTemplates;
private List<String> dataSourceNameList;
@Override
public JdbcTemplate getJdbcTemplate(ActionMode actionMode) {
if(CollectionUtils.isEmpty(this.slaves)) {
throw new RuntimeException("MagicMultipleDataSource must has at least one slave DataSource!");
}
boolean isMasterDataSource; | String currentQueryDataSourceName = RuntimeQueryDataSource.alias.get(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/MagicMultipleDataSource.java | // Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java
// public class RuntimeQueryDataSource {
//
// public static ThreadLocal<String> alias = new ThreadLocal<String>();
//
// public static ThreadLocal<DataSourceType> type = new ThreadLocal<DataSourceType>();
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
| import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.runtime.RuntimeQueryDataSource;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import javax.sql.DataSource;
import java.util.*; | package pers.zr.opensource.magic.dao;
/**
* Multiple DataSource
*
* For Reading and writing separation
*
* Created by zhurong on 2016-4-28.
*/
public class MagicMultipleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicMultipleDataSource.class);
private DataSource master;
private Map<String, DataSource> slaves;
private JdbcTemplate masterJdbcTemplate;
private Map<String, JdbcTemplate> slaveJdbcTemplates;
private List<String> dataSourceNameList;
@Override
public JdbcTemplate getJdbcTemplate(ActionMode actionMode) {
if(CollectionUtils.isEmpty(this.slaves)) {
throw new RuntimeException("MagicMultipleDataSource must has at least one slave DataSource!");
}
boolean isMasterDataSource;
String currentQueryDataSourceName = RuntimeQueryDataSource.alias.get(); | // Path: src/main/java/pers/zr/opensource/magic/dao/runtime/RuntimeQueryDataSource.java
// public class RuntimeQueryDataSource {
//
// public static ThreadLocal<String> alias = new ThreadLocal<String>();
//
// public static ThreadLocal<DataSourceType> type = new ThreadLocal<DataSourceType>();
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/DataSourceType.java
// public enum DataSourceType {
//
// MASTER, SLAVE
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/MagicMultipleDataSource.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.runtime.RuntimeQueryDataSource;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.DataSourceType;
import javax.sql.DataSource;
import java.util.*;
package pers.zr.opensource.magic.dao;
/**
* Multiple DataSource
*
* For Reading and writing separation
*
* Created by zhurong on 2016-4-28.
*/
public class MagicMultipleDataSource implements MagicDataSource {
private Log log = LogFactory.getLog(MagicMultipleDataSource.class);
private DataSource master;
private Map<String, DataSource> slaves;
private JdbcTemplate masterJdbcTemplate;
private Map<String, JdbcTemplate> slaveJdbcTemplates;
private List<String> dataSourceNameList;
@Override
public JdbcTemplate getJdbcTemplate(ActionMode actionMode) {
if(CollectionUtils.isEmpty(this.slaves)) {
throw new RuntimeException("MagicMultipleDataSource must has at least one slave DataSource!");
}
boolean isMasterDataSource;
String currentQueryDataSourceName = RuntimeQueryDataSource.alias.get(); | DataSourceType currentDataSourceType = RuntimeQueryDataSource.type.get(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/matcher/LessOrEqualsMatcher.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
| import pers.zr.opensource.magic.dao.constants.MatchType; | package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class LessOrEqualsMatcher extends Matcher {
private Object value;
public LessOrEqualsMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/LessOrEqualsMatcher.java
import pers.zr.opensource.magic.dao.constants.MatchType;
package pers.zr.opensource.magic.dao.matcher;
/**
* Created by zhurong on 2016-4-29.
*/
public class LessOrEqualsMatcher extends Matcher {
private Object value;
public LessOrEqualsMatcher(String column, Object value) {
this.column = column;
this.value = value;
}
public Object[] getValues() {
return new Object[]{value};
}
@Override | public MatchType getMatchType() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/Insert.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Insert extends Action {
private Map<String, Object> insertFields;
public void setInsertFields(Map<String, Object> insertFields) {
this.insertFields = insertFields;
}
private String realTableName = null;
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/Insert.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Insert extends Action {
private Map<String, Object> insertFields;
public void setInsertFields(Map<String, Object> insertFields) {
this.insertFields = insertFields;
}
private String realTableName = null;
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override | public ActionMode getActionMode() { |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/Insert.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map; | package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Insert extends Action {
private Map<String, Object> insertFields;
public void setInsertFields(Map<String, Object> insertFields) {
this.insertFields = insertFields;
}
private String realTableName = null;
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override
public ActionMode getActionMode() {
return ActionMode.INSERT;
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/Insert.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
package pers.zr.opensource.magic.dao.action;
/**
* Created by zhurong on 2016-4-28.
*/
public class Insert extends Action {
private Map<String, Object> insertFields;
public void setInsertFields(Map<String, Object> insertFields) {
this.insertFields = insertFields;
}
private String realTableName = null;
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override
public ActionMode getActionMode() {
return ActionMode.INSERT;
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist | TableShardStrategy tableShardStrategy = table.getTableShardStrategy(); |
rongzhu8888/magic-dao | src/main/java/pers/zr/opensource/magic/dao/action/Insert.java | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
| import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map; | @Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override
public ActionMode getActionMode() {
return ActionMode.INSERT;
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist
TableShardStrategy tableShardStrategy = table.getTableShardStrategy(); | // Path: src/main/java/pers/zr/opensource/magic/dao/constants/ActionMode.java
// public enum ActionMode {
//
// INSERT, UPDATE, DELETE, QUERY
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/constants/MatchType.java
// public enum MatchType {
//
// EQUALS("="),
//
// GREATER(">"),
//
// LESS("<"),
//
// NOT_EQUALS("!="),
//
// GREATER_OR_EQUALS(">="),
//
// LESS_OR_EQUALS("<="),
//
// IN("IN"),
//
// LIKE("LIKE"),
//
// BETWEEN_AND("BETWEEN ? AND");
//
//
// public String value;
//
// MatchType(String value) {
// this.value = value;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/matcher/Matcher.java
// public abstract class Matcher {
//
// protected String column;
//
// public abstract MatchType getMatchType();
//
// public abstract Object[] getValues();
//
// public String getColumn() {
// return column;
// }
//
// protected String convertSpecialChar(String value, MatchType matchType) {
// String newValue = value;
//
// if(MatchType.LIKE == matchType) {
// newValue = newValue.replace("\\", "\\\\");
// newValue = newValue.replace("%", "\\%");
// newValue = newValue.replace("_", "\\_");
// }
// return newValue;
// }
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardHandler.java
// public interface TableShardHandler {
//
// public String getRealTableName(TableShardStrategy shardStrategy, Object... columnValues);
//
//
// }
//
// Path: src/main/java/pers/zr/opensource/magic/dao/shard/TableShardStrategy.java
// public class TableShardStrategy {
//
// private String shardTable;
//
// private int shardCount;
//
// private String[] shardColumns;
//
// private String separator;
//
// public TableShardStrategy(String shardTable, int shardCount, String[] shardColumns, String separator) {
// this.shardTable = shardTable;
// this.shardCount = shardCount;
// this.shardColumns = shardColumns;
// this.separator = separator;
// }
//
// public String getShardTable() {
// return shardTable;
// }
//
// public int getShardCount() {
// return shardCount;
// }
//
// public String[] getShardColumns() {
// return shardColumns;
// }
//
// public String getSeparator() {
// return separator;
// }
// }
// Path: src/main/java/pers/zr/opensource/magic/dao/action/Insert.java
import org.springframework.util.CollectionUtils;
import pers.zr.opensource.magic.dao.constants.ActionMode;
import pers.zr.opensource.magic.dao.constants.MatchType;
import pers.zr.opensource.magic.dao.matcher.Matcher;
import pers.zr.opensource.magic.dao.shard.TableShardHandler;
import pers.zr.opensource.magic.dao.shard.TableShardStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Override
public String getSql() {
if(null == this.sql) {
parse();
}
if (log.isDebugEnabled()) {
log.debug("### [ " + sql + "] ###");
}
return this.sql;
}
@Override
public Object[] getParams() {
if(null == this.params) {
parse();
}
return this.params;
}
@Override
public ActionMode getActionMode() {
return ActionMode.INSERT;
}
protected String getRealTableName() {
if(null == realTableName) {
//get actual table name when shard exist
TableShardStrategy tableShardStrategy = table.getTableShardStrategy(); | TableShardHandler tableShardHandler = table.getTableShardHandler(); |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/AbstractJob.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/function/BooleanSupplier.java
// @FunctionalInterface
// public interface BooleanSupplier {
//
// /**
// * Gets a result
// *
// * @return the function result as boolean
// */
// boolean get();
// }
| import androidx.annotation.NonNull;
import androidx.work.BackoffPolicy;
import androidx.work.Constraints;
import androidx.work.NetworkType;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkRequest;
import com.adguard.android.contentblocker.commons.function.BooleanSupplier;
import java.util.concurrent.TimeUnit; | /*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* <pre>
* Abstract job implementation for later use in other classes.
*
* <b>FOR DEVELOPERS</b>
* This is implementation for periodic jobs.
* If you want to implement one time job, you have to implement another AbstractOneTimeJob class and rename this class.</pre>
*/
abstract class AbstractJob implements Job {
/**
* For our backoff policy we're using 10 minutes as the start value
* Which is then increased according to the linear policy.
*/
private static final long DEFAULT_BACKOFF_PERIOD = TimeUnit.MINUTES.toSeconds(10);
private Id id; | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/function/BooleanSupplier.java
// @FunctionalInterface
// public interface BooleanSupplier {
//
// /**
// * Gets a result
// *
// * @return the function result as boolean
// */
// boolean get();
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/AbstractJob.java
import androidx.annotation.NonNull;
import androidx.work.BackoffPolicy;
import androidx.work.Constraints;
import androidx.work.NetworkType;
import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkRequest;
import com.adguard.android.contentblocker.commons.function.BooleanSupplier;
import java.util.concurrent.TimeUnit;
/*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* <pre>
* Abstract job implementation for later use in other classes.
*
* <b>FOR DEVELOPERS</b>
* This is implementation for periodic jobs.
* If you want to implement one time job, you have to implement another AbstractOneTimeJob class and rename this class.</pre>
*/
abstract class AbstractJob implements Job {
/**
* For our backoff policy we're using 10 minutes as the start value
* Which is then increased according to the linear policy.
*/
private static final long DEFAULT_BACKOFF_PERIOD = TimeUnit.MINUTES.toSeconds(10);
private Id id; | private BooleanSupplier jobRunner; |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/JobFactory.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
| import android.content.Context;
import com.adguard.android.contentblocker.ServiceLocator; | /*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* Factory for the creation of tasks.
*/
class JobFactory {
/**
* Gets instance of job for running.
*
* @param context context
* @param id id of job
* @return instance of {@link Job} or {@code null} if factory cannot create a job with same id
*/
static Job getJob(Context context, Id id) { | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/JobFactory.java
import android.content.Context;
import com.adguard.android.contentblocker.ServiceLocator;
/*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* Factory for the creation of tasks.
*/
class JobFactory {
/**
* Gets instance of job for running.
*
* @param context context
* @param id id of job
* @return instance of {@link Job} or {@code null} if factory cannot create a job with same id
*/
static Job getJob(Context context, Id id) { | return getJob(ServiceLocator.getInstance(context), id); |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/ui/NoBrowsersFoundActivity.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ui/utils/ActivityUtils.java
// public class ActivityUtils {
//
// /**
// * Formats a date into a datetime string.
// *
// * @param dateTime dateTime
// * @return the formatted time string
// */
// public static String formatDateTime(Context context, Date dateTime) {
// return formatDate(context, dateTime) + " " + formatTime(context, dateTime);
// }
//
// public static void startMarket(Context context, String packageName, String referrer) {
// String referrerParam = referrer != null ? "&referrer=" + referrer : "";
// try {
// NavigationHelper.openWebSite(context, Uri.parse("market://details?id=" + packageName + referrerParam));
// } catch (ActivityNotFoundException e) {
// NavigationHelper.openWebSite(context, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName + referrerParam));
// }
// }
//
// /**
// * Formats date string
// *
// * @param date Date
// * @return Formatted date
// */
// static String formatDate(Context context, Date date) {
// return DateUtils.formatDateTime(context, date.getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR);
// }
//
// /**
// * Formats date to time string
// *
// * @param time Time
// * @return Formatted time
// */
// static String formatTime(Context context, Date time) {
// return DateUtils.formatDateTime(context, time.getTime(), DateUtils.FORMAT_SHOW_TIME);
// }
//
// /**
// * Locks specified activity's orientation until it is unlocked or recreated.
// *
// * @param activity activity
// */
// static void lockOrientation(Activity activity) {
// Configuration config = activity.getResources().getConfiguration();
// final int deviceOrientation = config.orientation;
// int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
//
// int orientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
// if (deviceOrientation == Configuration.ORIENTATION_PORTRAIT) {
// orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
// if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_180)
// orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
// } else if (deviceOrientation == Configuration.ORIENTATION_LANDSCAPE) {
// orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
// if (rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270)
// orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
// }
//
// activity.setRequestedOrientation(orientation);
// }
//
// /**
// * Unlocks specified activity's orientation.
// *
// * @param activity activity
// */
// static void unlockOrientation(Activity activity) {
// activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
// }
// }
| import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.adguard.android.contentblocker.R;
import com.adguard.android.contentblocker.ui.utils.ActivityUtils; | /*
This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
Copyright © 2018 AdGuard Content Blocker. All rights reserved.
AdGuard Content Blocker 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.
AdGuard Content Blocker 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
AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.ui;
public class NoBrowsersFoundActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_no_browsers_found);
findViewById(R.id.install_samsung_browser).setOnClickListener(v -> { | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ui/utils/ActivityUtils.java
// public class ActivityUtils {
//
// /**
// * Formats a date into a datetime string.
// *
// * @param dateTime dateTime
// * @return the formatted time string
// */
// public static String formatDateTime(Context context, Date dateTime) {
// return formatDate(context, dateTime) + " " + formatTime(context, dateTime);
// }
//
// public static void startMarket(Context context, String packageName, String referrer) {
// String referrerParam = referrer != null ? "&referrer=" + referrer : "";
// try {
// NavigationHelper.openWebSite(context, Uri.parse("market://details?id=" + packageName + referrerParam));
// } catch (ActivityNotFoundException e) {
// NavigationHelper.openWebSite(context, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName + referrerParam));
// }
// }
//
// /**
// * Formats date string
// *
// * @param date Date
// * @return Formatted date
// */
// static String formatDate(Context context, Date date) {
// return DateUtils.formatDateTime(context, date.getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR);
// }
//
// /**
// * Formats date to time string
// *
// * @param time Time
// * @return Formatted time
// */
// static String formatTime(Context context, Date time) {
// return DateUtils.formatDateTime(context, time.getTime(), DateUtils.FORMAT_SHOW_TIME);
// }
//
// /**
// * Locks specified activity's orientation until it is unlocked or recreated.
// *
// * @param activity activity
// */
// static void lockOrientation(Activity activity) {
// Configuration config = activity.getResources().getConfiguration();
// final int deviceOrientation = config.orientation;
// int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
//
// int orientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
// if (deviceOrientation == Configuration.ORIENTATION_PORTRAIT) {
// orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
// if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_180)
// orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
// } else if (deviceOrientation == Configuration.ORIENTATION_LANDSCAPE) {
// orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
// if (rotation == Surface.ROTATION_180 || rotation == Surface.ROTATION_270)
// orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
// }
//
// activity.setRequestedOrientation(orientation);
// }
//
// /**
// * Unlocks specified activity's orientation.
// *
// * @param activity activity
// */
// static void unlockOrientation(Activity activity) {
// activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
// }
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ui/NoBrowsersFoundActivity.java
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.adguard.android.contentblocker.R;
import com.adguard.android.contentblocker.ui.utils.ActivityUtils;
/*
This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
Copyright © 2018 AdGuard Content Blocker. All rights reserved.
AdGuard Content Blocker 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.
AdGuard Content Blocker 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
AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.ui;
public class NoBrowsersFoundActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_no_browsers_found);
findViewById(R.id.install_samsung_browser).setOnClickListener(v -> { | ActivityUtils.startMarket(NoBrowsersFoundActivity.this, "com.sec.android.app.sbrowser", null); |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/Worker.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
| import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.WorkerParameters;
import com.adguard.android.contentblocker.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* Class that performs jobs scheduled by {@link JobService}.
*/
public class Worker extends androidx.work.Worker {
private static final Logger LOG = LoggerFactory.getLogger(Worker.class);
public Worker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
Id id = getIdByTag();
Job job = JobFactory.getJob(getApplicationContext(), id);
if (job != null) {
LOG.info("Job with tag {} running...", id.getTag());
boolean result = job.run();
LOG.info("Job with tag {} result is {}", id.getTag(), result);
if (!result) {
// Default backoff policy will be used (30 sec, exponential).
// See {@link WorkRequest#setBackoffCriteria} comment for
// more details on it.
return Result.retry();
}
} else {
LOG.warn("Job was not found and will be canceled. Tags: {}. Resolved id: {}.", getTags(), id); | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/Worker.java
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.WorkerParameters;
import com.adguard.android.contentblocker.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* Class that performs jobs scheduled by {@link JobService}.
*/
public class Worker extends androidx.work.Worker {
private static final Logger LOG = LoggerFactory.getLogger(Worker.class);
public Worker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
Id id = getIdByTag();
Job job = JobFactory.getJob(getApplicationContext(), id);
if (job != null) {
LOG.info("Job with tag {} running...", id.getTag());
boolean result = job.run();
LOG.info("Job with tag {} result is {}", id.getTag(), result);
if (!result) {
// Default backoff policy will be used (30 sec, exponential).
// See {@link WorkRequest#setBackoffCriteria} comment for
// more details on it.
return Result.retry();
}
} else {
LOG.warn("Job was not found and will be canceled. Tags: {}. Resolved id: {}.", getTags(), id); | ServiceLocator.getInstance(getApplicationContext()).getJobService().cancelJob(getId()); |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/web/UrlUtils.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/io/IoUtils.java
// public class IoUtils {
// private static final Logger LOG = LoggerFactory.getLogger(IoUtils.class);
// private static final int DOWNLOAD_LIMIT_SIZE = 5 * 1024 * 1024; // 5 MB
//
// /**
// * Closes a <code>Closeable</code> unconditionally.
// *
// * @param closeable the objects to close, may be null or already closed
// * @see Throwable#addSuppressed(java.lang.Throwable)
// */
// public static void closeQuietly(Closeable closeable) {
// try {
// if (closeable != null) {
// closeable.close();
// }
// } catch (final IOException ioe) {
// LOG.debug("Suppressing an error while closing a Closeable\n", ioe);
// }
// }
//
// /**
// * Reads input stream to end
// *
// * @param inputStream Input stream
// * @return Bytes being read
// * @throws IOException
// */
// public static byte[] readToEnd(InputStream inputStream) throws IOException {
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// IOUtils.copyLarge(inputStream, outputStream);
// return outputStream.toByteArray();
// }
//
// /**
// * Gets input stream from url
// *
// * @param context Application context
// * @param url Path to file
// * @return Input stream from uri
// * @throws IOException Thrown if we can not open input stream
// */
// public static InputStream getInputStreamFromUrl(Context context, String url) throws IOException {
// InputStream inputStream;
// if (StringUtils.startsWith(url, "content://")) {
// ContentResolver contentResolver = context.getContentResolver();
// inputStream = contentResolver.openInputStream(Uri.parse(url));
// } else if (StringUtils.startsWith(url, "file://")) {
// String path = StringUtils.substringAfter(url, ":/");
// inputStream = getFileInputStream(path);
// } else {
// inputStream = getFileInputStream(url);
// if (inputStream == null) {
// String content = UrlUtils.downloadString(url, DOWNLOAD_LIMIT_SIZE);
// if (StringUtils.isNotBlank(content)) {
// inputStream = new ByteArrayInputStream(content.getBytes());
// }
// }
// return inputStream;
// }
//
// checkInputStreamSize(inputStream);
// return inputStream != null ? new BufferedInputStream(inputStream) : null;
// }
//
//
// /**
// * Gets file input stream from url
// *
// * @param url File path
// * @return file input stream
// * @throws IOException If file cannot be read
// */
// private static InputStream getFileInputStream(String url) throws IOException {
// File f = new File(url);
// if (f.exists() && f.isFile() && f.canRead()) {
// return new FileInputStream(f);
// }
// return null;
// }
//
// /**
// * Checks that the size of the input stream has exceeded the limit
// * If the input stream exceeds the limit, throw an exception
// *
// * @param inputStream input stream
// */
// private static void checkInputStreamSize(InputStream inputStream) throws IOException {
// if (inputStream != null && inputStream.available() > DOWNLOAD_LIMIT_SIZE) {
// throw new IOException("The input stream exceeded the limit of " + DOWNLOAD_LIMIT_SIZE + " bytes");
// }
// }
// }
| import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import com.adguard.android.contentblocker.commons.io.IoUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.CountingInputStream;
import org.apache.commons.io.output.StringBuilderWriter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection; | }
CountingInputStream countingInputStream = new CountingInputStream(connection.getInputStream());
inputStream = countingInputStream;
if ("gzip".equals(connection.getHeaderField("Content-Encoding"))) {
inputStream = new GZIPInputStream(inputStream);
}
StringBuilderWriter stringBuilderWriter = new StringBuilderWriter();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, encoding);
char[] buffer = new char[READ_BUFFER_SIZE];
int readBytes;
while((readBytes = inputStreamReader.read(buffer)) != -1) {
if (limit != -1 && countingInputStream.getByteCount() > limit) {
throw new IOException("The response exceeded the limit of " + limit + " bytes");
}
stringBuilderWriter.write(buffer, 0, readBytes);
}
return stringBuilderWriter.toString();
} catch (IOException ex) {
if (LOG.isDebugEnabled()) {
LOG.warn("Error downloading string from {}:\r\n", url, ex);
} else {
LOG.warn("Cannot download string from {}: {}", url, ex.getMessage());
}
// Ignoring exception
return null;
} finally { | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/io/IoUtils.java
// public class IoUtils {
// private static final Logger LOG = LoggerFactory.getLogger(IoUtils.class);
// private static final int DOWNLOAD_LIMIT_SIZE = 5 * 1024 * 1024; // 5 MB
//
// /**
// * Closes a <code>Closeable</code> unconditionally.
// *
// * @param closeable the objects to close, may be null or already closed
// * @see Throwable#addSuppressed(java.lang.Throwable)
// */
// public static void closeQuietly(Closeable closeable) {
// try {
// if (closeable != null) {
// closeable.close();
// }
// } catch (final IOException ioe) {
// LOG.debug("Suppressing an error while closing a Closeable\n", ioe);
// }
// }
//
// /**
// * Reads input stream to end
// *
// * @param inputStream Input stream
// * @return Bytes being read
// * @throws IOException
// */
// public static byte[] readToEnd(InputStream inputStream) throws IOException {
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// IOUtils.copyLarge(inputStream, outputStream);
// return outputStream.toByteArray();
// }
//
// /**
// * Gets input stream from url
// *
// * @param context Application context
// * @param url Path to file
// * @return Input stream from uri
// * @throws IOException Thrown if we can not open input stream
// */
// public static InputStream getInputStreamFromUrl(Context context, String url) throws IOException {
// InputStream inputStream;
// if (StringUtils.startsWith(url, "content://")) {
// ContentResolver contentResolver = context.getContentResolver();
// inputStream = contentResolver.openInputStream(Uri.parse(url));
// } else if (StringUtils.startsWith(url, "file://")) {
// String path = StringUtils.substringAfter(url, ":/");
// inputStream = getFileInputStream(path);
// } else {
// inputStream = getFileInputStream(url);
// if (inputStream == null) {
// String content = UrlUtils.downloadString(url, DOWNLOAD_LIMIT_SIZE);
// if (StringUtils.isNotBlank(content)) {
// inputStream = new ByteArrayInputStream(content.getBytes());
// }
// }
// return inputStream;
// }
//
// checkInputStreamSize(inputStream);
// return inputStream != null ? new BufferedInputStream(inputStream) : null;
// }
//
//
// /**
// * Gets file input stream from url
// *
// * @param url File path
// * @return file input stream
// * @throws IOException If file cannot be read
// */
// private static InputStream getFileInputStream(String url) throws IOException {
// File f = new File(url);
// if (f.exists() && f.isFile() && f.canRead()) {
// return new FileInputStream(f);
// }
// return null;
// }
//
// /**
// * Checks that the size of the input stream has exceeded the limit
// * If the input stream exceeds the limit, throw an exception
// *
// * @param inputStream input stream
// */
// private static void checkInputStreamSize(InputStream inputStream) throws IOException {
// if (inputStream != null && inputStream.available() > DOWNLOAD_LIMIT_SIZE) {
// throw new IOException("The input stream exceeded the limit of " + DOWNLOAD_LIMIT_SIZE + " bytes");
// }
// }
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/web/UrlUtils.java
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import com.adguard.android.contentblocker.commons.io.IoUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.CountingInputStream;
import org.apache.commons.io.output.StringBuilderWriter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
}
CountingInputStream countingInputStream = new CountingInputStream(connection.getInputStream());
inputStream = countingInputStream;
if ("gzip".equals(connection.getHeaderField("Content-Encoding"))) {
inputStream = new GZIPInputStream(inputStream);
}
StringBuilderWriter stringBuilderWriter = new StringBuilderWriter();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, encoding);
char[] buffer = new char[READ_BUFFER_SIZE];
int readBytes;
while((readBytes = inputStreamReader.read(buffer)) != -1) {
if (limit != -1 && countingInputStream.getByteCount() > limit) {
throw new IOException("The response exceeded the limit of " + limit + " bytes");
}
stringBuilderWriter.write(buffer, 0, readBytes);
}
return stringBuilderWriter.toString();
} catch (IOException ex) {
if (LOG.isDebugEnabled()) {
LOG.warn("Error downloading string from {}:\r\n", url, ex);
} else {
LOG.warn("Cannot download string from {}: {}", url, ex.getMessage());
}
// Ignoring exception
return null;
} finally { | IoUtils.closeQuietly(inputStream); |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/model/FilterList.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/ProductVersion.java
// @SuppressWarnings("UnusedDeclaration")
// public class ProductVersion implements Comparable<ProductVersion> {
//
// private final static int MAX_VERSION = 100;
// private int major;
// private int minor;
// private int revision;
// private int build;
//
// public ProductVersion() {
// }
//
// public ProductVersion(int major, int minor, int revision, int build) {
// this.major = major;
// this.minor = minor;
// this.revision = revision;
// this.build = build;
// }
//
// public ProductVersion(String version) {
// if (StringUtils.isEmpty(version)) {
// return;
// }
//
// String[] parts = StringUtils.split(version, ".");
//
// if (parts.length >= 4) {
// build = parseVersionPart(parts[3]);
// }
// if (parts.length >= 3) {
// revision = parseVersionPart(parts[2]);
// }
// if (parts.length >= 2) {
// minor = parseVersionPart(parts[1]);
// }
// if (parts.length >= 1) {
// major = parseVersionPart(parts[0]);
// }
// }
//
// private static int parseVersionPart(String part) {
// int versionPart = NumberUtils.toInt(part, 0);
// if (versionPart < 0) {
// versionPart = 0;
// }
// return versionPart;
// }
//
// /**
// * Increments product version
// */
// public void increment() {
// setBuild(getBuild() + 1);
// if (getBuild() >= MAX_VERSION) {
// setRevision(getRevision() + 1);
// setBuild(0);
// if (getRevision() >= MAX_VERSION) {
// setMinor(getMinor() + 1);
// setRevision(0);
// if (getMinor() >= MAX_VERSION) {
// setMajor(getMajor() + 1);
// setMinor(0);
// }
// }
// }
// }
//
// public int getMajor() {
// return major;
// }
//
// public void setMajor(int major) {
// this.major = major;
// }
//
// public int getMinor() {
// return minor;
// }
//
// public void setMinor(int minor) {
// this.minor = minor;
// }
//
// public int getRevision() {
// return revision;
// }
//
// public void setRevision(int revision) {
// this.revision = revision;
// }
//
// public int getBuild() {
// return build;
// }
//
// public void setBuild(int build) {
// this.build = build;
// }
//
// public String getShortVersionString() {
// return major + "." + minor;
// }
//
// public String getShortWithRevisionString() {
// return major + "." + minor + "." + revision;
// }
//
// public String getLongVersionString() {
// return major + "." + minor + "." + revision + "." + build;
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(major);
// sb.append(".");
// sb.append(minor);
// if (revision > 0 || build > 0) {
// sb.append(".");
// sb.append(revision);
// }
// if (build > 0) {
// sb.append(".");
// sb.append(build);
// }
// return sb.toString();
// }
//
// @Override
// public int compareTo(ProductVersion o) {
// if (getMajor() > o.getMajor()) {
// return 1;
// } else if (getMajor() < o.getMajor()) {
// return -1;
// }
//
// if (getMinor() > o.getMinor()) {
// return 1;
// } else if (getMinor() < o.getMinor()) {
// return -1;
// }
//
// if (getRevision() > o.getRevision()) {
// return 1;
// } else if (getRevision() < o.getRevision()) {
// return -1;
// }
//
// if (getBuild() > o.getBuild()) {
// return 1;
// } else if (getBuild() < o.getBuild()) {
// return -1;
// }
//
// return 0;
// }
// }
| import com.adguard.android.contentblocker.commons.ProductVersion;
import java.util.Date; | * @return Filter description
*/
public String getDescription() {
return description;
}
/**
* @param description Filter description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return true if filter is enabled
*/
public boolean isEnabled() {
return enabled;
}
/**
* @param enabled true if filter is enabled
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* @return Filter version
*/ | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/ProductVersion.java
// @SuppressWarnings("UnusedDeclaration")
// public class ProductVersion implements Comparable<ProductVersion> {
//
// private final static int MAX_VERSION = 100;
// private int major;
// private int minor;
// private int revision;
// private int build;
//
// public ProductVersion() {
// }
//
// public ProductVersion(int major, int minor, int revision, int build) {
// this.major = major;
// this.minor = minor;
// this.revision = revision;
// this.build = build;
// }
//
// public ProductVersion(String version) {
// if (StringUtils.isEmpty(version)) {
// return;
// }
//
// String[] parts = StringUtils.split(version, ".");
//
// if (parts.length >= 4) {
// build = parseVersionPart(parts[3]);
// }
// if (parts.length >= 3) {
// revision = parseVersionPart(parts[2]);
// }
// if (parts.length >= 2) {
// minor = parseVersionPart(parts[1]);
// }
// if (parts.length >= 1) {
// major = parseVersionPart(parts[0]);
// }
// }
//
// private static int parseVersionPart(String part) {
// int versionPart = NumberUtils.toInt(part, 0);
// if (versionPart < 0) {
// versionPart = 0;
// }
// return versionPart;
// }
//
// /**
// * Increments product version
// */
// public void increment() {
// setBuild(getBuild() + 1);
// if (getBuild() >= MAX_VERSION) {
// setRevision(getRevision() + 1);
// setBuild(0);
// if (getRevision() >= MAX_VERSION) {
// setMinor(getMinor() + 1);
// setRevision(0);
// if (getMinor() >= MAX_VERSION) {
// setMajor(getMajor() + 1);
// setMinor(0);
// }
// }
// }
// }
//
// public int getMajor() {
// return major;
// }
//
// public void setMajor(int major) {
// this.major = major;
// }
//
// public int getMinor() {
// return minor;
// }
//
// public void setMinor(int minor) {
// this.minor = minor;
// }
//
// public int getRevision() {
// return revision;
// }
//
// public void setRevision(int revision) {
// this.revision = revision;
// }
//
// public int getBuild() {
// return build;
// }
//
// public void setBuild(int build) {
// this.build = build;
// }
//
// public String getShortVersionString() {
// return major + "." + minor;
// }
//
// public String getShortWithRevisionString() {
// return major + "." + minor + "." + revision;
// }
//
// public String getLongVersionString() {
// return major + "." + minor + "." + revision + "." + build;
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append(major);
// sb.append(".");
// sb.append(minor);
// if (revision > 0 || build > 0) {
// sb.append(".");
// sb.append(revision);
// }
// if (build > 0) {
// sb.append(".");
// sb.append(build);
// }
// return sb.toString();
// }
//
// @Override
// public int compareTo(ProductVersion o) {
// if (getMajor() > o.getMajor()) {
// return 1;
// } else if (getMajor() < o.getMajor()) {
// return -1;
// }
//
// if (getMinor() > o.getMinor()) {
// return 1;
// } else if (getMinor() < o.getMinor()) {
// return -1;
// }
//
// if (getRevision() > o.getRevision()) {
// return 1;
// } else if (getRevision() < o.getRevision()) {
// return -1;
// }
//
// if (getBuild() > o.getBuild()) {
// return 1;
// } else if (getBuild() < o.getBuild()) {
// return -1;
// }
//
// return 0;
// }
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/model/FilterList.java
import com.adguard.android.contentblocker.commons.ProductVersion;
import java.util.Date;
* @return Filter description
*/
public String getDescription() {
return description;
}
/**
* @param description Filter description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return true if filter is enabled
*/
public boolean isEnabled() {
return enabled;
}
/**
* @param enabled true if filter is enabled
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* @return Filter version
*/ | public ProductVersion getVersion() { |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/service/LongRunningTask.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
//
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ui/utils/ProgressDialogUtils.java
// public class ProgressDialogUtils {
//
// /**
// * Shows progress dialog and locks activity orientation change.
// *
// * @param activity requester activity
// * @param titleResourceId progress dialog title resource id
// * @param messageResourceId progress dialog message resource id
// * @return progress dialog
// */
// public static ProgressDialog showProgressDialog(Activity activity, int titleResourceId, int messageResourceId) {
// if (activity == null) {
// return null;
// }
//
// ActivityUtils.lockOrientation(activity);
//
// ProgressDialog progressDialog = ProgressDialog.show(
// activity,
// titleResourceId > 0? activity.getString(titleResourceId) : null,
// activity.getString(messageResourceId),
// false,
// false);
// progressDialog.setOwnerActivity(activity);
//
// return progressDialog;
// }
//
// /**
// * Dismiss provided progress dialog and then unlocks activity orientation change.
// *
// * @param progressDialog progress dialog
// */
// public static void dismissProgressDialog(final ProgressDialog progressDialog) {
// //http://jira.performix.ru/browse/AG-6026
// try {
// if (progressDialog != null && progressDialog.isShowing()
// && !progressDialog.getOwnerActivity().isChangingConfigurations()
// && !progressDialog.getOwnerActivity().isFinishing()) {
// progressDialog.dismiss();
//
// ActivityUtils.unlockOrientation(progressDialog.getOwnerActivity());
// }
// } catch (Exception e) {
// //Ignore
// }
// }
// }
//
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/concurrent/DispatcherTask.java
// public interface DispatcherTask {
//
// void execute() throws Exception;
// }
| import android.app.Activity;
import android.app.ProgressDialog;
import com.adguard.android.contentblocker.R;
import com.adguard.android.contentblocker.ServiceLocator;
import com.adguard.android.contentblocker.ui.utils.ProgressDialogUtils;
import com.adguard.android.contentblocker.commons.concurrent.DispatcherTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | } catch (Exception ex) {
dismissProgressDialogOnError(progressDialog, ex);
} finally {
dismissProgressDialog(progressDialog);
LOG.info("Finished task {} execution", this.getClass().getSimpleName());
}
}
/**
* Dismisses progress dialog
*
* @param progressDialog Progress dialog to dismiss
*/
private void dismissProgressDialog(final ProgressDialog progressDialog) {
ProgressDialogUtils.dismissProgressDialog(progressDialog);
}
/**
* Dismisses progress dialog and shows generic error message
*
* @param progressDialog Progress dialog
*/
private void dismissProgressDialogOnError(ProgressDialog progressDialog, Exception ex) {
LOG.warn("Dismissing progress dialog on error:\r\n", ex);
Activity ownerActivity = progressDialog.getOwnerActivity();
if (ownerActivity == null) {
return;
}
| // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
//
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ui/utils/ProgressDialogUtils.java
// public class ProgressDialogUtils {
//
// /**
// * Shows progress dialog and locks activity orientation change.
// *
// * @param activity requester activity
// * @param titleResourceId progress dialog title resource id
// * @param messageResourceId progress dialog message resource id
// * @return progress dialog
// */
// public static ProgressDialog showProgressDialog(Activity activity, int titleResourceId, int messageResourceId) {
// if (activity == null) {
// return null;
// }
//
// ActivityUtils.lockOrientation(activity);
//
// ProgressDialog progressDialog = ProgressDialog.show(
// activity,
// titleResourceId > 0? activity.getString(titleResourceId) : null,
// activity.getString(messageResourceId),
// false,
// false);
// progressDialog.setOwnerActivity(activity);
//
// return progressDialog;
// }
//
// /**
// * Dismiss provided progress dialog and then unlocks activity orientation change.
// *
// * @param progressDialog progress dialog
// */
// public static void dismissProgressDialog(final ProgressDialog progressDialog) {
// //http://jira.performix.ru/browse/AG-6026
// try {
// if (progressDialog != null && progressDialog.isShowing()
// && !progressDialog.getOwnerActivity().isChangingConfigurations()
// && !progressDialog.getOwnerActivity().isFinishing()) {
// progressDialog.dismiss();
//
// ActivityUtils.unlockOrientation(progressDialog.getOwnerActivity());
// }
// } catch (Exception e) {
// //Ignore
// }
// }
// }
//
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/commons/concurrent/DispatcherTask.java
// public interface DispatcherTask {
//
// void execute() throws Exception;
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/service/LongRunningTask.java
import android.app.Activity;
import android.app.ProgressDialog;
import com.adguard.android.contentblocker.R;
import com.adguard.android.contentblocker.ServiceLocator;
import com.adguard.android.contentblocker.ui.utils.ProgressDialogUtils;
import com.adguard.android.contentblocker.commons.concurrent.DispatcherTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
} catch (Exception ex) {
dismissProgressDialogOnError(progressDialog, ex);
} finally {
dismissProgressDialog(progressDialog);
LOG.info("Finished task {} execution", this.getClass().getSimpleName());
}
}
/**
* Dismisses progress dialog
*
* @param progressDialog Progress dialog to dismiss
*/
private void dismissProgressDialog(final ProgressDialog progressDialog) {
ProgressDialogUtils.dismissProgressDialog(progressDialog);
}
/**
* Dismisses progress dialog and shows generic error message
*
* @param progressDialog Progress dialog
*/
private void dismissProgressDialogOnError(ProgressDialog progressDialog, Exception ex) {
LOG.warn("Dismissing progress dialog on error:\r\n", ex);
Activity ownerActivity = progressDialog.getOwnerActivity();
if (ownerActivity == null) {
return;
}
| NotificationService notificationService = ServiceLocator.getInstance(ownerActivity).getNotificationService(); |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/receiver/BootUpReceiver.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
| import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.adguard.android.contentblocker.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2018 AdGuard Content Blocker. All rights reserved.
* <p>
* AdGuard Content Blocker 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.
* <p>
* AdGuard Content Blocker 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.
* <p>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.receiver;
/**
* Boot up receiver class.
* Used to receive a boot completed call back and start filters update scheduler
*/
public class BootUpReceiver extends BroadcastReceiver {
private final static Logger LOG = LoggerFactory.getLogger(BootUpReceiver.class);
private final static String ACTION_QUICK_BOOT = "android.intent.action.QUICKBOOT_POWERON";
private final static String ACTION_QUICK_BOOT_HTC = "com.htc.intent.action.QUICKBOOT_POWERON";
@Override
public void onReceive(Context context, Intent intent) {
LOG.info("Receiver got an action {}", intent.getAction());
if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) &&
!ACTION_QUICK_BOOT.equals(intent.getAction()) &&
!ACTION_QUICK_BOOT_HTC.equals(intent.getAction())) {
return;
}
// We initialize service locator to do default actions inside its constructor | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/receiver/BootUpReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.adguard.android.contentblocker.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2018 AdGuard Content Blocker. All rights reserved.
* <p>
* AdGuard Content Blocker 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.
* <p>
* AdGuard Content Blocker 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.
* <p>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.receiver;
/**
* Boot up receiver class.
* Used to receive a boot completed call back and start filters update scheduler
*/
public class BootUpReceiver extends BroadcastReceiver {
private final static Logger LOG = LoggerFactory.getLogger(BootUpReceiver.class);
private final static String ACTION_QUICK_BOOT = "android.intent.action.QUICKBOOT_POWERON";
private final static String ACTION_QUICK_BOOT_HTC = "com.htc.intent.action.QUICKBOOT_POWERON";
@Override
public void onReceive(Context context, Intent intent) {
LOG.info("Receiver got an action {}", intent.getAction());
if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) &&
!ACTION_QUICK_BOOT.equals(intent.getAction()) &&
!ACTION_QUICK_BOOT_HTC.equals(intent.getAction())) {
return;
}
// We initialize service locator to do default actions inside its constructor | ServiceLocator.getInstance(context); |
AdguardTeam/ContentBlocker | adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/JobServiceImpl.java | // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.WorkInfo;
import androidx.work.WorkManager;
import com.adguard.android.contentblocker.BuildConfig;
import com.adguard.android.contentblocker.ServiceLocator;
import com.google.common.util.concurrent.ListenableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.ref.WeakReference; | /*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* Implementation of {@link JobService}.
*/
public class JobServiceImpl implements JobService {
private static final Logger LOG = LoggerFactory.getLogger(JobServiceImpl.class);
| // Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/ServiceLocator.java
// public class ServiceLocator {
// private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
// private static WeakHashMap<Context, ServiceLocator> locators = new WeakHashMap<>();
//
// private FilterService filterService;
// private PreferencesService preferencesService;
// private NotificationService notificationService;
// private JobService jobService;
//
// /**
// * Creates an instance of the ServiceLocator
// *
// * @param context Context
// */
// private ServiceLocator(Context context) {
// LOG.info("Initializing ServiceLocator for {}", context);
// preferencesService = new PreferencesServiceImpl(context);
// notificationService = new NotificationServiceImpl(context);
// filterService = new FilterServiceImpl(context, new DbHelper(context), preferencesService, notificationService);
// jobService = new JobServiceImpl(this, context);
//
// LOG.info("ServiceLocator setup...");
// checkFirstLaunch();
// jobService.cancelOldJobs();
// jobService.scheduleJobs(Id.FILTERS, Id.RATE_NOTIFICATION);
// }
//
// /**
// * Gets service locator instance
// *
// * @param context Context
// * @return ServiceLocator instance
// */
// public synchronized static ServiceLocator getInstance(Context context) {
// Context applicationContext = context.getApplicationContext();
// if (applicationContext == null) {
// applicationContext = context;
// }
// ServiceLocator instance = locators.get(applicationContext);
//
// if (instance == null) {
// instance = new ServiceLocator(applicationContext);
// locators.put(applicationContext, instance);
// }
//
// return instance;
// }
//
// /**
// * @return Filter service reference
// */
// public FilterService getFilterService() {
// return filterService;
// }
//
// /**
// * @return Preferences service reference
// */
// public PreferencesService getPreferencesService() {
// return preferencesService;
// }
//
// /**
// * @return notifications service reference
// */
// public NotificationService getNotificationService() {
// return notificationService;
// }
//
// /**
// * @return job service reference
// */
// public JobService getJobService() {
// return jobService;
// }
//
// private void checkFirstLaunch() {
// if (preferencesService.getInstallationTime() == 0L) {
// // It's first launch. We need to set installation time to current
// preferencesService.setInstallationTime(System.currentTimeMillis());
// }
// }
// }
// Path: adguard_cb/src/main/java/com/adguard/android/contentblocker/service/job/JobServiceImpl.java
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.WorkInfo;
import androidx.work.WorkManager;
import com.adguard.android.contentblocker.BuildConfig;
import com.adguard.android.contentblocker.ServiceLocator;
import com.google.common.util.concurrent.ListenableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.ref.WeakReference;
/*
* This file is part of AdGuard Content Blocker (https://github.com/AdguardTeam/ContentBlocker).
* Copyright © 2019 AdGuard Content Blocker. All rights reserved.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* AdGuard Content Blocker 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.
* <p/>
* You should have received a copy of the GNU General Public License along with
* AdGuard Content Blocker. If not, see <http://www.gnu.org/licenses/>.
*/
package com.adguard.android.contentblocker.service.job;
/**
* Implementation of {@link JobService}.
*/
public class JobServiceImpl implements JobService {
private static final Logger LOG = LoggerFactory.getLogger(JobServiceImpl.class);
| private WeakReference<ServiceLocator> serviceLocatorRef; |
Zoey76/L2J_LoginServer | src/main/java/com/l2jserver/login/network/clientpackets/AuthGameGuard.java | // Path: src/main/java/com/l2jserver/login/network/L2LoginClient.java
// public static enum LoginClientState
// {
// CONNECTED,
// AUTHED_GG,
// AUTHED_LOGIN
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/GGAuth.java
// public final class GGAuth extends L2LoginServerPacket
// {
// static final Logger _log = Logger.getLogger(GGAuth.class.getName());
// public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
//
// private final int _response;
//
// public GGAuth(int response)
// {
// _response = response;
// if (Config.DEBUG)
// {
// _log.warning("Reason Hex: " + (Integer.toHexString(response)));
// }
// }
//
// @Override
// protected void write()
// {
// writeC(0x0b);
// writeD(_response);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// }
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/LoginFail.java
// public static enum LoginFailReason
// {
// REASON_NO_MESSAGE(0x00),
// REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
// REASON_USER_OR_PASS_WRONG(0x02),
// REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
// REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
// REASON_ACCOUNT_IN_USE(0x07),
// REASON_UNDER_18_YEARS_KR(0x0C),
// REASON_SERVER_OVERLOADED(0x0F),
// REASON_SERVER_MAINTENANCE(0x10),
// REASON_TEMP_PASS_EXPIRED(0x11),
// REASON_GAME_TIME_EXPIRED(0x12),
// REASON_NO_TIME_LEFT(0x13),
// REASON_SYSTEM_ERROR(0x14),
// REASON_ACCESS_FAILED(0x15),
// REASON_RESTRICTED_IP(0x16),
// REASON_WEEK_USAGE_FINISHED(0x1E),
// REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
// REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
// REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
// REASON_DUAL_BOX(0x23),
// REASON_INACTIVE(0x24),
// REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
// REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
// REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
// REASON_ACCOUNT_SUSPENDED_CALL(0x28),
// REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
// REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
// REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
// REASON_CERTIFICATION_FAILED(0x2E),
// REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
// REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
// REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
// REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
// REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
// REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
// REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
// REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
// REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
// REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
//
// private final int _code;
//
// LoginFailReason(int code)
// {
// _code = code;
// }
//
// public final int getCode()
// {
// return _code;
// }
// }
| import com.l2jserver.login.network.L2LoginClient.LoginClientState;
import com.l2jserver.login.network.serverpackets.GGAuth;
import com.l2jserver.login.network.serverpackets.LoginFail.LoginFailReason;
| public int getData3()
{
return _data3;
}
public int getData4()
{
return _data4;
}
@Override
protected boolean readImpl()
{
if (super._buf.remaining() >= 20)
{
_sessionId = readD();
_data1 = readD();
_data2 = readD();
_data3 = readD();
_data4 = readD();
return true;
}
return false;
}
@Override
public void run()
{
if (_sessionId == getClient().getSessionId())
{
| // Path: src/main/java/com/l2jserver/login/network/L2LoginClient.java
// public static enum LoginClientState
// {
// CONNECTED,
// AUTHED_GG,
// AUTHED_LOGIN
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/GGAuth.java
// public final class GGAuth extends L2LoginServerPacket
// {
// static final Logger _log = Logger.getLogger(GGAuth.class.getName());
// public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
//
// private final int _response;
//
// public GGAuth(int response)
// {
// _response = response;
// if (Config.DEBUG)
// {
// _log.warning("Reason Hex: " + (Integer.toHexString(response)));
// }
// }
//
// @Override
// protected void write()
// {
// writeC(0x0b);
// writeD(_response);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// }
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/LoginFail.java
// public static enum LoginFailReason
// {
// REASON_NO_MESSAGE(0x00),
// REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
// REASON_USER_OR_PASS_WRONG(0x02),
// REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
// REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
// REASON_ACCOUNT_IN_USE(0x07),
// REASON_UNDER_18_YEARS_KR(0x0C),
// REASON_SERVER_OVERLOADED(0x0F),
// REASON_SERVER_MAINTENANCE(0x10),
// REASON_TEMP_PASS_EXPIRED(0x11),
// REASON_GAME_TIME_EXPIRED(0x12),
// REASON_NO_TIME_LEFT(0x13),
// REASON_SYSTEM_ERROR(0x14),
// REASON_ACCESS_FAILED(0x15),
// REASON_RESTRICTED_IP(0x16),
// REASON_WEEK_USAGE_FINISHED(0x1E),
// REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
// REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
// REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
// REASON_DUAL_BOX(0x23),
// REASON_INACTIVE(0x24),
// REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
// REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
// REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
// REASON_ACCOUNT_SUSPENDED_CALL(0x28),
// REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
// REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
// REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
// REASON_CERTIFICATION_FAILED(0x2E),
// REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
// REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
// REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
// REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
// REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
// REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
// REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
// REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
// REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
// REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
//
// private final int _code;
//
// LoginFailReason(int code)
// {
// _code = code;
// }
//
// public final int getCode()
// {
// return _code;
// }
// }
// Path: src/main/java/com/l2jserver/login/network/clientpackets/AuthGameGuard.java
import com.l2jserver.login.network.L2LoginClient.LoginClientState;
import com.l2jserver.login.network.serverpackets.GGAuth;
import com.l2jserver.login.network.serverpackets.LoginFail.LoginFailReason;
public int getData3()
{
return _data3;
}
public int getData4()
{
return _data4;
}
@Override
protected boolean readImpl()
{
if (super._buf.remaining() >= 20)
{
_sessionId = readD();
_data1 = readD();
_data2 = readD();
_data3 = readD();
_data4 = readD();
return true;
}
return false;
}
@Override
public void run()
{
if (_sessionId == getClient().getSessionId())
{
| getClient().setState(LoginClientState.AUTHED_GG);
|
Zoey76/L2J_LoginServer | src/main/java/com/l2jserver/login/network/clientpackets/AuthGameGuard.java | // Path: src/main/java/com/l2jserver/login/network/L2LoginClient.java
// public static enum LoginClientState
// {
// CONNECTED,
// AUTHED_GG,
// AUTHED_LOGIN
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/GGAuth.java
// public final class GGAuth extends L2LoginServerPacket
// {
// static final Logger _log = Logger.getLogger(GGAuth.class.getName());
// public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
//
// private final int _response;
//
// public GGAuth(int response)
// {
// _response = response;
// if (Config.DEBUG)
// {
// _log.warning("Reason Hex: " + (Integer.toHexString(response)));
// }
// }
//
// @Override
// protected void write()
// {
// writeC(0x0b);
// writeD(_response);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// }
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/LoginFail.java
// public static enum LoginFailReason
// {
// REASON_NO_MESSAGE(0x00),
// REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
// REASON_USER_OR_PASS_WRONG(0x02),
// REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
// REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
// REASON_ACCOUNT_IN_USE(0x07),
// REASON_UNDER_18_YEARS_KR(0x0C),
// REASON_SERVER_OVERLOADED(0x0F),
// REASON_SERVER_MAINTENANCE(0x10),
// REASON_TEMP_PASS_EXPIRED(0x11),
// REASON_GAME_TIME_EXPIRED(0x12),
// REASON_NO_TIME_LEFT(0x13),
// REASON_SYSTEM_ERROR(0x14),
// REASON_ACCESS_FAILED(0x15),
// REASON_RESTRICTED_IP(0x16),
// REASON_WEEK_USAGE_FINISHED(0x1E),
// REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
// REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
// REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
// REASON_DUAL_BOX(0x23),
// REASON_INACTIVE(0x24),
// REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
// REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
// REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
// REASON_ACCOUNT_SUSPENDED_CALL(0x28),
// REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
// REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
// REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
// REASON_CERTIFICATION_FAILED(0x2E),
// REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
// REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
// REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
// REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
// REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
// REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
// REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
// REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
// REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
// REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
//
// private final int _code;
//
// LoginFailReason(int code)
// {
// _code = code;
// }
//
// public final int getCode()
// {
// return _code;
// }
// }
| import com.l2jserver.login.network.L2LoginClient.LoginClientState;
import com.l2jserver.login.network.serverpackets.GGAuth;
import com.l2jserver.login.network.serverpackets.LoginFail.LoginFailReason;
| {
return _data3;
}
public int getData4()
{
return _data4;
}
@Override
protected boolean readImpl()
{
if (super._buf.remaining() >= 20)
{
_sessionId = readD();
_data1 = readD();
_data2 = readD();
_data3 = readD();
_data4 = readD();
return true;
}
return false;
}
@Override
public void run()
{
if (_sessionId == getClient().getSessionId())
{
getClient().setState(LoginClientState.AUTHED_GG);
| // Path: src/main/java/com/l2jserver/login/network/L2LoginClient.java
// public static enum LoginClientState
// {
// CONNECTED,
// AUTHED_GG,
// AUTHED_LOGIN
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/GGAuth.java
// public final class GGAuth extends L2LoginServerPacket
// {
// static final Logger _log = Logger.getLogger(GGAuth.class.getName());
// public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
//
// private final int _response;
//
// public GGAuth(int response)
// {
// _response = response;
// if (Config.DEBUG)
// {
// _log.warning("Reason Hex: " + (Integer.toHexString(response)));
// }
// }
//
// @Override
// protected void write()
// {
// writeC(0x0b);
// writeD(_response);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// }
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/LoginFail.java
// public static enum LoginFailReason
// {
// REASON_NO_MESSAGE(0x00),
// REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
// REASON_USER_OR_PASS_WRONG(0x02),
// REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
// REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
// REASON_ACCOUNT_IN_USE(0x07),
// REASON_UNDER_18_YEARS_KR(0x0C),
// REASON_SERVER_OVERLOADED(0x0F),
// REASON_SERVER_MAINTENANCE(0x10),
// REASON_TEMP_PASS_EXPIRED(0x11),
// REASON_GAME_TIME_EXPIRED(0x12),
// REASON_NO_TIME_LEFT(0x13),
// REASON_SYSTEM_ERROR(0x14),
// REASON_ACCESS_FAILED(0x15),
// REASON_RESTRICTED_IP(0x16),
// REASON_WEEK_USAGE_FINISHED(0x1E),
// REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
// REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
// REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
// REASON_DUAL_BOX(0x23),
// REASON_INACTIVE(0x24),
// REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
// REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
// REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
// REASON_ACCOUNT_SUSPENDED_CALL(0x28),
// REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
// REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
// REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
// REASON_CERTIFICATION_FAILED(0x2E),
// REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
// REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
// REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
// REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
// REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
// REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
// REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
// REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
// REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
// REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
//
// private final int _code;
//
// LoginFailReason(int code)
// {
// _code = code;
// }
//
// public final int getCode()
// {
// return _code;
// }
// }
// Path: src/main/java/com/l2jserver/login/network/clientpackets/AuthGameGuard.java
import com.l2jserver.login.network.L2LoginClient.LoginClientState;
import com.l2jserver.login.network.serverpackets.GGAuth;
import com.l2jserver.login.network.serverpackets.LoginFail.LoginFailReason;
{
return _data3;
}
public int getData4()
{
return _data4;
}
@Override
protected boolean readImpl()
{
if (super._buf.remaining() >= 20)
{
_sessionId = readD();
_data1 = readD();
_data2 = readD();
_data3 = readD();
_data4 = readD();
return true;
}
return false;
}
@Override
public void run()
{
if (_sessionId == getClient().getSessionId())
{
getClient().setState(LoginClientState.AUTHED_GG);
| getClient().sendPacket(new GGAuth(getClient().getSessionId()));
|
Zoey76/L2J_LoginServer | src/main/java/com/l2jserver/login/network/clientpackets/AuthGameGuard.java | // Path: src/main/java/com/l2jserver/login/network/L2LoginClient.java
// public static enum LoginClientState
// {
// CONNECTED,
// AUTHED_GG,
// AUTHED_LOGIN
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/GGAuth.java
// public final class GGAuth extends L2LoginServerPacket
// {
// static final Logger _log = Logger.getLogger(GGAuth.class.getName());
// public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
//
// private final int _response;
//
// public GGAuth(int response)
// {
// _response = response;
// if (Config.DEBUG)
// {
// _log.warning("Reason Hex: " + (Integer.toHexString(response)));
// }
// }
//
// @Override
// protected void write()
// {
// writeC(0x0b);
// writeD(_response);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// }
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/LoginFail.java
// public static enum LoginFailReason
// {
// REASON_NO_MESSAGE(0x00),
// REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
// REASON_USER_OR_PASS_WRONG(0x02),
// REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
// REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
// REASON_ACCOUNT_IN_USE(0x07),
// REASON_UNDER_18_YEARS_KR(0x0C),
// REASON_SERVER_OVERLOADED(0x0F),
// REASON_SERVER_MAINTENANCE(0x10),
// REASON_TEMP_PASS_EXPIRED(0x11),
// REASON_GAME_TIME_EXPIRED(0x12),
// REASON_NO_TIME_LEFT(0x13),
// REASON_SYSTEM_ERROR(0x14),
// REASON_ACCESS_FAILED(0x15),
// REASON_RESTRICTED_IP(0x16),
// REASON_WEEK_USAGE_FINISHED(0x1E),
// REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
// REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
// REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
// REASON_DUAL_BOX(0x23),
// REASON_INACTIVE(0x24),
// REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
// REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
// REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
// REASON_ACCOUNT_SUSPENDED_CALL(0x28),
// REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
// REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
// REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
// REASON_CERTIFICATION_FAILED(0x2E),
// REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
// REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
// REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
// REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
// REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
// REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
// REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
// REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
// REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
// REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
//
// private final int _code;
//
// LoginFailReason(int code)
// {
// _code = code;
// }
//
// public final int getCode()
// {
// return _code;
// }
// }
| import com.l2jserver.login.network.L2LoginClient.LoginClientState;
import com.l2jserver.login.network.serverpackets.GGAuth;
import com.l2jserver.login.network.serverpackets.LoginFail.LoginFailReason;
| public int getData4()
{
return _data4;
}
@Override
protected boolean readImpl()
{
if (super._buf.remaining() >= 20)
{
_sessionId = readD();
_data1 = readD();
_data2 = readD();
_data3 = readD();
_data4 = readD();
return true;
}
return false;
}
@Override
public void run()
{
if (_sessionId == getClient().getSessionId())
{
getClient().setState(LoginClientState.AUTHED_GG);
getClient().sendPacket(new GGAuth(getClient().getSessionId()));
}
else
{
| // Path: src/main/java/com/l2jserver/login/network/L2LoginClient.java
// public static enum LoginClientState
// {
// CONNECTED,
// AUTHED_GG,
// AUTHED_LOGIN
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/GGAuth.java
// public final class GGAuth extends L2LoginServerPacket
// {
// static final Logger _log = Logger.getLogger(GGAuth.class.getName());
// public static final int SKIP_GG_AUTH_REQUEST = 0x0b;
//
// private final int _response;
//
// public GGAuth(int response)
// {
// _response = response;
// if (Config.DEBUG)
// {
// _log.warning("Reason Hex: " + (Integer.toHexString(response)));
// }
// }
//
// @Override
// protected void write()
// {
// writeC(0x0b);
// writeD(_response);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// writeD(0x00);
// }
// }
//
// Path: src/main/java/com/l2jserver/login/network/serverpackets/LoginFail.java
// public static enum LoginFailReason
// {
// REASON_NO_MESSAGE(0x00),
// REASON_SYSTEM_ERROR_LOGIN_LATER(0x01),
// REASON_USER_OR_PASS_WRONG(0x02),
// REASON_ACCESS_FAILED_TRY_AGAIN_LATER(0x04),
// REASON_ACCOUNT_INFO_INCORRECT_CONTACT_SUPPORT(0x05),
// REASON_ACCOUNT_IN_USE(0x07),
// REASON_UNDER_18_YEARS_KR(0x0C),
// REASON_SERVER_OVERLOADED(0x0F),
// REASON_SERVER_MAINTENANCE(0x10),
// REASON_TEMP_PASS_EXPIRED(0x11),
// REASON_GAME_TIME_EXPIRED(0x12),
// REASON_NO_TIME_LEFT(0x13),
// REASON_SYSTEM_ERROR(0x14),
// REASON_ACCESS_FAILED(0x15),
// REASON_RESTRICTED_IP(0x16),
// REASON_WEEK_USAGE_FINISHED(0x1E),
// REASON_SECURITY_CARD_NUMBER_INVALID(0x1F),
// REASON_AGE_NOT_VERIFIED_CANT_LOG_BEETWEEN_10PM_6AM(0x20),
// REASON_SERVER_CANNOT_BE_ACCESSED_BY_YOUR_COUPON(0x21),
// REASON_DUAL_BOX(0x23),
// REASON_INACTIVE(0x24),
// REASON_USER_AGREEMENT_REJECTED_ON_WEBSITE(0x25),
// REASON_GUARDIAN_CONSENT_REQUIRED(0x26),
// REASON_USER_AGREEMENT_DECLINED_OR_WITHDRAWL_REQUEST(0x27),
// REASON_ACCOUNT_SUSPENDED_CALL(0x28),
// REASON_CHANGE_PASSWORD_AND_QUIZ_ON_WEBSITE(0x29),
// REASON_ALREADY_LOGGED_INTO_10_ACCOUNTS(0x2A),
// REASON_MASTER_ACCOUNT_RESTRICTED(0x2B),
// REASON_CERTIFICATION_FAILED(0x2E),
// REASON_TELEPHONE_CERTIFICATION_UNAVAILABLE(0x2F),
// REASON_TELEPHONE_SIGNALS_DELAYED(0x30),
// REASON_CERTIFICATION_FAILED_LINE_BUSY(0x31),
// REASON_CERTIFICATION_SERVICE_NUMBER_EXPIRED_OR_INCORRECT(0x32),
// REASON_CERTIFICATION_SERVICE_CURRENTLY_BEING_CHECKED(0x33),
// REASON_CERTIFICATION_SERVICE_CANT_BE_USED_HEAVY_VOLUME(0x34),
// REASON_CERTIFICATION_SERVICE_EXPIRED_GAMEPLAY_BLOCKED(0x35),
// REASON_CERTIFICATION_FAILED_3_TIMES_GAMEPLAY_BLOCKED_30_MIN(0x36),
// REASON_CERTIFICATION_DAILY_USE_EXCEEDED(0x37),
// REASON_CERTIFICATION_UNDERWAY_TRY_AGAIN_LATER(0x38);
//
// private final int _code;
//
// LoginFailReason(int code)
// {
// _code = code;
// }
//
// public final int getCode()
// {
// return _code;
// }
// }
// Path: src/main/java/com/l2jserver/login/network/clientpackets/AuthGameGuard.java
import com.l2jserver.login.network.L2LoginClient.LoginClientState;
import com.l2jserver.login.network.serverpackets.GGAuth;
import com.l2jserver.login.network.serverpackets.LoginFail.LoginFailReason;
public int getData4()
{
return _data4;
}
@Override
protected boolean readImpl()
{
if (super._buf.remaining() >= 20)
{
_sessionId = readD();
_data1 = readD();
_data2 = readD();
_data3 = readD();
_data4 = readD();
return true;
}
return false;
}
@Override
public void run()
{
if (_sessionId == getClient().getSessionId())
{
getClient().setState(LoginClientState.AUTHED_GG);
getClient().sendPacket(new GGAuth(getClient().getSessionId()));
}
else
{
| getClient().close(LoginFailReason.REASON_ACCESS_FAILED);
|
Zoey76/L2J_LoginServer | src/main/java/com/l2jserver/login/network/serverpackets/PlayOk.java | // Path: src/main/java/com/l2jserver/login/SessionKey.java
// public class SessionKey
// {
// public int playOkID1;
// public int playOkID2;
// public int loginOkID1;
// public int loginOkID2;
//
// public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
// {
// playOkID1 = playOK1;
// playOkID2 = playOK2;
// loginOkID1 = loginOK1;
// loginOkID2 = loginOK2;
// }
//
// @Override
// public String toString()
// {
// return "PlayOk: " + playOkID1 + " " + playOkID2 + " LoginOk:" + loginOkID1 + " " + loginOkID2;
// }
//
// public boolean checkLoginPair(int loginOk1, int loginOk2)
// {
// return (loginOkID1 == loginOk1) && (loginOkID2 == loginOk2);
// }
//
// /**
// * Only checks the PlayOk part of the session key if server doesn't show the license when player logs in.
// * @param o
// * @return true if keys are equal.
// */
// @Override
// public boolean equals(Object o)
// {
// if (this == o)
// {
// return true;
// }
// if (!(o instanceof SessionKey))
// {
// return false;
// }
// final SessionKey key = (SessionKey) o;
// // when server doesn't show license it doesn't send the LoginOk packet, client doesn't have this part of the key then.
// if (Config.SHOW_LICENCE)
// {
// return ((playOkID1 == key.playOkID1) && (loginOkID1 == key.loginOkID1) && (playOkID2 == key.playOkID2) && (loginOkID2 == key.loginOkID2));
// }
// return ((playOkID1 == key.playOkID1) && (playOkID2 == key.playOkID2));
// }
// }
| import com.l2jserver.login.SessionKey;
| /*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.login.network.serverpackets;
public final class PlayOk extends L2LoginServerPacket
{
private final int _playOk1, _playOk2;
| // Path: src/main/java/com/l2jserver/login/SessionKey.java
// public class SessionKey
// {
// public int playOkID1;
// public int playOkID2;
// public int loginOkID1;
// public int loginOkID2;
//
// public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
// {
// playOkID1 = playOK1;
// playOkID2 = playOK2;
// loginOkID1 = loginOK1;
// loginOkID2 = loginOK2;
// }
//
// @Override
// public String toString()
// {
// return "PlayOk: " + playOkID1 + " " + playOkID2 + " LoginOk:" + loginOkID1 + " " + loginOkID2;
// }
//
// public boolean checkLoginPair(int loginOk1, int loginOk2)
// {
// return (loginOkID1 == loginOk1) && (loginOkID2 == loginOk2);
// }
//
// /**
// * Only checks the PlayOk part of the session key if server doesn't show the license when player logs in.
// * @param o
// * @return true if keys are equal.
// */
// @Override
// public boolean equals(Object o)
// {
// if (this == o)
// {
// return true;
// }
// if (!(o instanceof SessionKey))
// {
// return false;
// }
// final SessionKey key = (SessionKey) o;
// // when server doesn't show license it doesn't send the LoginOk packet, client doesn't have this part of the key then.
// if (Config.SHOW_LICENCE)
// {
// return ((playOkID1 == key.playOkID1) && (loginOkID1 == key.loginOkID1) && (playOkID2 == key.playOkID2) && (loginOkID2 == key.loginOkID2));
// }
// return ((playOkID1 == key.playOkID1) && (playOkID2 == key.playOkID2));
// }
// }
// Path: src/main/java/com/l2jserver/login/network/serverpackets/PlayOk.java
import com.l2jserver.login.SessionKey;
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.login.network.serverpackets;
public final class PlayOk extends L2LoginServerPacket
{
private final int _playOk1, _playOk2;
| public PlayOk(SessionKey sessionKey)
|
Zoey76/L2J_LoginServer | src/main/java/com/l2jserver/login/network/serverpackets/LoginOk.java | // Path: src/main/java/com/l2jserver/login/SessionKey.java
// public class SessionKey
// {
// public int playOkID1;
// public int playOkID2;
// public int loginOkID1;
// public int loginOkID2;
//
// public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
// {
// playOkID1 = playOK1;
// playOkID2 = playOK2;
// loginOkID1 = loginOK1;
// loginOkID2 = loginOK2;
// }
//
// @Override
// public String toString()
// {
// return "PlayOk: " + playOkID1 + " " + playOkID2 + " LoginOk:" + loginOkID1 + " " + loginOkID2;
// }
//
// public boolean checkLoginPair(int loginOk1, int loginOk2)
// {
// return (loginOkID1 == loginOk1) && (loginOkID2 == loginOk2);
// }
//
// /**
// * Only checks the PlayOk part of the session key if server doesn't show the license when player logs in.
// * @param o
// * @return true if keys are equal.
// */
// @Override
// public boolean equals(Object o)
// {
// if (this == o)
// {
// return true;
// }
// if (!(o instanceof SessionKey))
// {
// return false;
// }
// final SessionKey key = (SessionKey) o;
// // when server doesn't show license it doesn't send the LoginOk packet, client doesn't have this part of the key then.
// if (Config.SHOW_LICENCE)
// {
// return ((playOkID1 == key.playOkID1) && (loginOkID1 == key.loginOkID1) && (playOkID2 == key.playOkID2) && (loginOkID2 == key.loginOkID2));
// }
// return ((playOkID1 == key.playOkID1) && (playOkID2 == key.playOkID2));
// }
// }
| import com.l2jserver.login.SessionKey;
| /*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.login.network.serverpackets;
/**
* <pre>
* Format: dddddddd
* f: the session key
* d: ?
* d: ?
* d: ?
* d: ?
* d: ?
* d: ?
* b: 16 bytes - unknown
* </pre>
*/
public final class LoginOk extends L2LoginServerPacket
{
private final int _loginOk1, _loginOk2;
| // Path: src/main/java/com/l2jserver/login/SessionKey.java
// public class SessionKey
// {
// public int playOkID1;
// public int playOkID2;
// public int loginOkID1;
// public int loginOkID2;
//
// public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
// {
// playOkID1 = playOK1;
// playOkID2 = playOK2;
// loginOkID1 = loginOK1;
// loginOkID2 = loginOK2;
// }
//
// @Override
// public String toString()
// {
// return "PlayOk: " + playOkID1 + " " + playOkID2 + " LoginOk:" + loginOkID1 + " " + loginOkID2;
// }
//
// public boolean checkLoginPair(int loginOk1, int loginOk2)
// {
// return (loginOkID1 == loginOk1) && (loginOkID2 == loginOk2);
// }
//
// /**
// * Only checks the PlayOk part of the session key if server doesn't show the license when player logs in.
// * @param o
// * @return true if keys are equal.
// */
// @Override
// public boolean equals(Object o)
// {
// if (this == o)
// {
// return true;
// }
// if (!(o instanceof SessionKey))
// {
// return false;
// }
// final SessionKey key = (SessionKey) o;
// // when server doesn't show license it doesn't send the LoginOk packet, client doesn't have this part of the key then.
// if (Config.SHOW_LICENCE)
// {
// return ((playOkID1 == key.playOkID1) && (loginOkID1 == key.loginOkID1) && (playOkID2 == key.playOkID2) && (loginOkID2 == key.loginOkID2));
// }
// return ((playOkID1 == key.playOkID1) && (playOkID2 == key.playOkID2));
// }
// }
// Path: src/main/java/com/l2jserver/login/network/serverpackets/LoginOk.java
import com.l2jserver.login.SessionKey;
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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 com.l2jserver.login.network.serverpackets;
/**
* <pre>
* Format: dddddddd
* f: the session key
* d: ?
* d: ?
* d: ?
* d: ?
* d: ?
* d: ?
* b: 16 bytes - unknown
* </pre>
*/
public final class LoginOk extends L2LoginServerPacket
{
private final int _loginOk1, _loginOk2;
| public LoginOk(SessionKey sessionKey)
|
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/AboutusActivity.java | // Path: app/src/main/java/cheetatech/com/colorhub/social/Links.java
// public class Links {
// public static final String APP_URL = "https://play.google.com/store/apps/details?id=cheetatech.com.colorhub";
// public static final String ANTRIKOD_URL = "http://www.antrikod.com";
// public static final String ANTRIKOD_PLAY_STORE = "https://play.google.com/store/apps/dev?id=7898216932904579846";
// public static final String ANTRIKOD_TWITTER = "https://twitter.com/antri_kod";
// public static final String ANTRIKOD_EMAIL = "info@antrikod.com";
// public static final String[] PERSON_LINKS = new String[]{
// "https://www.linkedin.com/in/erkan-g%C3%BCzeler-95b47252",
// "https://tr.linkedin.com/in/ali-guvenbas",
// "https://www.behance.net/nagihanozkar",
// "https://www.linkedin.com/in/itır-başar-104889b5"
// };
// }
| import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import cheetatech.com.colorhub.social.Links;
import cheetatech.com.colorhub.social.Social; | package cheetatech.com.colorhub;
public class AboutusActivity extends AppCompatActivity implements View.OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_aboutus);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_action_back_button);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});
getSupportActionBar().setTitle("ColorHub");
((TextView)findViewById(R.id.link_web_text)).setOnClickListener(this);
((FloatingActionButton) findViewById(R.id.fab)).setOnClickListener(this);
((ImageView)findViewById(R.id.steam_1)).setOnClickListener(this);
((ImageView)findViewById(R.id.steam_2)).setOnClickListener(this);
((ImageView)findViewById(R.id.gteam_1)).setOnClickListener(this);
((ImageView)findViewById(R.id.gteam_2)).setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId())
{
case R.id.link_web_text : | // Path: app/src/main/java/cheetatech/com/colorhub/social/Links.java
// public class Links {
// public static final String APP_URL = "https://play.google.com/store/apps/details?id=cheetatech.com.colorhub";
// public static final String ANTRIKOD_URL = "http://www.antrikod.com";
// public static final String ANTRIKOD_PLAY_STORE = "https://play.google.com/store/apps/dev?id=7898216932904579846";
// public static final String ANTRIKOD_TWITTER = "https://twitter.com/antri_kod";
// public static final String ANTRIKOD_EMAIL = "info@antrikod.com";
// public static final String[] PERSON_LINKS = new String[]{
// "https://www.linkedin.com/in/erkan-g%C3%BCzeler-95b47252",
// "https://tr.linkedin.com/in/ali-guvenbas",
// "https://www.behance.net/nagihanozkar",
// "https://www.linkedin.com/in/itır-başar-104889b5"
// };
// }
// Path: app/src/main/java/cheetatech/com/colorhub/AboutusActivity.java
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import cheetatech.com.colorhub.social.Links;
import cheetatech.com.colorhub.social.Social;
package cheetatech.com.colorhub;
public class AboutusActivity extends AppCompatActivity implements View.OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_aboutus);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_action_back_button);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});
getSupportActionBar().setTitle("ColorHub");
((TextView)findViewById(R.id.link_web_text)).setOnClickListener(this);
((FloatingActionButton) findViewById(R.id.fab)).setOnClickListener(this);
((ImageView)findViewById(R.id.steam_1)).setOnClickListener(this);
((ImageView)findViewById(R.id.steam_2)).setOnClickListener(this);
((ImageView)findViewById(R.id.gteam_1)).setOnClickListener(this);
((ImageView)findViewById(R.id.gteam_2)).setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId())
{
case R.id.link_web_text : | Social.Companion.openUrl(Links.ANTRIKOD_URL, AboutusActivity.this); |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/models/Model.java | // Path: app/src/main/java/cheetatech/com/colorhub/realm/RealmX.java
// public class RealmX {
//
// private static Realm realm;
//
// private static void getRealm(){
// try {
// realm = Realm.getDefaultInstance();
// }catch (Exception e){
// Log.e("TAG","Exception Exception " + e.getMessage());
// // RealmConfiguration config = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
// // realm = Realm.getInstance(config);
// }
// }
//
// public static Realm realm(){
// if(realm == null)
// getRealm();
// return realm;
// }
//
//
// public static void closeRealm(){
// if(realm != null){
// if(!realm.isClosed()){
// realm.close();
// }
// }
// }
//
//
// public static void save(final SavedObject object) {
// getRealm();
// realm.executeTransaction(new Realm.Transaction() {
// @Override
// public void execute(Realm realm) {
// realm.copyToRealm(object);
// //closeRealm();
// }
// });
// }
//
// public static void list(){
// getRealm();
// RealmResults<SavedObject> res = realm.where(SavedObject.class)
// .findAll();
//
// for (SavedObject s : res ) {
// Log.e("TAG", "list: " + s.getName() );
// for (Model m : s.getList() ) {
// Log.e("TAG", "list::: " + m.getColorCode() );
// }
// Log.e("TAG", "---------------------" );
// }
//
// //closeRealm();
// }
//
// public static RealmResults<SavedObject> getObject(){
// return realm.where(SavedObject.class).findAll();
// }
//
// public static SavedObject getObject(String name){
// return realm.where(SavedObject.class)
// .equalTo("name",name)
// .findFirst();
// }
//
// public static void setList(final String name, List<Model> list){
// final RealmList<Model> realmList = new RealmList<>();
// realmList.addAll(list);
// realm.executeTransaction(new Realm.Transaction() {
// @Override
// public void execute(Realm realm) {
// SavedObject res = realm.where(SavedObject.class)
// .equalTo("name",name)
// .findFirst();
// res.setList(realmList);
// Log.e("TAG", "execute: execute" );
// }
// });
// }
//
// public static void deleteObject(final String name) {
//
// realm.executeTransaction(new Realm.Transaction() {
// @Override
// public void execute(Realm realm) {
// RealmResults<SavedObject> list = realm.where(SavedObject.class).equalTo("name",name).findAll();
// list.deleteAllFromRealm();
// }
// });
// }
// }
| import cheetatech.com.colorhub.realm.RealmX;
import io.realm.RealmObject; | package cheetatech.com.colorhub.models;
/**
* Created by erkan on 17.03.2017.
*/
public class Model extends RealmObject{
private String colorCode;
public Model(){}
public Model(String colorCode) {
this.colorCode = colorCode;
}
public String getColorCode() {
return colorCode;
}
public void setColorCode(String colorCode) { | // Path: app/src/main/java/cheetatech/com/colorhub/realm/RealmX.java
// public class RealmX {
//
// private static Realm realm;
//
// private static void getRealm(){
// try {
// realm = Realm.getDefaultInstance();
// }catch (Exception e){
// Log.e("TAG","Exception Exception " + e.getMessage());
// // RealmConfiguration config = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
// // realm = Realm.getInstance(config);
// }
// }
//
// public static Realm realm(){
// if(realm == null)
// getRealm();
// return realm;
// }
//
//
// public static void closeRealm(){
// if(realm != null){
// if(!realm.isClosed()){
// realm.close();
// }
// }
// }
//
//
// public static void save(final SavedObject object) {
// getRealm();
// realm.executeTransaction(new Realm.Transaction() {
// @Override
// public void execute(Realm realm) {
// realm.copyToRealm(object);
// //closeRealm();
// }
// });
// }
//
// public static void list(){
// getRealm();
// RealmResults<SavedObject> res = realm.where(SavedObject.class)
// .findAll();
//
// for (SavedObject s : res ) {
// Log.e("TAG", "list: " + s.getName() );
// for (Model m : s.getList() ) {
// Log.e("TAG", "list::: " + m.getColorCode() );
// }
// Log.e("TAG", "---------------------" );
// }
//
// //closeRealm();
// }
//
// public static RealmResults<SavedObject> getObject(){
// return realm.where(SavedObject.class).findAll();
// }
//
// public static SavedObject getObject(String name){
// return realm.where(SavedObject.class)
// .equalTo("name",name)
// .findFirst();
// }
//
// public static void setList(final String name, List<Model> list){
// final RealmList<Model> realmList = new RealmList<>();
// realmList.addAll(list);
// realm.executeTransaction(new Realm.Transaction() {
// @Override
// public void execute(Realm realm) {
// SavedObject res = realm.where(SavedObject.class)
// .equalTo("name",name)
// .findFirst();
// res.setList(realmList);
// Log.e("TAG", "execute: execute" );
// }
// });
// }
//
// public static void deleteObject(final String name) {
//
// realm.executeTransaction(new Realm.Transaction() {
// @Override
// public void execute(Realm realm) {
// RealmResults<SavedObject> list = realm.where(SavedObject.class).equalTo("name",name).findAll();
// list.deleteAllFromRealm();
// }
// });
// }
// }
// Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
import cheetatech.com.colorhub.realm.RealmX;
import io.realm.RealmObject;
package cheetatech.com.colorhub.models;
/**
* Created by erkan on 17.03.2017.
*/
public class Model extends RealmObject{
private String colorCode;
public Model(){}
public Model(String colorCode) {
this.colorCode = colorCode;
}
public String getColorCode() {
return colorCode;
}
public void setColorCode(String colorCode) { | RealmX.realm().beginTransaction(); |
AntriKodSoft/ColorHub | app/src/main/java/layout/ColorPicker1.java | // Path: app/src/main/java/cheetatech/com/colorhub/defines/BoardEditor.java
// public class BoardEditor {
// private static BoardEditor ourInstance = null;
// private Context context = null;
//
// public static BoardEditor getInstance()
// {
// if(ourInstance == null)
// ourInstance = new BoardEditor();
// return ourInstance;
// }
//
// private BoardEditor() {
// }
//
// public Context getContext()
// {
// return this.context;
// }
//
// public void setContext(Context context)
// {
// this.context = context;
// }
// public void copyToClipBoard(String text)
// {
// ClipboardManager clipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData clip = ClipData.newPlainText("text",text);
// clipMan.setPrimaryClip(clip);
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/listeners/IOnFocusListenable.java
// public interface IOnFocusListenable {
// void onWindowFocusChanged(boolean hasFocus);
// }
| import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.math.BigInteger;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.BoardEditor;
import cheetatech.com.colorhub.listeners.IOnFocusListenable;
import cheetatech.com.colorhub.listeners.OnItemSelect; | public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});
ButterKnife.bind(this,view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
red = green = blue = 120;
opacity = 255;
ClipboardManager clipBoard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
window = getActivity().getWindow();
seekBarLeft = redSeekBar.getPaddingLeft();
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));
textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity, red, green, blue));
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
textViewColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) { | // Path: app/src/main/java/cheetatech/com/colorhub/defines/BoardEditor.java
// public class BoardEditor {
// private static BoardEditor ourInstance = null;
// private Context context = null;
//
// public static BoardEditor getInstance()
// {
// if(ourInstance == null)
// ourInstance = new BoardEditor();
// return ourInstance;
// }
//
// private BoardEditor() {
// }
//
// public Context getContext()
// {
// return this.context;
// }
//
// public void setContext(Context context)
// {
// this.context = context;
// }
// public void copyToClipBoard(String text)
// {
// ClipboardManager clipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData clip = ClipData.newPlainText("text",text);
// clipMan.setPrimaryClip(clip);
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/listeners/IOnFocusListenable.java
// public interface IOnFocusListenable {
// void onWindowFocusChanged(boolean hasFocus);
// }
// Path: app/src/main/java/layout/ColorPicker1.java
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.math.BigInteger;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.BoardEditor;
import cheetatech.com.colorhub.listeners.IOnFocusListenable;
import cheetatech.com.colorhub.listeners.OnItemSelect;
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});
ButterKnife.bind(this,view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
red = green = blue = 120;
opacity = 255;
ClipboardManager clipBoard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
window = getActivity().getWindow();
seekBarLeft = redSeekBar.getPaddingLeft();
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));
textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity, red, green, blue));
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
textViewColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) { | BoardEditor.getInstance().copyToClipBoard(textViewColor.getText().toString()); |
AntriKodSoft/ColorHub | app/src/main/java/layout/ColorPickerAdd.java | // Path: app/src/main/java/cheetatech/com/colorhub/defines/BoardEditor.java
// public class BoardEditor {
// private static BoardEditor ourInstance = null;
// private Context context = null;
//
// public static BoardEditor getInstance()
// {
// if(ourInstance == null)
// ourInstance = new BoardEditor();
// return ourInstance;
// }
//
// private BoardEditor() {
// }
//
// public Context getContext()
// {
// return this.context;
// }
//
// public void setContext(Context context)
// {
// this.context = context;
// }
// public void copyToClipBoard(String text)
// {
// ClipboardManager clipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData clip = ClipData.newPlainText("text",text);
// clipMan.setPrimaryClip(clip);
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/listeners/IOnFocusListenable.java
// public interface IOnFocusListenable {
// void onWindowFocusChanged(boolean hasFocus);
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
| import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.math.BigInteger;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.BoardEditor;
import cheetatech.com.colorhub.listeners.IOnFocusListenable;
import cheetatech.com.colorhub.models.Model; | package layout;
/**
* Created by erkan on 22.03.2017.
*/
public class ColorPickerAdd extends Fragment implements IOnFocusListenable {
@BindView(R.id.colorView2)
RelativeLayout colorViewLayout;
@BindView(R.id.textViewColor)
TextView textViewColor ;
@BindView(R.id.redSeekBar)
SeekBar redSeekBar;
@BindView(R.id.greenSeekBar)
SeekBar greenSeekBar;
@BindView(R.id.blueSeekBar)
SeekBar blueSeekBar;
@BindView(R.id.opacitySeekBar)
SeekBar opacitySeekBar;
@BindView(R.id.redToolTip)
TextView redToolTip;
@BindView(R.id.greenToolTip)
TextView greenToolTip;
@BindView(R.id.blueToolTip)
TextView blueToolTip;
@BindView(R.id.opacityToolTip)
TextView opacityToolTip;
ClipboardManager clipBoard;
ClipData clip;
Window window;
Display display;
int red, green, blue, seekBarLeft,opacity;
Rect thumbRect;
private int mPosition; | // Path: app/src/main/java/cheetatech/com/colorhub/defines/BoardEditor.java
// public class BoardEditor {
// private static BoardEditor ourInstance = null;
// private Context context = null;
//
// public static BoardEditor getInstance()
// {
// if(ourInstance == null)
// ourInstance = new BoardEditor();
// return ourInstance;
// }
//
// private BoardEditor() {
// }
//
// public Context getContext()
// {
// return this.context;
// }
//
// public void setContext(Context context)
// {
// this.context = context;
// }
// public void copyToClipBoard(String text)
// {
// ClipboardManager clipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData clip = ClipData.newPlainText("text",text);
// clipMan.setPrimaryClip(clip);
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/listeners/IOnFocusListenable.java
// public interface IOnFocusListenable {
// void onWindowFocusChanged(boolean hasFocus);
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
// Path: app/src/main/java/layout/ColorPickerAdd.java
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.math.BigInteger;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.BoardEditor;
import cheetatech.com.colorhub.listeners.IOnFocusListenable;
import cheetatech.com.colorhub.models.Model;
package layout;
/**
* Created by erkan on 22.03.2017.
*/
public class ColorPickerAdd extends Fragment implements IOnFocusListenable {
@BindView(R.id.colorView2)
RelativeLayout colorViewLayout;
@BindView(R.id.textViewColor)
TextView textViewColor ;
@BindView(R.id.redSeekBar)
SeekBar redSeekBar;
@BindView(R.id.greenSeekBar)
SeekBar greenSeekBar;
@BindView(R.id.blueSeekBar)
SeekBar blueSeekBar;
@BindView(R.id.opacitySeekBar)
SeekBar opacitySeekBar;
@BindView(R.id.redToolTip)
TextView redToolTip;
@BindView(R.id.greenToolTip)
TextView greenToolTip;
@BindView(R.id.blueToolTip)
TextView blueToolTip;
@BindView(R.id.opacityToolTip)
TextView opacityToolTip;
ClipboardManager clipBoard;
ClipData clip;
Window window;
Display display;
int red, green, blue, seekBarLeft,opacity;
Rect thumbRect;
private int mPosition; | private Model mModel = null; |
AntriKodSoft/ColorHub | app/src/main/java/layout/ColorPickerAdd.java | // Path: app/src/main/java/cheetatech/com/colorhub/defines/BoardEditor.java
// public class BoardEditor {
// private static BoardEditor ourInstance = null;
// private Context context = null;
//
// public static BoardEditor getInstance()
// {
// if(ourInstance == null)
// ourInstance = new BoardEditor();
// return ourInstance;
// }
//
// private BoardEditor() {
// }
//
// public Context getContext()
// {
// return this.context;
// }
//
// public void setContext(Context context)
// {
// this.context = context;
// }
// public void copyToClipBoard(String text)
// {
// ClipboardManager clipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData clip = ClipData.newPlainText("text",text);
// clipMan.setPrimaryClip(clip);
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/listeners/IOnFocusListenable.java
// public interface IOnFocusListenable {
// void onWindowFocusChanged(boolean hasFocus);
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
| import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.math.BigInteger;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.BoardEditor;
import cheetatech.com.colorhub.listeners.IOnFocusListenable;
import cheetatech.com.colorhub.models.Model; | @Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
red = green = blue = 120;
opacity = 255;
clipBoard = (ClipboardManager)getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
window = getActivity().getWindow();
seekBarLeft = redSeekBar.getPaddingLeft();
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
redSeekBar.setProgress(red);
greenSeekBar.setProgress(green);
blueSeekBar.setProgress(blue);
opacitySeekBar.setProgress(opacity);
colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));
textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity, red, green, blue));
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
textViewColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//addToView(new ColorItem(red,green,blue,opacity)); | // Path: app/src/main/java/cheetatech/com/colorhub/defines/BoardEditor.java
// public class BoardEditor {
// private static BoardEditor ourInstance = null;
// private Context context = null;
//
// public static BoardEditor getInstance()
// {
// if(ourInstance == null)
// ourInstance = new BoardEditor();
// return ourInstance;
// }
//
// private BoardEditor() {
// }
//
// public Context getContext()
// {
// return this.context;
// }
//
// public void setContext(Context context)
// {
// this.context = context;
// }
// public void copyToClipBoard(String text)
// {
// ClipboardManager clipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
// ClipData clip = ClipData.newPlainText("text",text);
// clipMan.setPrimaryClip(clip);
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/listeners/IOnFocusListenable.java
// public interface IOnFocusListenable {
// void onWindowFocusChanged(boolean hasFocus);
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
// Path: app/src/main/java/layout/ColorPickerAdd.java
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.math.BigInteger;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.BoardEditor;
import cheetatech.com.colorhub.listeners.IOnFocusListenable;
import cheetatech.com.colorhub.models.Model;
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
red = green = blue = 120;
opacity = 255;
clipBoard = (ClipboardManager)getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
window = getActivity().getWindow();
seekBarLeft = redSeekBar.getPaddingLeft();
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
redSeekBar.setProgress(red);
greenSeekBar.setProgress(green);
blueSeekBar.setProgress(blue);
opacitySeekBar.setProgress(opacity);
colorViewLayout.setBackgroundColor(Color.argb(opacity,red, green, blue));
textViewColor.setText(String.format("#%02x%02x%02x%02x", opacity, red, green, blue));
textViewColor.setTextColor(Color.parseColor(inverseColor(red,green,blue)));
textViewColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//addToView(new ColorItem(red,green,blue,opacity)); | BoardEditor.getInstance().copyToClipBoard(textViewColor.getText().toString()); |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/realm/RealmX.java | // Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
| import android.util.Log;
import java.util.List;
import cheetatech.com.colorhub.models.Model;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmResults; | }
public static void closeRealm(){
if(realm != null){
if(!realm.isClosed()){
realm.close();
}
}
}
public static void save(final SavedObject object) {
getRealm();
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.copyToRealm(object);
//closeRealm();
}
});
}
public static void list(){
getRealm();
RealmResults<SavedObject> res = realm.where(SavedObject.class)
.findAll();
for (SavedObject s : res ) {
Log.e("TAG", "list: " + s.getName() ); | // Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
// Path: app/src/main/java/cheetatech/com/colorhub/realm/RealmX.java
import android.util.Log;
import java.util.List;
import cheetatech.com.colorhub.models.Model;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmResults;
}
public static void closeRealm(){
if(realm != null){
if(!realm.isClosed()){
realm.close();
}
}
}
public static void save(final SavedObject object) {
getRealm();
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
realm.copyToRealm(object);
//closeRealm();
}
});
}
public static void list(){
getRealm();
RealmResults<SavedObject> res = realm.where(SavedObject.class)
.findAll();
for (SavedObject s : res ) {
Log.e("TAG", "list: " + s.getName() ); | for (Model m : s.getList() ) { |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/adapters/YourColorAdapter.java | // Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/realm/SavedObject.java
// public class SavedObject extends RealmObject {
//
// private String name;
// private RealmList<Model> list;
//
// public SavedObject(){}
//
// public SavedObject(String name, RealmList<Model> list){
// setName(name);
// setList(list);
// }
// public SavedObject(RealmList<Model> list){
// setList(list);
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Model> getList() {
// return list;
// }
//
// public void addList(List<Model> lists){
// RealmX.realm().beginTransaction();
// this.list.clear();
// this.list.addAll(lists);
// RealmX.realm().commitTransaction();
// }
//
// public void setList(RealmList<Model> list) {
// this.list = list;
// }
//
// public void setNameQuery(String name){
// RealmX.realm().beginTransaction();
// this.name = name;
// RealmX.realm().commitTransaction();
// }
//
// }
| import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.models.Model;
import cheetatech.com.colorhub.realm.SavedObject; | int position = mDataset.indexOf(item);
mDataset.remove(position);
notifyItemRemoved(position);
}
public YourColorAdapter(List<SavedObject> myDataset){
this.mDataset = myDataset;
}
public YourColorAdapter(List<SavedObject> myDataset, OnItemDelete listener){
this.mDataset = myDataset;
this.mListener = listener;
}
@Override
public YourColorAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
int layout = R.layout.your_color_item;
View v = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
context = parent.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(YourColorAdapter.ViewHolder holder, final int position) {
if(context != null){
boolean isDeleted = false;
if(!isDeleted){
final SavedObject object = this.mDataset.get(position);
holder.mPaletteName.setText(object.getName());
holder.mLayout.removeAllViews(); | // Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/realm/SavedObject.java
// public class SavedObject extends RealmObject {
//
// private String name;
// private RealmList<Model> list;
//
// public SavedObject(){}
//
// public SavedObject(String name, RealmList<Model> list){
// setName(name);
// setList(list);
// }
// public SavedObject(RealmList<Model> list){
// setList(list);
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Model> getList() {
// return list;
// }
//
// public void addList(List<Model> lists){
// RealmX.realm().beginTransaction();
// this.list.clear();
// this.list.addAll(lists);
// RealmX.realm().commitTransaction();
// }
//
// public void setList(RealmList<Model> list) {
// this.list = list;
// }
//
// public void setNameQuery(String name){
// RealmX.realm().beginTransaction();
// this.name = name;
// RealmX.realm().commitTransaction();
// }
//
// }
// Path: app/src/main/java/cheetatech/com/colorhub/adapters/YourColorAdapter.java
import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.models.Model;
import cheetatech.com.colorhub.realm.SavedObject;
int position = mDataset.indexOf(item);
mDataset.remove(position);
notifyItemRemoved(position);
}
public YourColorAdapter(List<SavedObject> myDataset){
this.mDataset = myDataset;
}
public YourColorAdapter(List<SavedObject> myDataset, OnItemDelete listener){
this.mDataset = myDataset;
this.mListener = listener;
}
@Override
public YourColorAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
int layout = R.layout.your_color_item;
View v = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
context = parent.getContext();
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(YourColorAdapter.ViewHolder holder, final int position) {
if(context != null){
boolean isDeleted = false;
if(!isDeleted){
final SavedObject object = this.mDataset.get(position);
holder.mPaletteName.setText(object.getName());
holder.mLayout.removeAllViews(); | for (Model m: object.getList()) { |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/view/ColorPickerView.java | // Path: app/src/main/java/cheetatech/com/colorhub/drawable/AlphaPatternDrawable.java
// public class AlphaPatternDrawable extends Drawable {
//
// private int mRectangleSize = 10;
//
// private Paint mPaint = new Paint();
// private Paint mPaintWhite = new Paint();
// private Paint mPaintGray = new Paint();
//
// private int numRectanglesHorizontal;
// private int numRectanglesVertical;
//
// /**
// * Bitmap in which the pattern will be cached.
// * This is so the pattern will not have to be recreated each time draw() gets called.
// * Because recreating the pattern i rather expensive. I will only be recreated if the
// * size changes.
// */
// private Bitmap mBitmap;
//
// public AlphaPatternDrawable(int rectangleSize) {
// mRectangleSize = rectangleSize;
// mPaintWhite.setColor(0xffffffff);
// mPaintGray.setColor(0xffcbcbcb);
// }
//
// @Override
// public void draw(Canvas canvas) {
// if(mBitmap != null && !mBitmap.isRecycled()) {
// canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
// }
// }
//
// @Override
// public int getOpacity() {
// return 0;
// }
//
// @Override
// public void setAlpha(int alpha) {
// throw new UnsupportedOperationException("Alpha is not supported by this drawable.");
// }
//
// @Override
// public void setColorFilter(ColorFilter cf) {
// throw new UnsupportedOperationException("ColorFilter is not supported by this drawable.");
// }
//
// @Override
// protected void onBoundsChange(Rect bounds) {
// super.onBoundsChange(bounds);
//
// int height = bounds.height();
// int width = bounds.width();
//
// numRectanglesHorizontal = (int) Math.ceil((width / mRectangleSize));
// numRectanglesVertical = (int) Math.ceil(height / mRectangleSize);
//
// generatePatternBitmap();
//
// }
//
// /**
// * This will generate a bitmap with the pattern
// * as big as the rectangle we were allow to draw on.
// * We do this to chache the bitmap so we don't need to
// * recreate it each time draw() is called since it
// * takes a few milliseconds.
// */
// private void generatePatternBitmap(){
//
// if(getBounds().width() <= 0 || getBounds().height() <= 0){
// return;
// }
//
// mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888);
// Canvas canvas = new Canvas(mBitmap);
//
// Rect r = new Rect();
// boolean verticalStartWhite = true;
// for (int i = 0; i <= numRectanglesVertical; i++) {
//
// boolean isWhite = verticalStartWhite;
// for (int j = 0; j <= numRectanglesHorizontal; j++) {
//
// r.top = i * mRectangleSize;
// r.left = j * mRectangleSize;
// r.bottom = r.top + mRectangleSize;
// r.right = r.left + mRectangleSize;
//
// canvas.drawRect(r, isWhite ? mPaintWhite : mPaintGray);
//
// isWhite = !isWhite;
// }
//
// verticalStartWhite = !verticalStartWhite;
//
// }
//
// }
//
// }
| import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ComposeShader;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.drawable.AlphaPatternDrawable; | private float mSat = 0f;
private float mVal = 0f;
private boolean mShowAlphaPanel = false;
private String mAlphaSliderText = null;
private int mSliderTrackerColor = DEFAULT_SLIDER_COLOR;
private int mBorderColor = DEFAULT_BORDER_COLOR;
/**
* Minimum required padding. The offset from the
* edge we must have or else the finger tracker will
* get clipped when it's drawn outside of the view.
*/
private int mRequiredPadding;
/**
* The Rect in which we are allowed to draw.
* Trackers can extend outside slightly,
* due to the required padding we have set.
*/
private Rect mDrawingRect;
private Rect mSatValRect;
private Rect mHueRect;
private Rect mAlphaRect;
private Point mStartTouchPoint = null;
| // Path: app/src/main/java/cheetatech/com/colorhub/drawable/AlphaPatternDrawable.java
// public class AlphaPatternDrawable extends Drawable {
//
// private int mRectangleSize = 10;
//
// private Paint mPaint = new Paint();
// private Paint mPaintWhite = new Paint();
// private Paint mPaintGray = new Paint();
//
// private int numRectanglesHorizontal;
// private int numRectanglesVertical;
//
// /**
// * Bitmap in which the pattern will be cached.
// * This is so the pattern will not have to be recreated each time draw() gets called.
// * Because recreating the pattern i rather expensive. I will only be recreated if the
// * size changes.
// */
// private Bitmap mBitmap;
//
// public AlphaPatternDrawable(int rectangleSize) {
// mRectangleSize = rectangleSize;
// mPaintWhite.setColor(0xffffffff);
// mPaintGray.setColor(0xffcbcbcb);
// }
//
// @Override
// public void draw(Canvas canvas) {
// if(mBitmap != null && !mBitmap.isRecycled()) {
// canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
// }
// }
//
// @Override
// public int getOpacity() {
// return 0;
// }
//
// @Override
// public void setAlpha(int alpha) {
// throw new UnsupportedOperationException("Alpha is not supported by this drawable.");
// }
//
// @Override
// public void setColorFilter(ColorFilter cf) {
// throw new UnsupportedOperationException("ColorFilter is not supported by this drawable.");
// }
//
// @Override
// protected void onBoundsChange(Rect bounds) {
// super.onBoundsChange(bounds);
//
// int height = bounds.height();
// int width = bounds.width();
//
// numRectanglesHorizontal = (int) Math.ceil((width / mRectangleSize));
// numRectanglesVertical = (int) Math.ceil(height / mRectangleSize);
//
// generatePatternBitmap();
//
// }
//
// /**
// * This will generate a bitmap with the pattern
// * as big as the rectangle we were allow to draw on.
// * We do this to chache the bitmap so we don't need to
// * recreate it each time draw() is called since it
// * takes a few milliseconds.
// */
// private void generatePatternBitmap(){
//
// if(getBounds().width() <= 0 || getBounds().height() <= 0){
// return;
// }
//
// mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888);
// Canvas canvas = new Canvas(mBitmap);
//
// Rect r = new Rect();
// boolean verticalStartWhite = true;
// for (int i = 0; i <= numRectanglesVertical; i++) {
//
// boolean isWhite = verticalStartWhite;
// for (int j = 0; j <= numRectanglesHorizontal; j++) {
//
// r.top = i * mRectangleSize;
// r.left = j * mRectangleSize;
// r.bottom = r.top + mRectangleSize;
// r.right = r.left + mRectangleSize;
//
// canvas.drawRect(r, isWhite ? mPaintWhite : mPaintGray);
//
// isWhite = !isWhite;
// }
//
// verticalStartWhite = !verticalStartWhite;
//
// }
//
// }
//
// }
// Path: app/src/main/java/cheetatech/com/colorhub/view/ColorPickerView.java
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ComposeShader;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.Shader.TileMode;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.drawable.AlphaPatternDrawable;
private float mSat = 0f;
private float mVal = 0f;
private boolean mShowAlphaPanel = false;
private String mAlphaSliderText = null;
private int mSliderTrackerColor = DEFAULT_SLIDER_COLOR;
private int mBorderColor = DEFAULT_BORDER_COLOR;
/**
* Minimum required padding. The offset from the
* edge we must have or else the finger tracker will
* get clipped when it's drawn outside of the view.
*/
private int mRequiredPadding;
/**
* The Rect in which we are allowed to draw.
* Trackers can extend outside slightly,
* due to the required padding we have set.
*/
private Rect mDrawingRect;
private Rect mSatValRect;
private Rect mHueRect;
private Rect mAlphaRect;
private Point mStartTouchPoint = null;
| private AlphaPatternDrawable mAlphaPattern; |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/view/ColorPanelView.java | // Path: app/src/main/java/cheetatech/com/colorhub/drawable/AlphaPatternDrawable.java
// public class AlphaPatternDrawable extends Drawable {
//
// private int mRectangleSize = 10;
//
// private Paint mPaint = new Paint();
// private Paint mPaintWhite = new Paint();
// private Paint mPaintGray = new Paint();
//
// private int numRectanglesHorizontal;
// private int numRectanglesVertical;
//
// /**
// * Bitmap in which the pattern will be cached.
// * This is so the pattern will not have to be recreated each time draw() gets called.
// * Because recreating the pattern i rather expensive. I will only be recreated if the
// * size changes.
// */
// private Bitmap mBitmap;
//
// public AlphaPatternDrawable(int rectangleSize) {
// mRectangleSize = rectangleSize;
// mPaintWhite.setColor(0xffffffff);
// mPaintGray.setColor(0xffcbcbcb);
// }
//
// @Override
// public void draw(Canvas canvas) {
// if(mBitmap != null && !mBitmap.isRecycled()) {
// canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
// }
// }
//
// @Override
// public int getOpacity() {
// return 0;
// }
//
// @Override
// public void setAlpha(int alpha) {
// throw new UnsupportedOperationException("Alpha is not supported by this drawable.");
// }
//
// @Override
// public void setColorFilter(ColorFilter cf) {
// throw new UnsupportedOperationException("ColorFilter is not supported by this drawable.");
// }
//
// @Override
// protected void onBoundsChange(Rect bounds) {
// super.onBoundsChange(bounds);
//
// int height = bounds.height();
// int width = bounds.width();
//
// numRectanglesHorizontal = (int) Math.ceil((width / mRectangleSize));
// numRectanglesVertical = (int) Math.ceil(height / mRectangleSize);
//
// generatePatternBitmap();
//
// }
//
// /**
// * This will generate a bitmap with the pattern
// * as big as the rectangle we were allow to draw on.
// * We do this to chache the bitmap so we don't need to
// * recreate it each time draw() is called since it
// * takes a few milliseconds.
// */
// private void generatePatternBitmap(){
//
// if(getBounds().width() <= 0 || getBounds().height() <= 0){
// return;
// }
//
// mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888);
// Canvas canvas = new Canvas(mBitmap);
//
// Rect r = new Rect();
// boolean verticalStartWhite = true;
// for (int i = 0; i <= numRectanglesVertical; i++) {
//
// boolean isWhite = verticalStartWhite;
// for (int j = 0; j <= numRectanglesHorizontal; j++) {
//
// r.top = i * mRectangleSize;
// r.left = j * mRectangleSize;
// r.bottom = r.top + mRectangleSize;
// r.right = r.left + mRectangleSize;
//
// canvas.drawRect(r, isWhite ? mPaintWhite : mPaintGray);
//
// isWhite = !isWhite;
// }
//
// verticalStartWhite = !verticalStartWhite;
//
// }
//
// }
//
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.drawable.AlphaPatternDrawable; | /*
* Copyright (C) 2015 Daniel Nilsson
*
* 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 cheetatech.com.colorhub.view;
/**
* This class draws a panel which which will be filled with a color which can be set.
* It can be used to show the currently selected color which you will get from
* the {@link ColorPickerView}.
* @author Daniel Nilsson
*
*/
public class ColorPanelView extends View{
/**
* The width in pixels of the border
* surrounding the color panel.
*/
private final static int BORDER_WIDTH_PX = 1;
private final static int DEFAULT_BORDER_COLOR = 0xFF6E6E6E;
private int mBorderColor = DEFAULT_BORDER_COLOR;
private int mColor = 0xff000000;
private Paint mBorderPaint;
private Paint mColorPaint;
private Rect mDrawingRect;
private Rect mColorRect;
| // Path: app/src/main/java/cheetatech/com/colorhub/drawable/AlphaPatternDrawable.java
// public class AlphaPatternDrawable extends Drawable {
//
// private int mRectangleSize = 10;
//
// private Paint mPaint = new Paint();
// private Paint mPaintWhite = new Paint();
// private Paint mPaintGray = new Paint();
//
// private int numRectanglesHorizontal;
// private int numRectanglesVertical;
//
// /**
// * Bitmap in which the pattern will be cached.
// * This is so the pattern will not have to be recreated each time draw() gets called.
// * Because recreating the pattern i rather expensive. I will only be recreated if the
// * size changes.
// */
// private Bitmap mBitmap;
//
// public AlphaPatternDrawable(int rectangleSize) {
// mRectangleSize = rectangleSize;
// mPaintWhite.setColor(0xffffffff);
// mPaintGray.setColor(0xffcbcbcb);
// }
//
// @Override
// public void draw(Canvas canvas) {
// if(mBitmap != null && !mBitmap.isRecycled()) {
// canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
// }
// }
//
// @Override
// public int getOpacity() {
// return 0;
// }
//
// @Override
// public void setAlpha(int alpha) {
// throw new UnsupportedOperationException("Alpha is not supported by this drawable.");
// }
//
// @Override
// public void setColorFilter(ColorFilter cf) {
// throw new UnsupportedOperationException("ColorFilter is not supported by this drawable.");
// }
//
// @Override
// protected void onBoundsChange(Rect bounds) {
// super.onBoundsChange(bounds);
//
// int height = bounds.height();
// int width = bounds.width();
//
// numRectanglesHorizontal = (int) Math.ceil((width / mRectangleSize));
// numRectanglesVertical = (int) Math.ceil(height / mRectangleSize);
//
// generatePatternBitmap();
//
// }
//
// /**
// * This will generate a bitmap with the pattern
// * as big as the rectangle we were allow to draw on.
// * We do this to chache the bitmap so we don't need to
// * recreate it each time draw() is called since it
// * takes a few milliseconds.
// */
// private void generatePatternBitmap(){
//
// if(getBounds().width() <= 0 || getBounds().height() <= 0){
// return;
// }
//
// mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888);
// Canvas canvas = new Canvas(mBitmap);
//
// Rect r = new Rect();
// boolean verticalStartWhite = true;
// for (int i = 0; i <= numRectanglesVertical; i++) {
//
// boolean isWhite = verticalStartWhite;
// for (int j = 0; j <= numRectanglesHorizontal; j++) {
//
// r.top = i * mRectangleSize;
// r.left = j * mRectangleSize;
// r.bottom = r.top + mRectangleSize;
// r.right = r.left + mRectangleSize;
//
// canvas.drawRect(r, isWhite ? mPaintWhite : mPaintGray);
//
// isWhite = !isWhite;
// }
//
// verticalStartWhite = !verticalStartWhite;
//
// }
//
// }
//
// }
// Path: app/src/main/java/cheetatech/com/colorhub/view/ColorPanelView.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.drawable.AlphaPatternDrawable;
/*
* Copyright (C) 2015 Daniel Nilsson
*
* 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 cheetatech.com.colorhub.view;
/**
* This class draws a panel which which will be filled with a color which can be set.
* It can be used to show the currently selected color which you will get from
* the {@link ColorPickerView}.
* @author Daniel Nilsson
*
*/
public class ColorPanelView extends View{
/**
* The width in pixels of the border
* surrounding the color panel.
*/
private final static int BORDER_WIDTH_PX = 1;
private final static int DEFAULT_BORDER_COLOR = 0xFF6E6E6E;
private int mBorderColor = DEFAULT_BORDER_COLOR;
private int mColor = 0xff000000;
private Paint mBorderPaint;
private Paint mColorPaint;
private Rect mDrawingRect;
private Rect mColorRect;
| private AlphaPatternDrawable mAlphaPattern; |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/ColorHubApplication.java | // Path: app/src/main/java/cheetatech/com/colorhub/ads/AdsUtils.java
// public class AdsUtils {
//
// public static boolean TEST = true;
// private Context context = null;
// private static InterstitialAd mInterstitialAd = null;
// private int mInteractionValue = 0;
// private static int INTERACT_THRESHOLD = 12;
// private int DELAY = 2000;
//
//
// private static AdsUtils instance = null;
//
// public static AdsUtils getInstance(){
// if(instance == null)
// instance = new AdsUtils();
// return instance;
// }
//
// public boolean showAds(){
// if(mInterstitialAd.isLoaded()){
// mInterstitialAd.show();
// return true;
// }else{
// requestNewInterstitial();
// return false;
// }
// }
//
// public void showAdsWithRunnable(){
// final Handler handler = new Handler();
// handler.postDelayed(new Runnable() {
// @Override
// public void run() {
// if(mInterstitialAd.isLoaded()){
// mInterstitialAd.show();
// handler.removeCallbacks(this);
// }else{
// requestNewInterstitial();
// handler.postDelayed(this,DELAY);
// }
// }
// },DELAY);
// }
//
//
//
// private void load(){
// if(mInterstitialAd == null){
// mInterstitialAd = new InterstitialAd(context);
// mInterstitialAd.setAdUnitId(context.getString(R.string.admob_inter_app_pub));
// mInterstitialAd.setAdListener(new AdListener() {
// @Override
// public void onAdClosed() {
// Log.e("TAG","onAdClosed and new Request Interstitial");
// requestNewInterstitial();
// }
// });
// requestNewInterstitial();
// }
// }
//
// public Context getContext() {
// return context;
// }
//
// public void setContext(Context context) {
// this.context = context;
// load();
// }
//
// private void requestNewInterstitial() {
// AdRequest ret = null;
// TEST = BuildConfig.DEBUG;
// if (TEST) {
// ret = new AdRequest.Builder()
// .addTestDevice("0A02E72208689385EF8EE5F0CCCFE947")
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
// .addTestDevice("9552A433781FF6F1766BC1BDF72022E5")
// .build();
// } else {
// ret = new AdRequest.Builder()
// .addTestDevice("0A02E72208689385EF8EE5F0CCCFE947")
// .addTestDevice("9552A433781FF6F1766BC1BDF72022E5")
// .build();
// }
// mInterstitialAd.loadAd(ret);
// }
//
// public void increaseInteraction(){
// mInteractionValue++;
// controlInteraction();
// }
//
// private void controlInteraction() {
// if(mInteractionValue % INTERACT_THRESHOLD == 0) // if removed ads, ads will not show on screen
// showAds();
// }
//
// }
| import android.app.Application;
import cheetatech.com.colorhub.ads.AdsUtils;
import io.realm.Realm; | package cheetatech.com.colorhub;
/**
* Created by erkan on 20.03.2017.
*/
public class ColorHubApplication extends Application {
@Override
public void onCreate(){
super.onCreate();
Realm.init(this);
// Initialize for first time... | // Path: app/src/main/java/cheetatech/com/colorhub/ads/AdsUtils.java
// public class AdsUtils {
//
// public static boolean TEST = true;
// private Context context = null;
// private static InterstitialAd mInterstitialAd = null;
// private int mInteractionValue = 0;
// private static int INTERACT_THRESHOLD = 12;
// private int DELAY = 2000;
//
//
// private static AdsUtils instance = null;
//
// public static AdsUtils getInstance(){
// if(instance == null)
// instance = new AdsUtils();
// return instance;
// }
//
// public boolean showAds(){
// if(mInterstitialAd.isLoaded()){
// mInterstitialAd.show();
// return true;
// }else{
// requestNewInterstitial();
// return false;
// }
// }
//
// public void showAdsWithRunnable(){
// final Handler handler = new Handler();
// handler.postDelayed(new Runnable() {
// @Override
// public void run() {
// if(mInterstitialAd.isLoaded()){
// mInterstitialAd.show();
// handler.removeCallbacks(this);
// }else{
// requestNewInterstitial();
// handler.postDelayed(this,DELAY);
// }
// }
// },DELAY);
// }
//
//
//
// private void load(){
// if(mInterstitialAd == null){
// mInterstitialAd = new InterstitialAd(context);
// mInterstitialAd.setAdUnitId(context.getString(R.string.admob_inter_app_pub));
// mInterstitialAd.setAdListener(new AdListener() {
// @Override
// public void onAdClosed() {
// Log.e("TAG","onAdClosed and new Request Interstitial");
// requestNewInterstitial();
// }
// });
// requestNewInterstitial();
// }
// }
//
// public Context getContext() {
// return context;
// }
//
// public void setContext(Context context) {
// this.context = context;
// load();
// }
//
// private void requestNewInterstitial() {
// AdRequest ret = null;
// TEST = BuildConfig.DEBUG;
// if (TEST) {
// ret = new AdRequest.Builder()
// .addTestDevice("0A02E72208689385EF8EE5F0CCCFE947")
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
// .addTestDevice("9552A433781FF6F1766BC1BDF72022E5")
// .build();
// } else {
// ret = new AdRequest.Builder()
// .addTestDevice("0A02E72208689385EF8EE5F0CCCFE947")
// .addTestDevice("9552A433781FF6F1766BC1BDF72022E5")
// .build();
// }
// mInterstitialAd.loadAd(ret);
// }
//
// public void increaseInteraction(){
// mInteractionValue++;
// controlInteraction();
// }
//
// private void controlInteraction() {
// if(mInteractionValue % INTERACT_THRESHOLD == 0) // if removed ads, ads will not show on screen
// showAds();
// }
//
// }
// Path: app/src/main/java/cheetatech/com/colorhub/ColorHubApplication.java
import android.app.Application;
import cheetatech.com.colorhub.ads.AdsUtils;
import io.realm.Realm;
package cheetatech.com.colorhub;
/**
* Created by erkan on 20.03.2017.
*/
public class ColorHubApplication extends Application {
@Override
public void onCreate(){
super.onCreate();
Realm.init(this);
// Initialize for first time... | AdsUtils.getInstance().setContext(this); |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/controller/ColorArrayController.java | // Path: app/src/main/java/cheetatech/com/colorhub/defines/ColorInfo.java
// public class ColorInfo {
//
// private String colorName = null;
// private String colorCode = null;
// public ColorInfo(){}
// public ColorInfo(String colorName,String colorCode)
// {
// this.colorName = colorName;
// this.colorCode = colorCode;
// }
// public void setColorName(String colorName)
// {
// this.colorName = colorName;
// }
// public String getColorName()
// {
// return this.colorName;
// }
// public void setColorCode(String colorCode)
// {
// this.colorCode = colorCode;
// }
// public String getColorCode()
// {
// return this.colorCode;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/defines/MaterialColorInfo.java
// public class MaterialColorInfo {
// private List<ColorInfo> colorInfoList = new ArrayList<ColorInfo>();
//
// public MaterialColorInfo(List<ColorInfo> colorInfos)
// {
// this.colorInfoList.addAll(colorInfos);
// }
// public List<ColorInfo> getColorInfoList()
// {
// return this.colorInfoList;
// }
// public ColorInfo getColorInfo(int index)
// {
// if(index > this.colorInfoList.size())
// return null;
// return this.colorInfoList.get(index);
// }
//
// public void setColorInfoList(List<ColorInfo> colorInfoList)
// {
// this.colorInfoList = colorInfoList;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/drawer/ColorSelect.java
// public class ColorSelect {
// private String title;
// public ColorSelect(String title)
// {
// this.title = title;
// }
// public String getTitle()
// {
// return this.title;
// }
// }
| import android.content.res.Resources;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.ColorInfo;
import cheetatech.com.colorhub.defines.MaterialColorInfo;
import cheetatech.com.colorhub.drawer.ColorSelect; | package cheetatech.com.colorhub.controller;
public class ColorArrayController {
private List<ColorInfo> materialList = null;
private List<ColorInfo> flatList = null;
private List<ColorInfo> socialList = null;
private List<ColorInfo> metroList = null;
private List<ColorInfo> htmlList = null;
private String[] headerColorList = null;
| // Path: app/src/main/java/cheetatech/com/colorhub/defines/ColorInfo.java
// public class ColorInfo {
//
// private String colorName = null;
// private String colorCode = null;
// public ColorInfo(){}
// public ColorInfo(String colorName,String colorCode)
// {
// this.colorName = colorName;
// this.colorCode = colorCode;
// }
// public void setColorName(String colorName)
// {
// this.colorName = colorName;
// }
// public String getColorName()
// {
// return this.colorName;
// }
// public void setColorCode(String colorCode)
// {
// this.colorCode = colorCode;
// }
// public String getColorCode()
// {
// return this.colorCode;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/defines/MaterialColorInfo.java
// public class MaterialColorInfo {
// private List<ColorInfo> colorInfoList = new ArrayList<ColorInfo>();
//
// public MaterialColorInfo(List<ColorInfo> colorInfos)
// {
// this.colorInfoList.addAll(colorInfos);
// }
// public List<ColorInfo> getColorInfoList()
// {
// return this.colorInfoList;
// }
// public ColorInfo getColorInfo(int index)
// {
// if(index > this.colorInfoList.size())
// return null;
// return this.colorInfoList.get(index);
// }
//
// public void setColorInfoList(List<ColorInfo> colorInfoList)
// {
// this.colorInfoList = colorInfoList;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/drawer/ColorSelect.java
// public class ColorSelect {
// private String title;
// public ColorSelect(String title)
// {
// this.title = title;
// }
// public String getTitle()
// {
// return this.title;
// }
// }
// Path: app/src/main/java/cheetatech/com/colorhub/controller/ColorArrayController.java
import android.content.res.Resources;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.ColorInfo;
import cheetatech.com.colorhub.defines.MaterialColorInfo;
import cheetatech.com.colorhub.drawer.ColorSelect;
package cheetatech.com.colorhub.controller;
public class ColorArrayController {
private List<ColorInfo> materialList = null;
private List<ColorInfo> flatList = null;
private List<ColorInfo> socialList = null;
private List<ColorInfo> metroList = null;
private List<ColorInfo> htmlList = null;
private String[] headerColorList = null;
| private List<MaterialColorInfo> materialColorInfoList = null; |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/controller/ColorArrayController.java | // Path: app/src/main/java/cheetatech/com/colorhub/defines/ColorInfo.java
// public class ColorInfo {
//
// private String colorName = null;
// private String colorCode = null;
// public ColorInfo(){}
// public ColorInfo(String colorName,String colorCode)
// {
// this.colorName = colorName;
// this.colorCode = colorCode;
// }
// public void setColorName(String colorName)
// {
// this.colorName = colorName;
// }
// public String getColorName()
// {
// return this.colorName;
// }
// public void setColorCode(String colorCode)
// {
// this.colorCode = colorCode;
// }
// public String getColorCode()
// {
// return this.colorCode;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/defines/MaterialColorInfo.java
// public class MaterialColorInfo {
// private List<ColorInfo> colorInfoList = new ArrayList<ColorInfo>();
//
// public MaterialColorInfo(List<ColorInfo> colorInfos)
// {
// this.colorInfoList.addAll(colorInfos);
// }
// public List<ColorInfo> getColorInfoList()
// {
// return this.colorInfoList;
// }
// public ColorInfo getColorInfo(int index)
// {
// if(index > this.colorInfoList.size())
// return null;
// return this.colorInfoList.get(index);
// }
//
// public void setColorInfoList(List<ColorInfo> colorInfoList)
// {
// this.colorInfoList = colorInfoList;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/drawer/ColorSelect.java
// public class ColorSelect {
// private String title;
// public ColorSelect(String title)
// {
// this.title = title;
// }
// public String getTitle()
// {
// return this.title;
// }
// }
| import android.content.res.Resources;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.ColorInfo;
import cheetatech.com.colorhub.defines.MaterialColorInfo;
import cheetatech.com.colorhub.drawer.ColorSelect; | public void initMetro()
{
if(resources == null)
return;
metroList.clear();
String[] colorCodes = resources.getStringArray(R.array.MetroColorCode);
String[] colorNames = resources.getStringArray(R.array.MetroColorName);
for(int i = 0; i< colorCodes.length;i++)
metroList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
}
public List<String> getMaterialNameList()
{
String[] colorNames = resources.getStringArray(R.array.MaterialColorNames);
return Arrays.asList(colorNames);
}
public void initHtml()
{
if(resources == null)
return;
htmlList.clear();
String[] colorCodes = resources.getStringArray(R.array.HtmlColorCode);
String[] colorNames = resources.getStringArray(R.array.HtmlColorName);
for(int i = 0; i< colorCodes.length;i++)
htmlList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
}
| // Path: app/src/main/java/cheetatech/com/colorhub/defines/ColorInfo.java
// public class ColorInfo {
//
// private String colorName = null;
// private String colorCode = null;
// public ColorInfo(){}
// public ColorInfo(String colorName,String colorCode)
// {
// this.colorName = colorName;
// this.colorCode = colorCode;
// }
// public void setColorName(String colorName)
// {
// this.colorName = colorName;
// }
// public String getColorName()
// {
// return this.colorName;
// }
// public void setColorCode(String colorCode)
// {
// this.colorCode = colorCode;
// }
// public String getColorCode()
// {
// return this.colorCode;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/defines/MaterialColorInfo.java
// public class MaterialColorInfo {
// private List<ColorInfo> colorInfoList = new ArrayList<ColorInfo>();
//
// public MaterialColorInfo(List<ColorInfo> colorInfos)
// {
// this.colorInfoList.addAll(colorInfos);
// }
// public List<ColorInfo> getColorInfoList()
// {
// return this.colorInfoList;
// }
// public ColorInfo getColorInfo(int index)
// {
// if(index > this.colorInfoList.size())
// return null;
// return this.colorInfoList.get(index);
// }
//
// public void setColorInfoList(List<ColorInfo> colorInfoList)
// {
// this.colorInfoList = colorInfoList;
// }
// }
//
// Path: app/src/main/java/cheetatech/com/colorhub/drawer/ColorSelect.java
// public class ColorSelect {
// private String title;
// public ColorSelect(String title)
// {
// this.title = title;
// }
// public String getTitle()
// {
// return this.title;
// }
// }
// Path: app/src/main/java/cheetatech/com/colorhub/controller/ColorArrayController.java
import android.content.res.Resources;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.defines.ColorInfo;
import cheetatech.com.colorhub.defines.MaterialColorInfo;
import cheetatech.com.colorhub.drawer.ColorSelect;
public void initMetro()
{
if(resources == null)
return;
metroList.clear();
String[] colorCodes = resources.getStringArray(R.array.MetroColorCode);
String[] colorNames = resources.getStringArray(R.array.MetroColorName);
for(int i = 0; i< colorCodes.length;i++)
metroList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
}
public List<String> getMaterialNameList()
{
String[] colorNames = resources.getStringArray(R.array.MaterialColorNames);
return Arrays.asList(colorNames);
}
public void initHtml()
{
if(resources == null)
return;
htmlList.clear();
String[] colorCodes = resources.getStringArray(R.array.HtmlColorCode);
String[] colorNames = resources.getStringArray(R.array.HtmlColorName);
for(int i = 0; i< colorCodes.length;i++)
htmlList.add(new ColorInfo(colorNames[i],colorCodes[i].toUpperCase()));
}
| public List<ColorSelect> getMaterialNameColorSelectList() |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/controller/DrawerListController.java | // Path: app/src/main/java/cheetatech/com/colorhub/drawer/NavigationSelect.java
// public class NavigationSelect {
// private String title;
// private int drawableId ;
// public NavigationSelect(String title,int id)
// {
// this.title = title;
// this.drawableId = id;
// }
// public String getTitle()
// {
// return this.title;
// }
// public int getDrawableId()
// {
// return this.drawableId;
// }
//
// }
| import java.util.ArrayList;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.drawer.NavigationSelect; | package cheetatech.com.colorhub.controller;
public class DrawerListController {
private static DrawerListController ourInstance = null;
| // Path: app/src/main/java/cheetatech/com/colorhub/drawer/NavigationSelect.java
// public class NavigationSelect {
// private String title;
// private int drawableId ;
// public NavigationSelect(String title,int id)
// {
// this.title = title;
// this.drawableId = id;
// }
// public String getTitle()
// {
// return this.title;
// }
// public int getDrawableId()
// {
// return this.drawableId;
// }
//
// }
// Path: app/src/main/java/cheetatech/com/colorhub/controller/DrawerListController.java
import java.util.ArrayList;
import cheetatech.com.colorhub.R;
import cheetatech.com.colorhub.drawer.NavigationSelect;
package cheetatech.com.colorhub.controller;
public class DrawerListController {
private static DrawerListController ourInstance = null;
| private ArrayList<NavigationSelect> navList = null; |
AntriKodSoft/ColorHub | app/src/main/java/cheetatech/com/colorhub/realm/SavedObject.java | // Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
| import java.util.List;
import cheetatech.com.colorhub.models.Model;
import io.realm.RealmList;
import io.realm.RealmObject; | package cheetatech.com.colorhub.realm;
/**
* Created by erkan on 20.03.2017.
*/
public class SavedObject extends RealmObject {
private String name; | // Path: app/src/main/java/cheetatech/com/colorhub/models/Model.java
// public class Model extends RealmObject{
// private String colorCode;
//
// public Model(){}
// public Model(String colorCode) {
// this.colorCode = colorCode;
// }
//
// public String getColorCode() {
// return colorCode;
// }
//
// public void setColorCode(String colorCode) {
// RealmX.realm().beginTransaction();
// this.colorCode = colorCode;
// RealmX.realm().commitTransaction();
// }
//
// }
// Path: app/src/main/java/cheetatech/com/colorhub/realm/SavedObject.java
import java.util.List;
import cheetatech.com.colorhub.models.Model;
import io.realm.RealmList;
import io.realm.RealmObject;
package cheetatech.com.colorhub.realm;
/**
* Created by erkan on 20.03.2017.
*/
public class SavedObject extends RealmObject {
private String name; | private RealmList<Model> list; |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/Utils.java | // Path: src/main/java/com/smartbear/swagger4j/SwaggerFormat.java
// public enum SwaggerFormat {
// xml, json;
//
// public String getExtension() {
// return this.name().toLowerCase();
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerStore.java
// public interface SwaggerStore {
//
// /**
// * Create a resource with the specified path
// *
// * @param path the path of the resource to create
// * @return a Writer to which the resource can be written
// * @throws IOException
// */
//
// public Writer createResource(String path) throws IOException;
// }
| import com.smartbear.swagger4j.SwaggerFormat;
import com.smartbear.swagger4j.SwaggerStore;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* General utilities methods, classes and constants
*/
public class Utils {
/**
* Method for creating a filename from a path - replaces format references and adds the extension.
*
* @param path the path to fix
* @param format the format to use
* @return the created fileName
*/
public static String createFileNameFromPath(String path, SwaggerFormat format) {
assert path != null && format != null : "Path and format must not be null";
String name = path.replaceAll("\\{format\\}", format.getExtension());
return name;
}
/**
* SwaggerStore implementation that writes Swagger definitions to a map of fileName to StringWriter
*
* @see SwaggerStore
*/
| // Path: src/main/java/com/smartbear/swagger4j/SwaggerFormat.java
// public enum SwaggerFormat {
// xml, json;
//
// public String getExtension() {
// return this.name().toLowerCase();
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerStore.java
// public interface SwaggerStore {
//
// /**
// * Create a resource with the specified path
// *
// * @param path the path of the resource to create
// * @return a Writer to which the resource can be written
// * @throws IOException
// */
//
// public Writer createResource(String path) throws IOException;
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/Utils.java
import com.smartbear.swagger4j.SwaggerFormat;
import com.smartbear.swagger4j.SwaggerStore;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* General utilities methods, classes and constants
*/
public class Utils {
/**
* Method for creating a filename from a path - replaces format references and adds the extension.
*
* @param path the path to fix
* @param format the format to use
* @return the created fileName
*/
public static String createFileNameFromPath(String path, SwaggerFormat format) {
assert path != null && format != null : "Path and format must not be null";
String name = path.replaceAll("\\{format\\}", format.getExtension());
return name;
}
/**
* SwaggerStore implementation that writes Swagger definitions to a map of fileName to StringWriter
*
* @see SwaggerStore
*/
| public static class MapSwaggerStore implements SwaggerStore { |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/Constants.java | // Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
| import com.smartbear.swagger4j.SwaggerVersion; | public static final String INFO_DESCRIPTION = "description";
public static final String INFO_LICENSE = "license";
public static final String INFO_LICENSE_URL = "licenseUrl";
public static final String INFO_TERMSOFSERVICEURL = "termsOfServiceUrl";
public static final String INFO_TITLE = "title";
public static final String RESPONSE_MODEL = "responseModel";
public static final String OAUTH2_SCOPE = "scope";
public static final String OAUTH2_SCOPE_DESCRIPTION = "description";
public static final String HTTP_METHOD = "httpMethod";
public static final String MODELS = "models";
public static final String ID = "id";
public static final String PROPERTIES = "properties";
public static final String $REF = "$ref";
public static final String FORMAT = "format";
public static final String ITEMS = "items";
public static final String ENUM = "enum";
public static final String MINIMUM = "minimum";
public static final String MAXIMUM = "maximum";
public static final String DEFAULT_VALUE = "defaultValue";
public String METHOD = "method";
public String TYPE = "type";
public String MESSAGE = "message";
public String RESPONSE_MESSAGES = "responseMessages";
public String OPERATION_TYPE = "type";
public static final Constants V1_1 = new V1_1Constants();
public static final Constants V1_2 = new Constants();
public static final Constants V2_0 = new Constants();
| // Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/Constants.java
import com.smartbear.swagger4j.SwaggerVersion;
public static final String INFO_DESCRIPTION = "description";
public static final String INFO_LICENSE = "license";
public static final String INFO_LICENSE_URL = "licenseUrl";
public static final String INFO_TERMSOFSERVICEURL = "termsOfServiceUrl";
public static final String INFO_TITLE = "title";
public static final String RESPONSE_MODEL = "responseModel";
public static final String OAUTH2_SCOPE = "scope";
public static final String OAUTH2_SCOPE_DESCRIPTION = "description";
public static final String HTTP_METHOD = "httpMethod";
public static final String MODELS = "models";
public static final String ID = "id";
public static final String PROPERTIES = "properties";
public static final String $REF = "$ref";
public static final String FORMAT = "format";
public static final String ITEMS = "items";
public static final String ENUM = "enum";
public static final String MINIMUM = "minimum";
public static final String MAXIMUM = "maximum";
public static final String DEFAULT_VALUE = "defaultValue";
public String METHOD = "method";
public String TYPE = "type";
public String MESSAGE = "message";
public String RESPONSE_MESSAGES = "responseMessages";
public String OPERATION_TYPE = "type";
public static final Constants V1_1 = new V1_1Constants();
public static final Constants V1_2 = new Constants();
public static final Constants V2_0 = new Constants();
| public static Constants get(SwaggerVersion version) { |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/Swagger.java | // Path: src/main/java/com/smartbear/swagger4j/impl/SwaggerFactoryImpl.java
// public class SwaggerFactoryImpl implements SwaggerFactory {
//
// @Override
// public ResourceListing createResourceListing(SwaggerVersion version) {
// assert version != null : "version can not be null";
// return new ResourceListingImpl(version);
// }
//
// @Override
// public ApiDeclaration createApiDeclaration(String basePath, String resourcePath) {
// assert basePath != null && resourcePath != null : "basePath and resourcePath can not be null";
// return new ApiDeclarationImpl(basePath, resourcePath);
// }
//
// @Override
// public SwaggerReader createSwaggerReader() {
// return new SwaggerReaderImpl();
// }
//
// @Override
// public SwaggerWriter createSwaggerWriter(SwaggerFormat format) {
// return new SwaggerWriterImpl(format);
// }
// }
| import com.smartbear.swagger4j.impl.SwaggerFactoryImpl;
import java.io.IOException;
import java.net.URI;
import java.util.Iterator;
import static java.util.ServiceLoader.load; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j;
/**
* Utility methods to read/write/create Swagger objects
*/
public class Swagger {
/**
* Avoid instantiation
*/
private Swagger() {
}
/**
* Creates an empty ResourceListing with the specified basePath - uses the standard SwaggerFactory
*
* @param swaggerVersion the Swagger version to use
* @return an empty ResourceListing
*/
public static ResourceListing createResourceListing(SwaggerVersion swaggerVersion) {
return createSwaggerFactory().createResourceListing(swaggerVersion);
}
/**
* Creates an empty ApiDeclaration with the specified basePath and resourcePath
*
* @param basePath used to resolve API paths defined in this declaration
* @param resourcePath path to the actual resource described in the declaration
* @return an empty ApiDeclaration
*/
public static ApiDeclaration createApiDeclaration(String basePath, String resourcePath) {
return createSwaggerFactory().createApiDeclaration(basePath, resourcePath);
}
/**
* Creates a SwaggerReader using the available SwaggerFactory
*
* @return a SwaggerReader
*/
public static SwaggerReader createReader() {
return createSwaggerFactory().createSwaggerReader();
}
/**
* Reads a Swagger definition from the specified URI, uses the default SwaggerReader implementation
*
* @param uri the URI of the api-docs document defining the Swagger ResourceListing
* @return the initialized ResourceListing object
* @throws IOException
*/
public static ResourceListing readSwagger(URI uri) throws IOException {
return createReader().readResourceListing(uri);
}
/**
* Writes the specified Swagger ResourceListing to the specified local path in json format. Uses the default SwaggerWriter
*
* @param resourceListing the resourceListing to write
* @param path path to an existing folder where the api-docs and api declarations will be written
* @throws IOException
*/
public static void writeSwagger(ResourceListing resourceListing, String path) throws IOException {
writeSwagger(resourceListing, path, SwaggerFormat.json);
}
/**
* Writes the specified Swagger ResourceListing to the specified local path in either json or xml format.
* Uses the default SwaggerWriter
*
* @param resourceListing the resourceListing to write
* @param path path to an existing folder where the api-docs and api declarations will be written
* @param format the format to use; either json or xml
* @throws IOException
*/
public static void writeSwagger(ResourceListing resourceListing, String path, SwaggerFormat format) throws IOException {
createWriter(format).writeSwagger(new FileSwaggerStore(path), resourceListing);
}
/**
* Creates a SwaggerWriter for the specified format using the default SwaggerFactory
*
* @param format the format the writer should use, either json or xml
* @return the created SwaggerWriter
*/
public static SwaggerWriter createWriter(SwaggerFormat format) {
return createSwaggerFactory().createSwaggerWriter(format);
}
/**
* method for creating a SwaggerFactory; uses java.util.ServiceLoader to find a SwaggerFactory
* implementation - falls back to the default implementation if none are found
*
* @return a SwaggerFactory instance
*/
public static SwaggerFactory createSwaggerFactory() {
Iterator<SwaggerFactory> iterator = load(SwaggerFactory.class).iterator();
if (iterator.hasNext()) {
return iterator.next();
}
| // Path: src/main/java/com/smartbear/swagger4j/impl/SwaggerFactoryImpl.java
// public class SwaggerFactoryImpl implements SwaggerFactory {
//
// @Override
// public ResourceListing createResourceListing(SwaggerVersion version) {
// assert version != null : "version can not be null";
// return new ResourceListingImpl(version);
// }
//
// @Override
// public ApiDeclaration createApiDeclaration(String basePath, String resourcePath) {
// assert basePath != null && resourcePath != null : "basePath and resourcePath can not be null";
// return new ApiDeclarationImpl(basePath, resourcePath);
// }
//
// @Override
// public SwaggerReader createSwaggerReader() {
// return new SwaggerReaderImpl();
// }
//
// @Override
// public SwaggerWriter createSwaggerWriter(SwaggerFormat format) {
// return new SwaggerWriterImpl(format);
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/Swagger.java
import com.smartbear.swagger4j.impl.SwaggerFactoryImpl;
import java.io.IOException;
import java.net.URI;
import java.util.Iterator;
import static java.util.ServiceLoader.load;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j;
/**
* Utility methods to read/write/create Swagger objects
*/
public class Swagger {
/**
* Avoid instantiation
*/
private Swagger() {
}
/**
* Creates an empty ResourceListing with the specified basePath - uses the standard SwaggerFactory
*
* @param swaggerVersion the Swagger version to use
* @return an empty ResourceListing
*/
public static ResourceListing createResourceListing(SwaggerVersion swaggerVersion) {
return createSwaggerFactory().createResourceListing(swaggerVersion);
}
/**
* Creates an empty ApiDeclaration with the specified basePath and resourcePath
*
* @param basePath used to resolve API paths defined in this declaration
* @param resourcePath path to the actual resource described in the declaration
* @return an empty ApiDeclaration
*/
public static ApiDeclaration createApiDeclaration(String basePath, String resourcePath) {
return createSwaggerFactory().createApiDeclaration(basePath, resourcePath);
}
/**
* Creates a SwaggerReader using the available SwaggerFactory
*
* @return a SwaggerReader
*/
public static SwaggerReader createReader() {
return createSwaggerFactory().createSwaggerReader();
}
/**
* Reads a Swagger definition from the specified URI, uses the default SwaggerReader implementation
*
* @param uri the URI of the api-docs document defining the Swagger ResourceListing
* @return the initialized ResourceListing object
* @throws IOException
*/
public static ResourceListing readSwagger(URI uri) throws IOException {
return createReader().readResourceListing(uri);
}
/**
* Writes the specified Swagger ResourceListing to the specified local path in json format. Uses the default SwaggerWriter
*
* @param resourceListing the resourceListing to write
* @param path path to an existing folder where the api-docs and api declarations will be written
* @throws IOException
*/
public static void writeSwagger(ResourceListing resourceListing, String path) throws IOException {
writeSwagger(resourceListing, path, SwaggerFormat.json);
}
/**
* Writes the specified Swagger ResourceListing to the specified local path in either json or xml format.
* Uses the default SwaggerWriter
*
* @param resourceListing the resourceListing to write
* @param path path to an existing folder where the api-docs and api declarations will be written
* @param format the format to use; either json or xml
* @throws IOException
*/
public static void writeSwagger(ResourceListing resourceListing, String path, SwaggerFormat format) throws IOException {
createWriter(format).writeSwagger(new FileSwaggerStore(path), resourceListing);
}
/**
* Creates a SwaggerWriter for the specified format using the default SwaggerFactory
*
* @param format the format the writer should use, either json or xml
* @return the created SwaggerWriter
*/
public static SwaggerWriter createWriter(SwaggerFormat format) {
return createSwaggerFactory().createSwaggerWriter(format);
}
/**
* method for creating a SwaggerFactory; uses java.util.ServiceLoader to find a SwaggerFactory
* implementation - falls back to the default implementation if none are found
*
* @return a SwaggerFactory instance
*/
public static SwaggerFactory createSwaggerFactory() {
Iterator<SwaggerFactory> iterator = load(SwaggerFactory.class).iterator();
if (iterator.hasNext()) {
return iterator.next();
}
| return new SwaggerFactoryImpl(); |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ModelImpl.java | // Path: src/main/java/com/smartbear/swagger4j/DataType.java
// public interface DataType {
//
// String getType();
//
// String getRef();
//
// String getFormat();
//
// boolean isArray();
//
// boolean isPrimitive();
//
// boolean isComplex();
//
// boolean isVoid();
//
// boolean isRef();
//
// DataType VOID = new DataType() {
//
// @Override
// public String toString() {
// return getType();
// }
//
// @Override
// public String getType() {
// return "void";
// }
//
// @Override
// public String getRef() {
// return null;
// }
//
// @Override
// public String getFormat() {
// return null;
// }
//
// @Override
// public boolean isArray() {
// return false;
// }
//
// @Override
// public boolean isPrimitive() {
// return false;
// }
//
// public boolean isComplex() {
// return false;
// }
//
// @Override
// public boolean isVoid() {
// return true;
// }
//
// @Override
// public boolean isRef() {
// return false;
// }
// };
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Property.java
// public interface Property extends HasDataType {
//
// String getDescription();
//
// boolean isRequired();
// }
| import com.smartbear.swagger4j.DataType;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.Property;
import java.util.Collections;
import java.util.List; | /*
* Copyright 2014 Yann D'Isanto.
*
* 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.smartbear.swagger4j.impl;
/**
* @author Yann D'Isanto
*/
public class ModelImpl implements Model {
private String id;
| // Path: src/main/java/com/smartbear/swagger4j/DataType.java
// public interface DataType {
//
// String getType();
//
// String getRef();
//
// String getFormat();
//
// boolean isArray();
//
// boolean isPrimitive();
//
// boolean isComplex();
//
// boolean isVoid();
//
// boolean isRef();
//
// DataType VOID = new DataType() {
//
// @Override
// public String toString() {
// return getType();
// }
//
// @Override
// public String getType() {
// return "void";
// }
//
// @Override
// public String getRef() {
// return null;
// }
//
// @Override
// public String getFormat() {
// return null;
// }
//
// @Override
// public boolean isArray() {
// return false;
// }
//
// @Override
// public boolean isPrimitive() {
// return false;
// }
//
// public boolean isComplex() {
// return false;
// }
//
// @Override
// public boolean isVoid() {
// return true;
// }
//
// @Override
// public boolean isRef() {
// return false;
// }
// };
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Property.java
// public interface Property extends HasDataType {
//
// String getDescription();
//
// boolean isRequired();
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ModelImpl.java
import com.smartbear.swagger4j.DataType;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.Property;
import java.util.Collections;
import java.util.List;
/*
* Copyright 2014 Yann D'Isanto.
*
* 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.smartbear.swagger4j.impl;
/**
* @author Yann D'Isanto
*/
public class ModelImpl implements Model {
private String id;
| private final DataType dataType; |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ModelImpl.java | // Path: src/main/java/com/smartbear/swagger4j/DataType.java
// public interface DataType {
//
// String getType();
//
// String getRef();
//
// String getFormat();
//
// boolean isArray();
//
// boolean isPrimitive();
//
// boolean isComplex();
//
// boolean isVoid();
//
// boolean isRef();
//
// DataType VOID = new DataType() {
//
// @Override
// public String toString() {
// return getType();
// }
//
// @Override
// public String getType() {
// return "void";
// }
//
// @Override
// public String getRef() {
// return null;
// }
//
// @Override
// public String getFormat() {
// return null;
// }
//
// @Override
// public boolean isArray() {
// return false;
// }
//
// @Override
// public boolean isPrimitive() {
// return false;
// }
//
// public boolean isComplex() {
// return false;
// }
//
// @Override
// public boolean isVoid() {
// return true;
// }
//
// @Override
// public boolean isRef() {
// return false;
// }
// };
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Property.java
// public interface Property extends HasDataType {
//
// String getDescription();
//
// boolean isRequired();
// }
| import com.smartbear.swagger4j.DataType;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.Property;
import java.util.Collections;
import java.util.List; | /*
* Copyright 2014 Yann D'Isanto.
*
* 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.smartbear.swagger4j.impl;
/**
* @author Yann D'Isanto
*/
public class ModelImpl implements Model {
private String id;
private final DataType dataType;
private String description;
private List<String> requiredProperties;
| // Path: src/main/java/com/smartbear/swagger4j/DataType.java
// public interface DataType {
//
// String getType();
//
// String getRef();
//
// String getFormat();
//
// boolean isArray();
//
// boolean isPrimitive();
//
// boolean isComplex();
//
// boolean isVoid();
//
// boolean isRef();
//
// DataType VOID = new DataType() {
//
// @Override
// public String toString() {
// return getType();
// }
//
// @Override
// public String getType() {
// return "void";
// }
//
// @Override
// public String getRef() {
// return null;
// }
//
// @Override
// public String getFormat() {
// return null;
// }
//
// @Override
// public boolean isArray() {
// return false;
// }
//
// @Override
// public boolean isPrimitive() {
// return false;
// }
//
// public boolean isComplex() {
// return false;
// }
//
// @Override
// public boolean isVoid() {
// return true;
// }
//
// @Override
// public boolean isRef() {
// return false;
// }
// };
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Property.java
// public interface Property extends HasDataType {
//
// String getDescription();
//
// boolean isRequired();
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ModelImpl.java
import com.smartbear.swagger4j.DataType;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.Property;
import java.util.Collections;
import java.util.List;
/*
* Copyright 2014 Yann D'Isanto.
*
* 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.smartbear.swagger4j.impl;
/**
* @author Yann D'Isanto
*/
public class ModelImpl implements Model {
private String id;
private final DataType dataType;
private String description;
private List<String> requiredProperties;
| private List<Property> properties; |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ResourceListingImpl.java | // Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResourceListing.java
// public interface ResourceListing {
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public List<ResourceListingApi> getApis();
//
// public void removeApi(ResourceListingApi api);
//
// public ResourceListingApi addApi(ApiDeclaration apiDeclaration, String path);
//
// /**
// * Concatenates then returns the models of all APIs.
// *
// * @return a Model collection.
// */
// public Collection<Model> getApisModels();
//
// /**
// * A reference to a Swagger API-Declaration contained within a Resource-Listing
// */
//
// public interface ResourceListingApi {
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public ApiDeclaration getDeclaration();
//
// public String getPath();
//
// public void setPath(String path);
// }
//
// public Info getInfo();
//
// public Authorizations getAuthorizations();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
| import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Authorizations;
import com.smartbear.swagger4j.Info;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.ResourceListing;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List; | public SwaggerVersion getSwaggerVersion() {
return swaggerVersion;
}
public void setSwaggerVersion(SwaggerVersion swaggerVersion) {
this.swaggerVersion = swaggerVersion;
}
public String getBasePath() {
return basePath;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
@Override
public List<ResourceListingApi> getApis() {
return Collections.unmodifiableList(apiList);
}
@Override
public void removeApi(ResourceListingApi api) {
if (apiList.contains(api)) {
apiList.remove(api);
}
}
@Override | // Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResourceListing.java
// public interface ResourceListing {
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public List<ResourceListingApi> getApis();
//
// public void removeApi(ResourceListingApi api);
//
// public ResourceListingApi addApi(ApiDeclaration apiDeclaration, String path);
//
// /**
// * Concatenates then returns the models of all APIs.
// *
// * @return a Model collection.
// */
// public Collection<Model> getApisModels();
//
// /**
// * A reference to a Swagger API-Declaration contained within a Resource-Listing
// */
//
// public interface ResourceListingApi {
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public ApiDeclaration getDeclaration();
//
// public String getPath();
//
// public void setPath(String path);
// }
//
// public Info getInfo();
//
// public Authorizations getAuthorizations();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ResourceListingImpl.java
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Authorizations;
import com.smartbear.swagger4j.Info;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.ResourceListing;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public SwaggerVersion getSwaggerVersion() {
return swaggerVersion;
}
public void setSwaggerVersion(SwaggerVersion swaggerVersion) {
this.swaggerVersion = swaggerVersion;
}
public String getBasePath() {
return basePath;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
@Override
public List<ResourceListingApi> getApis() {
return Collections.unmodifiableList(apiList);
}
@Override
public void removeApi(ResourceListingApi api) {
if (apiList.contains(api)) {
apiList.remove(api);
}
}
@Override | public ResourceListingApi addApi(ApiDeclaration apiDeclaration, String path) { |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ResourceListingImpl.java | // Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResourceListing.java
// public interface ResourceListing {
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public List<ResourceListingApi> getApis();
//
// public void removeApi(ResourceListingApi api);
//
// public ResourceListingApi addApi(ApiDeclaration apiDeclaration, String path);
//
// /**
// * Concatenates then returns the models of all APIs.
// *
// * @return a Model collection.
// */
// public Collection<Model> getApisModels();
//
// /**
// * A reference to a Swagger API-Declaration contained within a Resource-Listing
// */
//
// public interface ResourceListingApi {
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public ApiDeclaration getDeclaration();
//
// public String getPath();
//
// public void setPath(String path);
// }
//
// public Info getInfo();
//
// public Authorizations getAuthorizations();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
| import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Authorizations;
import com.smartbear.swagger4j.Info;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.ResourceListing;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List; |
@Override
public Info getInfo() {
if (info == null) {
info = new InfoImpl();
}
return info;
}
public Authorizations getAuthorizations() {
if (authorizations == null) {
authorizations = new AuthorizationsImpl();
}
return authorizations;
}
private ResourceListingApi getApi(String path) {
synchronized (apiList) {
for (ResourceListingApi api : apiList) {
if (api.getPath().equals(path)) {
return api;
}
}
return null;
}
}
| // Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResourceListing.java
// public interface ResourceListing {
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public List<ResourceListingApi> getApis();
//
// public void removeApi(ResourceListingApi api);
//
// public ResourceListingApi addApi(ApiDeclaration apiDeclaration, String path);
//
// /**
// * Concatenates then returns the models of all APIs.
// *
// * @return a Model collection.
// */
// public Collection<Model> getApisModels();
//
// /**
// * A reference to a Swagger API-Declaration contained within a Resource-Listing
// */
//
// public interface ResourceListingApi {
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public ApiDeclaration getDeclaration();
//
// public String getPath();
//
// public void setPath(String path);
// }
//
// public Info getInfo();
//
// public Authorizations getAuthorizations();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ResourceListingImpl.java
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Authorizations;
import com.smartbear.swagger4j.Info;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.ResourceListing;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@Override
public Info getInfo() {
if (info == null) {
info = new InfoImpl();
}
return info;
}
public Authorizations getAuthorizations() {
if (authorizations == null) {
authorizations = new AuthorizationsImpl();
}
return authorizations;
}
private ResourceListingApi getApi(String path) {
synchronized (apiList) {
for (ResourceListingApi api : apiList) {
if (api.getPath().equals(path)) {
return api;
}
}
return null;
}
}
| public Collection<Model> getApisModels() { |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ApiImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Operation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Api interface
*
* @see Api
*/
public class ApiImpl implements Api {
private String path;
private String description; | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ApiImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Operation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Api interface
*
* @see Api
*/
public class ApiImpl implements Api {
private String path;
private String description; | private final List<Operation> operations = new ArrayList<Operation>(); |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ApiImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Operation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Api interface
*
* @see Api
*/
public class ApiImpl implements Api {
private String path;
private String description;
private final List<Operation> operations = new ArrayList<Operation>(); | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ApiImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Operation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Api interface
*
* @see Api
*/
public class ApiImpl implements Api {
private String path;
private String description;
private final List<Operation> operations = new ArrayList<Operation>(); | private ApiDeclaration apiDeclaration; |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/OperationImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Parameter.java
// public interface Parameter {
// public ParamType getParamType();
//
// public void setParamType(ParamType paramType);
//
// public String getName();
//
// public void setName(String name);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public boolean isRequired();
//
// public void setRequired(boolean required);
//
// public String getType();
//
// public void setType(String type);
//
// public boolean isAllowMultiple();
//
// public void setAllowMultiple(boolean multiple);
//
// /**
// * Parameter type - see <a href="https://github.com/wordnik/swagger-core/wiki/Parameters"
// * target="_new">https://github.com/wordnik/swagger-core/wiki/Parameters</a>
// */
//
// public enum ParamType {
// path, query, body, header, form
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResponseMessage.java
// public interface ResponseMessage {
//
// public int getCode();
//
// public void setCode(int code);
//
// public String getMessage();
//
// public void setMessage(String message);
//
// public String getResponseModel();
//
// public void setResponseModel(String responseModel);
//
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.Operation;
import com.smartbear.swagger4j.Parameter;
import com.smartbear.swagger4j.ResponseMessage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Operation interface
*
* @see Operation
*/
public class OperationImpl implements Operation {
private String nickName;
private Method method;
private String responseClass;
private String summary;
private String notes;
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>(); | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Parameter.java
// public interface Parameter {
// public ParamType getParamType();
//
// public void setParamType(ParamType paramType);
//
// public String getName();
//
// public void setName(String name);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public boolean isRequired();
//
// public void setRequired(boolean required);
//
// public String getType();
//
// public void setType(String type);
//
// public boolean isAllowMultiple();
//
// public void setAllowMultiple(boolean multiple);
//
// /**
// * Parameter type - see <a href="https://github.com/wordnik/swagger-core/wiki/Parameters"
// * target="_new">https://github.com/wordnik/swagger-core/wiki/Parameters</a>
// */
//
// public enum ParamType {
// path, query, body, header, form
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResponseMessage.java
// public interface ResponseMessage {
//
// public int getCode();
//
// public void setCode(int code);
//
// public String getMessage();
//
// public void setMessage(String message);
//
// public String getResponseModel();
//
// public void setResponseModel(String responseModel);
//
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/OperationImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.Operation;
import com.smartbear.swagger4j.Parameter;
import com.smartbear.swagger4j.ResponseMessage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Operation interface
*
* @see Operation
*/
public class OperationImpl implements Operation {
private String nickName;
private Method method;
private String responseClass;
private String summary;
private String notes;
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>(); | private final List<Parameter> parameterList = new ArrayList<Parameter>(); |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/OperationImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Parameter.java
// public interface Parameter {
// public ParamType getParamType();
//
// public void setParamType(ParamType paramType);
//
// public String getName();
//
// public void setName(String name);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public boolean isRequired();
//
// public void setRequired(boolean required);
//
// public String getType();
//
// public void setType(String type);
//
// public boolean isAllowMultiple();
//
// public void setAllowMultiple(boolean multiple);
//
// /**
// * Parameter type - see <a href="https://github.com/wordnik/swagger-core/wiki/Parameters"
// * target="_new">https://github.com/wordnik/swagger-core/wiki/Parameters</a>
// */
//
// public enum ParamType {
// path, query, body, header, form
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResponseMessage.java
// public interface ResponseMessage {
//
// public int getCode();
//
// public void setCode(int code);
//
// public String getMessage();
//
// public void setMessage(String message);
//
// public String getResponseModel();
//
// public void setResponseModel(String responseModel);
//
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.Operation;
import com.smartbear.swagger4j.Parameter;
import com.smartbear.swagger4j.ResponseMessage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Operation interface
*
* @see Operation
*/
public class OperationImpl implements Operation {
private String nickName;
private Method method;
private String responseClass;
private String summary;
private String notes;
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>();
private final List<Parameter> parameterList = new ArrayList<Parameter>(); | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Parameter.java
// public interface Parameter {
// public ParamType getParamType();
//
// public void setParamType(ParamType paramType);
//
// public String getName();
//
// public void setName(String name);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public boolean isRequired();
//
// public void setRequired(boolean required);
//
// public String getType();
//
// public void setType(String type);
//
// public boolean isAllowMultiple();
//
// public void setAllowMultiple(boolean multiple);
//
// /**
// * Parameter type - see <a href="https://github.com/wordnik/swagger-core/wiki/Parameters"
// * target="_new">https://github.com/wordnik/swagger-core/wiki/Parameters</a>
// */
//
// public enum ParamType {
// path, query, body, header, form
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResponseMessage.java
// public interface ResponseMessage {
//
// public int getCode();
//
// public void setCode(int code);
//
// public String getMessage();
//
// public void setMessage(String message);
//
// public String getResponseModel();
//
// public void setResponseModel(String responseModel);
//
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/OperationImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.Operation;
import com.smartbear.swagger4j.Parameter;
import com.smartbear.swagger4j.ResponseMessage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Operation interface
*
* @see Operation
*/
public class OperationImpl implements Operation {
private String nickName;
private Method method;
private String responseClass;
private String summary;
private String notes;
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>();
private final List<Parameter> parameterList = new ArrayList<Parameter>(); | private final List<ResponseMessage> responseMessages = new ArrayList<ResponseMessage>(); |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/OperationImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Parameter.java
// public interface Parameter {
// public ParamType getParamType();
//
// public void setParamType(ParamType paramType);
//
// public String getName();
//
// public void setName(String name);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public boolean isRequired();
//
// public void setRequired(boolean required);
//
// public String getType();
//
// public void setType(String type);
//
// public boolean isAllowMultiple();
//
// public void setAllowMultiple(boolean multiple);
//
// /**
// * Parameter type - see <a href="https://github.com/wordnik/swagger-core/wiki/Parameters"
// * target="_new">https://github.com/wordnik/swagger-core/wiki/Parameters</a>
// */
//
// public enum ParamType {
// path, query, body, header, form
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResponseMessage.java
// public interface ResponseMessage {
//
// public int getCode();
//
// public void setCode(int code);
//
// public String getMessage();
//
// public void setMessage(String message);
//
// public String getResponseModel();
//
// public void setResponseModel(String responseModel);
//
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.Operation;
import com.smartbear.swagger4j.Parameter;
import com.smartbear.swagger4j.ResponseMessage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Operation interface
*
* @see Operation
*/
public class OperationImpl implements Operation {
private String nickName;
private Method method;
private String responseClass;
private String summary;
private String notes;
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>();
private final List<Parameter> parameterList = new ArrayList<Parameter>();
private final List<ResponseMessage> responseMessages = new ArrayList<ResponseMessage>(); | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Operation.java
// public interface Operation {
//
// public Api getApi();
//
// public Method getMethod();
//
// public void setMethod(Method method);
//
// public String getNickName();
//
// public void setNickName(String nickName);
//
// public String getResponseClass();
//
// public void setResponseClass(String responseClass);
//
// public String getSummary();
//
// public void setSummary(String summary);
//
// public String getNotes();
//
// public void setNotes(String notes);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public List<Parameter> getParameters();
//
// public Parameter getParameter(String name);
//
// public void removeParameter(Parameter parameter);
//
// public Parameter addParameter(String name, Parameter.ParamType type);
//
// public List<ResponseMessage> getResponseMessages();
//
// public ResponseMessage getResponseMessage(int code);
//
// public void removeResponseMessage(ResponseMessage responseMessage);
//
// public ResponseMessage addResponseMessage(int code, String message);
//
// /**
// * These are the methods supported by Swagger 1.2 - more to come
// */
//
// public enum Method {
// GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Parameter.java
// public interface Parameter {
// public ParamType getParamType();
//
// public void setParamType(ParamType paramType);
//
// public String getName();
//
// public void setName(String name);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public boolean isRequired();
//
// public void setRequired(boolean required);
//
// public String getType();
//
// public void setType(String type);
//
// public boolean isAllowMultiple();
//
// public void setAllowMultiple(boolean multiple);
//
// /**
// * Parameter type - see <a href="https://github.com/wordnik/swagger-core/wiki/Parameters"
// * target="_new">https://github.com/wordnik/swagger-core/wiki/Parameters</a>
// */
//
// public enum ParamType {
// path, query, body, header, form
// }
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ResponseMessage.java
// public interface ResponseMessage {
//
// public int getCode();
//
// public void setCode(int code);
//
// public String getMessage();
//
// public void setMessage(String message);
//
// public String getResponseModel();
//
// public void setResponseModel(String responseModel);
//
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/OperationImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.Operation;
import com.smartbear.swagger4j.Parameter;
import com.smartbear.swagger4j.ResponseMessage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the Operation interface
*
* @see Operation
*/
public class OperationImpl implements Operation {
private String nickName;
private Method method;
private String responseClass;
private String summary;
private String notes;
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>();
private final List<Parameter> parameterList = new ArrayList<Parameter>();
private final List<ResponseMessage> responseMessages = new ArrayList<ResponseMessage>(); | private Api api; |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ApiDeclarationImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the ApiDeclaration interface
*
* @see ApiDeclaration
*/
public class ApiDeclarationImpl implements ApiDeclaration {
private String apiVersion = DEFAULT_API_VERSION;
private String basePath; | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ApiDeclarationImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the ApiDeclaration interface
*
* @see ApiDeclaration
*/
public class ApiDeclarationImpl implements ApiDeclaration {
private String apiVersion = DEFAULT_API_VERSION;
private String basePath; | private SwaggerVersion swaggerVersion = SwaggerVersion.DEFAULT_VERSION; |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ApiDeclarationImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the ApiDeclaration interface
*
* @see ApiDeclaration
*/
public class ApiDeclarationImpl implements ApiDeclaration {
private String apiVersion = DEFAULT_API_VERSION;
private String basePath;
private SwaggerVersion swaggerVersion = SwaggerVersion.DEFAULT_VERSION;
private String resourcePath; | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ApiDeclarationImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the ApiDeclaration interface
*
* @see ApiDeclaration
*/
public class ApiDeclarationImpl implements ApiDeclaration {
private String apiVersion = DEFAULT_API_VERSION;
private String basePath;
private SwaggerVersion swaggerVersion = SwaggerVersion.DEFAULT_VERSION;
private String resourcePath; | private final List<Api> apiList = new ArrayList<Api>(); |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/ApiDeclarationImpl.java | // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
| import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the ApiDeclaration interface
*
* @see ApiDeclaration
*/
public class ApiDeclarationImpl implements ApiDeclaration {
private String apiVersion = DEFAULT_API_VERSION;
private String basePath;
private SwaggerVersion swaggerVersion = SwaggerVersion.DEFAULT_VERSION;
private String resourcePath;
private final List<Api> apiList = new ArrayList<Api>();
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>();
| // Path: src/main/java/com/smartbear/swagger4j/Api.java
// public interface Api {
//
// public String getPath();
//
// public void setPath(String path);
//
// public String getDescription();
//
// public void setDescription(String description);
//
// public Operation getOperation(String nickName);
//
// public List<Operation> getOperations();
//
// public void removeOperation(Operation operation);
//
// public Operation addOperation(String nickName, Operation.Method method);
//
// public ApiDeclaration getApiDeclaration();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/ApiDeclaration.java
// public interface ApiDeclaration {
//
// public final static String DEFAULT_API_VERSION = "1.0";
//
// public SwaggerVersion getSwaggerVersion();
//
// public void setSwaggerVersion(SwaggerVersion swaggerVersion);
//
// public String getApiVersion();
//
// public void setApiVersion(String apiVersion);
//
// public String getBasePath();
//
// public void setBasePath(String basePath);
//
// public String getResourcePath();
//
// public void setResourcePath(String resourcedPath);
//
// /**
// * Gets a list of APIs for this ApiDeclarations
// *
// * @return a list of Api objects
// * @see Api
// */
//
// public List<Api> getApis();
//
// /**
// * Removes the specified Api from this ApiDeclaration
// *
// * @param api the Api to remove
// * @see Api
// */
//
// public void removeApi(Api api);
//
// /**
// * Adds a new API to this ApiDeclaration with the specified path
// *
// * @param path the path for the API to add
// * @return the created API
// * @see Api
// */
//
// public Api addApi(String path);
//
// /**
// * Gets the API at the specified path
// *
// * @param path the path to the API
// * @return the API at that path, null if none available
// * @see Api
// */
//
// public Api getApi(String path);
//
// public Collection<String> getProduces();
//
// public void removeProduces(String produces);
//
// public void addProduces(String produces);
//
// public Collection<String> getConsumes();
//
// public void removeConsumes(String consumes);
//
// public void addConsumes(String consumes);
//
// public Collection<Model> getModels();
//
// public Model getModel(String id);
//
// public void addModel(Model model);
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Model.java
// public interface Model extends HasDataType {
//
// String getId();
//
// String getDescription();
//
// List<String> getRequiredProperties();
//
// List<Property> getProperties();
// }
//
// Path: src/main/java/com/smartbear/swagger4j/SwaggerVersion.java
// public enum SwaggerVersion {
// V1_0, V1_1, V1_2, V2_0;
//
// public String getIdentifier() {
// switch (this) {
// case V1_0:
// return "1.0";
// case V1_1:
// return "1.1";
// case V1_2:
// return "1.2";
// case V2_0:
// return "2.0";
// }
//
// throw new RuntimeException("Unexpected Swagger version: " + this.name());
// }
//
// public final static SwaggerVersion DEFAULT_VERSION = V1_2;
//
// public static SwaggerVersion fromIdentifier(String string) {
// if (V1_0.getIdentifier().equals(string)) {
// return V1_0;
// }
// if (V1_1.getIdentifier().equals(string)) {
// return V1_1;
// }
// if (V1_2.getIdentifier().equals(string)) {
// return V1_2;
// }
// if (V2_0.getIdentifier().equals(string)) {
// return V2_0;
// }
//
// throw new RuntimeException("Unknown Swagger Version: " + string);
// }
//
// public boolean isGreaterThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) < 0;
// }
//
// public boolean isLessThan(SwaggerVersion version) {
// return version.getIdentifier().compareTo(getIdentifier()) > 0;
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/ApiDeclarationImpl.java
import com.smartbear.swagger4j.Api;
import com.smartbear.swagger4j.ApiDeclaration;
import com.smartbear.swagger4j.Model;
import com.smartbear.swagger4j.SwaggerVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Default implementation of the ApiDeclaration interface
*
* @see ApiDeclaration
*/
public class ApiDeclarationImpl implements ApiDeclaration {
private String apiVersion = DEFAULT_API_VERSION;
private String basePath;
private SwaggerVersion swaggerVersion = SwaggerVersion.DEFAULT_VERSION;
private String resourcePath;
private final List<Api> apiList = new ArrayList<Api>();
private final Set<String> produces = new HashSet<String>();
private final Set<String> consumes = new HashSet<String>();
| private final Map<String, Model> models = new HashMap<String, Model>(); |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/SwaggerParser.java | // Path: src/main/java/com/smartbear/swagger4j/SwaggerFormat.java
// public enum SwaggerFormat {
// xml, json;
//
// public String getExtension() {
// return this.name().toLowerCase();
// }
// }
| import java.io.Reader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.smartbear.swagger4j.SwaggerFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.json.JsonArray;
import javax.json.JsonNumber;
import javax.json.JsonObject;
import javax.json.JsonString;
import javax.json.JsonValue;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.IOException; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Utility class for abstraction of reading actual format, since json and xml are read in the same way
*/
public abstract class SwaggerParser {
public abstract String getString(String name);
public abstract List<SwaggerParser> getChildren(String name);
public abstract boolean getBoolean(String name);
public abstract String getString();
| // Path: src/main/java/com/smartbear/swagger4j/SwaggerFormat.java
// public enum SwaggerFormat {
// xml, json;
//
// public String getExtension() {
// return this.name().toLowerCase();
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/SwaggerParser.java
import java.io.Reader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.smartbear.swagger4j.SwaggerFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import javax.json.JsonArray;
import javax.json.JsonNumber;
import javax.json.JsonObject;
import javax.json.JsonString;
import javax.json.JsonValue;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.IOException;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Utility class for abstraction of reading actual format, since json and xml are read in the same way
*/
public abstract class SwaggerParser {
public abstract String getString(String name);
public abstract List<SwaggerParser> getChildren(String name);
public abstract boolean getBoolean(String name);
public abstract String getString();
| public abstract SwaggerFormat getFormat(); |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/SwaggerGenerator.java | // Path: src/main/java/com/smartbear/swagger4j/SwaggerFormat.java
// public enum SwaggerFormat {
// xml, json;
//
// public String getExtension() {
// return this.name().toLowerCase();
// }
// }
| import com.smartbear.swagger4j.SwaggerFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonWriterFactory;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static javax.json.stream.JsonGenerator.PRETTY_PRINTING; | /**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Utility class for abstraction of writing an actual format, since json and xml are read in the same way
*/
public abstract class SwaggerGenerator {
public abstract SwaggerGenerator addString(String name, String value);
public abstract void finish() throws IOException;
public abstract SwaggerGenerator addObject(String name);
public abstract SwaggerGenerator addArrayObject(String name);
public abstract SwaggerGenerator addBoolean(String name, boolean value);
public abstract SwaggerGenerator addInt(String name, int value);
public abstract SwaggerGenerator addArray(String name, String[] values);
/**
* Builder for a SwaggerGenerator that can write XML
*/
public static SwaggerGenerator newXmlGenerator(Writer writer) throws IOException {
return new SwaggerXmlGenerator(writer);
}
/**
* Builder for a SwaggerGenerator that can write JSON
*/
public static SwaggerGenerator newJsonGenerator(Writer writer) {
return new SwaggerJsonGenerator(writer);
}
/**
* Builds a SwaggerGenerator for one of the supported formats
*
* @param writer the writer to write to
* @param format the format
* @return the SwaggerGenerator
* @throws IOException
*/
| // Path: src/main/java/com/smartbear/swagger4j/SwaggerFormat.java
// public enum SwaggerFormat {
// xml, json;
//
// public String getExtension() {
// return this.name().toLowerCase();
// }
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/SwaggerGenerator.java
import com.smartbear.swagger4j.SwaggerFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonWriterFactory;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static javax.json.stream.JsonGenerator.PRETTY_PRINTING;
/**
* Copyright 2013 SmartBear Software, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.smartbear.swagger4j.impl;
/**
* Utility class for abstraction of writing an actual format, since json and xml are read in the same way
*/
public abstract class SwaggerGenerator {
public abstract SwaggerGenerator addString(String name, String value);
public abstract void finish() throws IOException;
public abstract SwaggerGenerator addObject(String name);
public abstract SwaggerGenerator addArrayObject(String name);
public abstract SwaggerGenerator addBoolean(String name, boolean value);
public abstract SwaggerGenerator addInt(String name, int value);
public abstract SwaggerGenerator addArray(String name, String[] values);
/**
* Builder for a SwaggerGenerator that can write XML
*/
public static SwaggerGenerator newXmlGenerator(Writer writer) throws IOException {
return new SwaggerXmlGenerator(writer);
}
/**
* Builder for a SwaggerGenerator that can write JSON
*/
public static SwaggerGenerator newJsonGenerator(Writer writer) {
return new SwaggerJsonGenerator(writer);
}
/**
* Builds a SwaggerGenerator for one of the supported formats
*
* @param writer the writer to write to
* @param format the format
* @return the SwaggerGenerator
* @throws IOException
*/
| public static SwaggerGenerator newGenerator(Writer writer, SwaggerFormat format) throws IOException { |
SmartBear/swagger4j | src/main/java/com/smartbear/swagger4j/impl/PropertyImpl.java | // Path: src/main/java/com/smartbear/swagger4j/DataType.java
// public interface DataType {
//
// String getType();
//
// String getRef();
//
// String getFormat();
//
// boolean isArray();
//
// boolean isPrimitive();
//
// boolean isComplex();
//
// boolean isVoid();
//
// boolean isRef();
//
// DataType VOID = new DataType() {
//
// @Override
// public String toString() {
// return getType();
// }
//
// @Override
// public String getType() {
// return "void";
// }
//
// @Override
// public String getRef() {
// return null;
// }
//
// @Override
// public String getFormat() {
// return null;
// }
//
// @Override
// public boolean isArray() {
// return false;
// }
//
// @Override
// public boolean isPrimitive() {
// return false;
// }
//
// public boolean isComplex() {
// return false;
// }
//
// @Override
// public boolean isVoid() {
// return true;
// }
//
// @Override
// public boolean isRef() {
// return false;
// }
// };
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Property.java
// public interface Property extends HasDataType {
//
// String getDescription();
//
// boolean isRequired();
// }
| import com.smartbear.swagger4j.DataType;
import com.smartbear.swagger4j.Property;
import java.util.List; | /*
* Copyright 2014 Yann D'Isanto.
*
* 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.smartbear.swagger4j.impl;
/**
* @author Yann D'Isanto
*/
public final class PropertyImpl implements Property {
private String name;
| // Path: src/main/java/com/smartbear/swagger4j/DataType.java
// public interface DataType {
//
// String getType();
//
// String getRef();
//
// String getFormat();
//
// boolean isArray();
//
// boolean isPrimitive();
//
// boolean isComplex();
//
// boolean isVoid();
//
// boolean isRef();
//
// DataType VOID = new DataType() {
//
// @Override
// public String toString() {
// return getType();
// }
//
// @Override
// public String getType() {
// return "void";
// }
//
// @Override
// public String getRef() {
// return null;
// }
//
// @Override
// public String getFormat() {
// return null;
// }
//
// @Override
// public boolean isArray() {
// return false;
// }
//
// @Override
// public boolean isPrimitive() {
// return false;
// }
//
// public boolean isComplex() {
// return false;
// }
//
// @Override
// public boolean isVoid() {
// return true;
// }
//
// @Override
// public boolean isRef() {
// return false;
// }
// };
//
// }
//
// Path: src/main/java/com/smartbear/swagger4j/Property.java
// public interface Property extends HasDataType {
//
// String getDescription();
//
// boolean isRequired();
// }
// Path: src/main/java/com/smartbear/swagger4j/impl/PropertyImpl.java
import com.smartbear.swagger4j.DataType;
import com.smartbear.swagger4j.Property;
import java.util.List;
/*
* Copyright 2014 Yann D'Isanto.
*
* 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.smartbear.swagger4j.impl;
/**
* @author Yann D'Isanto
*/
public final class PropertyImpl implements Property {
private String name;
| private DataType dataType; |
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8HorizSum.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray32Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage; | /*
*
* Copyright 2008 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package jjil.algorithm;
/**
* Sum a Gray8Image in a horizontal window, with the width controllable, creating
* a Gray32Image.
* @author webb
*/
public class Gray8HorizSum extends PipelineStage {
int nSumWidth;
/**
* Initialize Gray8HorizSum. The width is set here.
* @param nWidth width of the sum.
*/
public Gray8HorizSum(int nWidth) {
this.nSumWidth = nWidth;
}
/**
* Sum a Gray8Image horizontally, creating a Gray32Image.
* The edges of the image (closer than width)
* are set to 0. The summing is done efficiently so that each pixel computation
* takes only 2 additions on average.<p>
* This code uses Gray8QmSum to form a cumulative sum of the whole image.
* Since the entire image is summed to a Gray32Image by Gray8QmSum overflow
* may occur if
* more thant 2**24 pixels are in the image (e.g., larger than 2**12x2**12 =
* 4096x4096).
* @param imageInput input Gray8Image.
* @throws jjil.core.Error if the input is not a Gray8Image.
*/ | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8HorizSum.java
import jjil.core.Error;
import jjil.core.Gray32Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
/*
*
* Copyright 2008 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package jjil.algorithm;
/**
* Sum a Gray8Image in a horizontal window, with the width controllable, creating
* a Gray32Image.
* @author webb
*/
public class Gray8HorizSum extends PipelineStage {
int nSumWidth;
/**
* Initialize Gray8HorizSum. The width is set here.
* @param nWidth width of the sum.
*/
public Gray8HorizSum(int nWidth) {
this.nSumWidth = nWidth;
}
/**
* Sum a Gray8Image horizontally, creating a Gray32Image.
* The edges of the image (closer than width)
* are set to 0. The summing is done efficiently so that each pixel computation
* takes only 2 additions on average.<p>
* This code uses Gray8QmSum to form a cumulative sum of the whole image.
* Since the entire image is summed to a Gray32Image by Gray8QmSum overflow
* may occur if
* more thant 2**24 pixels are in the image (e.g., larger than 2**12x2**12 =
* 4096x4096).
* @param imageInput input Gray8Image.
* @throws jjil.core.Error if the input is not a Gray8Image.
*/ | public void push(Image imageInput) throws Error { |
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8VertTrapWarp.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.Error;
import jjil.core.Gray8Image; | public int getColRightStart() {
return this.nRowBotStart;
}
/** Returns the ending row of the trapezoid.
*
* @return the bottom row of the trapezoid.
*/
public int getRowEnd() {
return this.nColEnd;
}
/** Returns the starting row of the trapezoid.
*
* @return the top row of the trapezoid.
*/
public int getRowStart() {
return this.nColStart;
}
/**
* Warps a trapezoidal region in the input gray image into a rectangular
* output image. Uses bilinear interpolation. The calculation of fractional
* image coordinates is done by multiplying all the coordinates by 256,
* to avoid floating point computation.
*
* @param image the input gray image.
* @throws jjil.core.Error if the input image is not gray,
* or the trapezoid already specified extends outside its bounds.
*/ | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8VertTrapWarp.java
import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.Error;
import jjil.core.Gray8Image;
public int getColRightStart() {
return this.nRowBotStart;
}
/** Returns the ending row of the trapezoid.
*
* @return the bottom row of the trapezoid.
*/
public int getRowEnd() {
return this.nColEnd;
}
/** Returns the starting row of the trapezoid.
*
* @return the top row of the trapezoid.
*/
public int getRowStart() {
return this.nColStart;
}
/**
* Warps a trapezoidal region in the input gray image into a rectangular
* output image. Uses bilinear interpolation. The calculation of fractional
* image coordinates is done by multiplying all the coordinates by 256,
* to avoid floating point computation.
*
* @param image the input gray image.
* @throws jjil.core.Error if the input image is not gray,
* or the trapezoid already specified extends outside its bounds.
*/ | public void push(Image image) throws jjil.core.Error { |
gast-lib/gast-lib | app/src/root/gast/playground/speech/food/multimatcher/MultiPartUnderstanderNoOrder.java | // Path: library/src/root/gast/speech/text/match/WordMatcher.java
// public class WordMatcher
// {
// private Set<String> words;
// public static final int NOT_IN = -1;
//
// public WordMatcher(String... wordsIn)
// {
// this(Arrays.asList(wordsIn));
// }
//
// public WordMatcher(List<String> wordsIn)
// {
// //care about order so we can execute isInAt
// words = new LinkedHashSet<String>(wordsIn);
// }
//
// public Set<String> getWords()
// {
// return words;
// }
//
// public boolean isIn(String word)
// {
// return words.contains(word);
// }
//
// public boolean isIn(String [] wordsIn)
// {
// boolean wordIn = false;
// for (String word : wordsIn)
// {
// if (isIn(word))
// {
// wordIn = true;
// break;
// }
// }
// return wordIn;
// }
//
// public int isInAt(String [] wordsIn)
// {
// int which = NOT_IN;
// for (String word : wordsIn)
// {
// which = isInAt(word);
// if (which != NOT_IN)
// {
// break;
// }
// }
// return which;
// }
//
// public int isInAt(String wordCheck)
// {
// int which = NOT_IN;
// int ct = 0;
// for (String word : words)
// {
// if (word.equals(wordCheck))
// {
// which = ct;
// break;
// }
// ct++;
// }
// return which;
// }
//
// @Override
// public String toString()
// {
// StringBuilder sb = new StringBuilder();
// for (String word : getWords())
// {
// sb.append(word).append(" ");
// }
// return sb.toString().trim();
// }
// }
| import java.util.List;
import root.gast.playground.speech.food.db.Food;
import root.gast.playground.speech.food.db.FtsIndexedFoodDatabase;
import root.gast.playground.speech.food.db.MatchedFood;
import root.gast.speech.text.match.WordMatcher;
import android.util.Log; | /*
* Copyright 2011 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.food.multimatcher;
/**
* Implements unordered matching of three food commands
* @author Greg Milette <<a
* href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
*/
public class MultiPartUnderstanderNoOrder extends MultiPartUnderstander
{
private static final String TAG = "MultiPartUnderstanderNoOrder";
public Food addFreeText(String toMatch)
{
Food toAdd = null; | // Path: library/src/root/gast/speech/text/match/WordMatcher.java
// public class WordMatcher
// {
// private Set<String> words;
// public static final int NOT_IN = -1;
//
// public WordMatcher(String... wordsIn)
// {
// this(Arrays.asList(wordsIn));
// }
//
// public WordMatcher(List<String> wordsIn)
// {
// //care about order so we can execute isInAt
// words = new LinkedHashSet<String>(wordsIn);
// }
//
// public Set<String> getWords()
// {
// return words;
// }
//
// public boolean isIn(String word)
// {
// return words.contains(word);
// }
//
// public boolean isIn(String [] wordsIn)
// {
// boolean wordIn = false;
// for (String word : wordsIn)
// {
// if (isIn(word))
// {
// wordIn = true;
// break;
// }
// }
// return wordIn;
// }
//
// public int isInAt(String [] wordsIn)
// {
// int which = NOT_IN;
// for (String word : wordsIn)
// {
// which = isInAt(word);
// if (which != NOT_IN)
// {
// break;
// }
// }
// return which;
// }
//
// public int isInAt(String wordCheck)
// {
// int which = NOT_IN;
// int ct = 0;
// for (String word : words)
// {
// if (word.equals(wordCheck))
// {
// which = ct;
// break;
// }
// ct++;
// }
// return which;
// }
//
// @Override
// public String toString()
// {
// StringBuilder sb = new StringBuilder();
// for (String word : getWords())
// {
// sb.append(word).append(" ");
// }
// return sb.toString().trim();
// }
// }
// Path: app/src/root/gast/playground/speech/food/multimatcher/MultiPartUnderstanderNoOrder.java
import java.util.List;
import root.gast.playground.speech.food.db.Food;
import root.gast.playground.speech.food.db.FtsIndexedFoodDatabase;
import root.gast.playground.speech.food.db.MatchedFood;
import root.gast.speech.text.match.WordMatcher;
import android.util.Log;
/*
* Copyright 2011 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.food.multimatcher;
/**
* Implements unordered matching of three food commands
* @author Greg Milette <<a
* href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
*/
public class MultiPartUnderstanderNoOrder extends MultiPartUnderstander
{
private static final String TAG = "MultiPartUnderstanderNoOrder";
public Food addFreeText(String toMatch)
{
Food toAdd = null; | WordMatcher dc = new WordMatcher("add"); |
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8HorizVar.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray16Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
| /*
* Gray8HorizVar.java
*
* Created on February 3, 2008, 4:32, PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2008 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Computes the variance of pixels horizontally distributed around
* the current pixel.
* @author webb
*/
public class Gray8HorizVar extends PipelineStage {
/**
* The window size -- pixels within nWindow of the current
* pixel are included in the window.
*/
int nWindow;
/**
* The output image.
*/
Gray16Image g16 = null;
/**
* Creates a new instance of Gray8HorizVar
* @param nWindow window size to compute horizontal variance over.
*/
public Gray8HorizVar(int nWindow) {
this.nWindow = nWindow;
}
/** Compute the horizontal variance of pixels within nWindow
* of the current pixel.
* @param image the input Gray8Image
* @throws jjil.core.Error if image is not a Gray8Image
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8HorizVar.java
import jjil.core.Error;
import jjil.core.Gray16Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
/*
* Gray8HorizVar.java
*
* Created on February 3, 2008, 4:32, PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2008 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Computes the variance of pixels horizontally distributed around
* the current pixel.
* @author webb
*/
public class Gray8HorizVar extends PipelineStage {
/**
* The window size -- pixels within nWindow of the current
* pixel are included in the window.
*/
int nWindow;
/**
* The output image.
*/
Gray16Image g16 = null;
/**
* Creates a new instance of Gray8HorizVar
* @param nWindow window size to compute horizontal variance over.
*/
public Gray8HorizVar(int nWindow) {
this.nWindow = nWindow;
}
/** Compute the horizontal variance of pixels within nWindow
* of the current pixel.
* @param image the input Gray8Image
* @throws jjil.core.Error if image is not a Gray8Image
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8AffineWarp.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Gray8OffsetImage;
import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.Vec2; | /*
* Gray8AffineWarp.java
*
* Created on September 9, 2006, 3:17 PM
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* This PipelineStage performs an affine transformation on an input
* @author webb
*/
public class Gray8AffineWarp extends PipelineStage {
static final int WARP_X_FIRST = 1;
static final int WARP_Y_FIRST = 2;
int nMaxX, nMaxY, nMinX, nMinY;
private int nWarpOrder; // either WARP_X_FIRST or WARP_Y_FIRST
int nXOffset, nYOffset;
int rnWarp[][];
int rnWarpX[];
int rnWarpY[];
/** Creates a new instance of Gray8AffineWarp. Gray8AffineWarp performs
* an affine warp on an input Gray8Image. The affine transformation is
* decomposed into two stages, following the work of George Wolberg.
* See http://www-cs.ccny.cuny.edu/~wolberg/diw.html for the definitive
* work on image warping.
* <p>
* @param warp the 2x3 affine warp to be performed. The elements of this
* matrix are assumed to be scaled by 2**16 for accuracy.
* @throws jjil.core.Error if the warp is null or not a 2x3 matrix.
*/
public Gray8AffineWarp(int[][] warp) throws jjil.core.Error {
this.setWarp(warp);
}
/**
* Calculate the affine transformation applied to p, keeping in mind
* that the warp is scaled by 2**16, so we must shift to get the
* correct result
* @param a 2x3 affine transformation, scaled by 2**16
* @param p input vector
* @return transformed vector
*/
private Vec2 affineTrans(int a[][], Vec2 p) {
return new Vec2(
(a[0][0] * p.getX() + a[0][1] * p.getY() + a[0][2])>>16,
(a[1][0] * p.getX() + a[1][1] * p.getY() + a[1][2])>>16);
}
/**
* Affine warp of an image.
*
* @param image the input gray image.
* @throws jjil.core.Error if the input image is not gray,
* or the trapezoid already specified extends outside its bounds.
*/ | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8AffineWarp.java
import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Gray8OffsetImage;
import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.Vec2;
/*
* Gray8AffineWarp.java
*
* Created on September 9, 2006, 3:17 PM
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* This PipelineStage performs an affine transformation on an input
* @author webb
*/
public class Gray8AffineWarp extends PipelineStage {
static final int WARP_X_FIRST = 1;
static final int WARP_Y_FIRST = 2;
int nMaxX, nMaxY, nMinX, nMinY;
private int nWarpOrder; // either WARP_X_FIRST or WARP_Y_FIRST
int nXOffset, nYOffset;
int rnWarp[][];
int rnWarpX[];
int rnWarpY[];
/** Creates a new instance of Gray8AffineWarp. Gray8AffineWarp performs
* an affine warp on an input Gray8Image. The affine transformation is
* decomposed into two stages, following the work of George Wolberg.
* See http://www-cs.ccny.cuny.edu/~wolberg/diw.html for the definitive
* work on image warping.
* <p>
* @param warp the 2x3 affine warp to be performed. The elements of this
* matrix are assumed to be scaled by 2**16 for accuracy.
* @throws jjil.core.Error if the warp is null or not a 2x3 matrix.
*/
public Gray8AffineWarp(int[][] warp) throws jjil.core.Error {
this.setWarp(warp);
}
/**
* Calculate the affine transformation applied to p, keeping in mind
* that the warp is scaled by 2**16, so we must shift to get the
* correct result
* @param a 2x3 affine transformation, scaled by 2**16
* @param p input vector
* @return transformed vector
*/
private Vec2 affineTrans(int a[][], Vec2 p) {
return new Vec2(
(a[0][0] * p.getX() + a[0][1] * p.getY() + a[0][2])>>16,
(a[1][0] * p.getX() + a[1][1] * p.getY() + a[1][2])>>16);
}
/**
* Affine warp of an image.
*
* @param image the input gray image.
* @throws jjil.core.Error if the input image is not gray,
* or the trapezoid already specified extends outside its bounds.
*/ | public void push(Image image) throws jjil.core.Error { |
gast-lib/gast-lib | jjil/src/jjil/algorithm/RgbCrop.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.Rect;
import jjil.core.RgbImage;
| /*
* RgbCrop.java
*
* Created on August 27, 2006, 2:38 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage crops a gray image to a given rectangular cropping window.
* @author webb
*/
public class RgbCrop extends PipelineStage {
int cHeight; /* height of cropping window */
int cWidth; /* width of cropping window */
int cX; /* left edge of cropping window */
int cY; /* top of cropping window */
/** Creates a new instance of RgbCrop. The cropping window
* is specified here.
*
* @param x left edge of cropping window
* @param y top edge of cropping window
* @param width width of cropping window
* @param height height of cropping window
* @throws jjil.core.Error if the top left corner of the
* window is negative, or the window area is non-positive.
*/
public RgbCrop(
int x,
int y,
int width,
int height) throws jjil.core.Error {
setWindow(x, y, width, height);
}
/** Creates a new instance of RgbCrop. The cropping window
* is specified here.
*
* @param r the rectangle to crop to
* @throws jjil.core.Error if the top left corner of the
* window is negative, or the window area is non-positive.
*/
public RgbCrop(Rect r) throws jjil.core.Error {
setWindow(r.getLeft(), r.getTop(), r.getWidth(), r.getHeight());
}
/** Crops the input RGB image to the cropping window that was
* specified in the constructor.
*
* @param image the input image.
* @throws jjil.core.Error if the cropping window
* extends outside the input image, or the input image
* is not an RgbImage.
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/RgbCrop.java
import jjil.core.Error;
import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.Rect;
import jjil.core.RgbImage;
/*
* RgbCrop.java
*
* Created on August 27, 2006, 2:38 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage crops a gray image to a given rectangular cropping window.
* @author webb
*/
public class RgbCrop extends PipelineStage {
int cHeight; /* height of cropping window */
int cWidth; /* width of cropping window */
int cX; /* left edge of cropping window */
int cY; /* top of cropping window */
/** Creates a new instance of RgbCrop. The cropping window
* is specified here.
*
* @param x left edge of cropping window
* @param y top edge of cropping window
* @param width width of cropping window
* @param height height of cropping window
* @throws jjil.core.Error if the top left corner of the
* window is negative, or the window area is non-positive.
*/
public RgbCrop(
int x,
int y,
int width,
int height) throws jjil.core.Error {
setWindow(x, y, width, height);
}
/** Creates a new instance of RgbCrop. The cropping window
* is specified here.
*
* @param r the rectangle to crop to
* @throws jjil.core.Error if the top left corner of the
* window is negative, or the window area is non-positive.
*/
public RgbCrop(Rect r) throws jjil.core.Error {
setWindow(r.getLeft(), r.getTop(), r.getWidth(), r.getHeight());
}
/** Crops the input RGB image to the cropping window that was
* specified in the constructor.
*
* @param image the input image.
* @throws jjil.core.Error if the cropping window
* extends outside the input image, or the input image
* is not an RgbImage.
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | app/src/root/gast/playground/speech/food/multimatcher/MultiPartUnderstanderOrdered.java | // Path: library/src/root/gast/speech/text/match/WordMatcher.java
// public class WordMatcher
// {
// private Set<String> words;
// public static final int NOT_IN = -1;
//
// public WordMatcher(String... wordsIn)
// {
// this(Arrays.asList(wordsIn));
// }
//
// public WordMatcher(List<String> wordsIn)
// {
// //care about order so we can execute isInAt
// words = new LinkedHashSet<String>(wordsIn);
// }
//
// public Set<String> getWords()
// {
// return words;
// }
//
// public boolean isIn(String word)
// {
// return words.contains(word);
// }
//
// public boolean isIn(String [] wordsIn)
// {
// boolean wordIn = false;
// for (String word : wordsIn)
// {
// if (isIn(word))
// {
// wordIn = true;
// break;
// }
// }
// return wordIn;
// }
//
// public int isInAt(String [] wordsIn)
// {
// int which = NOT_IN;
// for (String word : wordsIn)
// {
// which = isInAt(word);
// if (which != NOT_IN)
// {
// break;
// }
// }
// return which;
// }
//
// public int isInAt(String wordCheck)
// {
// int which = NOT_IN;
// int ct = 0;
// for (String word : words)
// {
// if (word.equals(wordCheck))
// {
// which = ct;
// break;
// }
// ct++;
// }
// return which;
// }
//
// @Override
// public String toString()
// {
// StringBuilder sb = new StringBuilder();
// for (String word : getWords())
// {
// sb.append(word).append(" ");
// }
// return sb.toString().trim();
// }
// }
| import java.util.List;
import root.gast.playground.speech.food.db.Food;
import root.gast.playground.speech.food.db.FtsIndexedFoodDatabase;
import root.gast.playground.speech.food.db.MatchedFood;
import root.gast.speech.text.WordList;
import root.gast.speech.text.match.WordMatcher;
import android.util.Log; | /*
* Copyright 2011 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.food.multimatcher;
/**
* Implements unordered matching of three food commands
* @author Greg Milette <<a href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
*/
public class MultiPartUnderstanderOrdered extends MultiPartUnderstander
{
private static final String TAG = "MultiPartUnderstanderOrdered";
public Food addFreeText(String toMatch)
{
Food toAdd = null;
WordList wordList = new WordList(toMatch); | // Path: library/src/root/gast/speech/text/match/WordMatcher.java
// public class WordMatcher
// {
// private Set<String> words;
// public static final int NOT_IN = -1;
//
// public WordMatcher(String... wordsIn)
// {
// this(Arrays.asList(wordsIn));
// }
//
// public WordMatcher(List<String> wordsIn)
// {
// //care about order so we can execute isInAt
// words = new LinkedHashSet<String>(wordsIn);
// }
//
// public Set<String> getWords()
// {
// return words;
// }
//
// public boolean isIn(String word)
// {
// return words.contains(word);
// }
//
// public boolean isIn(String [] wordsIn)
// {
// boolean wordIn = false;
// for (String word : wordsIn)
// {
// if (isIn(word))
// {
// wordIn = true;
// break;
// }
// }
// return wordIn;
// }
//
// public int isInAt(String [] wordsIn)
// {
// int which = NOT_IN;
// for (String word : wordsIn)
// {
// which = isInAt(word);
// if (which != NOT_IN)
// {
// break;
// }
// }
// return which;
// }
//
// public int isInAt(String wordCheck)
// {
// int which = NOT_IN;
// int ct = 0;
// for (String word : words)
// {
// if (word.equals(wordCheck))
// {
// which = ct;
// break;
// }
// ct++;
// }
// return which;
// }
//
// @Override
// public String toString()
// {
// StringBuilder sb = new StringBuilder();
// for (String word : getWords())
// {
// sb.append(word).append(" ");
// }
// return sb.toString().trim();
// }
// }
// Path: app/src/root/gast/playground/speech/food/multimatcher/MultiPartUnderstanderOrdered.java
import java.util.List;
import root.gast.playground.speech.food.db.Food;
import root.gast.playground.speech.food.db.FtsIndexedFoodDatabase;
import root.gast.playground.speech.food.db.MatchedFood;
import root.gast.speech.text.WordList;
import root.gast.speech.text.match.WordMatcher;
import android.util.Log;
/*
* Copyright 2011 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.food.multimatcher;
/**
* Implements unordered matching of three food commands
* @author Greg Milette <<a href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
*/
public class MultiPartUnderstanderOrdered extends MultiPartUnderstander
{
private static final String TAG = "MultiPartUnderstanderOrdered";
public Food addFreeText(String toMatch)
{
Food toAdd = null;
WordList wordList = new WordList(toMatch); | WordMatcher dc = new WordMatcher("add"); |
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8RectStretch.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
| /*
* Gray8RectStretch.java
*
* Created on September 9, 2006, 8:08 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/** Pipeline stage stretches an image to a larger rectangular size with
* bilinear interpolation. For more information on this and other image
* warps, see George Wolberg's excellent book, "Digital Image Warping",
* Wiley-IEEE Computer Society Press, 1990.
* @author webb
*/
public class Gray8RectStretch extends PipelineStage {
private int cHeight;
private int cWidth;
/** Creates a new instance of Gray8RectStretch.
*
* @param cWidth new image width
* @param cHeight new image height
* @throws jjil.core.Error if either is less than or equal to zero.
*/
public Gray8RectStretch(int cWidth, int cHeight)
throws jjil.core.Error {
setWidth(cWidth);
setHeight(cHeight);
}
/** Gets current target height
*
* @return current height
*/
public int getHeight() {
return this.cHeight;
}
/** Gets current target width
*
* @return current width
*/
public int getWidth() {
return this.cWidth;
}
/** Bilinear interpolation to stretch image to (cWidth, cHeight).
* Does this in two passes, for more efficient computation.
*
* @param image the input image
* @throws jjil.core.Error if input image is not gray 8 bits,
* or the input image size is larger than the target size. This class
* does not do subsampling, only interpolation.
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8RectStretch.java
import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
/*
* Gray8RectStretch.java
*
* Created on September 9, 2006, 8:08 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/** Pipeline stage stretches an image to a larger rectangular size with
* bilinear interpolation. For more information on this and other image
* warps, see George Wolberg's excellent book, "Digital Image Warping",
* Wiley-IEEE Computer Society Press, 1990.
* @author webb
*/
public class Gray8RectStretch extends PipelineStage {
private int cHeight;
private int cWidth;
/** Creates a new instance of Gray8RectStretch.
*
* @param cWidth new image width
* @param cHeight new image height
* @throws jjil.core.Error if either is less than or equal to zero.
*/
public Gray8RectStretch(int cWidth, int cHeight)
throws jjil.core.Error {
setWidth(cWidth);
setHeight(cHeight);
}
/** Gets current target height
*
* @return current height
*/
public int getHeight() {
return this.cHeight;
}
/** Gets current target width
*
* @return current width
*/
public int getWidth() {
return this.cWidth;
}
/** Bilinear interpolation to stretch image to (cWidth, cHeight).
* Does this in two passes, for more efficient computation.
*
* @param image the input image
* @throws jjil.core.Error if input image is not gray 8 bits,
* or the input image size is larger than the target size. This class
* does not do subsampling, only interpolation.
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8QmSum.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray32Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
| /*
* Gray8QmSum.java
*
* Created on August 27, 2006, 9:02 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Gray8QmSum forms the cumulative sum of an image.
* <blockquote> Output(i,j) = ∑<sub>k ≤ i, l ≤ j</sub> Input(k,l). </blockquote>
* Output is a 32-bit gray image.
* Input is an 8-bit gray image.<p>
* Note that since the output is 32 bits the input image cannot have more than
* 2<sup>24</sup> pixels without risking overflow. For example, an image larger than
* 4096 × 4096 (=2<sup>12</sup> × 2<sup>12</sup>) might overflow.
* @author webb
*/
public class Gray8QmSum extends PipelineStage {
/**
* Creates a new instance of Gray8QmSum
*/
public Gray8QmSum() {
}
/** Forms the cumulative sum of an image.
* Output(i,j) = ∑<sub>k ≤ i, l ≤ j</sub> Input(k,l)).
* Output is 32-bit gray image.
* Input is 8-bit gray image.
*
* @param image the input image.
* @throws jjil.core.Error if the input is not a Gray8Image
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8QmSum.java
import jjil.core.Error;
import jjil.core.Gray32Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
/*
* Gray8QmSum.java
*
* Created on August 27, 2006, 9:02 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Gray8QmSum forms the cumulative sum of an image.
* <blockquote> Output(i,j) = ∑<sub>k ≤ i, l ≤ j</sub> Input(k,l). </blockquote>
* Output is a 32-bit gray image.
* Input is an 8-bit gray image.<p>
* Note that since the output is 32 bits the input image cannot have more than
* 2<sup>24</sup> pixels without risking overflow. For example, an image larger than
* 4096 × 4096 (=2<sup>12</sup> × 2<sup>12</sup>) might overflow.
* @author webb
*/
public class Gray8QmSum extends PipelineStage {
/**
* Creates a new instance of Gray8QmSum
*/
public Gray8QmSum() {
}
/** Forms the cumulative sum of an image.
* Output(i,j) = ∑<sub>k ≤ i, l ≤ j</sub> Input(k,l)).
* Output is 32-bit gray image.
* Input is 8-bit gray image.
*
* @param image the input image.
* @throws jjil.core.Error if the input is not a Gray8Image
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8Rect.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
| /*
* Gray8Rect.java
*
* Created on September 9, 2006, 2:52 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage assigns a constant value to a rectangle in an input Gray8Image
* to produce an output Gray8Image.
* @author webb
*/
public class Gray8Rect extends PipelineStage {
private int cX, cY, nWidth, nHeight;
private byte bValue;
/**
* Creates a new instance of Gray8Rect.
* @param cX The horizontal offset of the rectangle.
* @param cY the vertical offset of the rectangle.
* @param nWidth the width of the rectangle.
* @param nHeight the height of the rectangle.
* @param bValue the value to be assigned to the rectangle.
* @throws jjil.core.Error if the height or width of the rectange is negative or zero.
*/
public Gray8Rect(int cX, int cY, int nWidth, int nHeight, byte bValue)
throws jjil.core.Error {
setWindow(cX, cY, nWidth, nHeight);
this.bValue = bValue;
}
/**
* Assigns a constant rectangle to the input Gray8Image, replacing values in the image.
* @param image the input image (output replaces input).
* @throws jjil.core.Error if the input is not a Gray8Image.
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8Rect.java
import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
/*
* Gray8Rect.java
*
* Created on September 9, 2006, 2:52 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage assigns a constant value to a rectangle in an input Gray8Image
* to produce an output Gray8Image.
* @author webb
*/
public class Gray8Rect extends PipelineStage {
private int cX, cY, nWidth, nHeight;
private byte bValue;
/**
* Creates a new instance of Gray8Rect.
* @param cX The horizontal offset of the rectangle.
* @param cY the vertical offset of the rectangle.
* @param nWidth the width of the rectangle.
* @param nHeight the height of the rectangle.
* @param bValue the value to be assigned to the rectangle.
* @throws jjil.core.Error if the height or width of the rectange is negative or zero.
*/
public Gray8Rect(int cX, int cY, int nWidth, int nHeight, byte bValue)
throws jjil.core.Error {
setWindow(cX, cY, nWidth, nHeight);
this.bValue = bValue;
}
/**
* Assigns a constant rectangle to the input Gray8Image, replacing values in the image.
* @param image the input image (output replaces input).
* @throws jjil.core.Error if the input is not a Gray8Image.
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | app/src/root/gast/playground/speech/food/command/RemoveFood.java | // Path: library/src/root/gast/speech/text/match/WordMatcher.java
// public class WordMatcher
// {
// private Set<String> words;
// public static final int NOT_IN = -1;
//
// public WordMatcher(String... wordsIn)
// {
// this(Arrays.asList(wordsIn));
// }
//
// public WordMatcher(List<String> wordsIn)
// {
// //care about order so we can execute isInAt
// words = new LinkedHashSet<String>(wordsIn);
// }
//
// public Set<String> getWords()
// {
// return words;
// }
//
// public boolean isIn(String word)
// {
// return words.contains(word);
// }
//
// public boolean isIn(String [] wordsIn)
// {
// boolean wordIn = false;
// for (String word : wordsIn)
// {
// if (isIn(word))
// {
// wordIn = true;
// break;
// }
// }
// return wordIn;
// }
//
// public int isInAt(String [] wordsIn)
// {
// int which = NOT_IN;
// for (String word : wordsIn)
// {
// which = isInAt(word);
// if (which != NOT_IN)
// {
// break;
// }
// }
// return which;
// }
//
// public int isInAt(String wordCheck)
// {
// int which = NOT_IN;
// int ct = 0;
// for (String word : words)
// {
// if (word.equals(wordCheck))
// {
// which = ct;
// break;
// }
// ct++;
// }
// return which;
// }
//
// @Override
// public String toString()
// {
// StringBuilder sb = new StringBuilder();
// for (String word : getWords())
// {
// sb.append(word).append(" ");
// }
// return sb.toString().trim();
// }
// }
| import android.util.Log;
import java.util.List;
import root.gast.playground.R;
import root.gast.playground.speech.food.db.Food;
import root.gast.playground.speech.food.db.FtsIndexedFoodDatabase;
import root.gast.playground.speech.food.db.MatchedFood;
import root.gast.speech.text.WordList;
import root.gast.speech.text.match.SoundsLikeThresholdWordMatcher;
import root.gast.speech.text.match.WordMatcher;
import root.gast.speech.voiceaction.OnNotUnderstoodListener;
import root.gast.speech.voiceaction.OnUnderstoodListener;
import root.gast.speech.voiceaction.VoiceActionCommand;
import root.gast.speech.voiceaction.VoiceActionExecutor;
import root.gast.speech.voiceaction.VoiceAlertDialog;
import android.content.Context; | /*
* Copyright 2011 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.food.command;
/**
* @author Greg Milette <<a
* href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
*
*/
public class RemoveFood implements VoiceActionCommand
{
private static final String TAG = "RemoveFood";
| // Path: library/src/root/gast/speech/text/match/WordMatcher.java
// public class WordMatcher
// {
// private Set<String> words;
// public static final int NOT_IN = -1;
//
// public WordMatcher(String... wordsIn)
// {
// this(Arrays.asList(wordsIn));
// }
//
// public WordMatcher(List<String> wordsIn)
// {
// //care about order so we can execute isInAt
// words = new LinkedHashSet<String>(wordsIn);
// }
//
// public Set<String> getWords()
// {
// return words;
// }
//
// public boolean isIn(String word)
// {
// return words.contains(word);
// }
//
// public boolean isIn(String [] wordsIn)
// {
// boolean wordIn = false;
// for (String word : wordsIn)
// {
// if (isIn(word))
// {
// wordIn = true;
// break;
// }
// }
// return wordIn;
// }
//
// public int isInAt(String [] wordsIn)
// {
// int which = NOT_IN;
// for (String word : wordsIn)
// {
// which = isInAt(word);
// if (which != NOT_IN)
// {
// break;
// }
// }
// return which;
// }
//
// public int isInAt(String wordCheck)
// {
// int which = NOT_IN;
// int ct = 0;
// for (String word : words)
// {
// if (word.equals(wordCheck))
// {
// which = ct;
// break;
// }
// ct++;
// }
// return which;
// }
//
// @Override
// public String toString()
// {
// StringBuilder sb = new StringBuilder();
// for (String word : getWords())
// {
// sb.append(word).append(" ");
// }
// return sb.toString().trim();
// }
// }
// Path: app/src/root/gast/playground/speech/food/command/RemoveFood.java
import android.util.Log;
import java.util.List;
import root.gast.playground.R;
import root.gast.playground.speech.food.db.Food;
import root.gast.playground.speech.food.db.FtsIndexedFoodDatabase;
import root.gast.playground.speech.food.db.MatchedFood;
import root.gast.speech.text.WordList;
import root.gast.speech.text.match.SoundsLikeThresholdWordMatcher;
import root.gast.speech.text.match.WordMatcher;
import root.gast.speech.voiceaction.OnNotUnderstoodListener;
import root.gast.speech.voiceaction.OnUnderstoodListener;
import root.gast.speech.voiceaction.VoiceActionCommand;
import root.gast.speech.voiceaction.VoiceActionExecutor;
import root.gast.speech.voiceaction.VoiceAlertDialog;
import android.content.Context;
/*
* Copyright 2011 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.food.command;
/**
* @author Greg Milette <<a
* href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
*
*/
public class RemoveFood implements VoiceActionCommand
{
private static final String TAG = "RemoveFood";
| private WordMatcher match; |
gast-lib/gast-lib | jjil/src/jjil/algorithm/RgbStretch.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.PipelineStage;
import jjil.core.RgbImage;
import jjil.core.Sequence;
import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
| /*
* RgbShrink.java.
* Reduces a color image to a new size by averaging the pixels nearest each
* target pixel's pre-image. This is done by converting each band of the image
* into a gray image, shrinking them individually, then recombining them into
* an RgbImage
*
* Created on October 13, 2007, 2:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Stretches a color (RgbImage) to a given size. Each band is shrunk independently.
* The output image must be greater than or equal to the size of the
* input.
* @author webb
*/
public class RgbStretch extends PipelineStage {
private int cHeight;
private int cWidth;
private Sequence seqR, seqG, seqB;
/** Creates a new instance of RgbStretch.
*
* @param cWidth new image width
* @param cHeight new image height
* @throws jjil.core.Error if either is less than or equal to zero.
*/
public RgbStretch(int cWidth, int cHeight)
throws jjil.core.Error {
this.cWidth = cWidth;
this.cHeight = cHeight;
setupPipeline();
}
/** Gets current target height
*
* @return current height
*/
public int getHeight() {
return this.cHeight;
}
/** Gets current target width
*
* @return current width
*/
public int getWidth() {
return this.cWidth;
}
/**
* Process an image.
* @param image the input RgbImage.
* @throws jjil.core.Error if the input is not an RgbImage, or is smaller than the target image either
* horizontally or vertically.
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/RgbStretch.java
import jjil.core.PipelineStage;
import jjil.core.RgbImage;
import jjil.core.Sequence;
import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
/*
* RgbShrink.java.
* Reduces a color image to a new size by averaging the pixels nearest each
* target pixel's pre-image. This is done by converting each band of the image
* into a gray image, shrinking them individually, then recombining them into
* an RgbImage
*
* Created on October 13, 2007, 2:21 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Stretches a color (RgbImage) to a given size. Each band is shrunk independently.
* The output image must be greater than or equal to the size of the
* input.
* @author webb
*/
public class RgbStretch extends PipelineStage {
private int cHeight;
private int cWidth;
private Sequence seqR, seqG, seqB;
/** Creates a new instance of RgbStretch.
*
* @param cWidth new image width
* @param cHeight new image height
* @throws jjil.core.Error if either is less than or equal to zero.
*/
public RgbStretch(int cWidth, int cHeight)
throws jjil.core.Error {
this.cWidth = cWidth;
this.cHeight = cHeight;
setupPipeline();
}
/** Gets current target height
*
* @return current height
*/
public int getHeight() {
return this.cHeight;
}
/** Gets current target width
*
* @return current width
*/
public int getWidth() {
return this.cWidth;
}
/**
* Process an image.
* @param image the input RgbImage.
* @throws jjil.core.Error if the input is not an RgbImage, or is smaller than the target image either
* horizontally or vertically.
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/Rgb3x3Average.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.RgbImage;
import jjil.core.RgbVal;
| /*
* Rgb3x3Average.java
*
* Created on August 27, 2006, 1:58 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage performs a 3x3 RGB average of the input.
* @author webb
*/
public class Rgb3x3Average extends PipelineStage {
/**
* Creates a new instance of Rgb3x3Average
*/
public Rgb3x3Average() {
}
/**
* Do a color 3x3 average of the input image. The red, green, and blue
* bands are averaged independently. The code has been written to be
* as efficient as possible. Borders are handled by duplicating the
* first or last row, and replacing the first and last column
* with 0, when doing the average.
*
* @param imageInput the input image
* @throws jjil.core.Error if imageInput is not an RgbImage
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Rgb3x3Average.java
import jjil.core.Error;
import jjil.core.Image;
import jjil.core.PipelineStage;
import jjil.core.RgbImage;
import jjil.core.RgbVal;
/*
* Rgb3x3Average.java
*
* Created on August 27, 2006, 1:58 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage performs a 3x3 RGB average of the input.
* @author webb
*/
public class Rgb3x3Average extends PipelineStage {
/**
* Creates a new instance of Rgb3x3Average
*/
public Rgb3x3Average() {
}
/**
* Do a color 3x3 average of the input image. The red, green, and blue
* bands are averaged independently. The code has been written to be
* as efficient as possible. Borders are handled by duplicating the
* first or last row, and replacing the first and last column
* with 0, when doing the average.
*
* @param imageInput the input image
* @throws jjil.core.Error if imageInput is not an RgbImage
*/
| public void push(Image imageInput) throws jjil.core.Error
|
gast-lib/gast-lib | app/src/root/gast/playground/speech/activation/util/TagWriterActivity.java | // Path: library/src/root/gast/nfc/TagWriter.java
// public class TagWriter
// {
// private static final String TAG = "TagWriter";
//
// private Activity context;
//
// private AlertDialog mWriteTagDialog;
//
// private NfcAdapter mNfcAdapter;
//
// public TagWriter(Activity context, NfcAdapter mNfcAdapter)
// {
// this.context = context;
// this.mNfcAdapter = mNfcAdapter;
// }
//
// public void startTagWriting(
// IntentFilter[] writeTagFilters, PendingIntent pendingIntent)
// {
// enableTagWriteMode(writeTagFilters, pendingIntent);
//
// AlertDialog.Builder builder =
// new AlertDialog.Builder(context)
// .setTitle(context.getString(R.string.ready_to_write))
// .setMessage(
// context.getString(R.string.ready_to_write_instructions))
// .setCancelable(true)
// .setNegativeButton("Cancel",
// new DialogInterface.OnClickListener()
// {
// public void onClick(DialogInterface dialog,
// int id)
// {
// disableTagWriteMode();
// dialog.cancel();
// }
// })
// .setOnCancelListener(
// new DialogInterface.OnCancelListener()
// {
// @Override
// public void
// onCancel(DialogInterface dialog)
// {
// disableTagWriteMode();
// }
// });
// mWriteTagDialog = builder.create();
// mWriteTagDialog.show();
// }
//
// public void endTagWriting()
// {
// if (mWriteTagDialog != null)
// {
// mWriteTagDialog.cancel();
// }
// disableTagWriteMode();
// }
//
// private void enableTagWriteMode(IntentFilter[] writeTagFilters,
// PendingIntent pendingIntent)
// {
// Log.d(TAG, "enable write mode");
// mNfcAdapter.enableForegroundDispatch(context, pendingIntent,
// writeTagFilters, null);
// }
//
// private void disableTagWriteMode()
// {
// Log.d(TAG, "disable write mode");
// if (mNfcAdapter != null)
// {
// mNfcAdapter.disableForegroundDispatch(context);
// }
// }
//
// }
| import root.gast.nfc.NfcUtil;
import root.gast.nfc.TagWriter;
import root.gast.playground.R;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
import android.util.Log;
import android.view.View;
import android.widget.Button; | /*
* Copyright 2012 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.activation.util;
/**
* this is an alternate method for writing the speech activation tag
* @author Greg Milette <<a
* href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
* @author Pearl Chen <<a
* href="mailto:dotdotdotspace@gmail.com">mailto:dotdotdotspace@gmail.com</a>>
*/
public class TagWriterActivity extends Activity
{
private static final String TAG = "TagWriterActivity";
private NfcAdapter mNfcAdapter;
| // Path: library/src/root/gast/nfc/TagWriter.java
// public class TagWriter
// {
// private static final String TAG = "TagWriter";
//
// private Activity context;
//
// private AlertDialog mWriteTagDialog;
//
// private NfcAdapter mNfcAdapter;
//
// public TagWriter(Activity context, NfcAdapter mNfcAdapter)
// {
// this.context = context;
// this.mNfcAdapter = mNfcAdapter;
// }
//
// public void startTagWriting(
// IntentFilter[] writeTagFilters, PendingIntent pendingIntent)
// {
// enableTagWriteMode(writeTagFilters, pendingIntent);
//
// AlertDialog.Builder builder =
// new AlertDialog.Builder(context)
// .setTitle(context.getString(R.string.ready_to_write))
// .setMessage(
// context.getString(R.string.ready_to_write_instructions))
// .setCancelable(true)
// .setNegativeButton("Cancel",
// new DialogInterface.OnClickListener()
// {
// public void onClick(DialogInterface dialog,
// int id)
// {
// disableTagWriteMode();
// dialog.cancel();
// }
// })
// .setOnCancelListener(
// new DialogInterface.OnCancelListener()
// {
// @Override
// public void
// onCancel(DialogInterface dialog)
// {
// disableTagWriteMode();
// }
// });
// mWriteTagDialog = builder.create();
// mWriteTagDialog.show();
// }
//
// public void endTagWriting()
// {
// if (mWriteTagDialog != null)
// {
// mWriteTagDialog.cancel();
// }
// disableTagWriteMode();
// }
//
// private void enableTagWriteMode(IntentFilter[] writeTagFilters,
// PendingIntent pendingIntent)
// {
// Log.d(TAG, "enable write mode");
// mNfcAdapter.enableForegroundDispatch(context, pendingIntent,
// writeTagFilters, null);
// }
//
// private void disableTagWriteMode()
// {
// Log.d(TAG, "disable write mode");
// if (mNfcAdapter != null)
// {
// mNfcAdapter.disableForegroundDispatch(context);
// }
// }
//
// }
// Path: app/src/root/gast/playground/speech/activation/util/TagWriterActivity.java
import root.gast.nfc.NfcUtil;
import root.gast.nfc.TagWriter;
import root.gast.playground.R;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
import android.util.Log;
import android.view.View;
import android.widget.Button;
/*
* Copyright 2012 Greg Milette and Adam Stroud
*
* 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 root.gast.playground.speech.activation.util;
/**
* this is an alternate method for writing the speech activation tag
* @author Greg Milette <<a
* href="mailto:gregorym@gmail.com">gregorym@gmail.com</a>>
* @author Pearl Chen <<a
* href="mailto:dotdotdotspace@gmail.com">mailto:dotdotdotspace@gmail.com</a>>
*/
public class TagWriterActivity extends Activity
{
private static final String TAG = "TagWriterActivity";
private NfcAdapter mNfcAdapter;
| private TagWriter writer; |
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8Lookup.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
| /*
* Gray8Lookup.java
*
* Created on September 9, 2006, 2:52 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage applies a lookup table to an image. The lookup table
* can be supplied through the constructor or by the setTable procedure.
* This pipeline stage modifies its input.
*
* @author webb
*/
public class Gray8Lookup extends PipelineStage {
private byte[] table;
/**
* Creates a new instance of Gray8Lookup.
* @param table The mapping table. Element i maps gray value Byte.MinValue + i to table[i].
* @throws jjil.core.Error when table is not a 256-element array.
*/
public Gray8Lookup(byte[] table) throws jjil.core.Error {
setTable(table);
}
/**
* Return the lookup table currently being used.
* @return the lookup table.
*/
public byte[] getTable() {
byte[] result = new byte[256];
System.arraycopy(this.table, 0, result, 0, this.table.length);
return result;
}
/**
* Maps input Gray8Image through the lookup table, replacing values in the image.
* @param image the input image (output replaces input).
* @throws jjil.core.Error if image is not a Gray8Image.
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8Lookup.java
import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
/*
* Gray8Lookup.java
*
* Created on September 9, 2006, 2:52 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Pipeline stage applies a lookup table to an image. The lookup table
* can be supplied through the constructor or by the setTable procedure.
* This pipeline stage modifies its input.
*
* @author webb
*/
public class Gray8Lookup extends PipelineStage {
private byte[] table;
/**
* Creates a new instance of Gray8Lookup.
* @param table The mapping table. Element i maps gray value Byte.MinValue + i to table[i].
* @throws jjil.core.Error when table is not a 256-element array.
*/
public Gray8Lookup(byte[] table) throws jjil.core.Error {
setTable(table);
}
/**
* Return the lookup table currently being used.
* @return the lookup table.
*/
public byte[] getTable() {
byte[] result = new byte[256];
System.arraycopy(this.table, 0, result, 0, this.table.length);
return result;
}
/**
* Maps input Gray8Image through the lookup table, replacing values in the image.
* @param image the input image (output replaces input).
* @throws jjil.core.Error if image is not a Gray8Image.
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/LinefitHough.java | // Path: jjil/src/jjil/core/Point.java
// public class Point implements Serializable {
// private int mnX;
// private int mnY;
//
// /** Creates a new instance of Point
// *
// * @param mnX the Point's x position (column)
// * @param mnY the Point's y position (row)
// */
// public Point(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// }
//
// /**
// * Offset a point by a 2-dimensional vector Vec2, returning modified point.
// * @param v Vec2 to offset this point by
// * @return modified Point
// */
// public Point add(Vec2 v) {
// this.mnX += v.getX();
// this.mnY += v.getY();
// return this;
// }
//
// /**
// * Make a copy of this Point, so that modifications by other
// * operations don't affect the original.
// */
// public Point clone() {
// return new Point(this.mnX, this.mnY);
// }
//
// /**
// * Compute a vector from another Point to this
// * @param pos starting point
// * @return a Vec2 which, when added to pos, will give this
// */
// public Vec2 diff(Point pos) {
// return new Vec2(this.mnX-pos.mnX, this.mnY-pos.mnY);
// }
//
// /**
// * Returns true iff this Point equals the first parameter.
// */
// public boolean equals(Object o) {
// if (!(o instanceof Point)) {
// return false;
// }
// Point p = (Point) o;
// return this.mnX == p.mnX && this.mnY == p.mnY;
// }
//
// /**
// * Return the point's x-coordinate.
// * @return the horizontal position of the point.
// */
// public int getX() {
// return this.mnX;
// }
//
// /**
// * Return the point's y-coordinate.
// * @return the vertical position of the point.
// */
// public int getY() {
// return this.mnY;
// }
//
// public int hashCode() {
// int hash = 5;
// hash = 67 * hash + this.mnX;
// hash = 67 * hash + this.mnY;
// return hash;
// }
//
// /**
// * Offset a point by a certain x,y
// * @param x x offset
// * @param y y offset
// * @return modified Point
// */
// public Point offset(int nX, int nY) {
// this.mnX += nX;
// this.mnY += nY;
// return this;
// }
//
// /**
// * Change the (x,y) coordinates of this Point
// * @param nX new X coordinate
// * @param nY new Y coordinate
// * @return the modified Point
// */
// public Point setXY(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// return this;
// }
//
// /**
// * Implement toString
// * @return Object address + (x,y)
// */
// public String toString() {
// return super.toString() + "(" +
// new Integer(this.mnX).toString() + "," +
// new Integer(this.mnY).toString() + ")";
// }
// }
| import java.util.Enumeration;
import java.util.Vector;
import jjil.core.Error;
import jjil.core.Point;
| this.cMaxY = cMaxY;
if (cMaxSlope < cMinSlope) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_RANGE_NULL_OR_NEGATIVE,
new Integer(cMinSlope).toString(),
new Integer(cMaxSlope).toString(),
null);
}
if (cSteps <= 0) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_OUT_OF_RANGE,
new Integer(cSteps).toString(),
new Integer(1).toString(),
new Integer(Integer.MAX_VALUE).toString());
}
this.cMinSlope = cMinSlope;
this.cMaxSlope = cMaxSlope;
this.cSteps = cSteps;
}
/** Add a new point to the Hough accumulator array. We increment along the
* line in the array
* from (cMinSlope>>8, yIntStart) to (cMaxSlope>>8, yIntEnd), where
* yIntStart is the y-intercept assuming the slope is at the minimum,
* and yIntEnd is the y-intercept assuming the slope is maximal.
*
* @param p the point to add to the accumulator array
*/
| // Path: jjil/src/jjil/core/Point.java
// public class Point implements Serializable {
// private int mnX;
// private int mnY;
//
// /** Creates a new instance of Point
// *
// * @param mnX the Point's x position (column)
// * @param mnY the Point's y position (row)
// */
// public Point(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// }
//
// /**
// * Offset a point by a 2-dimensional vector Vec2, returning modified point.
// * @param v Vec2 to offset this point by
// * @return modified Point
// */
// public Point add(Vec2 v) {
// this.mnX += v.getX();
// this.mnY += v.getY();
// return this;
// }
//
// /**
// * Make a copy of this Point, so that modifications by other
// * operations don't affect the original.
// */
// public Point clone() {
// return new Point(this.mnX, this.mnY);
// }
//
// /**
// * Compute a vector from another Point to this
// * @param pos starting point
// * @return a Vec2 which, when added to pos, will give this
// */
// public Vec2 diff(Point pos) {
// return new Vec2(this.mnX-pos.mnX, this.mnY-pos.mnY);
// }
//
// /**
// * Returns true iff this Point equals the first parameter.
// */
// public boolean equals(Object o) {
// if (!(o instanceof Point)) {
// return false;
// }
// Point p = (Point) o;
// return this.mnX == p.mnX && this.mnY == p.mnY;
// }
//
// /**
// * Return the point's x-coordinate.
// * @return the horizontal position of the point.
// */
// public int getX() {
// return this.mnX;
// }
//
// /**
// * Return the point's y-coordinate.
// * @return the vertical position of the point.
// */
// public int getY() {
// return this.mnY;
// }
//
// public int hashCode() {
// int hash = 5;
// hash = 67 * hash + this.mnX;
// hash = 67 * hash + this.mnY;
// return hash;
// }
//
// /**
// * Offset a point by a certain x,y
// * @param x x offset
// * @param y y offset
// * @return modified Point
// */
// public Point offset(int nX, int nY) {
// this.mnX += nX;
// this.mnY += nY;
// return this;
// }
//
// /**
// * Change the (x,y) coordinates of this Point
// * @param nX new X coordinate
// * @param nY new Y coordinate
// * @return the modified Point
// */
// public Point setXY(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// return this;
// }
//
// /**
// * Implement toString
// * @return Object address + (x,y)
// */
// public String toString() {
// return super.toString() + "(" +
// new Integer(this.mnX).toString() + "," +
// new Integer(this.mnY).toString() + ")";
// }
// }
// Path: jjil/src/jjil/algorithm/LinefitHough.java
import java.util.Enumeration;
import java.util.Vector;
import jjil.core.Error;
import jjil.core.Point;
this.cMaxY = cMaxY;
if (cMaxSlope < cMinSlope) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_RANGE_NULL_OR_NEGATIVE,
new Integer(cMinSlope).toString(),
new Integer(cMaxSlope).toString(),
null);
}
if (cSteps <= 0) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_OUT_OF_RANGE,
new Integer(cSteps).toString(),
new Integer(1).toString(),
new Integer(Integer.MAX_VALUE).toString());
}
this.cMinSlope = cMinSlope;
this.cMaxSlope = cMaxSlope;
this.cSteps = cSteps;
}
/** Add a new point to the Hough accumulator array. We increment along the
* line in the array
* from (cMinSlope>>8, yIntStart) to (cMaxSlope>>8, yIntEnd), where
* yIntStart is the y-intercept assuming the slope is at the minimum,
* and yIntEnd is the y-intercept assuming the slope is maximal.
*
* @param p the point to add to the accumulator array
*/
| private void addPoint(Point p) {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8LinComb.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.Ladder;
| /*
* Gray8LinComb.java
* Forms the linear combination of two gray images
*
* Created on September 9, 2006, 10:25 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Computes linear combination of two Gray8Images. Result is
* (a*first image + b*second image) / c. The signed image values are shifted so
* the minimum value is 0 and the result is then shifted back to the signed
* range.<br>
* Intended to be used as a combination stage in a ladder operation.
* @author webb
*/
public class Gray8LinComb implements Ladder.Join {
private int nA;
private int nB;
private int nC;
/**
* Creates a new instance of Gray8LinComb
* @param a Multiplier for first image.
* @param b Multiplier for second image.
* @param c Divisor for linear combination.
* @throws jjil.core.Error if the divisor (c) is 0.
*/
public Gray8LinComb(int a, int b, int c) throws jjil.core.Error {
if (c == 0) {
throw new Error(
Error.PACKAGE.CORE,
jjil.core.ErrorCodes.MATH_DIVISION_ZERO,
null,
null,
null);
}
this.nA = a;
this.nB = b;
this.nC = c;
}
/**
* Computes the linear combination of the two images, forming a*the first image
* + b *the second image, all divided by c.
* @param imageFirst the first image (and output)
* @param imageSecond the second image
* @return the linear combination of the two byte images, replacing the first.
* @throws jjil.core.Error if either image is not a gray 8-bit
* image, or they are of different sizes.
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8LinComb.java
import jjil.core.Error;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.Ladder;
/*
* Gray8LinComb.java
* Forms the linear combination of two gray images
*
* Created on September 9, 2006, 10:25 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2007 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Computes linear combination of two Gray8Images. Result is
* (a*first image + b*second image) / c. The signed image values are shifted so
* the minimum value is 0 and the result is then shifted back to the signed
* range.<br>
* Intended to be used as a combination stage in a ladder operation.
* @author webb
*/
public class Gray8LinComb implements Ladder.Join {
private int nA;
private int nB;
private int nC;
/**
* Creates a new instance of Gray8LinComb
* @param a Multiplier for first image.
* @param b Multiplier for second image.
* @param c Divisor for linear combination.
* @throws jjil.core.Error if the divisor (c) is 0.
*/
public Gray8LinComb(int a, int b, int c) throws jjil.core.Error {
if (c == 0) {
throw new Error(
Error.PACKAGE.CORE,
jjil.core.ErrorCodes.MATH_DIVISION_ZERO,
null,
null,
null);
}
this.nA = a;
this.nB = b;
this.nC = c;
}
/**
* Computes the linear combination of the two images, forming a*the first image
* + b *the second image, all divided by c.
* @param imageFirst the first image (and output)
* @param imageSecond the second image
* @return the linear combination of the two byte images, replacing the first.
* @throws jjil.core.Error if either image is not a gray 8-bit
* image, or they are of different sizes.
*/
| public Image doJoin(Image imageFirst, Image imageSecond)
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8UnsignedBackgroundSubtract.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray32Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
| package jjil.algorithm;
/**
* Compensates for uneven background illumination in an input image,
* at the same time changing an unsigned byte image to a signed
* byte image, which is the type used through JJIL. Unsigned byte
* images are supplied by, e.g., the Google G1 phone when operating
* in preview mode.
* @author webb
*
*/
public class Gray8UnsignedBackgroundSubtract extends PipelineStage {
Gray32Image mg32 = null;
int mnHeight;
int mnWidth;
/**
* Set the width and height of the window used for averaging when computing
* the background illumination.
* @param nWidth width to average over
*/
public Gray8UnsignedBackgroundSubtract(int nWidth, int nHeight) {
this.mnWidth = nWidth;
this.mnHeight = nHeight;
}
/**
* Compute an output Gray8Image which is the difference of the input
* unsigned Gray8Image and an average of a window of width x height
* size of the input. This is done using a cumulative sum operation
* so the operation is done efficiently.
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8UnsignedBackgroundSubtract.java
import jjil.core.Error;
import jjil.core.Gray32Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
package jjil.algorithm;
/**
* Compensates for uneven background illumination in an input image,
* at the same time changing an unsigned byte image to a signed
* byte image, which is the type used through JJIL. Unsigned byte
* images are supplied by, e.g., the Google G1 phone when operating
* in preview mode.
* @author webb
*
*/
public class Gray8UnsignedBackgroundSubtract extends PipelineStage {
Gray32Image mg32 = null;
int mnHeight;
int mnWidth;
/**
* Set the width and height of the window used for averaging when computing
* the background illumination.
* @param nWidth width to average over
*/
public Gray8UnsignedBackgroundSubtract(int nWidth, int nHeight) {
this.mnWidth = nWidth;
this.mnHeight = nHeight;
}
/**
* Compute an output Gray8Image which is the difference of the input
* unsigned Gray8Image and an average of a window of width x height
* size of the input. This is done using a cumulative sum operation
* so the operation is done efficiently.
*/
| public void push(Image imageInput) throws Error {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/Gray8VertVar.java | // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
| import jjil.core.Error;
import jjil.core.Gray16Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
| /*
* Gray8VertVar.java
*
* Created on February 3, 2008, 4:32, PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2008 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Computes the variance of pixels vertically distributed around
* the current pixel.
* @author webb
*/
public class Gray8VertVar extends PipelineStage {
/**
* The window size -- pixels within nWindow of the current
* pixel are included in the window.
*/
int nWindow;
/**
* The output image.
*/
Gray16Image g16 = null;
/**
* Creates a new instance of Gray8VertVar
* @param nWindow height of window to calculate variance over.
*/
public Gray8VertVar(int nWindow) {
this.nWindow = nWindow;
}
/** Compute the vertical variance of pixels within nWindow
* of the current pixel.
* @param image the input Gray8Image
* @throws jjil.core.Error if image is not a Gray8Image
*/
| // Path: jjil/src/jjil/core/Image.java
// public abstract class Image {
// /**
// * The image height.
// */
// private final int mnHeight;
// /**
// * The image width.
// */
// private final int mnWidth;
//
// /** Creates a new instance of Image
// *
// * @param mnWidth the image width
// * @param mnHeight the image height
// */
// public Image(int mnWidth, int mnHeight) {
// this.mnWidth = mnWidth;
// this.mnHeight = mnHeight;
// }
//
// /**
// * Makes a copy of the image
// * @return the image copy
// */
// public abstract Object clone();
//
// /** Returns the image height
// *
// * @return the image height (rows)
// */
// public int getHeight()
// {
// return this.mnHeight;
// }
//
// /**
// * Returns a Point object giving the size of this image
// * (width x height)
// * @return a Point indicating the image size
// */
// public Point getSize() {
// return new Point(this.mnWidth, this.mnHeight);
// }
//
// /** Returns the image width
// *
// * @return the image width (columns)
// */
// public int getWidth()
// {
// return this.mnWidth;
// }
// }
// Path: jjil/src/jjil/algorithm/Gray8VertVar.java
import jjil.core.Error;
import jjil.core.Gray16Image;
import jjil.core.Gray8Image;
import jjil.core.Image;
import jjil.core.PipelineStage;
/*
* Gray8VertVar.java
*
* Created on February 3, 2008, 4:32, PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*
* Copyright 2008 by Jon A. Webb
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package jjil.algorithm;
/**
* Computes the variance of pixels vertically distributed around
* the current pixel.
* @author webb
*/
public class Gray8VertVar extends PipelineStage {
/**
* The window size -- pixels within nWindow of the current
* pixel are included in the window.
*/
int nWindow;
/**
* The output image.
*/
Gray16Image g16 = null;
/**
* Creates a new instance of Gray8VertVar
* @param nWindow height of window to calculate variance over.
*/
public Gray8VertVar(int nWindow) {
this.nWindow = nWindow;
}
/** Compute the vertical variance of pixels within nWindow
* of the current pixel.
* @param image the input Gray8Image
* @throws jjil.core.Error if image is not a Gray8Image
*/
| public void push(Image image) throws jjil.core.Error {
|
gast-lib/gast-lib | jjil/src/jjil/algorithm/LinefitHoughVert.java | // Path: jjil/src/jjil/core/Point.java
// public class Point implements Serializable {
// private int mnX;
// private int mnY;
//
// /** Creates a new instance of Point
// *
// * @param mnX the Point's x position (column)
// * @param mnY the Point's y position (row)
// */
// public Point(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// }
//
// /**
// * Offset a point by a 2-dimensional vector Vec2, returning modified point.
// * @param v Vec2 to offset this point by
// * @return modified Point
// */
// public Point add(Vec2 v) {
// this.mnX += v.getX();
// this.mnY += v.getY();
// return this;
// }
//
// /**
// * Make a copy of this Point, so that modifications by other
// * operations don't affect the original.
// */
// public Point clone() {
// return new Point(this.mnX, this.mnY);
// }
//
// /**
// * Compute a vector from another Point to this
// * @param pos starting point
// * @return a Vec2 which, when added to pos, will give this
// */
// public Vec2 diff(Point pos) {
// return new Vec2(this.mnX-pos.mnX, this.mnY-pos.mnY);
// }
//
// /**
// * Returns true iff this Point equals the first parameter.
// */
// public boolean equals(Object o) {
// if (!(o instanceof Point)) {
// return false;
// }
// Point p = (Point) o;
// return this.mnX == p.mnX && this.mnY == p.mnY;
// }
//
// /**
// * Return the point's x-coordinate.
// * @return the horizontal position of the point.
// */
// public int getX() {
// return this.mnX;
// }
//
// /**
// * Return the point's y-coordinate.
// * @return the vertical position of the point.
// */
// public int getY() {
// return this.mnY;
// }
//
// public int hashCode() {
// int hash = 5;
// hash = 67 * hash + this.mnX;
// hash = 67 * hash + this.mnY;
// return hash;
// }
//
// /**
// * Offset a point by a certain x,y
// * @param x x offset
// * @param y y offset
// * @return modified Point
// */
// public Point offset(int nX, int nY) {
// this.mnX += nX;
// this.mnY += nY;
// return this;
// }
//
// /**
// * Change the (x,y) coordinates of this Point
// * @param nX new X coordinate
// * @param nY new Y coordinate
// * @return the modified Point
// */
// public Point setXY(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// return this;
// }
//
// /**
// * Implement toString
// * @return Object address + (x,y)
// */
// public String toString() {
// return super.toString() + "(" +
// new Integer(this.mnX).toString() + "," +
// new Integer(this.mnY).toString() + ")";
// }
// }
| import java.util.Enumeration;
import java.util.Vector;
import jjil.core.Error;
import jjil.core.Point; | this.cMaxX = cMaxX;
if (cMaxSlope < cMinSlope) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_RANGE_NULL_OR_NEGATIVE,
new Integer(cMinSlope).toString(),
new Integer(cMaxSlope).toString(),
null);
}
if (cSteps <= 0) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_OUT_OF_RANGE,
new Integer(cSteps).toString(),
new Integer(1).toString(),
new Integer(Integer.MAX_VALUE).toString());
}
this.cMinSlope = cMinSlope;
this.cMaxSlope = cMaxSlope;
this.cSteps = cSteps;
}
/** Add a new point to the Hough accumulator array. We increment along the
* line in the array
* from (cMinSlope>>8, xIntStart) to (cMaxSlope>>8, xIntEnd), where
* xIntStart is the x-intercept assuming the slope is at the minimum,
* and xIntEnd is the x-intercept assuming the slope is maximal.
*
* @param p the point to add to the accumulator array
*/ | // Path: jjil/src/jjil/core/Point.java
// public class Point implements Serializable {
// private int mnX;
// private int mnY;
//
// /** Creates a new instance of Point
// *
// * @param mnX the Point's x position (column)
// * @param mnY the Point's y position (row)
// */
// public Point(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// }
//
// /**
// * Offset a point by a 2-dimensional vector Vec2, returning modified point.
// * @param v Vec2 to offset this point by
// * @return modified Point
// */
// public Point add(Vec2 v) {
// this.mnX += v.getX();
// this.mnY += v.getY();
// return this;
// }
//
// /**
// * Make a copy of this Point, so that modifications by other
// * operations don't affect the original.
// */
// public Point clone() {
// return new Point(this.mnX, this.mnY);
// }
//
// /**
// * Compute a vector from another Point to this
// * @param pos starting point
// * @return a Vec2 which, when added to pos, will give this
// */
// public Vec2 diff(Point pos) {
// return new Vec2(this.mnX-pos.mnX, this.mnY-pos.mnY);
// }
//
// /**
// * Returns true iff this Point equals the first parameter.
// */
// public boolean equals(Object o) {
// if (!(o instanceof Point)) {
// return false;
// }
// Point p = (Point) o;
// return this.mnX == p.mnX && this.mnY == p.mnY;
// }
//
// /**
// * Return the point's x-coordinate.
// * @return the horizontal position of the point.
// */
// public int getX() {
// return this.mnX;
// }
//
// /**
// * Return the point's y-coordinate.
// * @return the vertical position of the point.
// */
// public int getY() {
// return this.mnY;
// }
//
// public int hashCode() {
// int hash = 5;
// hash = 67 * hash + this.mnX;
// hash = 67 * hash + this.mnY;
// return hash;
// }
//
// /**
// * Offset a point by a certain x,y
// * @param x x offset
// * @param y y offset
// * @return modified Point
// */
// public Point offset(int nX, int nY) {
// this.mnX += nX;
// this.mnY += nY;
// return this;
// }
//
// /**
// * Change the (x,y) coordinates of this Point
// * @param nX new X coordinate
// * @param nY new Y coordinate
// * @return the modified Point
// */
// public Point setXY(int nX, int nY) {
// this.mnX = nX;
// this.mnY = nY;
// return this;
// }
//
// /**
// * Implement toString
// * @return Object address + (x,y)
// */
// public String toString() {
// return super.toString() + "(" +
// new Integer(this.mnX).toString() + "," +
// new Integer(this.mnY).toString() + ")";
// }
// }
// Path: jjil/src/jjil/algorithm/LinefitHoughVert.java
import java.util.Enumeration;
import java.util.Vector;
import jjil.core.Error;
import jjil.core.Point;
this.cMaxX = cMaxX;
if (cMaxSlope < cMinSlope) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_RANGE_NULL_OR_NEGATIVE,
new Integer(cMinSlope).toString(),
new Integer(cMaxSlope).toString(),
null);
}
if (cSteps <= 0) {
throw new Error(
Error.PACKAGE.ALGORITHM,
ErrorCodes.PARAMETER_OUT_OF_RANGE,
new Integer(cSteps).toString(),
new Integer(1).toString(),
new Integer(Integer.MAX_VALUE).toString());
}
this.cMinSlope = cMinSlope;
this.cMaxSlope = cMaxSlope;
this.cSteps = cSteps;
}
/** Add a new point to the Hough accumulator array. We increment along the
* line in the array
* from (cMinSlope>>8, xIntStart) to (cMaxSlope>>8, xIntEnd), where
* xIntStart is the x-intercept assuming the slope is at the minimum,
* and xIntEnd is the x-intercept assuming the slope is maximal.
*
* @param p the point to add to the accumulator array
*/ | private void addPoint(Point p) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.