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
|
---|---|---|---|---|---|---|
dianping/polestar | src/main/java/com/dianping/polestar/CancelQueryListener.java | // Path: src/main/java/com/dianping/polestar/jobs/Job.java
// public interface Job {
//
// Integer run() throws Exception;
//
// void cancel();
//
// boolean isCanceled();
//
// }
//
// Path: src/main/java/com/dianping/polestar/jobs/JobManager.java
// public class JobManager {
// private final static Map<String, Job> idToJob = new ConcurrentHashMap<String, Job>(
// 100);
// private final static Map<String, JobContext> idToJobContext = new ConcurrentHashMap<String, JobContext>(
// 100);
//
// public static Job getJobById(String id) {
// return idToJob.get(id);
// }
//
// public static JobContext getJobContextById(String id) {
// return idToJobContext.get(id);
// }
//
// public static void putJob(String id, Job job, JobContext jobctx) {
// synchronized (JobManager.class) {
// idToJob.put(id, job);
// idToJobContext.put(id, jobctx);
// }
// }
//
// public static void removeJob(String id) {
// synchronized (JobManager.class) {
// idToJob.remove(id);
// idToJobContext.remove(id);
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
| import java.util.List;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.jobs.Job;
import com.dianping.polestar.jobs.JobManager;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryCancel; | package com.dianping.polestar;
public class CancelQueryListener implements ServletContextListener {
private final static Log LOG = LogFactory.getLog(CancelQueryListener.class);
private final static long CHECK_DB_INTERVAL_IN_MILLISECONDS = 3000L;
private final QueryDAO queryDao = QueryDAOFactory.getInstance();
private CancelQueryThread cancelQueryThread;
@Override
public void contextInitialized(ServletContextEvent sce) {
cancelQueryThread = new CancelQueryThread();
cancelQueryThread.setDaemon(true);
cancelQueryThread.start();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
if (cancelQueryThread != null) {
cancelQueryThread.interrupt();
}
}
class CancelQueryThread extends Thread {
@Override
public void run() {
LOG.info("start to launch CancelQuery Thread"); | // Path: src/main/java/com/dianping/polestar/jobs/Job.java
// public interface Job {
//
// Integer run() throws Exception;
//
// void cancel();
//
// boolean isCanceled();
//
// }
//
// Path: src/main/java/com/dianping/polestar/jobs/JobManager.java
// public class JobManager {
// private final static Map<String, Job> idToJob = new ConcurrentHashMap<String, Job>(
// 100);
// private final static Map<String, JobContext> idToJobContext = new ConcurrentHashMap<String, JobContext>(
// 100);
//
// public static Job getJobById(String id) {
// return idToJob.get(id);
// }
//
// public static JobContext getJobContextById(String id) {
// return idToJobContext.get(id);
// }
//
// public static void putJob(String id, Job job, JobContext jobctx) {
// synchronized (JobManager.class) {
// idToJob.put(id, job);
// idToJobContext.put(id, jobctx);
// }
// }
//
// public static void removeJob(String id) {
// synchronized (JobManager.class) {
// idToJob.remove(id);
// idToJobContext.remove(id);
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
// Path: src/main/java/com/dianping/polestar/CancelQueryListener.java
import java.util.List;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.jobs.Job;
import com.dianping.polestar.jobs.JobManager;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryCancel;
package com.dianping.polestar;
public class CancelQueryListener implements ServletContextListener {
private final static Log LOG = LogFactory.getLog(CancelQueryListener.class);
private final static long CHECK_DB_INTERVAL_IN_MILLISECONDS = 3000L;
private final QueryDAO queryDao = QueryDAOFactory.getInstance();
private CancelQueryThread cancelQueryThread;
@Override
public void contextInitialized(ServletContextEvent sce) {
cancelQueryThread = new CancelQueryThread();
cancelQueryThread.setDaemon(true);
cancelQueryThread.start();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
if (cancelQueryThread != null) {
cancelQueryThread.interrupt();
}
}
class CancelQueryThread extends Thread {
@Override
public void run() {
LOG.info("start to launch CancelQuery Thread"); | List<QueryCancel> queryCancels = null; |
dianping/polestar | src/main/java/com/dianping/polestar/CancelQueryListener.java | // Path: src/main/java/com/dianping/polestar/jobs/Job.java
// public interface Job {
//
// Integer run() throws Exception;
//
// void cancel();
//
// boolean isCanceled();
//
// }
//
// Path: src/main/java/com/dianping/polestar/jobs/JobManager.java
// public class JobManager {
// private final static Map<String, Job> idToJob = new ConcurrentHashMap<String, Job>(
// 100);
// private final static Map<String, JobContext> idToJobContext = new ConcurrentHashMap<String, JobContext>(
// 100);
//
// public static Job getJobById(String id) {
// return idToJob.get(id);
// }
//
// public static JobContext getJobContextById(String id) {
// return idToJobContext.get(id);
// }
//
// public static void putJob(String id, Job job, JobContext jobctx) {
// synchronized (JobManager.class) {
// idToJob.put(id, job);
// idToJobContext.put(id, jobctx);
// }
// }
//
// public static void removeJob(String id) {
// synchronized (JobManager.class) {
// idToJob.remove(id);
// idToJobContext.remove(id);
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
| import java.util.List;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.jobs.Job;
import com.dianping.polestar.jobs.JobManager;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryCancel; | package com.dianping.polestar;
public class CancelQueryListener implements ServletContextListener {
private final static Log LOG = LogFactory.getLog(CancelQueryListener.class);
private final static long CHECK_DB_INTERVAL_IN_MILLISECONDS = 3000L;
private final QueryDAO queryDao = QueryDAOFactory.getInstance();
private CancelQueryThread cancelQueryThread;
@Override
public void contextInitialized(ServletContextEvent sce) {
cancelQueryThread = new CancelQueryThread();
cancelQueryThread.setDaemon(true);
cancelQueryThread.start();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
if (cancelQueryThread != null) {
cancelQueryThread.interrupt();
}
}
class CancelQueryThread extends Thread {
@Override
public void run() {
LOG.info("start to launch CancelQuery Thread");
List<QueryCancel> queryCancels = null;
while (true) {
try {
queryCancels = queryDao
.findQueryCancelWithouHost(EnvironmentConstants.LOCAL_HOST_ADDRESS);
if (queryCancels != null && queryCancels.size() > 0) {
for (QueryCancel qc : queryCancels) { | // Path: src/main/java/com/dianping/polestar/jobs/Job.java
// public interface Job {
//
// Integer run() throws Exception;
//
// void cancel();
//
// boolean isCanceled();
//
// }
//
// Path: src/main/java/com/dianping/polestar/jobs/JobManager.java
// public class JobManager {
// private final static Map<String, Job> idToJob = new ConcurrentHashMap<String, Job>(
// 100);
// private final static Map<String, JobContext> idToJobContext = new ConcurrentHashMap<String, JobContext>(
// 100);
//
// public static Job getJobById(String id) {
// return idToJob.get(id);
// }
//
// public static JobContext getJobContextById(String id) {
// return idToJobContext.get(id);
// }
//
// public static void putJob(String id, Job job, JobContext jobctx) {
// synchronized (JobManager.class) {
// idToJob.put(id, job);
// idToJobContext.put(id, jobctx);
// }
// }
//
// public static void removeJob(String id) {
// synchronized (JobManager.class) {
// idToJob.remove(id);
// idToJobContext.remove(id);
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
// Path: src/main/java/com/dianping/polestar/CancelQueryListener.java
import java.util.List;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.jobs.Job;
import com.dianping.polestar.jobs.JobManager;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryCancel;
package com.dianping.polestar;
public class CancelQueryListener implements ServletContextListener {
private final static Log LOG = LogFactory.getLog(CancelQueryListener.class);
private final static long CHECK_DB_INTERVAL_IN_MILLISECONDS = 3000L;
private final QueryDAO queryDao = QueryDAOFactory.getInstance();
private CancelQueryThread cancelQueryThread;
@Override
public void contextInitialized(ServletContextEvent sce) {
cancelQueryThread = new CancelQueryThread();
cancelQueryThread.setDaemon(true);
cancelQueryThread.start();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
if (cancelQueryThread != null) {
cancelQueryThread.interrupt();
}
}
class CancelQueryThread extends Thread {
@Override
public void run() {
LOG.info("start to launch CancelQuery Thread");
List<QueryCancel> queryCancels = null;
while (true) {
try {
queryCancels = queryDao
.findQueryCancelWithouHost(EnvironmentConstants.LOCAL_HOST_ADDRESS);
if (queryCancels != null && queryCancels.size() > 0) {
for (QueryCancel qc : queryCancels) { | Job job = JobManager.getJobById(qc.getId()); |
dianping/polestar | src/main/java/com/dianping/polestar/CancelQueryListener.java | // Path: src/main/java/com/dianping/polestar/jobs/Job.java
// public interface Job {
//
// Integer run() throws Exception;
//
// void cancel();
//
// boolean isCanceled();
//
// }
//
// Path: src/main/java/com/dianping/polestar/jobs/JobManager.java
// public class JobManager {
// private final static Map<String, Job> idToJob = new ConcurrentHashMap<String, Job>(
// 100);
// private final static Map<String, JobContext> idToJobContext = new ConcurrentHashMap<String, JobContext>(
// 100);
//
// public static Job getJobById(String id) {
// return idToJob.get(id);
// }
//
// public static JobContext getJobContextById(String id) {
// return idToJobContext.get(id);
// }
//
// public static void putJob(String id, Job job, JobContext jobctx) {
// synchronized (JobManager.class) {
// idToJob.put(id, job);
// idToJobContext.put(id, jobctx);
// }
// }
//
// public static void removeJob(String id) {
// synchronized (JobManager.class) {
// idToJob.remove(id);
// idToJobContext.remove(id);
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
| import java.util.List;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.jobs.Job;
import com.dianping.polestar.jobs.JobManager;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryCancel; | package com.dianping.polestar;
public class CancelQueryListener implements ServletContextListener {
private final static Log LOG = LogFactory.getLog(CancelQueryListener.class);
private final static long CHECK_DB_INTERVAL_IN_MILLISECONDS = 3000L;
private final QueryDAO queryDao = QueryDAOFactory.getInstance();
private CancelQueryThread cancelQueryThread;
@Override
public void contextInitialized(ServletContextEvent sce) {
cancelQueryThread = new CancelQueryThread();
cancelQueryThread.setDaemon(true);
cancelQueryThread.start();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
if (cancelQueryThread != null) {
cancelQueryThread.interrupt();
}
}
class CancelQueryThread extends Thread {
@Override
public void run() {
LOG.info("start to launch CancelQuery Thread");
List<QueryCancel> queryCancels = null;
while (true) {
try {
queryCancels = queryDao
.findQueryCancelWithouHost(EnvironmentConstants.LOCAL_HOST_ADDRESS);
if (queryCancels != null && queryCancels.size() > 0) {
for (QueryCancel qc : queryCancels) { | // Path: src/main/java/com/dianping/polestar/jobs/Job.java
// public interface Job {
//
// Integer run() throws Exception;
//
// void cancel();
//
// boolean isCanceled();
//
// }
//
// Path: src/main/java/com/dianping/polestar/jobs/JobManager.java
// public class JobManager {
// private final static Map<String, Job> idToJob = new ConcurrentHashMap<String, Job>(
// 100);
// private final static Map<String, JobContext> idToJobContext = new ConcurrentHashMap<String, JobContext>(
// 100);
//
// public static Job getJobById(String id) {
// return idToJob.get(id);
// }
//
// public static JobContext getJobContextById(String id) {
// return idToJobContext.get(id);
// }
//
// public static void putJob(String id, Job job, JobContext jobctx) {
// synchronized (JobManager.class) {
// idToJob.put(id, job);
// idToJobContext.put(id, jobctx);
// }
// }
//
// public static void removeJob(String id) {
// synchronized (JobManager.class) {
// idToJob.remove(id);
// idToJobContext.remove(id);
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
// Path: src/main/java/com/dianping/polestar/CancelQueryListener.java
import java.util.List;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.jobs.Job;
import com.dianping.polestar.jobs.JobManager;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryCancel;
package com.dianping.polestar;
public class CancelQueryListener implements ServletContextListener {
private final static Log LOG = LogFactory.getLog(CancelQueryListener.class);
private final static long CHECK_DB_INTERVAL_IN_MILLISECONDS = 3000L;
private final QueryDAO queryDao = QueryDAOFactory.getInstance();
private CancelQueryThread cancelQueryThread;
@Override
public void contextInitialized(ServletContextEvent sce) {
cancelQueryThread = new CancelQueryThread();
cancelQueryThread.setDaemon(true);
cancelQueryThread.start();
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
if (cancelQueryThread != null) {
cancelQueryThread.interrupt();
}
}
class CancelQueryThread extends Thread {
@Override
public void run() {
LOG.info("start to launch CancelQuery Thread");
List<QueryCancel> queryCancels = null;
while (true) {
try {
queryCancels = queryDao
.findQueryCancelWithouHost(EnvironmentConstants.LOCAL_HOST_ADDRESS);
if (queryCancels != null && queryCancels.size() > 0) {
for (QueryCancel qc : queryCancels) { | Job job = JobManager.getJobById(qc.getId()); |
dianping/polestar | src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java | // Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryInfo.java
// public class QueryInfo {
// private String sql;
// private String mode;
// private String username;
// private String resultFilePath;
// private long execTime;
// private String addtime;
//
// public QueryInfo() {
// }
//
// public QueryInfo(Query q, QueryResult rs, long starttime) {
// setSql(q.getSql());
// setMode(q.getMode());
// setUsername(q.getUsername());
// setResultFilePath(rs.getResultFilePath());
// setExecTime(rs.getExecTime());
// setAddtime(EnvironmentConstants.DATE_FORMAT.format(new Date(starttime)));
// }
//
// public String getSql() {
// return sql;
// }
//
// public void setSql(String sql) {
// this.sql = sql;
// }
//
// public String getMode() {
// return mode;
// }
//
// public void setMode(String mode) {
// this.mode = mode;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getResultFilePath() {
// return resultFilePath;
// }
//
// public void setResultFilePath(String resultFilePath) {
// this.resultFilePath = resultFilePath;
// }
//
// public long getExecTime() {
// return execTime;
// }
//
// public void setExecTime(long execTime) {
// this.execTime = execTime;
// }
//
// public String getAddtime() {
// return addtime;
// }
//
// public void setAddtime(String addtime) {
// this.addtime = addtime;
// }
//
// @Override
// public String toString() {
// return "QueryInfo [sql=" + sql + ", mode=" + mode + ", username="
// + username + ", resultFilePath=" + resultFilePath
// + ", execTime=" + execTime + ", addtime=" + addtime + "]";
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
| import java.util.List;
import com.dianping.polestar.store.mysql.domain.QueryCancel;
import com.dianping.polestar.store.mysql.domain.QueryInfo;
import com.dianping.polestar.store.mysql.domain.QueryProgress; | package com.dianping.polestar.store.mysql.dao;
public interface QueryDAO {
public void insertQueryInfo(QueryInfo queryInfo);
public List<QueryInfo> findQueryInfoByUsername(String username);
| // Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryInfo.java
// public class QueryInfo {
// private String sql;
// private String mode;
// private String username;
// private String resultFilePath;
// private long execTime;
// private String addtime;
//
// public QueryInfo() {
// }
//
// public QueryInfo(Query q, QueryResult rs, long starttime) {
// setSql(q.getSql());
// setMode(q.getMode());
// setUsername(q.getUsername());
// setResultFilePath(rs.getResultFilePath());
// setExecTime(rs.getExecTime());
// setAddtime(EnvironmentConstants.DATE_FORMAT.format(new Date(starttime)));
// }
//
// public String getSql() {
// return sql;
// }
//
// public void setSql(String sql) {
// this.sql = sql;
// }
//
// public String getMode() {
// return mode;
// }
//
// public void setMode(String mode) {
// this.mode = mode;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getResultFilePath() {
// return resultFilePath;
// }
//
// public void setResultFilePath(String resultFilePath) {
// this.resultFilePath = resultFilePath;
// }
//
// public long getExecTime() {
// return execTime;
// }
//
// public void setExecTime(long execTime) {
// this.execTime = execTime;
// }
//
// public String getAddtime() {
// return addtime;
// }
//
// public void setAddtime(String addtime) {
// this.addtime = addtime;
// }
//
// @Override
// public String toString() {
// return "QueryInfo [sql=" + sql + ", mode=" + mode + ", username="
// + username + ", resultFilePath=" + resultFilePath
// + ", execTime=" + execTime + ", addtime=" + addtime + "]";
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
import java.util.List;
import com.dianping.polestar.store.mysql.domain.QueryCancel;
import com.dianping.polestar.store.mysql.domain.QueryInfo;
import com.dianping.polestar.store.mysql.domain.QueryProgress;
package com.dianping.polestar.store.mysql.dao;
public interface QueryDAO {
public void insertQueryInfo(QueryInfo queryInfo);
public List<QueryInfo> findQueryInfoByUsername(String username);
| public void insertQueryProgress(QueryProgress queryProgress); |
dianping/polestar | src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java | // Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryInfo.java
// public class QueryInfo {
// private String sql;
// private String mode;
// private String username;
// private String resultFilePath;
// private long execTime;
// private String addtime;
//
// public QueryInfo() {
// }
//
// public QueryInfo(Query q, QueryResult rs, long starttime) {
// setSql(q.getSql());
// setMode(q.getMode());
// setUsername(q.getUsername());
// setResultFilePath(rs.getResultFilePath());
// setExecTime(rs.getExecTime());
// setAddtime(EnvironmentConstants.DATE_FORMAT.format(new Date(starttime)));
// }
//
// public String getSql() {
// return sql;
// }
//
// public void setSql(String sql) {
// this.sql = sql;
// }
//
// public String getMode() {
// return mode;
// }
//
// public void setMode(String mode) {
// this.mode = mode;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getResultFilePath() {
// return resultFilePath;
// }
//
// public void setResultFilePath(String resultFilePath) {
// this.resultFilePath = resultFilePath;
// }
//
// public long getExecTime() {
// return execTime;
// }
//
// public void setExecTime(long execTime) {
// this.execTime = execTime;
// }
//
// public String getAddtime() {
// return addtime;
// }
//
// public void setAddtime(String addtime) {
// this.addtime = addtime;
// }
//
// @Override
// public String toString() {
// return "QueryInfo [sql=" + sql + ", mode=" + mode + ", username="
// + username + ", resultFilePath=" + resultFilePath
// + ", execTime=" + execTime + ", addtime=" + addtime + "]";
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
| import java.util.List;
import com.dianping.polestar.store.mysql.domain.QueryCancel;
import com.dianping.polestar.store.mysql.domain.QueryInfo;
import com.dianping.polestar.store.mysql.domain.QueryProgress; | package com.dianping.polestar.store.mysql.dao;
public interface QueryDAO {
public void insertQueryInfo(QueryInfo queryInfo);
public List<QueryInfo> findQueryInfoByUsername(String username);
public void insertQueryProgress(QueryProgress queryProgress);
public QueryProgress findQueryProgressById(String id);
| // Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryCancel.java
// public class QueryCancel {
// private String id;
// private String host;
//
// public QueryCancel() {
// }
//
// public QueryCancel(String id, String host) {
// this.id = id;
// this.host = host;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getHost() {
// return host;
// }
//
// public void setHost(String host) {
// this.host = host;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryInfo.java
// public class QueryInfo {
// private String sql;
// private String mode;
// private String username;
// private String resultFilePath;
// private long execTime;
// private String addtime;
//
// public QueryInfo() {
// }
//
// public QueryInfo(Query q, QueryResult rs, long starttime) {
// setSql(q.getSql());
// setMode(q.getMode());
// setUsername(q.getUsername());
// setResultFilePath(rs.getResultFilePath());
// setExecTime(rs.getExecTime());
// setAddtime(EnvironmentConstants.DATE_FORMAT.format(new Date(starttime)));
// }
//
// public String getSql() {
// return sql;
// }
//
// public void setSql(String sql) {
// this.sql = sql;
// }
//
// public String getMode() {
// return mode;
// }
//
// public void setMode(String mode) {
// this.mode = mode;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getResultFilePath() {
// return resultFilePath;
// }
//
// public void setResultFilePath(String resultFilePath) {
// this.resultFilePath = resultFilePath;
// }
//
// public long getExecTime() {
// return execTime;
// }
//
// public void setExecTime(long execTime) {
// this.execTime = execTime;
// }
//
// public String getAddtime() {
// return addtime;
// }
//
// public void setAddtime(String addtime) {
// this.addtime = addtime;
// }
//
// @Override
// public String toString() {
// return "QueryInfo [sql=" + sql + ", mode=" + mode + ", username="
// + username + ", resultFilePath=" + resultFilePath
// + ", execTime=" + execTime + ", addtime=" + addtime + "]";
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
import java.util.List;
import com.dianping.polestar.store.mysql.domain.QueryCancel;
import com.dianping.polestar.store.mysql.domain.QueryInfo;
import com.dianping.polestar.store.mysql.domain.QueryProgress;
package com.dianping.polestar.store.mysql.dao;
public interface QueryDAO {
public void insertQueryInfo(QueryInfo queryInfo);
public List<QueryInfo> findQueryInfoByUsername(String username);
public void insertQueryProgress(QueryProgress queryProgress);
public QueryProgress findQueryProgressById(String id);
| public void insertQueryCancel(QueryCancel qc); |
dianping/polestar | src/main/java/com/dianping/polestar/jobs/ProcessJob.java | // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
| import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryProgress; | package com.dianping.polestar.jobs;
public class ProcessJob extends AbstractJob {
public final static Log LOG = LogFactory.getLog(ProcessJob.class);
private final static int FLUSH_STDERROR_IN_MILLISECONDS = 2000;
private final static String KRB5CCNAME = "KRB5CCNAME";
private final static String TICKET_CACHE_EXTENTION = ".ticketcache";
private final static String SHARK_FILTER_STRING = "spray-io-worker";
| // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
// Path: src/main/java/com/dianping/polestar/jobs/ProcessJob.java
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryProgress;
package com.dianping.polestar.jobs;
public class ProcessJob extends AbstractJob {
public final static Log LOG = LogFactory.getLog(ProcessJob.class);
private final static int FLUSH_STDERROR_IN_MILLISECONDS = 2000;
private final static String KRB5CCNAME = "KRB5CCNAME";
private final static String TICKET_CACHE_EXTENTION = ".ticketcache";
private final static String SHARK_FILTER_STRING = "spray-io-worker";
| private final QueryDAO queryDao = QueryDAOFactory.getInstance(); |
dianping/polestar | src/main/java/com/dianping/polestar/jobs/ProcessJob.java | // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
| import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryProgress; | package com.dianping.polestar.jobs;
public class ProcessJob extends AbstractJob {
public final static Log LOG = LogFactory.getLog(ProcessJob.class);
private final static int FLUSH_STDERROR_IN_MILLISECONDS = 2000;
private final static String KRB5CCNAME = "KRB5CCNAME";
private final static String TICKET_CACHE_EXTENTION = ".ticketcache";
private final static String SHARK_FILTER_STRING = "spray-io-worker";
| // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/QueryDAO.java
// public interface QueryDAO {
//
// public void insertQueryInfo(QueryInfo queryInfo);
//
// public List<QueryInfo> findQueryInfoByUsername(String username);
//
// public void insertQueryProgress(QueryProgress queryProgress);
//
// public QueryProgress findQueryProgressById(String id);
//
// public void insertQueryCancel(QueryCancel qc);
//
// public List<QueryCancel> findQueryCancelWithouHost(String host);
//
// public void deleteQueryCancelById(String id);
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/dao/impl/QueryDAOFactory.java
// public final class QueryDAOFactory {
//
// public static QueryDAO queryDao;
//
// public static QueryDAO getInstance() {
// if (queryDao == null) {
// synchronized (QueryDAOFactory.class) {
// if (queryDao == null) {
// AbstractApplicationContext cxt = new ClassPathXmlApplicationContext(
// "applicationContext.xml");
// queryDao = (QueryDAO) cxt.getBean("queryDaoImpl");
// }
// }
// }
// return queryDao;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/store/mysql/domain/QueryProgress.java
// public class QueryProgress {
// private String id;
// private String progressInfo;
//
// public QueryProgress() {
// }
//
// public QueryProgress(String id, String progressInfo) {
// this.id = id;
// this.progressInfo = progressInfo;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProgressInfo() {
// return progressInfo;
// }
//
// public void setProgressInfo(String progressInfo) {
// this.progressInfo = progressInfo;
// }
//
// @Override
// public String toString() {
// return "QueryProgress [id=" + id + ", progressInfo=" + progressInfo
// + "]";
// }
// }
// Path: src/main/java/com/dianping/polestar/jobs/ProcessJob.java
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.store.mysql.dao.QueryDAO;
import com.dianping.polestar.store.mysql.dao.impl.QueryDAOFactory;
import com.dianping.polestar.store.mysql.domain.QueryProgress;
package com.dianping.polestar.jobs;
public class ProcessJob extends AbstractJob {
public final static Log LOG = LogFactory.getLog(ProcessJob.class);
private final static int FLUSH_STDERROR_IN_MILLISECONDS = 2000;
private final static String KRB5CCNAME = "KRB5CCNAME";
private final static String TICKET_CACHE_EXTENTION = ".ticketcache";
private final static String SHARK_FILTER_STRING = "spray-io-worker";
| private final QueryDAO queryDao = QueryDAOFactory.getInstance(); |
dianping/polestar | src/main/java/com/dianping/polestar/service/IQueryService.java | // Path: src/main/java/com/dianping/polestar/entity/Query.java
// public class Query extends Entity {
// private String sql;
// private String mode;
// private String database;
// private String username;
// private String password;
// private boolean storeResult;
//
// public String getSql() {
// return sql;
// }
//
// public void setSql(String sql) {
// this.sql = sql;
// }
//
// public String getMode() {
// return mode;
// }
//
// public void setMode(String mode) {
// this.mode = mode;
// }
//
// public String getDatabase() {
// return database;
// }
//
// public void setDatabase(String database) {
// this.database = database;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public boolean isStoreResult() {
// return storeResult;
// }
//
// public void setStoreResult(boolean storeResult) {
// this.storeResult = storeResult;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/entity/QueryResult.java
// public final class QueryResult extends Entity {
// private String[] columnNames = new String[]{};
// private List<String[]> data = new ArrayList<String[]>();
// private long execTime = -1L;
// private String errorMsg = "";
// private String resultFilePath = "";
// private Boolean success = false;
//
// public String[] getColumnNames() {
// return columnNames;
// }
// public void setColumnNames(String[] columnNames) {
// this.columnNames = columnNames;
// }
// public List<String[]> getData() {
// return data;
// }
// public void setData(List<String[]> data) {
// this.data = data;
// }
// public long getExecTime() {
// return execTime;
// }
// public void setExecTime(long execTime) {
// this.execTime = execTime;
// }
// public String getErrorMsg() {
// return errorMsg;
// }
// public void setErrorMsg(String errorMsg) {
// this.errorMsg = errorMsg;
// }
// public String getResultFilePath() {
// return resultFilePath;
// }
// public void setResultFilePath(String resultFilePath) {
// this.resultFilePath = resultFilePath;
// }
// public Boolean getSuccess() {
// return success;
// }
// public void setSuccess(Boolean success) {
// this.success = success;
// }
//
// @Override
// public String toString() {
// return "QueryResult [columnNames=" + Arrays.toString(columnNames)
// + ", data=" + data + ", execTime=" + execTime + ", errorMsg="
// + errorMsg + ", resultFilePath=" + resultFilePath
// + ", success=" + success + "]";
// }
// }
//
// Path: src/main/java/com/dianping/polestar/entity/QueryStatus.java
// public class QueryStatus extends Entity {
// private String message;
// private Boolean success;
//
// public String getMessage() {
// return message;
// }
// public void setMessage(String message) {
// this.message = message;
// }
// public Boolean getSuccess() {
// return success;
// }
// public void setSuccess(Boolean success) {
// this.success = success;
// }
//
// @Override
// public String toString() {
// return "QueryStatus [message=" + message + ", success=" + success + "]";
// }
//
// }
//
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// private static final long serialVersionUID = 6788167073159708825L;
//
// public BadParamException(String msg) {
// super(Status.BAD_REQUEST.getStatusCode(), msg);
// }
//
// public BadParamException(Status status, String msg) {
// super(status.getStatusCode(), msg);
// }
// }
| import javax.ws.rs.core.StreamingOutput;
import com.dianping.polestar.entity.Query;
import com.dianping.polestar.entity.QueryResult;
import com.dianping.polestar.entity.QueryStatus;
import com.dianping.polestar.rest.BadParamException; | package com.dianping.polestar.service;
public interface IQueryService {
QueryResult postQuery(Query query) throws BadParamException;
| // Path: src/main/java/com/dianping/polestar/entity/Query.java
// public class Query extends Entity {
// private String sql;
// private String mode;
// private String database;
// private String username;
// private String password;
// private boolean storeResult;
//
// public String getSql() {
// return sql;
// }
//
// public void setSql(String sql) {
// this.sql = sql;
// }
//
// public String getMode() {
// return mode;
// }
//
// public void setMode(String mode) {
// this.mode = mode;
// }
//
// public String getDatabase() {
// return database;
// }
//
// public void setDatabase(String database) {
// this.database = database;
// }
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public boolean isStoreResult() {
// return storeResult;
// }
//
// public void setStoreResult(boolean storeResult) {
// this.storeResult = storeResult;
// }
// }
//
// Path: src/main/java/com/dianping/polestar/entity/QueryResult.java
// public final class QueryResult extends Entity {
// private String[] columnNames = new String[]{};
// private List<String[]> data = new ArrayList<String[]>();
// private long execTime = -1L;
// private String errorMsg = "";
// private String resultFilePath = "";
// private Boolean success = false;
//
// public String[] getColumnNames() {
// return columnNames;
// }
// public void setColumnNames(String[] columnNames) {
// this.columnNames = columnNames;
// }
// public List<String[]> getData() {
// return data;
// }
// public void setData(List<String[]> data) {
// this.data = data;
// }
// public long getExecTime() {
// return execTime;
// }
// public void setExecTime(long execTime) {
// this.execTime = execTime;
// }
// public String getErrorMsg() {
// return errorMsg;
// }
// public void setErrorMsg(String errorMsg) {
// this.errorMsg = errorMsg;
// }
// public String getResultFilePath() {
// return resultFilePath;
// }
// public void setResultFilePath(String resultFilePath) {
// this.resultFilePath = resultFilePath;
// }
// public Boolean getSuccess() {
// return success;
// }
// public void setSuccess(Boolean success) {
// this.success = success;
// }
//
// @Override
// public String toString() {
// return "QueryResult [columnNames=" + Arrays.toString(columnNames)
// + ", data=" + data + ", execTime=" + execTime + ", errorMsg="
// + errorMsg + ", resultFilePath=" + resultFilePath
// + ", success=" + success + "]";
// }
// }
//
// Path: src/main/java/com/dianping/polestar/entity/QueryStatus.java
// public class QueryStatus extends Entity {
// private String message;
// private Boolean success;
//
// public String getMessage() {
// return message;
// }
// public void setMessage(String message) {
// this.message = message;
// }
// public Boolean getSuccess() {
// return success;
// }
// public void setSuccess(Boolean success) {
// this.success = success;
// }
//
// @Override
// public String toString() {
// return "QueryStatus [message=" + message + ", success=" + success + "]";
// }
//
// }
//
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// private static final long serialVersionUID = 6788167073159708825L;
//
// public BadParamException(String msg) {
// super(Status.BAD_REQUEST.getStatusCode(), msg);
// }
//
// public BadParamException(Status status, String msg) {
// super(status.getStatusCode(), msg);
// }
// }
// Path: src/main/java/com/dianping/polestar/service/IQueryService.java
import javax.ws.rs.core.StreamingOutput;
import com.dianping.polestar.entity.Query;
import com.dianping.polestar.entity.QueryResult;
import com.dianping.polestar.entity.QueryStatus;
import com.dianping.polestar.rest.BadParamException;
package com.dianping.polestar.service;
public interface IQueryService {
QueryResult postQuery(Query query) throws BadParamException;
| QueryStatus getStatusInfo(String id); |
dianping/polestar | src/main/java/com/dianping/polestar/store/HDFSManager.java | // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/PolestarException.java
// public class PolestarException extends RuntimeException {
// private static final long serialVersionUID = 6525L;
//
// public PolestarException() {
// super();
// }
//
// public PolestarException(String message) {
// super(message);
// }
//
// public PolestarException(Throwable e) {
// super(e);
// }
//
// public PolestarException(String msg, Throwable e) {
// super(msg, e);
// }
// }
//
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// private static final long serialVersionUID = 6788167073159708825L;
//
// public BadParamException(String msg) {
// super(Status.BAD_REQUEST.getStatusCode(), msg);
// }
//
// public BadParamException(Status status, String msg) {
// super(status.getStatusCode(), msg);
// }
// }
| import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.PolestarException;
import com.dianping.polestar.rest.BadParamException; | } catch (IOException e) {
LOG.error("filesystem is not initialized correctly!" + e);
e.printStackTrace();
}
}
return fs;
}
public static void putFileToHDFS(String src, String dest) {
try {
getFS().copyFromLocalFile(false, true, new Path(src),
new Path(dest));
LOG.info("put file " + src + " to " + dest + " succeed !");
} catch (IOException e) {
LOG.error("put file " + src + " to " + dest + " failed !", e);
}
}
public static Configuration getDefaultConfiguration() {
Configuration conf = null;
File coreSite = new File(getHadoopConfDir(), "core-site.xml");
File hdfsSite = new File(getHadoopConfDir(), "hdfs-site.xml");
if (coreSite.exists() && hdfsSite.exists()) {
conf = new Configuration(true);
conf.addResource(new Path(coreSite.getAbsolutePath()));
conf.addResource(new Path(hdfsSite.getAbsolutePath()));
try {
// 设置服务申请者的Principle
conf.set("hadoop.principal", | // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/PolestarException.java
// public class PolestarException extends RuntimeException {
// private static final long serialVersionUID = 6525L;
//
// public PolestarException() {
// super();
// }
//
// public PolestarException(String message) {
// super(message);
// }
//
// public PolestarException(Throwable e) {
// super(e);
// }
//
// public PolestarException(String msg, Throwable e) {
// super(msg, e);
// }
// }
//
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// private static final long serialVersionUID = 6788167073159708825L;
//
// public BadParamException(String msg) {
// super(Status.BAD_REQUEST.getStatusCode(), msg);
// }
//
// public BadParamException(Status status, String msg) {
// super(status.getStatusCode(), msg);
// }
// }
// Path: src/main/java/com/dianping/polestar/store/HDFSManager.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.PolestarException;
import com.dianping.polestar.rest.BadParamException;
} catch (IOException e) {
LOG.error("filesystem is not initialized correctly!" + e);
e.printStackTrace();
}
}
return fs;
}
public static void putFileToHDFS(String src, String dest) {
try {
getFS().copyFromLocalFile(false, true, new Path(src),
new Path(dest));
LOG.info("put file " + src + " to " + dest + " succeed !");
} catch (IOException e) {
LOG.error("put file " + src + " to " + dest + " failed !", e);
}
}
public static Configuration getDefaultConfiguration() {
Configuration conf = null;
File coreSite = new File(getHadoopConfDir(), "core-site.xml");
File hdfsSite = new File(getHadoopConfDir(), "hdfs-site.xml");
if (coreSite.exists() && hdfsSite.exists()) {
conf = new Configuration(true);
conf.addResource(new Path(coreSite.getAbsolutePath()));
conf.addResource(new Path(hdfsSite.getAbsolutePath()));
try {
// 设置服务申请者的Principle
conf.set("hadoop.principal", | EnvironmentConstants.HADOOP_PRINCIPAL); |
dianping/polestar | src/main/java/com/dianping/polestar/store/HDFSManager.java | // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/PolestarException.java
// public class PolestarException extends RuntimeException {
// private static final long serialVersionUID = 6525L;
//
// public PolestarException() {
// super();
// }
//
// public PolestarException(String message) {
// super(message);
// }
//
// public PolestarException(Throwable e) {
// super(e);
// }
//
// public PolestarException(String msg, Throwable e) {
// super(msg, e);
// }
// }
//
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// private static final long serialVersionUID = 6788167073159708825L;
//
// public BadParamException(String msg) {
// super(Status.BAD_REQUEST.getStatusCode(), msg);
// }
//
// public BadParamException(Status status, String msg) {
// super(status.getStatusCode(), msg);
// }
// }
| import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.PolestarException;
import com.dianping.polestar.rest.BadParamException; | UserGroupInformation.setConfiguration(conf);
SecurityUtil.login(conf, "hadoop.keytab.file",
"hadoop.principal");
} catch (IOException e) {
LOG.error(e);
e.printStackTrace();
}
} else {
LOG.error("core-site.xml or hdfs-site.xml is not found in the system environment!");
}
return conf;
}
public static String getHadoopConfDir() {
String confDir = System.getenv("HADOOP_CONF_DIR");
if (StringUtils.isBlank(confDir)) {
confDir = getHadoopHome() + File.separator + "conf";
}
return confDir;
}
public static String getHadoopHome() {
return System.getenv("HADOOP_HOME");
}
public static String getHiveHome() {
return System.getenv("HIVE_HOME");
}
public static InputStream openFSDataInputStream(String absolutePath) | // Path: src/main/java/com/dianping/polestar/EnvironmentConstants.java
// public final class EnvironmentConstants {
// public final static Log LOG = LogFactory.getLog(EnvironmentConstants.class);
//
// public final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm:ss");
// public static String DATA_FILE_EXTENSION = ".gz";
// public static String WORKING_DIRECTORY_ROOT = "/tmp";
// public static int DEFAULT_RESULT_DATA_NUMBER = 500;
// public static int MAX_RESULT_DATA_NUMBER = 1000000;
// // result data will be stored in this location
// public static String HDFS_DATA_ROOT_PATH = "hdfs://10.1.77.86/data/polestar";
//
// // hadoop security
// public static String HADOOP_PRINCIPAL = "[email protected]";
// public static String HADOOP_KEYTAB_FILE = "/home/hadoop/.keytab";
//
// public static String LOCAL_HOST_ADDRESS;
//
// static {
// try {
// LOCAL_HOST_ADDRESS = InetAddress.getLocalHost().getHostAddress();
// LOG.info("local host address: " + LOCAL_HOST_ADDRESS);
// } catch (UnknownHostException uhe) {
// LOG.error("get local host address failed, " + uhe);
// }
//
// InputStream is = ClassUtils.getResourceAsStream("polestar.properties");
// Properties pros = new Properties();
// try {
// pros.load(is);
//
// DATA_FILE_EXTENSION = pros.getProperty("DATA_FILE_EXTENSION",
// DATA_FILE_EXTENSION);
//
// WORKING_DIRECTORY_ROOT = pros.getProperty("WORKING_DIRECTORY_ROOT",
// WORKING_DIRECTORY_ROOT);
//
// DEFAULT_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "DEFAULT_RESULT_DATA_NUMBER",
// String.valueOf(DEFAULT_RESULT_DATA_NUMBER)));
//
// MAX_RESULT_DATA_NUMBER = Integer.valueOf(pros.getProperty(
// "MAX_RESULT_DATA_NUMBER",
// String.valueOf(MAX_RESULT_DATA_NUMBER)));
//
// HDFS_DATA_ROOT_PATH = pros.getProperty("HDFS_DATA_ROOT_PATH",
// HDFS_DATA_ROOT_PATH);
//
// HADOOP_PRINCIPAL = pros.getProperty(
// pros.getProperty("HADOOP_PRINCIPAL"), HADOOP_PRINCIPAL);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/dianping/polestar/PolestarException.java
// public class PolestarException extends RuntimeException {
// private static final long serialVersionUID = 6525L;
//
// public PolestarException() {
// super();
// }
//
// public PolestarException(String message) {
// super(message);
// }
//
// public PolestarException(Throwable e) {
// super(e);
// }
//
// public PolestarException(String msg, Throwable e) {
// super(msg, e);
// }
// }
//
// Path: src/main/java/com/dianping/polestar/rest/BadParamException.java
// public class BadParamException extends SimpleWebException {
// private static final long serialVersionUID = 6788167073159708825L;
//
// public BadParamException(String msg) {
// super(Status.BAD_REQUEST.getStatusCode(), msg);
// }
//
// public BadParamException(Status status, String msg) {
// super(status.getStatusCode(), msg);
// }
// }
// Path: src/main/java/com/dianping/polestar/store/HDFSManager.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import com.dianping.polestar.EnvironmentConstants;
import com.dianping.polestar.PolestarException;
import com.dianping.polestar.rest.BadParamException;
UserGroupInformation.setConfiguration(conf);
SecurityUtil.login(conf, "hadoop.keytab.file",
"hadoop.principal");
} catch (IOException e) {
LOG.error(e);
e.printStackTrace();
}
} else {
LOG.error("core-site.xml or hdfs-site.xml is not found in the system environment!");
}
return conf;
}
public static String getHadoopConfDir() {
String confDir = System.getenv("HADOOP_CONF_DIR");
if (StringUtils.isBlank(confDir)) {
confDir = getHadoopHome() + File.separator + "conf";
}
return confDir;
}
public static String getHadoopHome() {
return System.getenv("HADOOP_HOME");
}
public static String getHiveHome() {
return System.getenv("HIVE_HOME");
}
public static InputStream openFSDataInputStream(String absolutePath) | throws BadParamException { |
IstiN/schedule | backend/src/main/java/com/github/istin/schedule/backend/servlet/UniversityList.java | // Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
| import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; | /*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class UniversityList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8"); | // Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
// Path: backend/src/main/java/com/github/istin/schedule/backend/servlet/UniversityList.java
import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class UniversityList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8"); | List<University> universities = new ArrayList<>(); |
IstiN/schedule | backend/src/main/java/com/github/istin/schedule/backend/adapter/grsu/domain/LessonModel.java | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
| import com.github.istin.schedule.gson.Lesson; | package com.github.istin.schedule.backend.adapter.grsu.domain;
public class LessonModel {
private String id;
private String date;
private String timeStart;
private String timeEnd;
private String title;
private String address;
private String room;
public void setDate(String pDate) {
date = pDate;
}
| // Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
// Path: backend/src/main/java/com/github/istin/schedule/backend/adapter/grsu/domain/LessonModel.java
import com.github.istin.schedule.gson.Lesson;
package com.github.istin.schedule.backend.adapter.grsu.domain;
public class LessonModel {
private String id;
private String date;
private String timeStart;
private String timeEnd;
private String title;
private String address;
private String room;
public void setDate(String pDate) {
date = pDate;
}
| public Lesson doOptimize() { |
IstiN/schedule | backend/src/main/java/com/github/istin/schedule/backend/IUniversityAdapter.java | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
| import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.Lesson;
import java.util.List; | package com.github.istin.schedule.backend;
/**
* Created by uladzimir_klyshevich on 10/12/15.
*/
public interface IUniversityAdapter {
List<Lecturer> getLecturerList() throws Exception;
| // Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
// Path: backend/src/main/java/com/github/istin/schedule/backend/IUniversityAdapter.java
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.Lesson;
import java.util.List;
package com.github.istin.schedule.backend;
/**
* Created by uladzimir_klyshevich on 10/12/15.
*/
public interface IUniversityAdapter {
List<Lecturer> getLecturerList() throws Exception;
| List<Lesson> getLecturerScheduleList(String pLid) throws Exception; |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
| import android.content.Context;
import android.os.Handler;
import com.github.istin.schedule.CoreApplication; | package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 10/19/15.
*/
public class ThreadManager {
public static final String APP_SERVICE_KEY = "thread:manager";
public static ThreadManager get(Context pContext) { | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
// Path: app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java
import android.content.Context;
import android.os.Handler;
import com.github.istin.schedule.CoreApplication;
package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 10/19/15.
*/
public class ThreadManager {
public static final String APP_SERVICE_KEY = "thread:manager";
public static ThreadManager get(Context pContext) { | return CoreApplication.get(pContext, APP_SERVICE_KEY); |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/CoreApplication.java | // Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java
// public class ThreadManager {
//
// public static final String APP_SERVICE_KEY = "thread:manager";
//
// public static ThreadManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public interface IExecutionListener<Result> {
//
// void onJobStarted();
//
// void onDone(Result pResult);
//
// void onError(Exception e);
//
// }
//
// public interface IJob<Result> {
//
// Result doJob() throws Exception;
//
// }
//
// public <Result> void execute(final IJob<Result> pJob, final IExecutionListener<Result> pExecutionListener) {
// pExecutionListener.onJobStarted();
// final Handler handler = new Handler();
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// final Result result = pJob.doJob();
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onDone(result);
// }
// });
// } catch (final Exception e) {
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onError(e);
// }
// });
// }
// }
// }).start();
// }
//
// }
| import android.app.Application;
import android.content.Context;
import com.github.istin.schedule.manager.ConfigurationManager;
import com.github.istin.schedule.manager.ThreadManager; | package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/5/15.
*/
public class CoreApplication extends Application {
private ConfigurationManager mConfigurationManager;
| // Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java
// public class ThreadManager {
//
// public static final String APP_SERVICE_KEY = "thread:manager";
//
// public static ThreadManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public interface IExecutionListener<Result> {
//
// void onJobStarted();
//
// void onDone(Result pResult);
//
// void onError(Exception e);
//
// }
//
// public interface IJob<Result> {
//
// Result doJob() throws Exception;
//
// }
//
// public <Result> void execute(final IJob<Result> pJob, final IExecutionListener<Result> pExecutionListener) {
// pExecutionListener.onJobStarted();
// final Handler handler = new Handler();
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// final Result result = pJob.doJob();
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onDone(result);
// }
// });
// } catch (final Exception e) {
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onError(e);
// }
// });
// }
// }
// }).start();
// }
//
// }
// Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
import android.app.Application;
import android.content.Context;
import com.github.istin.schedule.manager.ConfigurationManager;
import com.github.istin.schedule.manager.ThreadManager;
package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/5/15.
*/
public class CoreApplication extends Application {
private ConfigurationManager mConfigurationManager;
| private ThreadManager mThreadManager; |
IstiN/schedule | backend/src/main/java/com/github/istin/schedule/backend/servlet/ScheduleList.java | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: backend/src/main/java/com/github/istin/schedule/backend/adapter/grsu/domain/LessonModel.java
// public class LessonModel {
//
// private String id;
//
// private String date;
//
// private String timeStart;
//
// private String timeEnd;
//
// private String title;
//
// private String address;
//
// private String room;
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public Lesson doOptimize() {
// final Lesson optimized = new Lesson();
// optimized.setId(this.id);
// optimized.setTimeEnd(this.timeEnd);
// optimized.setTimeStart(this.timeStart);
// optimized.setTitle(this.title);
// optimized.setAddress(this.address);
// optimized.setDate(this.date);
// optimized.setRoom(this.room);
// return optimized;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
| import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.backend.adapter.grsu.domain.LessonModel;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.Lesson;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; | /*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class ScheduleList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String uid = req.getParameter("uid");
final String lid = req.getParameter("lid"); | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: backend/src/main/java/com/github/istin/schedule/backend/adapter/grsu/domain/LessonModel.java
// public class LessonModel {
//
// private String id;
//
// private String date;
//
// private String timeStart;
//
// private String timeEnd;
//
// private String title;
//
// private String address;
//
// private String room;
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public Lesson doOptimize() {
// final Lesson optimized = new Lesson();
// optimized.setId(this.id);
// optimized.setTimeEnd(this.timeEnd);
// optimized.setTimeStart(this.timeStart);
// optimized.setTitle(this.title);
// optimized.setAddress(this.address);
// optimized.setDate(this.date);
// optimized.setRoom(this.room);
// return optimized;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
// Path: backend/src/main/java/com/github/istin/schedule/backend/servlet/ScheduleList.java
import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.backend.adapter.grsu.domain.LessonModel;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.Lesson;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class ScheduleList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String uid = req.getParameter("uid");
final String lid = req.getParameter("lid"); | final University university = University.values()[Integer.valueOf(uid)]; |
IstiN/schedule | backend/src/main/java/com/github/istin/schedule/backend/servlet/ScheduleList.java | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: backend/src/main/java/com/github/istin/schedule/backend/adapter/grsu/domain/LessonModel.java
// public class LessonModel {
//
// private String id;
//
// private String date;
//
// private String timeStart;
//
// private String timeEnd;
//
// private String title;
//
// private String address;
//
// private String room;
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public Lesson doOptimize() {
// final Lesson optimized = new Lesson();
// optimized.setId(this.id);
// optimized.setTimeEnd(this.timeEnd);
// optimized.setTimeStart(this.timeStart);
// optimized.setTitle(this.title);
// optimized.setAddress(this.address);
// optimized.setDate(this.date);
// optimized.setRoom(this.room);
// return optimized;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
| import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.backend.adapter.grsu.domain.LessonModel;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.Lesson;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; | /*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class ScheduleList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String uid = req.getParameter("uid");
final String lid = req.getParameter("lid");
final University university = University.values()[Integer.valueOf(uid)]; | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: backend/src/main/java/com/github/istin/schedule/backend/adapter/grsu/domain/LessonModel.java
// public class LessonModel {
//
// private String id;
//
// private String date;
//
// private String timeStart;
//
// private String timeEnd;
//
// private String title;
//
// private String address;
//
// private String room;
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public Lesson doOptimize() {
// final Lesson optimized = new Lesson();
// optimized.setId(this.id);
// optimized.setTimeEnd(this.timeEnd);
// optimized.setTimeStart(this.timeStart);
// optimized.setTitle(this.title);
// optimized.setAddress(this.address);
// optimized.setDate(this.date);
// optimized.setRoom(this.room);
// return optimized;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
// Path: backend/src/main/java/com/github/istin/schedule/backend/servlet/ScheduleList.java
import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.backend.adapter.grsu.domain.LessonModel;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.Lesson;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class ScheduleList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String uid = req.getParameter("uid");
final String lid = req.getParameter("lid");
final University university = University.values()[Integer.valueOf(uid)]; | List<Lesson> lessonModelList = null; |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/SelectLecturerActivity.java | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
| import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.github.istin.schedule.manager.ConfigurationManager; | package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public class SelectLecturerActivity extends CommonHttpJobActivity<Lecturer[]> {
public static final String EXTRA_ITEM = "item";
@Override
protected int getContentViewLayout() {
return R.layout.activity_select;
}
@Override
protected Class<Lecturer[]> getResultClass() {
return Lecturer[].class;
}
@Override
protected String getUrl() { | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
// Path: app/src/main/java/com/github/istin/schedule/SelectLecturerActivity.java
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.github.istin.schedule.manager.ConfigurationManager;
package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public class SelectLecturerActivity extends CommonHttpJobActivity<Lecturer[]> {
public static final String EXTRA_ITEM = "item";
@Override
protected int getContentViewLayout() {
return R.layout.activity_select;
}
@Override
protected Class<Lecturer[]> getResultClass() {
return Lecturer[].class;
}
@Override
protected String getUrl() { | final University university = (University) getIntent().getSerializableExtra(EXTRA_ITEM); |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/SelectLecturerActivity.java | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
| import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.github.istin.schedule.manager.ConfigurationManager; | package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public class SelectLecturerActivity extends CommonHttpJobActivity<Lecturer[]> {
public static final String EXTRA_ITEM = "item";
@Override
protected int getContentViewLayout() {
return R.layout.activity_select;
}
@Override
protected Class<Lecturer[]> getResultClass() {
return Lecturer[].class;
}
@Override
protected String getUrl() {
final University university = (University) getIntent().getSerializableExtra(EXTRA_ITEM);
return Api.LECTURER_LIST + university.getId();
}
@Override
protected void applyResult(Lecturer[] pLecturers) {
ListView listView = (ListView) findViewById(android.R.id.list);
final ArrayAdapter<Lecturer> adapter = new ArrayAdapter<>(SelectLecturerActivity.this, android.R.layout.simple_list_item_1, pLecturers);
listView.setAdapter(adapter);
initFilter(adapter, R.string.search_lecturer_hint);
if (BuildConfig.DEBUG) {
((EditText) findViewById(R.id.search_edit_text)).setText("клышевич");
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final Lecturer lecturer = (Lecturer) parent.getAdapter().getItem(position); | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
// Path: app/src/main/java/com/github/istin/schedule/SelectLecturerActivity.java
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.github.istin.schedule.manager.ConfigurationManager;
package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public class SelectLecturerActivity extends CommonHttpJobActivity<Lecturer[]> {
public static final String EXTRA_ITEM = "item";
@Override
protected int getContentViewLayout() {
return R.layout.activity_select;
}
@Override
protected Class<Lecturer[]> getResultClass() {
return Lecturer[].class;
}
@Override
protected String getUrl() {
final University university = (University) getIntent().getSerializableExtra(EXTRA_ITEM);
return Api.LECTURER_LIST + university.getId();
}
@Override
protected void applyResult(Lecturer[] pLecturers) {
ListView listView = (ListView) findViewById(android.R.id.list);
final ArrayAdapter<Lecturer> adapter = new ArrayAdapter<>(SelectLecturerActivity.this, android.R.layout.simple_list_item_1, pLecturers);
listView.setAdapter(adapter);
initFilter(adapter, R.string.search_lecturer_hint);
if (BuildConfig.DEBUG) {
((EditText) findViewById(R.id.search_edit_text)).setText("клышевич");
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final Lecturer lecturer = (Lecturer) parent.getAdapter().getItem(position); | ConfigurationManager.Config config = new ConfigurationManager.Config((University) getIntent().getSerializableExtra(EXTRA_ITEM), lecturer); |
IstiN/schedule | backend/src/main/java/com/github/istin/schedule/backend/servlet/LecturerList.java | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
| import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.gson.Lecturer;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; | /*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class LecturerList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String id = req.getParameter("id"); | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
// Path: backend/src/main/java/com/github/istin/schedule/backend/servlet/LecturerList.java
import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.gson.Lecturer;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class LecturerList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String id = req.getParameter("id"); | final University university = University.values()[Integer.valueOf(id)]; |
IstiN/schedule | backend/src/main/java/com/github/istin/schedule/backend/servlet/LecturerList.java | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
| import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.gson.Lecturer;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; | /*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class LecturerList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String id = req.getParameter("id");
final University university = University.values()[Integer.valueOf(id)]; | // Path: backend/src/main/java/com/github/istin/schedule/backend/University.java
// public enum University {
//
// GRSU("ГрГУ", new GrsuAdapter()),
// GR_MED_UNIVER("Гродненский Мед. университет", new GrsuAdapter());
//
// private String mName;
//
// private IUniversityAdapter mUniversityAdapter;
//
// University(String pName, IUniversityAdapter pUniversityAdapter) {
// mName = pName;
// mUniversityAdapter = pUniversityAdapter;
// }
//
// public String getName() {
// return mName;
// }
//
// public IUniversityAdapter getUniversityAdapter() {
// return mUniversityAdapter;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
// Path: backend/src/main/java/com/github/istin/schedule/backend/servlet/LecturerList.java
import com.github.istin.schedule.backend.University;
import com.github.istin.schedule.gson.Lecturer;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.github.istin.schedule.backend.servlet;
public class LecturerList extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("UTF-8");
final String id = req.getParameter("id");
final University university = University.values()[Integer.valueOf(id)]; | List<Lecturer> lecturerList = null; |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/StartActivity.java | // Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
| import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.github.istin.schedule.manager.ConfigurationManager; | package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public class StartActivity extends Activity {
private static final String CONFIG_STATE = "config_state";
private boolean isConfigurationProcessStarted = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
isConfigurationProcessStarted = savedInstanceState.getBoolean(CONFIG_STATE);
if (isConfigurationProcessStarted) {
return;
}
}
checkAndRedirect();
}
private void checkAndRedirect() { | // Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
// Path: app/src/main/java/com/github/istin/schedule/StartActivity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.github.istin.schedule.manager.ConfigurationManager;
package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public class StartActivity extends Activity {
private static final String CONFIG_STATE = "config_state";
private boolean isConfigurationProcessStarted = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
isConfigurationProcessStarted = savedInstanceState.getBoolean(CONFIG_STATE);
if (isConfigurationProcessStarted) {
return;
}
}
checkAndRedirect();
}
private void checkAndRedirect() { | if (ConfigurationManager.get(this).isConfigured()) { |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/MainActivity.java | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
| import android.content.Intent;
import android.provider.CalendarContract;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.github.istin.schedule.gson.Lesson;
import com.github.istin.schedule.manager.ConfigurationManager;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; | package com.github.istin.schedule;
public class MainActivity extends CommonHttpJobActivity<Lesson[]> {
@Override
protected int getContentViewLayout() {
return R.layout.activity_main;
}
@Override
protected Class<Lesson[]> getResultClass() {
return Lesson[].class;
}
@Override
protected String getUrl() { | // Path: domain/src/main/java/com/github/istin/schedule/gson/Lesson.java
// public class Lesson implements Serializable {
// @SerializedName("i")
// private String id;
//
// @SerializedName("s")
// private String timeStart;
//
// @SerializedName("e")
// private String timeEnd;
//
// @SerializedName("d")
// private String date;
//
// @SerializedName("t")
// private String title;
//
// @SerializedName("a")
// private String address;
//
// @SerializedName("r")
// private String room;
//
// public String getId() {
// return id;
// }
//
// public void setId(String pId) {
// id = pId;
// }
//
// public String getTimeStart() {
// return timeStart;
// }
//
// public void setTimeStart(String pTimeStart) {
// timeStart = pTimeStart;
// }
//
// public String getTimeEnd() {
// return timeEnd;
// }
//
// public void setTimeEnd(String pTimeEnd) {
// timeEnd = pTimeEnd;
// }
//
// public String getDate() {
// return date;
// }
//
// public void setDate(String pDate) {
// date = pDate;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String pTitle) {
// title = pTitle;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String pAddress) {
// address = pAddress;
// }
//
// public String getRoom() {
// return room;
// }
//
// public void setRoom(String pRoom) {
// room = pRoom;
// }
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
// public class ConfigurationManager {
//
// public static final String KEY_CONFIG = "_config";
//
// public static final String APP_SERVICE_KEY = "config:manager";
//
// public static ConfigurationManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public boolean isConfigured() {
// return getConfig() != null;
// }
//
// public static class Config implements Serializable {
//
// @SerializedName("l")
// private Lecturer mLecturer;
//
// @SerializedName("u")
// private University mUniversity;
//
// public Config(University pUniversity, Lecturer pLecturer) {
// mLecturer = pLecturer;
// mUniversity = pUniversity;
// }
//
// public Lecturer getLecturer() {
// return mLecturer;
// }
//
// public University getUniversity() {
// return mUniversity;
// }
//
// }
//
// private Config mConfig;
//
// private Context mContext;
//
// private Object mLock = new Object();
//
// private boolean isInited = false;
//
// public ConfigurationManager(Context pContext) {
// mContext = pContext;
// new Thread(new Runnable() {
// @Override
// public void run() {
// if (isInited) {
// return;
// }
// firstInitialization();
// }
// }).start();
// }
//
// protected void firstInitialization() {
// synchronized (mLock) {
// if (isInited) {
// return;
// }
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = defaultSharedPreferences.getString(KEY_CONFIG, null);
// if (value != null) {
// mConfig = new Gson().fromJson(value, Config.class);
// }
// isInited = true;
// }
// }
//
// public void setConfig(Config pConfig) {
// mConfig = pConfig;
// final SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
// final String value = new Gson().toJson(mConfig, Config.class);
// defaultSharedPreferences.edit().putString(KEY_CONFIG, value).apply();
// }
//
// public Config getConfig() {
// if (isInited) {
// return mConfig;
// }
// firstInitialization();
// return mConfig;
// }
// }
// Path: app/src/main/java/com/github/istin/schedule/MainActivity.java
import android.content.Intent;
import android.provider.CalendarContract;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.github.istin.schedule.gson.Lesson;
import com.github.istin.schedule.manager.ConfigurationManager;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
package com.github.istin.schedule;
public class MainActivity extends CommonHttpJobActivity<Lesson[]> {
@Override
protected int getContentViewLayout() {
return R.layout.activity_main;
}
@Override
protected Class<Lesson[]> getResultClass() {
return Lesson[].class;
}
@Override
protected String getUrl() { | final ConfigurationManager.Config config = ConfigurationManager.get(this).getConfig(); |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.github.istin.schedule.CoreApplication;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable; | package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 11/20/15.
*/
public class ConfigurationManager {
public static final String KEY_CONFIG = "_config";
public static final String APP_SERVICE_KEY = "config:manager";
public static ConfigurationManager get(Context pContext) { | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.github.istin.schedule.CoreApplication;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 11/20/15.
*/
public class ConfigurationManager {
public static final String KEY_CONFIG = "_config";
public static final String APP_SERVICE_KEY = "config:manager";
public static ConfigurationManager get(Context pContext) { | return CoreApplication.get(pContext, APP_SERVICE_KEY); |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.github.istin.schedule.CoreApplication;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable; | package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 11/20/15.
*/
public class ConfigurationManager {
public static final String KEY_CONFIG = "_config";
public static final String APP_SERVICE_KEY = "config:manager";
public static ConfigurationManager get(Context pContext) {
return CoreApplication.get(pContext, APP_SERVICE_KEY);
}
public boolean isConfigured() {
return getConfig() != null;
}
public static class Config implements Serializable {
@SerializedName("l") | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.github.istin.schedule.CoreApplication;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 11/20/15.
*/
public class ConfigurationManager {
public static final String KEY_CONFIG = "_config";
public static final String APP_SERVICE_KEY = "config:manager";
public static ConfigurationManager get(Context pContext) {
return CoreApplication.get(pContext, APP_SERVICE_KEY);
}
public boolean isConfigured() {
return getConfig() != null;
}
public static class Config implements Serializable {
@SerializedName("l") | private Lecturer mLecturer; |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.github.istin.schedule.CoreApplication;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable; | package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 11/20/15.
*/
public class ConfigurationManager {
public static final String KEY_CONFIG = "_config";
public static final String APP_SERVICE_KEY = "config:manager";
public static ConfigurationManager get(Context pContext) {
return CoreApplication.get(pContext, APP_SERVICE_KEY);
}
public boolean isConfigured() {
return getConfig() != null;
}
public static class Config implements Serializable {
@SerializedName("l")
private Lecturer mLecturer;
@SerializedName("u") | // Path: app/src/main/java/com/github/istin/schedule/CoreApplication.java
// public class CoreApplication extends Application {
//
// private ConfigurationManager mConfigurationManager;
//
// private ThreadManager mThreadManager;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mConfigurationManager = new ConfigurationManager(this);
// mThreadManager = new ThreadManager();
// }
//
// @Override
// public Object getSystemService(String name) {
// if (ConfigurationManager.APP_SERVICE_KEY.equals(name)) {
// return mConfigurationManager;
// }
// if (ThreadManager.APP_SERVICE_KEY.equals(name)) {
// return mThreadManager;
// }
// return super.getSystemService(name);
// }
//
// public static <T> T get(Context context, String name) {
// if (context == null || name == null) {
// throw new IllegalArgumentException("Context and key must not be null");
// }
// T systemService = (T) context.getSystemService(name);
// if (systemService == null) {
// context = context.getApplicationContext();
// systemService = (T) context.getSystemService(name);
// }
// if (systemService == null) {
// throw new IllegalStateException(name + " not available");
// }
// return systemService;
// }
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/Lecturer.java
// public class Lecturer extends BaseModel {
//
// }
//
// Path: domain/src/main/java/com/github/istin/schedule/gson/University.java
// public class University extends BaseModel {
//
// }
// Path: app/src/main/java/com/github/istin/schedule/manager/ConfigurationManager.java
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.github.istin.schedule.CoreApplication;
import com.github.istin.schedule.gson.Lecturer;
import com.github.istin.schedule.gson.University;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
package com.github.istin.schedule.manager;
/**
* Created by uladzimir_klyshevich on 11/20/15.
*/
public class ConfigurationManager {
public static final String KEY_CONFIG = "_config";
public static final String APP_SERVICE_KEY = "config:manager";
public static ConfigurationManager get(Context pContext) {
return CoreApplication.get(pContext, APP_SERVICE_KEY);
}
public boolean isConfigured() {
return getConfig() != null;
}
public static class Config implements Serializable {
@SerializedName("l")
private Lecturer mLecturer;
@SerializedName("u") | private University mUniversity; |
IstiN/schedule | app/src/main/java/com/github/istin/schedule/CommonHttpJobActivity.java | // Path: app/src/main/java/com/github/istin/schedule/http/HttpJob.java
// public class HttpJob<Result> implements ThreadManager.IJob<Result> {
//
// private String mUrl;
//
// private Class<Result> mResultClass;
//
// public HttpJob(String pUrl, Class<Result> pResultClass) {
// mUrl = pUrl;
// mResultClass = pResultClass;
// }
//
// @Override
// public Result doJob() throws Exception {
// InputStream inputStream = null;
// InputStreamReader inputStreamReader = null;
// BufferedReader bufferedReader = null;
// try {
// inputStream = HttpUtils.getInputStream(mUrl);
// inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
// bufferedReader = new BufferedReader(inputStreamReader, 8192);
// //return new Gson().fromJson(bufferedReader, returnedClass());
// return new Gson().fromJson(bufferedReader, mResultClass);
// } finally {
// HttpUtils.close(inputStream);
// HttpUtils.close(inputStreamReader);
// HttpUtils.close(bufferedReader);
// }
// }
//
// public Class<Result> returnedClass() {
// ParameterizedType parameterizedType = (ParameterizedType)getClass().getGenericSuperclass();
// return (Class<Result>) parameterizedType.getActualTypeArguments()[0];
// }
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java
// public class ThreadManager {
//
// public static final String APP_SERVICE_KEY = "thread:manager";
//
// public static ThreadManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public interface IExecutionListener<Result> {
//
// void onJobStarted();
//
// void onDone(Result pResult);
//
// void onError(Exception e);
//
// }
//
// public interface IJob<Result> {
//
// Result doJob() throws Exception;
//
// }
//
// public <Result> void execute(final IJob<Result> pJob, final IExecutionListener<Result> pExecutionListener) {
// pExecutionListener.onJobStarted();
// final Handler handler = new Handler();
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// final Result result = pJob.doJob();
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onDone(result);
// }
// });
// } catch (final Exception e) {
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onError(e);
// }
// });
// }
// }
// }).start();
// }
//
// }
| import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import com.github.istin.schedule.http.HttpJob;
import com.github.istin.schedule.manager.ThreadManager; | package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public abstract class CommonHttpJobActivity<Result> extends AppCompatActivity implements ThreadManager.IExecutionListener<Result> {
private EditText mSearchEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentViewLayout());
mSearchEditText = (EditText) findViewById(R.id.search_edit_text);
execute();
}
private void execute() { | // Path: app/src/main/java/com/github/istin/schedule/http/HttpJob.java
// public class HttpJob<Result> implements ThreadManager.IJob<Result> {
//
// private String mUrl;
//
// private Class<Result> mResultClass;
//
// public HttpJob(String pUrl, Class<Result> pResultClass) {
// mUrl = pUrl;
// mResultClass = pResultClass;
// }
//
// @Override
// public Result doJob() throws Exception {
// InputStream inputStream = null;
// InputStreamReader inputStreamReader = null;
// BufferedReader bufferedReader = null;
// try {
// inputStream = HttpUtils.getInputStream(mUrl);
// inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
// bufferedReader = new BufferedReader(inputStreamReader, 8192);
// //return new Gson().fromJson(bufferedReader, returnedClass());
// return new Gson().fromJson(bufferedReader, mResultClass);
// } finally {
// HttpUtils.close(inputStream);
// HttpUtils.close(inputStreamReader);
// HttpUtils.close(bufferedReader);
// }
// }
//
// public Class<Result> returnedClass() {
// ParameterizedType parameterizedType = (ParameterizedType)getClass().getGenericSuperclass();
// return (Class<Result>) parameterizedType.getActualTypeArguments()[0];
// }
// }
//
// Path: app/src/main/java/com/github/istin/schedule/manager/ThreadManager.java
// public class ThreadManager {
//
// public static final String APP_SERVICE_KEY = "thread:manager";
//
// public static ThreadManager get(Context pContext) {
// return CoreApplication.get(pContext, APP_SERVICE_KEY);
// }
//
// public interface IExecutionListener<Result> {
//
// void onJobStarted();
//
// void onDone(Result pResult);
//
// void onError(Exception e);
//
// }
//
// public interface IJob<Result> {
//
// Result doJob() throws Exception;
//
// }
//
// public <Result> void execute(final IJob<Result> pJob, final IExecutionListener<Result> pExecutionListener) {
// pExecutionListener.onJobStarted();
// final Handler handler = new Handler();
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// final Result result = pJob.doJob();
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onDone(result);
// }
// });
// } catch (final Exception e) {
// handler.post(new Runnable() {
// @Override
// public void run() {
// pExecutionListener.onError(e);
// }
// });
// }
// }
// }).start();
// }
//
// }
// Path: app/src/main/java/com/github/istin/schedule/CommonHttpJobActivity.java
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import com.github.istin.schedule.http.HttpJob;
import com.github.istin.schedule.manager.ThreadManager;
package com.github.istin.schedule;
/**
* Created by uladzimir_klyshevich on 10/6/15.
*/
public abstract class CommonHttpJobActivity<Result> extends AppCompatActivity implements ThreadManager.IExecutionListener<Result> {
private EditText mSearchEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentViewLayout());
mSearchEditText = (EditText) findViewById(R.id.search_edit_text);
execute();
}
private void execute() { | ThreadManager.get(this).execute(new HttpJob<>(getUrl(), getResultClass()), this); |
Stratio/crossdata | testsAT/src/test/java/com/stratio/tests/ATCreateExternalTable.java | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
| import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions; | /*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
@CucumberOptions(features = {
"src/test/resources/features/Catalog/CreateCassandraExternalTables.feature",
"src/test/resources/features/Catalog/CreateMongoDBExternalTables.feature"
}) | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
// Path: testsAT/src/test/java/com/stratio/tests/ATCreateExternalTable.java
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions;
/*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
@CucumberOptions(features = {
"src/test/resources/features/Catalog/CreateCassandraExternalTables.feature",
"src/test/resources/features/Catalog/CreateMongoDBExternalTables.feature"
}) | public class ATCreateExternalTable extends BaseTest { |
Stratio/crossdata | testsAT/src/test/java/com/stratio/tests/ATPostgreSqlXDTest.java | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
| import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.CassandraUtils;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.TimeZone; | /*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
//Indicar feature
@CucumberOptions(features = {
"src/test/resources/features/PostgreSQL/PostgresqlNotBetweenFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlBetweenFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlLimit.feature",
"src/test/resources/features/PostgreSQL/PostgresqlInFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlLessFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlLessEqualFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlGreaterFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlGreaterEqualsFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlSelectAndOrFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlSelectSimple.feature",
"src/test/resources/features/PostgreSQL/PostgresqlSelectEqualsFilter.feature"
}) | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
// Path: testsAT/src/test/java/com/stratio/tests/ATPostgreSqlXDTest.java
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.CassandraUtils;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.TimeZone;
/*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
//Indicar feature
@CucumberOptions(features = {
"src/test/resources/features/PostgreSQL/PostgresqlNotBetweenFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlBetweenFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlLimit.feature",
"src/test/resources/features/PostgreSQL/PostgresqlInFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlLessFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlLessEqualFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlGreaterFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlGreaterEqualsFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlSelectAndOrFilter.feature",
"src/test/resources/features/PostgreSQL/PostgresqlSelectSimple.feature",
"src/test/resources/features/PostgreSQL/PostgresqlSelectEqualsFilter.feature"
}) | public class ATPostgreSqlXDTest extends BaseTest { |
Stratio/crossdata | testsAT/src/test/java/com/stratio/tests/ATCassandraXDTest.java | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
| import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.exceptions.DBException;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.CassandraUtils;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions; | /*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
//Indicar feature
@CucumberOptions(features = {
"src/test/resources/features/Cassandra/CassandraSelectSimple.feature",
"src/test/resources/features/Cassandra/CassandraSelectLimit.feature",
"src/test/resources/features/Cassandra/CassandraSelectEqualsFilter.feature",
"src/test/resources/features/Cassandra/CassandraSelectUDF.feature",
"src/test/resources/features/Cassandra/CassandraPureNativeAggregation.feature",
"src/test/resources/features/Udaf/Group_concat.feature",
"src/test/resources/features/Views/TemporaryViews.feature",
"src/test/resources/features/Views/Views.feature",
"src/test/resources/features/Views/DropViews.feature",
"src/test/resources/features/Catalog/DropPersistedTables.feature",
"src/test/resources/features/Cassandra/CassandraInsertInto.feature"
}) | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
// Path: testsAT/src/test/java/com/stratio/tests/ATCassandraXDTest.java
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.exceptions.DBException;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.CassandraUtils;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions;
/*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
//Indicar feature
@CucumberOptions(features = {
"src/test/resources/features/Cassandra/CassandraSelectSimple.feature",
"src/test/resources/features/Cassandra/CassandraSelectLimit.feature",
"src/test/resources/features/Cassandra/CassandraSelectEqualsFilter.feature",
"src/test/resources/features/Cassandra/CassandraSelectUDF.feature",
"src/test/resources/features/Cassandra/CassandraPureNativeAggregation.feature",
"src/test/resources/features/Udaf/Group_concat.feature",
"src/test/resources/features/Views/TemporaryViews.feature",
"src/test/resources/features/Views/Views.feature",
"src/test/resources/features/Views/DropViews.feature",
"src/test/resources/features/Catalog/DropPersistedTables.feature",
"src/test/resources/features/Cassandra/CassandraInsertInto.feature"
}) | public class ATCassandraXDTest extends BaseTest { |
Stratio/crossdata | testsAT/src/test/java/com/stratio/tests/ATElasticSearchXDJavaDriverTest.java | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
| import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions; | /*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
//Indicar feature
@CucumberOptions(features = {
"src/test/resources/features/Elasticsearch/ElasticSearchSelectSimple.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchelectAnd.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectINFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectEqualsFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectGreaterFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectGreaterEqualsFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectLessFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectLessEqualsFilter.feature",
"src/test/resources/features/Udaf/Group_concat.feature",
"src/test/resources/features/Elasticsearch/TemporaryViews.feature",
"src/test/resources/features/Elasticsearch/Views.feature"
}) | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
// Path: testsAT/src/test/java/com/stratio/tests/ATElasticSearchXDJavaDriverTest.java
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.ThreadProperty;
import cucumber.api.CucumberOptions;
/*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
//Indicar feature
@CucumberOptions(features = {
"src/test/resources/features/Elasticsearch/ElasticSearchSelectSimple.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchelectAnd.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectINFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectEqualsFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectGreaterFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectGreaterEqualsFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectLessFilter.feature",
"src/test/resources/features/Elasticsearch/ElasticSearchSelectLessEqualsFilter.feature",
"src/test/resources/features/Udaf/Group_concat.feature",
"src/test/resources/features/Elasticsearch/TemporaryViews.feature",
"src/test/resources/features/Elasticsearch/Views.feature"
}) | public class ATElasticSearchXDJavaDriverTest extends BaseTest { |
Stratio/crossdata | testsAT/src/test/java/com/stratio/tests/ATPersistentCatalogXDTest.java | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
| import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.TimeZone;
import java.util.Date;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.mongodb.BasicDBObjectBuilder;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.CassandraUtils;
import com.stratio.qa.utils.ThreadProperty;
import java.text.ParseException;
import cucumber.api.CucumberOptions; | /*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
@CucumberOptions(features = { "src/test/resources/features/Catalog/PersistentCatalogMySQL.feature",
"src/test/resources/features/Catalog/PersistentCatalogMySQLDropTable.feature",
"src/test/resources/features/Catalog/PersistentCatalogMySQLImportTables.feature",
"src/test/resources/features/Catalog/PersistentCatalogMySQLImportTablesUsingApi.feature"
}) | // Path: testsAT/src/test/java/com/stratio/qa/utils/BaseTest.java
// abstract public class BaseTest extends BaseGTest {
//
// protected String browser = "";
//
// @BeforeSuite(alwaysRun = true)
// public void beforeSuite(ITestContext context) {
// }
//
// @AfterSuite(alwaysRun = true)
// public void afterSuite(ITestContext context) {
// }
//
// @BeforeClass(alwaysRun = true)
// public void beforeClass(ITestContext context) {
// }
//
// @BeforeMethod(alwaysRun = true)
// public void beforeMethod(Method method) {
// ThreadProperty.set("browser", this.browser);
// }
//
// @AfterMethod(alwaysRun = true)
// public void afterMethod(Method method) {
// }
//
// @AfterClass()
// public void afterClass() {
// }
// }
// Path: testsAT/src/test/java/com/stratio/tests/ATPersistentCatalogXDTest.java
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.TimeZone;
import java.util.Date;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.mongodb.BasicDBObjectBuilder;
import com.stratio.qa.cucumber.testng.CucumberRunner;
import com.stratio.qa.utils.BaseTest;
import com.stratio.qa.utils.CassandraUtils;
import com.stratio.qa.utils.ThreadProperty;
import java.text.ParseException;
import cucumber.api.CucumberOptions;
/*
* Copyright (C) 2015 Stratio (http://stratio.com)
*
* 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.stratio.tests;
@CucumberOptions(features = { "src/test/resources/features/Catalog/PersistentCatalogMySQL.feature",
"src/test/resources/features/Catalog/PersistentCatalogMySQLDropTable.feature",
"src/test/resources/features/Catalog/PersistentCatalogMySQLImportTables.feature",
"src/test/resources/features/Catalog/PersistentCatalogMySQLImportTablesUsingApi.feature"
}) | public class ATPersistentCatalogXDTest extends BaseTest { |
sopeco/DynamicSpotter | org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/providers/ResultExtensionsImageProvider.java | // Path: org.spotter.shared/src/org/spotter/shared/hierarchy/model/XPerformanceProblem.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "PerformanceProblem", propOrder = { "extensionName", "uniqueId", "config", "problem" })
// @XmlRootElement(name = "root")
// public class XPerformanceProblem implements Serializable {
//
// private static final long serialVersionUID = -3934559836199225205L;
//
// @XmlElement(name = "extensionName", required = false)
// private String extensionName;
//
// /**
// * The unique id is always required and is used to identify
// * problem instances.
// */
// @XmlElement(name = "uniqueId", required = true)
// private String uniqueId;
//
// /**
// * The configuration is always required. At least, the property
// * if this node is detectable must be set.
// */
// @XmlElement(name = "config", required = true)
// private List<XMConfiguration> config;
//
// /**
// * A sub node for a problem is not required, as
// * a {@link XPerformanceProblem} can be a root-cause. A
// * root-cause of a performance problem does not contain
// * more problems.
// */
// @XmlElement(name = "problem", required = false)
// private List<XPerformanceProblem> problem;
//
// /**
// * @return the extensionName
// */
// public String getExtensionName() {
// return extensionName;
// }
//
// /**
// * @param extensionName the extensionName to set
// */
// public void setExtensionName(String extensionName) {
// this.extensionName = extensionName;
// }
//
// /**
// * @return the uniqueId
// */
// public String getUniqueId() {
// return uniqueId;
// }
//
// /**
// * @param uniqueId the uniqueId to set
// */
// public void setUniqueId(String uniqueId) {
// this.uniqueId = uniqueId;
// }
//
// /**
// * @return the config
// */
// public List<XMConfiguration> getConfig() {
// return config;
// }
//
// /**
// * @param config the config to set
// */
// public void setConfig(List<XMConfiguration> config) {
// this.config = config;
// }
//
// /**
// * @return the problem
// */
// public List<XPerformanceProblem> getProblem() {
// return problem;
// }
//
// /**
// * @param problem the problem to set
// */
// public void setProblem(List<XPerformanceProblem> problem) {
// this.problem = problem;
// }
//
// }
| import org.eclipse.swt.graphics.Image;
import org.spotter.eclipse.ui.Activator;
import org.spotter.eclipse.ui.model.IExtensionItem;
import org.spotter.shared.hierarchy.model.XPerformanceProblem;
import org.spotter.shared.result.model.ResultsContainer;
import org.spotter.shared.result.model.SpotterResult; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.providers;
/**
* An image provider for extension items displayed in the results view.
*
* @author Denis Knoepfle
*
*/
public class ResultExtensionsImageProvider extends SpotterExtensionsImageProvider {
private static final Image IMG_NO_LOOKUP = Activator.getImage("icons/exclamation.png");
private static final Image IMG_DETECTED = Activator.getImage("icons/flag-red.png");
private static final Image IMG_NOT_DETECTED = Activator.getImage("icons/flag-green.png");
private ResultsContainer resultsContainer;
/**
* Set the results container.
*
* @param resultsContainer
* The results container to set
*/
public void setResultsContainer(ResultsContainer resultsContainer) {
this.resultsContainer = resultsContainer;
}
@Override
public Image getImage(IExtensionItem item) {
Object xmlModel = item.getModelWrapper().getXMLModel(); | // Path: org.spotter.shared/src/org/spotter/shared/hierarchy/model/XPerformanceProblem.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "PerformanceProblem", propOrder = { "extensionName", "uniqueId", "config", "problem" })
// @XmlRootElement(name = "root")
// public class XPerformanceProblem implements Serializable {
//
// private static final long serialVersionUID = -3934559836199225205L;
//
// @XmlElement(name = "extensionName", required = false)
// private String extensionName;
//
// /**
// * The unique id is always required and is used to identify
// * problem instances.
// */
// @XmlElement(name = "uniqueId", required = true)
// private String uniqueId;
//
// /**
// * The configuration is always required. At least, the property
// * if this node is detectable must be set.
// */
// @XmlElement(name = "config", required = true)
// private List<XMConfiguration> config;
//
// /**
// * A sub node for a problem is not required, as
// * a {@link XPerformanceProblem} can be a root-cause. A
// * root-cause of a performance problem does not contain
// * more problems.
// */
// @XmlElement(name = "problem", required = false)
// private List<XPerformanceProblem> problem;
//
// /**
// * @return the extensionName
// */
// public String getExtensionName() {
// return extensionName;
// }
//
// /**
// * @param extensionName the extensionName to set
// */
// public void setExtensionName(String extensionName) {
// this.extensionName = extensionName;
// }
//
// /**
// * @return the uniqueId
// */
// public String getUniqueId() {
// return uniqueId;
// }
//
// /**
// * @param uniqueId the uniqueId to set
// */
// public void setUniqueId(String uniqueId) {
// this.uniqueId = uniqueId;
// }
//
// /**
// * @return the config
// */
// public List<XMConfiguration> getConfig() {
// return config;
// }
//
// /**
// * @param config the config to set
// */
// public void setConfig(List<XMConfiguration> config) {
// this.config = config;
// }
//
// /**
// * @return the problem
// */
// public List<XPerformanceProblem> getProblem() {
// return problem;
// }
//
// /**
// * @param problem the problem to set
// */
// public void setProblem(List<XPerformanceProblem> problem) {
// this.problem = problem;
// }
//
// }
// Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/providers/ResultExtensionsImageProvider.java
import org.eclipse.swt.graphics.Image;
import org.spotter.eclipse.ui.Activator;
import org.spotter.eclipse.ui.model.IExtensionItem;
import org.spotter.shared.hierarchy.model.XPerformanceProblem;
import org.spotter.shared.result.model.ResultsContainer;
import org.spotter.shared.result.model.SpotterResult;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.providers;
/**
* An image provider for extension items displayed in the results view.
*
* @author Denis Knoepfle
*
*/
public class ResultExtensionsImageProvider extends SpotterExtensionsImageProvider {
private static final Image IMG_NO_LOOKUP = Activator.getImage("icons/exclamation.png");
private static final Image IMG_DETECTED = Activator.getImage("icons/flag-red.png");
private static final Image IMG_NOT_DETECTED = Activator.getImage("icons/flag-green.png");
private ResultsContainer resultsContainer;
/**
* Set the results container.
*
* @param resultsContainer
* The results container to set
*/
public void setResultsContainer(ResultsContainer resultsContainer) {
this.resultsContainer = resultsContainer;
}
@Override
public Image getImage(IExtensionItem item) {
Object xmlModel = item.getModelWrapper().getXMLModel(); | if (resultsContainer == null || !(xmlModel instanceof XPerformanceProblem)) { |
sopeco/DynamicSpotter | org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/navigator/SpotterProjectHierarchy.java | // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/handlers/OpenHandler.java
// public class OpenHandler extends AbstractHandler {
//
// /**
// * The id of the open command.
// */
// public static final String OPEN_COMMAND_ID = "org.spotter.eclipse.ui.commands.open";
//
// @Override
// public Object execute(ExecutionEvent event) throws ExecutionException {
// Iterator<?> iter = SpotterUtils.getActiveWindowStructuredSelectionIterator();
// if (iter == null) {
// return null;
// }
//
// while (iter.hasNext()) {
// SpotterUtils.openElement(iter.next());
// }
//
// return null;
// }
//
// /**
// * Returns <code>true</code> if only elements are selected that are
// * openable.
// *
// * @return <code>true</code> if only elements are selected that are openable
// */
// @Override
// public boolean isEnabled() {
// Iterator<?> iter = SpotterUtils.getActiveWindowStructuredSelectionIterator();
// if (iter == null) {
// return false;
// }
//
// while (iter.hasNext()) {
// Object openable = SpotterUtils.toConcreteHandler(iter.next(), OPEN_COMMAND_ID);
// if (!(openable instanceof IOpenable)) {
// return false;
// }
// }
//
// return true;
// }
//
// }
| import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.spotter.eclipse.ui.Activator;
import org.spotter.eclipse.ui.editors.AbstractSpotterEditor;
import org.spotter.eclipse.ui.editors.HierarchyEditor;
import org.spotter.eclipse.ui.editors.HierarchyEditorInput;
import org.spotter.eclipse.ui.handlers.OpenHandler;
import org.spotter.eclipse.ui.menu.IOpenable;
import org.spotter.shared.configuration.FileManager; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.navigator;
/**
* An element that represents the hierarchy node.
*
* @author Denis Knoepfle
*
*/
public class SpotterProjectHierarchy extends AbstractProjectElement {
public static final String IMAGE_PATH = "icons/hierarchy.gif"; //$NON-NLS-1$
private static final String ELEMENT_NAME = "Hierarchy";
private static final String OPEN_ID = HierarchyEditor.ID;
private ISpotterProjectElement parent;
/**
* Create the hierarchy node.
*
* @param parent
* The parent of this node
*/
public SpotterProjectHierarchy(ISpotterProjectElement parent) {
super(IMAGE_PATH);
this.parent = parent; | // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/handlers/OpenHandler.java
// public class OpenHandler extends AbstractHandler {
//
// /**
// * The id of the open command.
// */
// public static final String OPEN_COMMAND_ID = "org.spotter.eclipse.ui.commands.open";
//
// @Override
// public Object execute(ExecutionEvent event) throws ExecutionException {
// Iterator<?> iter = SpotterUtils.getActiveWindowStructuredSelectionIterator();
// if (iter == null) {
// return null;
// }
//
// while (iter.hasNext()) {
// SpotterUtils.openElement(iter.next());
// }
//
// return null;
// }
//
// /**
// * Returns <code>true</code> if only elements are selected that are
// * openable.
// *
// * @return <code>true</code> if only elements are selected that are openable
// */
// @Override
// public boolean isEnabled() {
// Iterator<?> iter = SpotterUtils.getActiveWindowStructuredSelectionIterator();
// if (iter == null) {
// return false;
// }
//
// while (iter.hasNext()) {
// Object openable = SpotterUtils.toConcreteHandler(iter.next(), OPEN_COMMAND_ID);
// if (!(openable instanceof IOpenable)) {
// return false;
// }
// }
//
// return true;
// }
//
// }
// Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/navigator/SpotterProjectHierarchy.java
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.spotter.eclipse.ui.Activator;
import org.spotter.eclipse.ui.editors.AbstractSpotterEditor;
import org.spotter.eclipse.ui.editors.HierarchyEditor;
import org.spotter.eclipse.ui.editors.HierarchyEditorInput;
import org.spotter.eclipse.ui.handlers.OpenHandler;
import org.spotter.eclipse.ui.menu.IOpenable;
import org.spotter.shared.configuration.FileManager;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.navigator;
/**
* An element that represents the hierarchy node.
*
* @author Denis Knoepfle
*
*/
public class SpotterProjectHierarchy extends AbstractProjectElement {
public static final String IMAGE_PATH = "icons/hierarchy.gif"; //$NON-NLS-1$
private static final String ELEMENT_NAME = "Hierarchy";
private static final String OPEN_ID = HierarchyEditor.ID;
private ISpotterProjectElement parent;
/**
* Create the hierarchy node.
*
* @param parent
* The parent of this node
*/
public SpotterProjectHierarchy(ISpotterProjectElement parent) {
super(IMAGE_PATH);
this.parent = parent; | addHandler(OpenHandler.OPEN_COMMAND_ID, new IOpenable() { |
sopeco/DynamicSpotter | org.spotter.core/test/org/spotter/core/test/dummies/detection/DetectionEExtension.java | // Path: org.spotter.core/src/org/spotter/core/detection/AbstractDetectionExtension.java
// public abstract class AbstractDetectionExtension implements IDetectionExtension {
//
// public static final String REUSE_EXPERIMENTS_FROM_PARENT = "reuseExperimentsFromParent";
//
// private final Set<ConfigParameterDescription> configParameters;
//
// /**
// * Constructor.
// */
// public AbstractDetectionExtension() {
//
// configParameters = new HashSet<ConfigParameterDescription>();
// configParameters.add(createIsDetectableParameter());
// if (this.createExtensionArtifact() instanceof IExperimentReuser) {
// configParameters.add(createReuseExperimentsParameter());
// }
// initializeConfigurationParameters();
// }
//
// /**
// * This method is called to initialize heuristic specific configuration
// * parameters.
// */
// protected abstract void initializeConfigurationParameters();
//
// /**
// * Adds a configuration parameter to the extension.
// *
// * @param parameter
// * parameter to add to this extension
// */
// protected void addConfigParameter(ConfigParameterDescription parameter) {
// configParameters.add(parameter);
// }
//
// @Override
// public final Set<ConfigParameterDescription> getConfigParameters() {
// return configParameters;
// }
//
// private ConfigParameterDescription createReuseExperimentsParameter() {
// ConfigParameterDescription reuseExperimentsParameter = new ConfigParameterDescription(
// REUSE_EXPERIMENTS_FROM_PARENT, LpeSupportedTypes.Boolean);
// reuseExperimentsParameter.setDescription("Indicates whether the experiments from "
// + "the parent heuristic should be used for this heuristic.");
// reuseExperimentsParameter.setDefaultValue(String.valueOf(false));
// return reuseExperimentsParameter;
// }
//
// private ConfigParameterDescription createIsDetectableParameter() {
// ConfigParameterDescription nameParameter = new ConfigParameterDescription(ConfigKeys.DETECTABLE_KEY,
// LpeSupportedTypes.Boolean);
// nameParameter.setMandatory(true);
// nameParameter.setASet(false);
// nameParameter.setDefaultValue("true");
// nameParameter.setDescription("Specifies if this problem node is detectable!");
//
// return nameParameter;
// }
// }
//
// Path: org.spotter.core/src/org/spotter/core/detection/IDetectionController.java
// public interface IDetectionController extends IExtensionArtifact {
// /**
// * Analyzes the problem under investigation.
// *
// * @return a {@link SpotterResult} instance indicating whether the problem
// * has been detected or not.
// * @throws InstrumentationException
// * if code instrumentation failed
// * @throws MeasurementException
// * if measurement failed
// * @throws WorkloadException
// * if workload cannot be generated
// */
// SpotterResult analyzeProblem() throws InstrumentationException, MeasurementException, WorkloadException;
//
// /**
// * Sets the configuration for the problem detection.
// *
// * @param problemDetectionConfiguration
// * configuration properties
// */
// void setProblemDetectionConfiguration(Properties problemDetectionConfiguration);
//
// /**
// * @return the problem detection configuration
// */
// Properties getProblemDetectionConfiguration();
//
// /**
// *
// * @param reuser
// * a detection heuristic which should reuser the experiments of
// * this heuristic
// */
// void addExperimentReuser(IExperimentReuser reuser);
//
// /**
// * Loads properties from hierarchy description.
// */
// void loadProperties();
//
// /**
// * Returns the result manager for this detection controller.
// *
// * @return result manager
// */
// DetectionResultManager getResultManager();
//
// /**
// * @return the problemId
// */
// String getProblemId();
//
// /**
// * @param problemId
// * the problemId to set
// */
// void setProblemId(String problemId);
//
// /**
// * Returns the estimated duration of the experiment series conducted for the
// * corresponding performance problem. unit: [seconds]
// *
// * @return duration of experiments
// */
// long getExperimentSeriesDuration();
//
// /**
// * Triggers heuristic specific experiment execution.
// *
// * @throws InstrumentationException
// * if instrumentation fails
// * @throws MeasurementException
// * if measurement data cannot be collected
// * @throws WorkloadException
// * if load cannot be generated properly
// */
// void executeExperiments() throws InstrumentationException, MeasurementException, WorkloadException;
// }
| import org.spotter.core.detection.AbstractDetectionExtension;
import org.spotter.core.detection.IDetectionController; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.detection;
public class DetectionEExtension extends AbstractDetectionExtension{
@Override | // Path: org.spotter.core/src/org/spotter/core/detection/AbstractDetectionExtension.java
// public abstract class AbstractDetectionExtension implements IDetectionExtension {
//
// public static final String REUSE_EXPERIMENTS_FROM_PARENT = "reuseExperimentsFromParent";
//
// private final Set<ConfigParameterDescription> configParameters;
//
// /**
// * Constructor.
// */
// public AbstractDetectionExtension() {
//
// configParameters = new HashSet<ConfigParameterDescription>();
// configParameters.add(createIsDetectableParameter());
// if (this.createExtensionArtifact() instanceof IExperimentReuser) {
// configParameters.add(createReuseExperimentsParameter());
// }
// initializeConfigurationParameters();
// }
//
// /**
// * This method is called to initialize heuristic specific configuration
// * parameters.
// */
// protected abstract void initializeConfigurationParameters();
//
// /**
// * Adds a configuration parameter to the extension.
// *
// * @param parameter
// * parameter to add to this extension
// */
// protected void addConfigParameter(ConfigParameterDescription parameter) {
// configParameters.add(parameter);
// }
//
// @Override
// public final Set<ConfigParameterDescription> getConfigParameters() {
// return configParameters;
// }
//
// private ConfigParameterDescription createReuseExperimentsParameter() {
// ConfigParameterDescription reuseExperimentsParameter = new ConfigParameterDescription(
// REUSE_EXPERIMENTS_FROM_PARENT, LpeSupportedTypes.Boolean);
// reuseExperimentsParameter.setDescription("Indicates whether the experiments from "
// + "the parent heuristic should be used for this heuristic.");
// reuseExperimentsParameter.setDefaultValue(String.valueOf(false));
// return reuseExperimentsParameter;
// }
//
// private ConfigParameterDescription createIsDetectableParameter() {
// ConfigParameterDescription nameParameter = new ConfigParameterDescription(ConfigKeys.DETECTABLE_KEY,
// LpeSupportedTypes.Boolean);
// nameParameter.setMandatory(true);
// nameParameter.setASet(false);
// nameParameter.setDefaultValue("true");
// nameParameter.setDescription("Specifies if this problem node is detectable!");
//
// return nameParameter;
// }
// }
//
// Path: org.spotter.core/src/org/spotter/core/detection/IDetectionController.java
// public interface IDetectionController extends IExtensionArtifact {
// /**
// * Analyzes the problem under investigation.
// *
// * @return a {@link SpotterResult} instance indicating whether the problem
// * has been detected or not.
// * @throws InstrumentationException
// * if code instrumentation failed
// * @throws MeasurementException
// * if measurement failed
// * @throws WorkloadException
// * if workload cannot be generated
// */
// SpotterResult analyzeProblem() throws InstrumentationException, MeasurementException, WorkloadException;
//
// /**
// * Sets the configuration for the problem detection.
// *
// * @param problemDetectionConfiguration
// * configuration properties
// */
// void setProblemDetectionConfiguration(Properties problemDetectionConfiguration);
//
// /**
// * @return the problem detection configuration
// */
// Properties getProblemDetectionConfiguration();
//
// /**
// *
// * @param reuser
// * a detection heuristic which should reuser the experiments of
// * this heuristic
// */
// void addExperimentReuser(IExperimentReuser reuser);
//
// /**
// * Loads properties from hierarchy description.
// */
// void loadProperties();
//
// /**
// * Returns the result manager for this detection controller.
// *
// * @return result manager
// */
// DetectionResultManager getResultManager();
//
// /**
// * @return the problemId
// */
// String getProblemId();
//
// /**
// * @param problemId
// * the problemId to set
// */
// void setProblemId(String problemId);
//
// /**
// * Returns the estimated duration of the experiment series conducted for the
// * corresponding performance problem. unit: [seconds]
// *
// * @return duration of experiments
// */
// long getExperimentSeriesDuration();
//
// /**
// * Triggers heuristic specific experiment execution.
// *
// * @throws InstrumentationException
// * if instrumentation fails
// * @throws MeasurementException
// * if measurement data cannot be collected
// * @throws WorkloadException
// * if load cannot be generated properly
// */
// void executeExperiments() throws InstrumentationException, MeasurementException, WorkloadException;
// }
// Path: org.spotter.core/test/org/spotter/core/test/dummies/detection/DetectionEExtension.java
import org.spotter.core.detection.AbstractDetectionExtension;
import org.spotter.core.detection.IDetectionController;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.detection;
public class DetectionEExtension extends AbstractDetectionExtension{
@Override | public IDetectionController createExtensionArtifact() { |
sopeco/DynamicSpotter | org.spotter.core/test/org/spotter/core/test/dummies/satellites/DummyInstrumentationExtension.java | // Path: org.spotter.core/src/org/spotter/core/instrumentation/IInstrumentationAdapter.java
// public interface IInstrumentationAdapter extends IExtensionArtifact {
//
// String INSTRUMENTATION_INCLUDES = "org.spotter.instrumentation.packageIncludes";
// String INSTRUMENTATION_EXCLUDES = "org.spotter.instrumentation.packageExcludes";
//
// /**
// * @return the name
// */
// String getName();
//
// /**
// * @return the port
// */
// String getPort();
//
// /**
// * @return the host
// */
// String getHost();
//
// /**
// * @return the properties
// */
// Properties getProperties();
//
// /**
// * Initializes the instrumentation engine.
// *
// * @throws InstrumentationException
// * thrown if exception occur during initialization
// */
// void initialize() throws InstrumentationException;
//
// /**
// * Instruments the code according to the passed
// * {@link InstrumentationDescription}.
// *
// * @param description
// * describes where and how to instrument the application code
// * @throws InstrumentationException
// * thrown if exception occur during instrumentation
// */
// void instrument(InstrumentationDescription description) throws InstrumentationException;
//
// /**
// * Reverts all previous instrumentation steps and resets the application
// * code to the original state.
// *
// * false
// *
// * @throws InstrumentationException
// * thrown if exception occur during uninstrumentation
// */
// void uninstrument() throws InstrumentationException;
//
// /**
// * @param properties
// * the properties to set
// */
// void setProperties(Properties properties);
//
// }
| import org.lpe.common.config.ConfigParameterDescription;
import org.lpe.common.util.LpeSupportedTypes;
import org.spotter.core.instrumentation.AbstractInstrumentationExtension;
import org.spotter.core.instrumentation.IInstrumentationAdapter; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.satellites;
public class DummyInstrumentationExtension extends AbstractInstrumentationExtension{
@Override
public String getName() {
return "DummyInstrumentation";
}
@Override | // Path: org.spotter.core/src/org/spotter/core/instrumentation/IInstrumentationAdapter.java
// public interface IInstrumentationAdapter extends IExtensionArtifact {
//
// String INSTRUMENTATION_INCLUDES = "org.spotter.instrumentation.packageIncludes";
// String INSTRUMENTATION_EXCLUDES = "org.spotter.instrumentation.packageExcludes";
//
// /**
// * @return the name
// */
// String getName();
//
// /**
// * @return the port
// */
// String getPort();
//
// /**
// * @return the host
// */
// String getHost();
//
// /**
// * @return the properties
// */
// Properties getProperties();
//
// /**
// * Initializes the instrumentation engine.
// *
// * @throws InstrumentationException
// * thrown if exception occur during initialization
// */
// void initialize() throws InstrumentationException;
//
// /**
// * Instruments the code according to the passed
// * {@link InstrumentationDescription}.
// *
// * @param description
// * describes where and how to instrument the application code
// * @throws InstrumentationException
// * thrown if exception occur during instrumentation
// */
// void instrument(InstrumentationDescription description) throws InstrumentationException;
//
// /**
// * Reverts all previous instrumentation steps and resets the application
// * code to the original state.
// *
// * false
// *
// * @throws InstrumentationException
// * thrown if exception occur during uninstrumentation
// */
// void uninstrument() throws InstrumentationException;
//
// /**
// * @param properties
// * the properties to set
// */
// void setProperties(Properties properties);
//
// }
// Path: org.spotter.core/test/org/spotter/core/test/dummies/satellites/DummyInstrumentationExtension.java
import org.lpe.common.config.ConfigParameterDescription;
import org.lpe.common.util.LpeSupportedTypes;
import org.spotter.core.instrumentation.AbstractInstrumentationExtension;
import org.spotter.core.instrumentation.IInstrumentationAdapter;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.satellites;
public class DummyInstrumentationExtension extends AbstractInstrumentationExtension{
@Override
public String getName() {
return "DummyInstrumentation";
}
@Override | public IInstrumentationAdapter createExtensionArtifact() { |
sopeco/DynamicSpotter | org.spotter.core/test/org/spotter/core/test/dummies/satellites/DummyMeasurementExtension.java | // Path: org.spotter.core/src/org/spotter/core/measurement/IMeasurementAdapter.java
// public interface IMeasurementAdapter extends IExtensionArtifact {
// /**
// * Prepares monitoring with given description.
// *
// * @param monitoringDescription
// * description
// * @throws MeasurementException
// */
// void prepareMonitoring(InstrumentationDescription monitoringDescription) throws MeasurementException;
//
// /**
// * Resets monitoring
// *
// * @throws MeasurementException
// */
// void resetMonitoring() throws MeasurementException;
//
// /**
// * Enables monitoring or measurement data collection.
// *
// * @param monitoringDescription
// * description what to monitor
// * @throws MeasurementException
// * thrown if monitoring fails
// */
// void enableMonitoring() throws MeasurementException;
//
// /**
// * Disables monitoring or measurement data collection.
// *
// * @throws MeasurementException
// * thrown if monitoring fails
// */
// void disableMonitoring() throws MeasurementException;
//
// /**
// *
// * @return collected measurement data
// * @throws MeasurementException
// * thrown if data cannot be retrieved
// */
// MeasurementData getMeasurementData() throws MeasurementException;
//
// /**
// * Pipes the measurement data to the given outpit stream. Note: this method
// * call is blocking until all data has been written to the outputstream!!
// *
// * @param oStream
// * stream where to pipe to
// * @throws MeasurementException
// * thrown if streaming fails
// */
// void pipeToOutputStream(OutputStream oStream) throws MeasurementException;
//
// /**
// * Initializes measruement controller.
// *
// * @throws MeasurementException
// * thrown if initialization fails
// */
// void initialize() throws MeasurementException;
//
// /**
// *
// * @return the current local timestamp of the specific controller
// */
// long getCurrentTime();
//
// /**
// * @return the name
// */
// String getName();
//
// /**
// * @return the port
// */
// String getPort();
//
// /**
// * @return the host
// */
// String getHost();
//
// /**
// * @return the properties
// */
// Properties getProperties();
//
// /**
// * @param properties
// * the properties to set
// */
// void setProperties(Properties properties);
//
// /**
// *
// * @return the controller relative time of the experiment start
// */
// long getControllerRelativeTime();
//
// /**
// *
// * @param relativeTime
// * the controller relative time of the experiment start
// */
// void setControllerRelativeTime(long relativeTime);
//
// /**
// *
// * @param path
// * the path where the report file is to be stored
// * @throws MeasurementException
// * thrown if storing fails
// */
// void storeReport(String path) throws MeasurementException;
// }
| import org.lpe.common.config.ConfigParameterDescription;
import org.lpe.common.util.LpeSupportedTypes;
import org.spotter.core.measurement.AbstractMeasurmentExtension;
import org.spotter.core.measurement.IMeasurementAdapter; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.satellites;
public class DummyMeasurementExtension extends AbstractMeasurmentExtension{
@Override
public String getName() {
return "DummyMeasurement";
}
@Override | // Path: org.spotter.core/src/org/spotter/core/measurement/IMeasurementAdapter.java
// public interface IMeasurementAdapter extends IExtensionArtifact {
// /**
// * Prepares monitoring with given description.
// *
// * @param monitoringDescription
// * description
// * @throws MeasurementException
// */
// void prepareMonitoring(InstrumentationDescription monitoringDescription) throws MeasurementException;
//
// /**
// * Resets monitoring
// *
// * @throws MeasurementException
// */
// void resetMonitoring() throws MeasurementException;
//
// /**
// * Enables monitoring or measurement data collection.
// *
// * @param monitoringDescription
// * description what to monitor
// * @throws MeasurementException
// * thrown if monitoring fails
// */
// void enableMonitoring() throws MeasurementException;
//
// /**
// * Disables monitoring or measurement data collection.
// *
// * @throws MeasurementException
// * thrown if monitoring fails
// */
// void disableMonitoring() throws MeasurementException;
//
// /**
// *
// * @return collected measurement data
// * @throws MeasurementException
// * thrown if data cannot be retrieved
// */
// MeasurementData getMeasurementData() throws MeasurementException;
//
// /**
// * Pipes the measurement data to the given outpit stream. Note: this method
// * call is blocking until all data has been written to the outputstream!!
// *
// * @param oStream
// * stream where to pipe to
// * @throws MeasurementException
// * thrown if streaming fails
// */
// void pipeToOutputStream(OutputStream oStream) throws MeasurementException;
//
// /**
// * Initializes measruement controller.
// *
// * @throws MeasurementException
// * thrown if initialization fails
// */
// void initialize() throws MeasurementException;
//
// /**
// *
// * @return the current local timestamp of the specific controller
// */
// long getCurrentTime();
//
// /**
// * @return the name
// */
// String getName();
//
// /**
// * @return the port
// */
// String getPort();
//
// /**
// * @return the host
// */
// String getHost();
//
// /**
// * @return the properties
// */
// Properties getProperties();
//
// /**
// * @param properties
// * the properties to set
// */
// void setProperties(Properties properties);
//
// /**
// *
// * @return the controller relative time of the experiment start
// */
// long getControllerRelativeTime();
//
// /**
// *
// * @param relativeTime
// * the controller relative time of the experiment start
// */
// void setControllerRelativeTime(long relativeTime);
//
// /**
// *
// * @param path
// * the path where the report file is to be stored
// * @throws MeasurementException
// * thrown if storing fails
// */
// void storeReport(String path) throws MeasurementException;
// }
// Path: org.spotter.core/test/org/spotter/core/test/dummies/satellites/DummyMeasurementExtension.java
import org.lpe.common.config.ConfigParameterDescription;
import org.lpe.common.util.LpeSupportedTypes;
import org.spotter.core.measurement.AbstractMeasurmentExtension;
import org.spotter.core.measurement.IMeasurementAdapter;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.satellites;
public class DummyMeasurementExtension extends AbstractMeasurmentExtension{
@Override
public String getName() {
return "DummyMeasurement";
}
@Override | public IMeasurementAdapter createExtensionArtifact() { |
sopeco/DynamicSpotter | org.spotter.core/src/org/spotter/core/result/ResultBlackboard.java | // Path: org.spotter.core/src/org/spotter/core/config/interpretation/PerformanceProblem.java
// public class PerformanceProblem {
// private List<PerformanceProblem> children;
//
// private Properties configuration;
//
// private IDetectionController detectionController;
//
// private String problemName = null;
//
// private Boolean detectable = null;
//
// private String uniqueId;
//
// /**
// * Create a new instance with the given unique id.
// *
// * @param uniqueId
// * unique id of this problem
// */
// public PerformanceProblem(String uniqueId) {
// this.uniqueId = uniqueId;
// this.children = new ArrayList<PerformanceProblem>();
// setConfiguration(new Properties());
// }
//
// /**
// * Returns the detection controller (
// * {@link org.spotter.core.detection.AbstractDetectionController}) to be
// * used for detection of this problem.
// *
// * @return the detection controller (
// * {@link org.spotter.core.detection.AbstractDetectionController})
// * to be used for detection of this problem.
// */
// public IDetectionController getDetectionController() {
// return detectionController;
// }
//
// /**
// * Sets the detection controller (
// * {@link org.spotter.core.detection.AbstractDetectionController}) to be
// * used for detection of this problem.
// *
// * @param detectionController
// * detection controller to be used.
// */
// public void setDetectionController(IDetectionController detectionController) {
// this.detectionController = detectionController;
// this.detectionController.setProblemId(this.getUniqueId());
// }
//
// /**
// * Returns the unique id of this problem.
// *
// * @return the unique id of this problem.
// */
// public String getUniqueId() {
// return uniqueId;
// }
//
// /**
// * Returns all child performance problems as described by the performance
// * problem hierarchy.
// *
// * @return all child performance problems.
// */
// public List<PerformanceProblem> getChildren() {
// return children;
// }
//
// /**
// * Indicates whether this problem is detectable or not. A non-detectable
// * performance problem is an abstract problem which comprises different
// * concrete problems.
// *
// * @return true, if problem is detectable
// */
// public boolean isDetectable() {
// if (detectable == null) {
// detectable = Boolean.parseBoolean(getConfiguration().getProperty(ConfigKeys.DETECTABLE_KEY, "true"));
// }
//
// return detectable;
// }
//
// /**
// *
// * @return Returns a list of all descending problems including itself.
// */
// public List<PerformanceProblem> getAllDEscendingProblems() {
// List<PerformanceProblem> problems = new ArrayList<PerformanceProblem>();
// problems.add(this);
// int i = 0;
// while (i < problems.size()) {
// problems.addAll(problems.get(i).getChildren());
// i++;
// }
// return problems;
// }
//
// /**
// *
// * @return Configuration
// */
// public Properties getConfiguration() {
// return configuration;
// }
//
// /**
// * Sets the configuration.
// *
// * @param configuration
// * new configuration
// */
// public void setConfiguration(Properties configuration) {
// this.configuration = configuration;
// }
//
// /**
// * @return the problemName
// */
// public String getProblemName() {
// return problemName;
// }
//
// /**
// * @param problemName
// * the problemName to set
// */
// public void setProblemName(String problemName) {
// this.problemName = problemName;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// PerformanceProblem other = (PerformanceProblem) obj;
// if (uniqueId == null) {
// if (other.uniqueId != null) {
// return false;
// }
// } else if (!uniqueId.equals(other.uniqueId)) {
// return false;
// }
// return true;
// }
//
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.spotter.core.config.interpretation.PerformanceProblem;
import org.spotter.shared.result.model.SpotterResult; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.result;
/**
* Singleton Blackboard for all PPD results.
*
* @author Alexander Wert
*
*/
public final class ResultBlackboard {
private static ResultBlackboard instance;
/**
*
* @return singleton instance
*/
public static ResultBlackboard getInstance() {
if (instance == null) {
instance = new ResultBlackboard();
}
return instance;
}
// maps performance problems using their unique id to the corresponding
// spotter result
private final Map<String, SpotterResult> results = new HashMap<String, SpotterResult>(); | // Path: org.spotter.core/src/org/spotter/core/config/interpretation/PerformanceProblem.java
// public class PerformanceProblem {
// private List<PerformanceProblem> children;
//
// private Properties configuration;
//
// private IDetectionController detectionController;
//
// private String problemName = null;
//
// private Boolean detectable = null;
//
// private String uniqueId;
//
// /**
// * Create a new instance with the given unique id.
// *
// * @param uniqueId
// * unique id of this problem
// */
// public PerformanceProblem(String uniqueId) {
// this.uniqueId = uniqueId;
// this.children = new ArrayList<PerformanceProblem>();
// setConfiguration(new Properties());
// }
//
// /**
// * Returns the detection controller (
// * {@link org.spotter.core.detection.AbstractDetectionController}) to be
// * used for detection of this problem.
// *
// * @return the detection controller (
// * {@link org.spotter.core.detection.AbstractDetectionController})
// * to be used for detection of this problem.
// */
// public IDetectionController getDetectionController() {
// return detectionController;
// }
//
// /**
// * Sets the detection controller (
// * {@link org.spotter.core.detection.AbstractDetectionController}) to be
// * used for detection of this problem.
// *
// * @param detectionController
// * detection controller to be used.
// */
// public void setDetectionController(IDetectionController detectionController) {
// this.detectionController = detectionController;
// this.detectionController.setProblemId(this.getUniqueId());
// }
//
// /**
// * Returns the unique id of this problem.
// *
// * @return the unique id of this problem.
// */
// public String getUniqueId() {
// return uniqueId;
// }
//
// /**
// * Returns all child performance problems as described by the performance
// * problem hierarchy.
// *
// * @return all child performance problems.
// */
// public List<PerformanceProblem> getChildren() {
// return children;
// }
//
// /**
// * Indicates whether this problem is detectable or not. A non-detectable
// * performance problem is an abstract problem which comprises different
// * concrete problems.
// *
// * @return true, if problem is detectable
// */
// public boolean isDetectable() {
// if (detectable == null) {
// detectable = Boolean.parseBoolean(getConfiguration().getProperty(ConfigKeys.DETECTABLE_KEY, "true"));
// }
//
// return detectable;
// }
//
// /**
// *
// * @return Returns a list of all descending problems including itself.
// */
// public List<PerformanceProblem> getAllDEscendingProblems() {
// List<PerformanceProblem> problems = new ArrayList<PerformanceProblem>();
// problems.add(this);
// int i = 0;
// while (i < problems.size()) {
// problems.addAll(problems.get(i).getChildren());
// i++;
// }
// return problems;
// }
//
// /**
// *
// * @return Configuration
// */
// public Properties getConfiguration() {
// return configuration;
// }
//
// /**
// * Sets the configuration.
// *
// * @param configuration
// * new configuration
// */
// public void setConfiguration(Properties configuration) {
// this.configuration = configuration;
// }
//
// /**
// * @return the problemName
// */
// public String getProblemName() {
// return problemName;
// }
//
// /**
// * @param problemName
// * the problemName to set
// */
// public void setProblemName(String problemName) {
// this.problemName = problemName;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// PerformanceProblem other = (PerformanceProblem) obj;
// if (uniqueId == null) {
// if (other.uniqueId != null) {
// return false;
// }
// } else if (!uniqueId.equals(other.uniqueId)) {
// return false;
// }
// return true;
// }
//
// }
// Path: org.spotter.core/src/org/spotter/core/result/ResultBlackboard.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.spotter.core.config.interpretation.PerformanceProblem;
import org.spotter.shared.result.model.SpotterResult;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.result;
/**
* Singleton Blackboard for all PPD results.
*
* @author Alexander Wert
*
*/
public final class ResultBlackboard {
private static ResultBlackboard instance;
/**
*
* @return singleton instance
*/
public static ResultBlackboard getInstance() {
if (instance == null) {
instance = new ResultBlackboard();
}
return instance;
}
// maps performance problems using their unique id to the corresponding
// spotter result
private final Map<String, SpotterResult> results = new HashMap<String, SpotterResult>(); | private final List<PerformanceProblem> knownProblems = new ArrayList<PerformanceProblem>(); |
sopeco/DynamicSpotter | org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/handlers/ServiceClientSettingsHandler.java | // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/dialogs/ServiceClientSettingsDialog.java
// public class ServiceClientSettingsDialog extends TitleAreaDialog implements IConnectionChangedListener {
//
// private final ServiceClientWrapper client;
// private ConnectionTestComposite connTestComposite;
//
// /**
// * Creates a new dialog for the given project.
// *
// * @param parentShell
// * The underlying shell for this dialog
// * @param projectName
// * The name of the project whose settings will be edited
// */
// public ServiceClientSettingsDialog(Shell parentShell, String projectName) {
// super(parentShell);
// this.client = Activator.getDefault().getClient(projectName);
// setHelpAvailable(false);
// }
//
// /**
// * Create contents of the dialog.
// *
// * @param parent
// * The parent composite the content is placed in
// * @return a {@link Control} instance
// */
// @Override
// protected Control createDialogArea(Composite parent) {
// setTitle(ConnectionWizardPage.TITLE);
// setMessage(ConnectionWizardPage.DESCRIPTION);
//
// Composite area = (Composite) super.createDialogArea(parent);
// Composite container = new Composite(area, SWT.NONE);
// container.setLayoutData(new GridData(GridData.FILL_BOTH));
// container.setLayout(new FillLayout());
//
// connTestComposite = new ConnectionTestComposite(container, false, client);
// connTestComposite.addConnectionChangedListener(this);
//
// return area;
// }
//
// /**
// * Create contents of the button bar.
// *
// * @param parent
// * The parent composite the content is placed in
// */
// @Override
// protected void createButtonsForButtonBar(Composite parent) {
// createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
// createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
// }
//
// @Override
// protected void okPressed() {
// String host = connTestComposite.getHost();
// String port = connTestComposite.getPort();
// if (!client.saveServiceClientSettings(host, port)) {
// return;
// }
// super.okPressed();
// }
//
// @Override
// public void connectionChanged(boolean connectionOk) {
// String errorMsg = connTestComposite.getErrorMessage();
// setErrorMessage(errorMsg);
// Button okButton = getButton(IDialogConstants.OK_ID);
// if (okButton != null) {
// okButton.setEnabled(errorMsg == null);
// }
// }
//
// }
| import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.spotter.eclipse.ui.Activator;
import org.spotter.eclipse.ui.dialogs.ServiceClientSettingsDialog; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.handlers;
/**
* A handler for the service client settings command which opens the service
* client settings dialog.
*
* @author Denis Knoepfle
*
*/
public class ServiceClientSettingsHandler extends AbstractHandler implements ISelectionChangedListener {
/**
* The id of the corresponding service client settings command.
*/
public static final String CLIENT_SETTINGS_COMMAND_ID = "org.spotter.eclipse.ui.commands.serviceClientSettings";
private boolean isEnabled;
/**
* Constructor.
*/
public ServiceClientSettingsHandler() {
super();
selectionChanged(null);
Activator.getDefault().addProjectSelectionListener(this);
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Activator activator = Activator.getDefault();
if (activator.getSelectedProjects().size() != 1) {
return null;
}
String projectName = activator.getSelectedProjects().iterator().next().getName();
Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); | // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/dialogs/ServiceClientSettingsDialog.java
// public class ServiceClientSettingsDialog extends TitleAreaDialog implements IConnectionChangedListener {
//
// private final ServiceClientWrapper client;
// private ConnectionTestComposite connTestComposite;
//
// /**
// * Creates a new dialog for the given project.
// *
// * @param parentShell
// * The underlying shell for this dialog
// * @param projectName
// * The name of the project whose settings will be edited
// */
// public ServiceClientSettingsDialog(Shell parentShell, String projectName) {
// super(parentShell);
// this.client = Activator.getDefault().getClient(projectName);
// setHelpAvailable(false);
// }
//
// /**
// * Create contents of the dialog.
// *
// * @param parent
// * The parent composite the content is placed in
// * @return a {@link Control} instance
// */
// @Override
// protected Control createDialogArea(Composite parent) {
// setTitle(ConnectionWizardPage.TITLE);
// setMessage(ConnectionWizardPage.DESCRIPTION);
//
// Composite area = (Composite) super.createDialogArea(parent);
// Composite container = new Composite(area, SWT.NONE);
// container.setLayoutData(new GridData(GridData.FILL_BOTH));
// container.setLayout(new FillLayout());
//
// connTestComposite = new ConnectionTestComposite(container, false, client);
// connTestComposite.addConnectionChangedListener(this);
//
// return area;
// }
//
// /**
// * Create contents of the button bar.
// *
// * @param parent
// * The parent composite the content is placed in
// */
// @Override
// protected void createButtonsForButtonBar(Composite parent) {
// createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
// createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
// }
//
// @Override
// protected void okPressed() {
// String host = connTestComposite.getHost();
// String port = connTestComposite.getPort();
// if (!client.saveServiceClientSettings(host, port)) {
// return;
// }
// super.okPressed();
// }
//
// @Override
// public void connectionChanged(boolean connectionOk) {
// String errorMsg = connTestComposite.getErrorMessage();
// setErrorMessage(errorMsg);
// Button okButton = getButton(IDialogConstants.OK_ID);
// if (okButton != null) {
// okButton.setEnabled(errorMsg == null);
// }
// }
//
// }
// Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/handlers/ServiceClientSettingsHandler.java
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.spotter.eclipse.ui.Activator;
import org.spotter.eclipse.ui.dialogs.ServiceClientSettingsDialog;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.handlers;
/**
* A handler for the service client settings command which opens the service
* client settings dialog.
*
* @author Denis Knoepfle
*
*/
public class ServiceClientSettingsHandler extends AbstractHandler implements ISelectionChangedListener {
/**
* The id of the corresponding service client settings command.
*/
public static final String CLIENT_SETTINGS_COMMAND_ID = "org.spotter.eclipse.ui.commands.serviceClientSettings";
private boolean isEnabled;
/**
* Constructor.
*/
public ServiceClientSettingsHandler() {
super();
selectionChanged(null);
Activator.getDefault().addProjectSelectionListener(this);
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Activator activator = Activator.getDefault();
if (activator.getSelectedProjects().size() != 1) {
return null;
}
String projectName = activator.getSelectedProjects().iterator().next().getName();
Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); | ServiceClientSettingsDialog dialog = new ServiceClientSettingsDialog(shell, projectName); |
sopeco/DynamicSpotter | org.spotter.core/test/org/spotter/core/test/dummies/detection/DetectionDExtension.java | // Path: org.spotter.core/src/org/spotter/core/detection/AbstractDetectionExtension.java
// public abstract class AbstractDetectionExtension implements IDetectionExtension {
//
// public static final String REUSE_EXPERIMENTS_FROM_PARENT = "reuseExperimentsFromParent";
//
// private final Set<ConfigParameterDescription> configParameters;
//
// /**
// * Constructor.
// */
// public AbstractDetectionExtension() {
//
// configParameters = new HashSet<ConfigParameterDescription>();
// configParameters.add(createIsDetectableParameter());
// if (this.createExtensionArtifact() instanceof IExperimentReuser) {
// configParameters.add(createReuseExperimentsParameter());
// }
// initializeConfigurationParameters();
// }
//
// /**
// * This method is called to initialize heuristic specific configuration
// * parameters.
// */
// protected abstract void initializeConfigurationParameters();
//
// /**
// * Adds a configuration parameter to the extension.
// *
// * @param parameter
// * parameter to add to this extension
// */
// protected void addConfigParameter(ConfigParameterDescription parameter) {
// configParameters.add(parameter);
// }
//
// @Override
// public final Set<ConfigParameterDescription> getConfigParameters() {
// return configParameters;
// }
//
// private ConfigParameterDescription createReuseExperimentsParameter() {
// ConfigParameterDescription reuseExperimentsParameter = new ConfigParameterDescription(
// REUSE_EXPERIMENTS_FROM_PARENT, LpeSupportedTypes.Boolean);
// reuseExperimentsParameter.setDescription("Indicates whether the experiments from "
// + "the parent heuristic should be used for this heuristic.");
// reuseExperimentsParameter.setDefaultValue(String.valueOf(false));
// return reuseExperimentsParameter;
// }
//
// private ConfigParameterDescription createIsDetectableParameter() {
// ConfigParameterDescription nameParameter = new ConfigParameterDescription(ConfigKeys.DETECTABLE_KEY,
// LpeSupportedTypes.Boolean);
// nameParameter.setMandatory(true);
// nameParameter.setASet(false);
// nameParameter.setDefaultValue("true");
// nameParameter.setDescription("Specifies if this problem node is detectable!");
//
// return nameParameter;
// }
// }
//
// Path: org.spotter.core/src/org/spotter/core/detection/IDetectionController.java
// public interface IDetectionController extends IExtensionArtifact {
// /**
// * Analyzes the problem under investigation.
// *
// * @return a {@link SpotterResult} instance indicating whether the problem
// * has been detected or not.
// * @throws InstrumentationException
// * if code instrumentation failed
// * @throws MeasurementException
// * if measurement failed
// * @throws WorkloadException
// * if workload cannot be generated
// */
// SpotterResult analyzeProblem() throws InstrumentationException, MeasurementException, WorkloadException;
//
// /**
// * Sets the configuration for the problem detection.
// *
// * @param problemDetectionConfiguration
// * configuration properties
// */
// void setProblemDetectionConfiguration(Properties problemDetectionConfiguration);
//
// /**
// * @return the problem detection configuration
// */
// Properties getProblemDetectionConfiguration();
//
// /**
// *
// * @param reuser
// * a detection heuristic which should reuser the experiments of
// * this heuristic
// */
// void addExperimentReuser(IExperimentReuser reuser);
//
// /**
// * Loads properties from hierarchy description.
// */
// void loadProperties();
//
// /**
// * Returns the result manager for this detection controller.
// *
// * @return result manager
// */
// DetectionResultManager getResultManager();
//
// /**
// * @return the problemId
// */
// String getProblemId();
//
// /**
// * @param problemId
// * the problemId to set
// */
// void setProblemId(String problemId);
//
// /**
// * Returns the estimated duration of the experiment series conducted for the
// * corresponding performance problem. unit: [seconds]
// *
// * @return duration of experiments
// */
// long getExperimentSeriesDuration();
//
// /**
// * Triggers heuristic specific experiment execution.
// *
// * @throws InstrumentationException
// * if instrumentation fails
// * @throws MeasurementException
// * if measurement data cannot be collected
// * @throws WorkloadException
// * if load cannot be generated properly
// */
// void executeExperiments() throws InstrumentationException, MeasurementException, WorkloadException;
// }
| import org.spotter.core.detection.AbstractDetectionExtension;
import org.spotter.core.detection.IDetectionController; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.detection;
public class DetectionDExtension extends AbstractDetectionExtension{
@Override | // Path: org.spotter.core/src/org/spotter/core/detection/AbstractDetectionExtension.java
// public abstract class AbstractDetectionExtension implements IDetectionExtension {
//
// public static final String REUSE_EXPERIMENTS_FROM_PARENT = "reuseExperimentsFromParent";
//
// private final Set<ConfigParameterDescription> configParameters;
//
// /**
// * Constructor.
// */
// public AbstractDetectionExtension() {
//
// configParameters = new HashSet<ConfigParameterDescription>();
// configParameters.add(createIsDetectableParameter());
// if (this.createExtensionArtifact() instanceof IExperimentReuser) {
// configParameters.add(createReuseExperimentsParameter());
// }
// initializeConfigurationParameters();
// }
//
// /**
// * This method is called to initialize heuristic specific configuration
// * parameters.
// */
// protected abstract void initializeConfigurationParameters();
//
// /**
// * Adds a configuration parameter to the extension.
// *
// * @param parameter
// * parameter to add to this extension
// */
// protected void addConfigParameter(ConfigParameterDescription parameter) {
// configParameters.add(parameter);
// }
//
// @Override
// public final Set<ConfigParameterDescription> getConfigParameters() {
// return configParameters;
// }
//
// private ConfigParameterDescription createReuseExperimentsParameter() {
// ConfigParameterDescription reuseExperimentsParameter = new ConfigParameterDescription(
// REUSE_EXPERIMENTS_FROM_PARENT, LpeSupportedTypes.Boolean);
// reuseExperimentsParameter.setDescription("Indicates whether the experiments from "
// + "the parent heuristic should be used for this heuristic.");
// reuseExperimentsParameter.setDefaultValue(String.valueOf(false));
// return reuseExperimentsParameter;
// }
//
// private ConfigParameterDescription createIsDetectableParameter() {
// ConfigParameterDescription nameParameter = new ConfigParameterDescription(ConfigKeys.DETECTABLE_KEY,
// LpeSupportedTypes.Boolean);
// nameParameter.setMandatory(true);
// nameParameter.setASet(false);
// nameParameter.setDefaultValue("true");
// nameParameter.setDescription("Specifies if this problem node is detectable!");
//
// return nameParameter;
// }
// }
//
// Path: org.spotter.core/src/org/spotter/core/detection/IDetectionController.java
// public interface IDetectionController extends IExtensionArtifact {
// /**
// * Analyzes the problem under investigation.
// *
// * @return a {@link SpotterResult} instance indicating whether the problem
// * has been detected or not.
// * @throws InstrumentationException
// * if code instrumentation failed
// * @throws MeasurementException
// * if measurement failed
// * @throws WorkloadException
// * if workload cannot be generated
// */
// SpotterResult analyzeProblem() throws InstrumentationException, MeasurementException, WorkloadException;
//
// /**
// * Sets the configuration for the problem detection.
// *
// * @param problemDetectionConfiguration
// * configuration properties
// */
// void setProblemDetectionConfiguration(Properties problemDetectionConfiguration);
//
// /**
// * @return the problem detection configuration
// */
// Properties getProblemDetectionConfiguration();
//
// /**
// *
// * @param reuser
// * a detection heuristic which should reuser the experiments of
// * this heuristic
// */
// void addExperimentReuser(IExperimentReuser reuser);
//
// /**
// * Loads properties from hierarchy description.
// */
// void loadProperties();
//
// /**
// * Returns the result manager for this detection controller.
// *
// * @return result manager
// */
// DetectionResultManager getResultManager();
//
// /**
// * @return the problemId
// */
// String getProblemId();
//
// /**
// * @param problemId
// * the problemId to set
// */
// void setProblemId(String problemId);
//
// /**
// * Returns the estimated duration of the experiment series conducted for the
// * corresponding performance problem. unit: [seconds]
// *
// * @return duration of experiments
// */
// long getExperimentSeriesDuration();
//
// /**
// * Triggers heuristic specific experiment execution.
// *
// * @throws InstrumentationException
// * if instrumentation fails
// * @throws MeasurementException
// * if measurement data cannot be collected
// * @throws WorkloadException
// * if load cannot be generated properly
// */
// void executeExperiments() throws InstrumentationException, MeasurementException, WorkloadException;
// }
// Path: org.spotter.core/test/org/spotter/core/test/dummies/detection/DetectionDExtension.java
import org.spotter.core.detection.AbstractDetectionExtension;
import org.spotter.core.detection.IDetectionController;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.detection;
public class DetectionDExtension extends AbstractDetectionExtension{
@Override | public IDetectionController createExtensionArtifact() { |
sopeco/DynamicSpotter | org.spotter.core/test/org/spotter/core/test/dummies/detection/DetectionCExtension.java | // Path: org.spotter.core/src/org/spotter/core/detection/AbstractDetectionExtension.java
// public abstract class AbstractDetectionExtension implements IDetectionExtension {
//
// public static final String REUSE_EXPERIMENTS_FROM_PARENT = "reuseExperimentsFromParent";
//
// private final Set<ConfigParameterDescription> configParameters;
//
// /**
// * Constructor.
// */
// public AbstractDetectionExtension() {
//
// configParameters = new HashSet<ConfigParameterDescription>();
// configParameters.add(createIsDetectableParameter());
// if (this.createExtensionArtifact() instanceof IExperimentReuser) {
// configParameters.add(createReuseExperimentsParameter());
// }
// initializeConfigurationParameters();
// }
//
// /**
// * This method is called to initialize heuristic specific configuration
// * parameters.
// */
// protected abstract void initializeConfigurationParameters();
//
// /**
// * Adds a configuration parameter to the extension.
// *
// * @param parameter
// * parameter to add to this extension
// */
// protected void addConfigParameter(ConfigParameterDescription parameter) {
// configParameters.add(parameter);
// }
//
// @Override
// public final Set<ConfigParameterDescription> getConfigParameters() {
// return configParameters;
// }
//
// private ConfigParameterDescription createReuseExperimentsParameter() {
// ConfigParameterDescription reuseExperimentsParameter = new ConfigParameterDescription(
// REUSE_EXPERIMENTS_FROM_PARENT, LpeSupportedTypes.Boolean);
// reuseExperimentsParameter.setDescription("Indicates whether the experiments from "
// + "the parent heuristic should be used for this heuristic.");
// reuseExperimentsParameter.setDefaultValue(String.valueOf(false));
// return reuseExperimentsParameter;
// }
//
// private ConfigParameterDescription createIsDetectableParameter() {
// ConfigParameterDescription nameParameter = new ConfigParameterDescription(ConfigKeys.DETECTABLE_KEY,
// LpeSupportedTypes.Boolean);
// nameParameter.setMandatory(true);
// nameParameter.setASet(false);
// nameParameter.setDefaultValue("true");
// nameParameter.setDescription("Specifies if this problem node is detectable!");
//
// return nameParameter;
// }
// }
//
// Path: org.spotter.core/src/org/spotter/core/detection/IDetectionController.java
// public interface IDetectionController extends IExtensionArtifact {
// /**
// * Analyzes the problem under investigation.
// *
// * @return a {@link SpotterResult} instance indicating whether the problem
// * has been detected or not.
// * @throws InstrumentationException
// * if code instrumentation failed
// * @throws MeasurementException
// * if measurement failed
// * @throws WorkloadException
// * if workload cannot be generated
// */
// SpotterResult analyzeProblem() throws InstrumentationException, MeasurementException, WorkloadException;
//
// /**
// * Sets the configuration for the problem detection.
// *
// * @param problemDetectionConfiguration
// * configuration properties
// */
// void setProblemDetectionConfiguration(Properties problemDetectionConfiguration);
//
// /**
// * @return the problem detection configuration
// */
// Properties getProblemDetectionConfiguration();
//
// /**
// *
// * @param reuser
// * a detection heuristic which should reuser the experiments of
// * this heuristic
// */
// void addExperimentReuser(IExperimentReuser reuser);
//
// /**
// * Loads properties from hierarchy description.
// */
// void loadProperties();
//
// /**
// * Returns the result manager for this detection controller.
// *
// * @return result manager
// */
// DetectionResultManager getResultManager();
//
// /**
// * @return the problemId
// */
// String getProblemId();
//
// /**
// * @param problemId
// * the problemId to set
// */
// void setProblemId(String problemId);
//
// /**
// * Returns the estimated duration of the experiment series conducted for the
// * corresponding performance problem. unit: [seconds]
// *
// * @return duration of experiments
// */
// long getExperimentSeriesDuration();
//
// /**
// * Triggers heuristic specific experiment execution.
// *
// * @throws InstrumentationException
// * if instrumentation fails
// * @throws MeasurementException
// * if measurement data cannot be collected
// * @throws WorkloadException
// * if load cannot be generated properly
// */
// void executeExperiments() throws InstrumentationException, MeasurementException, WorkloadException;
// }
| import org.spotter.core.detection.AbstractDetectionExtension;
import org.spotter.core.detection.IDetectionController; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.detection;
public class DetectionCExtension extends AbstractDetectionExtension{
@Override | // Path: org.spotter.core/src/org/spotter/core/detection/AbstractDetectionExtension.java
// public abstract class AbstractDetectionExtension implements IDetectionExtension {
//
// public static final String REUSE_EXPERIMENTS_FROM_PARENT = "reuseExperimentsFromParent";
//
// private final Set<ConfigParameterDescription> configParameters;
//
// /**
// * Constructor.
// */
// public AbstractDetectionExtension() {
//
// configParameters = new HashSet<ConfigParameterDescription>();
// configParameters.add(createIsDetectableParameter());
// if (this.createExtensionArtifact() instanceof IExperimentReuser) {
// configParameters.add(createReuseExperimentsParameter());
// }
// initializeConfigurationParameters();
// }
//
// /**
// * This method is called to initialize heuristic specific configuration
// * parameters.
// */
// protected abstract void initializeConfigurationParameters();
//
// /**
// * Adds a configuration parameter to the extension.
// *
// * @param parameter
// * parameter to add to this extension
// */
// protected void addConfigParameter(ConfigParameterDescription parameter) {
// configParameters.add(parameter);
// }
//
// @Override
// public final Set<ConfigParameterDescription> getConfigParameters() {
// return configParameters;
// }
//
// private ConfigParameterDescription createReuseExperimentsParameter() {
// ConfigParameterDescription reuseExperimentsParameter = new ConfigParameterDescription(
// REUSE_EXPERIMENTS_FROM_PARENT, LpeSupportedTypes.Boolean);
// reuseExperimentsParameter.setDescription("Indicates whether the experiments from "
// + "the parent heuristic should be used for this heuristic.");
// reuseExperimentsParameter.setDefaultValue(String.valueOf(false));
// return reuseExperimentsParameter;
// }
//
// private ConfigParameterDescription createIsDetectableParameter() {
// ConfigParameterDescription nameParameter = new ConfigParameterDescription(ConfigKeys.DETECTABLE_KEY,
// LpeSupportedTypes.Boolean);
// nameParameter.setMandatory(true);
// nameParameter.setASet(false);
// nameParameter.setDefaultValue("true");
// nameParameter.setDescription("Specifies if this problem node is detectable!");
//
// return nameParameter;
// }
// }
//
// Path: org.spotter.core/src/org/spotter/core/detection/IDetectionController.java
// public interface IDetectionController extends IExtensionArtifact {
// /**
// * Analyzes the problem under investigation.
// *
// * @return a {@link SpotterResult} instance indicating whether the problem
// * has been detected or not.
// * @throws InstrumentationException
// * if code instrumentation failed
// * @throws MeasurementException
// * if measurement failed
// * @throws WorkloadException
// * if workload cannot be generated
// */
// SpotterResult analyzeProblem() throws InstrumentationException, MeasurementException, WorkloadException;
//
// /**
// * Sets the configuration for the problem detection.
// *
// * @param problemDetectionConfiguration
// * configuration properties
// */
// void setProblemDetectionConfiguration(Properties problemDetectionConfiguration);
//
// /**
// * @return the problem detection configuration
// */
// Properties getProblemDetectionConfiguration();
//
// /**
// *
// * @param reuser
// * a detection heuristic which should reuser the experiments of
// * this heuristic
// */
// void addExperimentReuser(IExperimentReuser reuser);
//
// /**
// * Loads properties from hierarchy description.
// */
// void loadProperties();
//
// /**
// * Returns the result manager for this detection controller.
// *
// * @return result manager
// */
// DetectionResultManager getResultManager();
//
// /**
// * @return the problemId
// */
// String getProblemId();
//
// /**
// * @param problemId
// * the problemId to set
// */
// void setProblemId(String problemId);
//
// /**
// * Returns the estimated duration of the experiment series conducted for the
// * corresponding performance problem. unit: [seconds]
// *
// * @return duration of experiments
// */
// long getExperimentSeriesDuration();
//
// /**
// * Triggers heuristic specific experiment execution.
// *
// * @throws InstrumentationException
// * if instrumentation fails
// * @throws MeasurementException
// * if measurement data cannot be collected
// * @throws WorkloadException
// * if load cannot be generated properly
// */
// void executeExperiments() throws InstrumentationException, MeasurementException, WorkloadException;
// }
// Path: org.spotter.core/test/org/spotter/core/test/dummies/detection/DetectionCExtension.java
import org.spotter.core.detection.AbstractDetectionExtension;
import org.spotter.core.detection.IDetectionController;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.core.test.dummies.detection;
public class DetectionCExtension extends AbstractDetectionExtension{
@Override | public IDetectionController createExtensionArtifact() { |
sopeco/DynamicSpotter | org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/editors/MeasurementEditorInput.java | // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/model/xml/MeasurementEnvironmentFactory.java
// public final class MeasurementEnvironmentFactory {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(MeasurementEnvironmentFactory.class);
//
// private static MeasurementEnvironmentFactory instance;
//
// /**
// * @return singleton instance
// */
// public static MeasurementEnvironmentFactory getInstance() {
// if (instance == null) {
// instance = new MeasurementEnvironmentFactory();
// }
// return instance;
// }
//
// private MeasurementEnvironmentFactory() {
// }
//
// /**
// * Reads the file from disk specified by the given <code>fileName</code> and
// * parses it for creation of an {@link XMeasurementEnvironment}.
// *
// * @param fileName
// * specifies the name of the XML file containing the measurement
// * environment description
// * @return the <code>XMeasurementEnvironment</code> object
// * @throws UICoreException
// * when either file could not be found or when there was an
// * error parsing the file
// */
// public XMeasurementEnvironment parseXMLFile(String fileName) throws UICoreException {
// try {
// return JAXBUtil.parseXMLFile(fileName, ObjectFactory.class.getPackage().getName());
// } catch (FileNotFoundException e) {
// String message = "Could not find file '" + fileName + "'!";
// LOGGER.error(message);
// throw new UICoreException(message, e);
// } catch (JAXBException e) {
// String message = "Failed to parse measurement environment description file '" + fileName + "'!";
// LOGGER.error(message + " Cause: {}", e.getMessage());
// throw new UICoreException(message, e);
// }
// }
//
// /**
// * Creates an empty instance of a measurement environment. This factory
// * method initializes the fields with empty lists.
// *
// * @return an empty instance
// */
// public XMeasurementEnvironment createMeasurementEnvironment() {
// XMeasurementEnvironment env = new XMeasurementEnvironment();
//
// List<XMeasurementEnvObject> instrumentationControllers = new LinkedList<>();
// List<XMeasurementEnvObject> measurementControllers = new LinkedList<>();
// List<XMeasurementEnvObject> workloadAdapters = new LinkedList<>();
//
// env.setInstrumentationController(instrumentationControllers);
// env.setMeasurementController(measurementControllers);
// env.setWorkloadAdapter(workloadAdapters);
//
// return env;
// }
//
// /**
// * Creates a copy of the given measurement environment object.
// *
// * @param envObj
// * the object to copy
// * @return the copy of the given object
// */
// public XMeasurementEnvObject copyMeasurementEnvObject(XMeasurementEnvObject envObj) {
// XMeasurementEnvObject envObjCopy = new XMeasurementEnvObject();
// envObjCopy.setExtensionName(envObj.getExtensionName());
// if (envObj.getConfig() != null) {
// envObjCopy.setConfig(SpotterUtils.copyConfigurationList(envObj.getConfig()));
// }
// return envObjCopy;
// }
//
// }
//
// Path: org.spotter.shared/src/org/spotter/shared/environment/model/XMeasurementEnvObject.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "MeasurementEnvObject", propOrder = { "extensionName", "config" })
// public class XMeasurementEnvObject {
//
// @XmlElement(name = "extensionName", required = true)
// private String extensionName;
//
// private List<XMConfiguration> config;
//
// /**
// * @return the extensionName
// */
// public String getExtensionName() {
// return extensionName;
// }
//
// /**
// * @param extensionName
// * the extensionName to set
// */
// public void setExtensionName(String extensionName) {
// this.extensionName = extensionName;
// }
//
// /**
// * @return the config
// */
// public List<XMConfiguration> getConfig() {
// return config;
// }
//
// /**
// * @param config
// * the config to set
// */
// public void setConfig(List<XMConfiguration> config) {
// this.config = config;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.spotter.eclipse.ui.UICoreException;
import org.spotter.eclipse.ui.model.xml.MeasurementEnvironmentFactory;
import org.spotter.eclipse.ui.navigator.SpotterProjectConfigMeasurement;
import org.spotter.shared.environment.model.XMeasurementEnvObject;
import org.spotter.shared.environment.model.XMeasurementEnvironment; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.editors;
/**
* Editor input for the Measurement Editor.
*
* @author Denis Knoepfle
*
*/
public class MeasurementEditorInput extends AbstractSpotterEditorInput {
private static final String NAME = "Measurement Satellite Adapter";
private static final String IMAGE_PATH = SpotterProjectConfigMeasurement.IMAGE_PATH;
| // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/model/xml/MeasurementEnvironmentFactory.java
// public final class MeasurementEnvironmentFactory {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(MeasurementEnvironmentFactory.class);
//
// private static MeasurementEnvironmentFactory instance;
//
// /**
// * @return singleton instance
// */
// public static MeasurementEnvironmentFactory getInstance() {
// if (instance == null) {
// instance = new MeasurementEnvironmentFactory();
// }
// return instance;
// }
//
// private MeasurementEnvironmentFactory() {
// }
//
// /**
// * Reads the file from disk specified by the given <code>fileName</code> and
// * parses it for creation of an {@link XMeasurementEnvironment}.
// *
// * @param fileName
// * specifies the name of the XML file containing the measurement
// * environment description
// * @return the <code>XMeasurementEnvironment</code> object
// * @throws UICoreException
// * when either file could not be found or when there was an
// * error parsing the file
// */
// public XMeasurementEnvironment parseXMLFile(String fileName) throws UICoreException {
// try {
// return JAXBUtil.parseXMLFile(fileName, ObjectFactory.class.getPackage().getName());
// } catch (FileNotFoundException e) {
// String message = "Could not find file '" + fileName + "'!";
// LOGGER.error(message);
// throw new UICoreException(message, e);
// } catch (JAXBException e) {
// String message = "Failed to parse measurement environment description file '" + fileName + "'!";
// LOGGER.error(message + " Cause: {}", e.getMessage());
// throw new UICoreException(message, e);
// }
// }
//
// /**
// * Creates an empty instance of a measurement environment. This factory
// * method initializes the fields with empty lists.
// *
// * @return an empty instance
// */
// public XMeasurementEnvironment createMeasurementEnvironment() {
// XMeasurementEnvironment env = new XMeasurementEnvironment();
//
// List<XMeasurementEnvObject> instrumentationControllers = new LinkedList<>();
// List<XMeasurementEnvObject> measurementControllers = new LinkedList<>();
// List<XMeasurementEnvObject> workloadAdapters = new LinkedList<>();
//
// env.setInstrumentationController(instrumentationControllers);
// env.setMeasurementController(measurementControllers);
// env.setWorkloadAdapter(workloadAdapters);
//
// return env;
// }
//
// /**
// * Creates a copy of the given measurement environment object.
// *
// * @param envObj
// * the object to copy
// * @return the copy of the given object
// */
// public XMeasurementEnvObject copyMeasurementEnvObject(XMeasurementEnvObject envObj) {
// XMeasurementEnvObject envObjCopy = new XMeasurementEnvObject();
// envObjCopy.setExtensionName(envObj.getExtensionName());
// if (envObj.getConfig() != null) {
// envObjCopy.setConfig(SpotterUtils.copyConfigurationList(envObj.getConfig()));
// }
// return envObjCopy;
// }
//
// }
//
// Path: org.spotter.shared/src/org/spotter/shared/environment/model/XMeasurementEnvObject.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "MeasurementEnvObject", propOrder = { "extensionName", "config" })
// public class XMeasurementEnvObject {
//
// @XmlElement(name = "extensionName", required = true)
// private String extensionName;
//
// private List<XMConfiguration> config;
//
// /**
// * @return the extensionName
// */
// public String getExtensionName() {
// return extensionName;
// }
//
// /**
// * @param extensionName
// * the extensionName to set
// */
// public void setExtensionName(String extensionName) {
// this.extensionName = extensionName;
// }
//
// /**
// * @return the config
// */
// public List<XMConfiguration> getConfig() {
// return config;
// }
//
// /**
// * @param config
// * the config to set
// */
// public void setConfig(List<XMConfiguration> config) {
// this.config = config;
// }
//
// }
// Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/editors/MeasurementEditorInput.java
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.spotter.eclipse.ui.UICoreException;
import org.spotter.eclipse.ui.model.xml.MeasurementEnvironmentFactory;
import org.spotter.eclipse.ui.navigator.SpotterProjectConfigMeasurement;
import org.spotter.shared.environment.model.XMeasurementEnvObject;
import org.spotter.shared.environment.model.XMeasurementEnvironment;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.editors;
/**
* Editor input for the Measurement Editor.
*
* @author Denis Knoepfle
*
*/
public class MeasurementEditorInput extends AbstractSpotterEditorInput {
private static final String NAME = "Measurement Satellite Adapter";
private static final String IMAGE_PATH = SpotterProjectConfigMeasurement.IMAGE_PATH;
| private List<XMeasurementEnvObject> measurementControllers; |
sopeco/DynamicSpotter | org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/editors/MeasurementEditorInput.java | // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/model/xml/MeasurementEnvironmentFactory.java
// public final class MeasurementEnvironmentFactory {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(MeasurementEnvironmentFactory.class);
//
// private static MeasurementEnvironmentFactory instance;
//
// /**
// * @return singleton instance
// */
// public static MeasurementEnvironmentFactory getInstance() {
// if (instance == null) {
// instance = new MeasurementEnvironmentFactory();
// }
// return instance;
// }
//
// private MeasurementEnvironmentFactory() {
// }
//
// /**
// * Reads the file from disk specified by the given <code>fileName</code> and
// * parses it for creation of an {@link XMeasurementEnvironment}.
// *
// * @param fileName
// * specifies the name of the XML file containing the measurement
// * environment description
// * @return the <code>XMeasurementEnvironment</code> object
// * @throws UICoreException
// * when either file could not be found or when there was an
// * error parsing the file
// */
// public XMeasurementEnvironment parseXMLFile(String fileName) throws UICoreException {
// try {
// return JAXBUtil.parseXMLFile(fileName, ObjectFactory.class.getPackage().getName());
// } catch (FileNotFoundException e) {
// String message = "Could not find file '" + fileName + "'!";
// LOGGER.error(message);
// throw new UICoreException(message, e);
// } catch (JAXBException e) {
// String message = "Failed to parse measurement environment description file '" + fileName + "'!";
// LOGGER.error(message + " Cause: {}", e.getMessage());
// throw new UICoreException(message, e);
// }
// }
//
// /**
// * Creates an empty instance of a measurement environment. This factory
// * method initializes the fields with empty lists.
// *
// * @return an empty instance
// */
// public XMeasurementEnvironment createMeasurementEnvironment() {
// XMeasurementEnvironment env = new XMeasurementEnvironment();
//
// List<XMeasurementEnvObject> instrumentationControllers = new LinkedList<>();
// List<XMeasurementEnvObject> measurementControllers = new LinkedList<>();
// List<XMeasurementEnvObject> workloadAdapters = new LinkedList<>();
//
// env.setInstrumentationController(instrumentationControllers);
// env.setMeasurementController(measurementControllers);
// env.setWorkloadAdapter(workloadAdapters);
//
// return env;
// }
//
// /**
// * Creates a copy of the given measurement environment object.
// *
// * @param envObj
// * the object to copy
// * @return the copy of the given object
// */
// public XMeasurementEnvObject copyMeasurementEnvObject(XMeasurementEnvObject envObj) {
// XMeasurementEnvObject envObjCopy = new XMeasurementEnvObject();
// envObjCopy.setExtensionName(envObj.getExtensionName());
// if (envObj.getConfig() != null) {
// envObjCopy.setConfig(SpotterUtils.copyConfigurationList(envObj.getConfig()));
// }
// return envObjCopy;
// }
//
// }
//
// Path: org.spotter.shared/src/org/spotter/shared/environment/model/XMeasurementEnvObject.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "MeasurementEnvObject", propOrder = { "extensionName", "config" })
// public class XMeasurementEnvObject {
//
// @XmlElement(name = "extensionName", required = true)
// private String extensionName;
//
// private List<XMConfiguration> config;
//
// /**
// * @return the extensionName
// */
// public String getExtensionName() {
// return extensionName;
// }
//
// /**
// * @param extensionName
// * the extensionName to set
// */
// public void setExtensionName(String extensionName) {
// this.extensionName = extensionName;
// }
//
// /**
// * @return the config
// */
// public List<XMConfiguration> getConfig() {
// return config;
// }
//
// /**
// * @param config
// * the config to set
// */
// public void setConfig(List<XMConfiguration> config) {
// this.config = config;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.spotter.eclipse.ui.UICoreException;
import org.spotter.eclipse.ui.model.xml.MeasurementEnvironmentFactory;
import org.spotter.eclipse.ui.navigator.SpotterProjectConfigMeasurement;
import org.spotter.shared.environment.model.XMeasurementEnvObject;
import org.spotter.shared.environment.model.XMeasurementEnvironment; | /**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.editors;
/**
* Editor input for the Measurement Editor.
*
* @author Denis Knoepfle
*
*/
public class MeasurementEditorInput extends AbstractSpotterEditorInput {
private static final String NAME = "Measurement Satellite Adapter";
private static final String IMAGE_PATH = SpotterProjectConfigMeasurement.IMAGE_PATH;
private List<XMeasurementEnvObject> measurementControllers;
/**
* Creates a new instance of this class.
*
* @param file
* the associated file.
*/
public MeasurementEditorInput(IFile file) {
super(file); | // Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/model/xml/MeasurementEnvironmentFactory.java
// public final class MeasurementEnvironmentFactory {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(MeasurementEnvironmentFactory.class);
//
// private static MeasurementEnvironmentFactory instance;
//
// /**
// * @return singleton instance
// */
// public static MeasurementEnvironmentFactory getInstance() {
// if (instance == null) {
// instance = new MeasurementEnvironmentFactory();
// }
// return instance;
// }
//
// private MeasurementEnvironmentFactory() {
// }
//
// /**
// * Reads the file from disk specified by the given <code>fileName</code> and
// * parses it for creation of an {@link XMeasurementEnvironment}.
// *
// * @param fileName
// * specifies the name of the XML file containing the measurement
// * environment description
// * @return the <code>XMeasurementEnvironment</code> object
// * @throws UICoreException
// * when either file could not be found or when there was an
// * error parsing the file
// */
// public XMeasurementEnvironment parseXMLFile(String fileName) throws UICoreException {
// try {
// return JAXBUtil.parseXMLFile(fileName, ObjectFactory.class.getPackage().getName());
// } catch (FileNotFoundException e) {
// String message = "Could not find file '" + fileName + "'!";
// LOGGER.error(message);
// throw new UICoreException(message, e);
// } catch (JAXBException e) {
// String message = "Failed to parse measurement environment description file '" + fileName + "'!";
// LOGGER.error(message + " Cause: {}", e.getMessage());
// throw new UICoreException(message, e);
// }
// }
//
// /**
// * Creates an empty instance of a measurement environment. This factory
// * method initializes the fields with empty lists.
// *
// * @return an empty instance
// */
// public XMeasurementEnvironment createMeasurementEnvironment() {
// XMeasurementEnvironment env = new XMeasurementEnvironment();
//
// List<XMeasurementEnvObject> instrumentationControllers = new LinkedList<>();
// List<XMeasurementEnvObject> measurementControllers = new LinkedList<>();
// List<XMeasurementEnvObject> workloadAdapters = new LinkedList<>();
//
// env.setInstrumentationController(instrumentationControllers);
// env.setMeasurementController(measurementControllers);
// env.setWorkloadAdapter(workloadAdapters);
//
// return env;
// }
//
// /**
// * Creates a copy of the given measurement environment object.
// *
// * @param envObj
// * the object to copy
// * @return the copy of the given object
// */
// public XMeasurementEnvObject copyMeasurementEnvObject(XMeasurementEnvObject envObj) {
// XMeasurementEnvObject envObjCopy = new XMeasurementEnvObject();
// envObjCopy.setExtensionName(envObj.getExtensionName());
// if (envObj.getConfig() != null) {
// envObjCopy.setConfig(SpotterUtils.copyConfigurationList(envObj.getConfig()));
// }
// return envObjCopy;
// }
//
// }
//
// Path: org.spotter.shared/src/org/spotter/shared/environment/model/XMeasurementEnvObject.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "MeasurementEnvObject", propOrder = { "extensionName", "config" })
// public class XMeasurementEnvObject {
//
// @XmlElement(name = "extensionName", required = true)
// private String extensionName;
//
// private List<XMConfiguration> config;
//
// /**
// * @return the extensionName
// */
// public String getExtensionName() {
// return extensionName;
// }
//
// /**
// * @param extensionName
// * the extensionName to set
// */
// public void setExtensionName(String extensionName) {
// this.extensionName = extensionName;
// }
//
// /**
// * @return the config
// */
// public List<XMConfiguration> getConfig() {
// return config;
// }
//
// /**
// * @param config
// * the config to set
// */
// public void setConfig(List<XMConfiguration> config) {
// this.config = config;
// }
//
// }
// Path: org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/editors/MeasurementEditorInput.java
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.spotter.eclipse.ui.UICoreException;
import org.spotter.eclipse.ui.model.xml.MeasurementEnvironmentFactory;
import org.spotter.eclipse.ui.navigator.SpotterProjectConfigMeasurement;
import org.spotter.shared.environment.model.XMeasurementEnvObject;
import org.spotter.shared.environment.model.XMeasurementEnvironment;
/**
* Copyright 2014 SAP AG
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spotter.eclipse.ui.editors;
/**
* Editor input for the Measurement Editor.
*
* @author Denis Knoepfle
*
*/
public class MeasurementEditorInput extends AbstractSpotterEditorInput {
private static final String NAME = "Measurement Satellite Adapter";
private static final String IMAGE_PATH = SpotterProjectConfigMeasurement.IMAGE_PATH;
private List<XMeasurementEnvObject> measurementControllers;
/**
* Creates a new instance of this class.
*
* @param file
* the associated file.
*/
public MeasurementEditorInput(IFile file) {
super(file); | MeasurementEnvironmentFactory factory = MeasurementEnvironmentFactory.getInstance(); |
CesarValiente/PermissionsSample | app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
| import android.content.pm.PackageManager;
import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 15/09/15.
*/
public class PermissionPresenter {
private PermissionAction permissionAction;
private PermissionCallbacks permissionCallbacks;
public PermissionPresenter(PermissionAction permissionAction, PermissionCallbacks permissionCallbacks) {
this.permissionAction = permissionAction;
this.permissionCallbacks = permissionCallbacks;
}
public void requestReadContactsPermission() { | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java
import android.content.pm.PackageManager;
import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 15/09/15.
*/
public class PermissionPresenter {
private PermissionAction permissionAction;
private PermissionCallbacks permissionCallbacks;
public PermissionPresenter(PermissionAction permissionAction, PermissionCallbacks permissionCallbacks) {
this.permissionAction = permissionAction;
this.permissionCallbacks = permissionCallbacks;
}
public void requestReadContactsPermission() { | checkAndRequestPermission(Action.READ_CONTACTS); |
CesarValiente/PermissionsSample | action/src/main/java/com/cesarvaliente/permissionssample/action/impl/permission/PermissionActionFactory.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
| import android.app.Activity;
import com.cesarvaliente.permissionssample.action.PermissionAction; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.action.impl.permission;
/**
* Created by Cesar on 27/09/15.
*/
public class PermissionActionFactory {
public static final int ACTIVITY_IMPL = 1;
public static final int SUPPORT_IMPL = 2;
private Activity activity;
public PermissionActionFactory(Activity activity) {
this.activity = activity;
}
| // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/impl/permission/PermissionActionFactory.java
import android.app.Activity;
import com.cesarvaliente.permissionssample.action.PermissionAction;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.action.impl.permission;
/**
* Created by Cesar on 27/09/15.
*/
public class PermissionActionFactory {
public static final int ACTIVITY_IMPL = 1;
public static final int SUPPORT_IMPL = 2;
private Activity activity;
public PermissionActionFactory(Activity activity) {
this.activity = activity;
}
| public PermissionAction getPermissionAction(int type) { |
CesarValiente/PermissionsSample | action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCaseImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/ImageAction.java
// public interface ImageAction {
//
// boolean saveImage(Uri uri, String contactName) throws IOException;
// }
| import java.io.IOException;
import android.net.Uri;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionssample.action.ImageAction; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.action.usecase;
/**
* Created by Cesar on 24/09/15.
*/
public class ImageUseCaseImpl implements ImageUseCase {
private ImageAction imageAction; | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/ImageAction.java
// public interface ImageAction {
//
// boolean saveImage(Uri uri, String contactName) throws IOException;
// }
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCaseImpl.java
import java.io.IOException;
import android.net.Uri;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionssample.action.ImageAction;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.action.usecase;
/**
* Created by Cesar on 24/09/15.
*/
public class ImageUseCaseImpl implements ImageUseCase {
private ImageAction imageAction; | private ThreadExecutor threadExecutor; |
CesarValiente/PermissionsSample | action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCaseImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/ImageAction.java
// public interface ImageAction {
//
// boolean saveImage(Uri uri, String contactName) throws IOException;
// }
| import java.io.IOException;
import android.net.Uri;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionssample.action.ImageAction; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.action.usecase;
/**
* Created by Cesar on 24/09/15.
*/
public class ImageUseCaseImpl implements ImageUseCase {
private ImageAction imageAction;
private ThreadExecutor threadExecutor; | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/ImageAction.java
// public interface ImageAction {
//
// boolean saveImage(Uri uri, String contactName) throws IOException;
// }
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCaseImpl.java
import java.io.IOException;
import android.net.Uri;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionssample.action.ImageAction;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.action.usecase;
/**
* Created by Cesar on 24/09/15.
*/
public class ImageUseCaseImpl implements ImageUseCase {
private ImageAction imageAction;
private ThreadExecutor threadExecutor; | private PostExecutionThread postExecutionThread; |
CesarValiente/PermissionsSample | app/src/test/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenterTest.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java
// public interface PermissionCallbacks {
// void permissionAccepted(@Action.ActionCode int actionCode);
//
// void permissionDenied(@Action.ActionCode int actionCode);
//
// void showRationale(@Action.ActionCode int actionCode);
// }
| import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action;
import com.cesarvaliente.permissionssample.presentation.presenter.PermissionPresenter.PermissionCallbacks;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static android.Manifest.permission.READ_CONTACTS;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 17/09/15.
*/
@RunWith(JUnit4.class)
public class PermissionPresenterTest {
PermissionPresenter permissionPresenter;
@Mock | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java
// public interface PermissionCallbacks {
// void permissionAccepted(@Action.ActionCode int actionCode);
//
// void permissionDenied(@Action.ActionCode int actionCode);
//
// void showRationale(@Action.ActionCode int actionCode);
// }
// Path: app/src/test/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenterTest.java
import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action;
import com.cesarvaliente.permissionssample.presentation.presenter.PermissionPresenter.PermissionCallbacks;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static android.Manifest.permission.READ_CONTACTS;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 17/09/15.
*/
@RunWith(JUnit4.class)
public class PermissionPresenterTest {
PermissionPresenter permissionPresenter;
@Mock | PermissionAction permissionAction; |
CesarValiente/PermissionsSample | app/src/test/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenterTest.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java
// public interface PermissionCallbacks {
// void permissionAccepted(@Action.ActionCode int actionCode);
//
// void permissionDenied(@Action.ActionCode int actionCode);
//
// void showRationale(@Action.ActionCode int actionCode);
// }
| import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action;
import com.cesarvaliente.permissionssample.presentation.presenter.PermissionPresenter.PermissionCallbacks;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static android.Manifest.permission.READ_CONTACTS;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 17/09/15.
*/
@RunWith(JUnit4.class)
public class PermissionPresenterTest {
PermissionPresenter permissionPresenter;
@Mock
PermissionAction permissionAction;
@Mock | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java
// public interface PermissionCallbacks {
// void permissionAccepted(@Action.ActionCode int actionCode);
//
// void permissionDenied(@Action.ActionCode int actionCode);
//
// void showRationale(@Action.ActionCode int actionCode);
// }
// Path: app/src/test/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenterTest.java
import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action;
import com.cesarvaliente.permissionssample.presentation.presenter.PermissionPresenter.PermissionCallbacks;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static android.Manifest.permission.READ_CONTACTS;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 17/09/15.
*/
@RunWith(JUnit4.class)
public class PermissionPresenterTest {
PermissionPresenter permissionPresenter;
@Mock
PermissionAction permissionAction;
@Mock | PermissionCallbacks permissionCallbacks; |
CesarValiente/PermissionsSample | app/src/test/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenterTest.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java
// public interface PermissionCallbacks {
// void permissionAccepted(@Action.ActionCode int actionCode);
//
// void permissionDenied(@Action.ActionCode int actionCode);
//
// void showRationale(@Action.ActionCode int actionCode);
// }
| import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action;
import com.cesarvaliente.permissionssample.presentation.presenter.PermissionPresenter.PermissionCallbacks;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static android.Manifest.permission.READ_CONTACTS;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 17/09/15.
*/
@RunWith(JUnit4.class)
public class PermissionPresenterTest {
PermissionPresenter permissionPresenter;
@Mock
PermissionAction permissionAction;
@Mock
PermissionCallbacks permissionCallbacks;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
permissionPresenter = new PermissionPresenter(permissionAction, permissionCallbacks);
}
@Test
public void shouldCallAcceptedPermission() {
when(permissionAction.hasSelfPermission(READ_CONTACTS)).thenReturn(true);
permissionPresenter.requestReadContactsPermission(); | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/Action.java
// public class Action {
//
// @IntDef({ ACTION_CODE_READ_CONTACTS, ACTION_CODE_SAVE_IMAGE, ACTION_CODE_SEND_SMS })
// @Retention(RetentionPolicy.SOURCE)
// public @interface ActionCode {
// }
//
// public static final int ACTION_CODE_READ_CONTACTS = 0;
// public static final int ACTION_CODE_SAVE_IMAGE = 1;
// public static final int ACTION_CODE_SEND_SMS = 2;
//
// public static final Action READ_CONTACTS = new Action(ACTION_CODE_READ_CONTACTS, Manifest.permission
// .READ_CONTACTS);
// public static final Action SAVE_IMAGE = new Action(ACTION_CODE_SAVE_IMAGE, Manifest.permission
// .WRITE_EXTERNAL_STORAGE);
// public static final Action SEND_SMS = new Action(ACTION_CODE_SEND_SMS, Manifest.permission.SEND_SMS);
//
// private int code;
// private String permission;
//
// private Action(@ActionCode int value, String name) {
// this.code = value;
// this.permission = name;
// }
//
// @ActionCode
// public int getCode() {
// return code;
// }
//
// public String getPermission() {
// return permission;
// }
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenter.java
// public interface PermissionCallbacks {
// void permissionAccepted(@Action.ActionCode int actionCode);
//
// void permissionDenied(@Action.ActionCode int actionCode);
//
// void showRationale(@Action.ActionCode int actionCode);
// }
// Path: app/src/test/java/com/cesarvaliente/permissionssample/presentation/presenter/PermissionPresenterTest.java
import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.presentation.model.Action;
import com.cesarvaliente.permissionssample.presentation.presenter.PermissionPresenter.PermissionCallbacks;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import static android.Manifest.permission.READ_CONTACTS;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 17/09/15.
*/
@RunWith(JUnit4.class)
public class PermissionPresenterTest {
PermissionPresenter permissionPresenter;
@Mock
PermissionAction permissionAction;
@Mock
PermissionCallbacks permissionCallbacks;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
permissionPresenter = new PermissionPresenter(permissionAction, permissionCallbacks);
}
@Test
public void shouldCallAcceptedPermission() {
when(permissionAction.hasSelfPermission(READ_CONTACTS)).thenReturn(true);
permissionPresenter.requestReadContactsPermission(); | verify(permissionCallbacks).permissionAccepted(Action.ACTION_CODE_READ_CONTACTS); |
CesarValiente/PermissionsSample | app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/MainView.java | // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
| import com.cesarvaliente.permissionssample.presentation.model.ContactModel; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.view;
/**
* Created by Cesar on 13/09/15.
*/
public interface MainView {
void configureActionBar();
void setActionBarTitle(String title);
void setActionBarHome(boolean home);
void showProgressBar();
void hideProgressBar();
void showContactListFragment();
| // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/MainView.java
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.view;
/**
* Created by Cesar on 13/09/15.
*/
public interface MainView {
void configureActionBar();
void setActionBarTitle(String title);
void setActionBarHome(boolean home);
void showProgressBar();
void hideProgressBar();
void showContactListFragment();
| void showContactFragment(ContactModel contact); |
CesarValiente/PermissionsSample | domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
| import java.util.List;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionsample.domain.action;
/**
* In this case, that the data source can change completely the ListContactAction is good that we have here
* instead in the action module, so if we change the data source for instance we add a database where we have
* some contacts, this interface, in a possible module "data" it would be implemented there so the domain could
* work with it even knowing anything of the implementation.
*/
public interface ListContactsAction {
interface DataCallback { | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
import java.util.List;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionsample.domain.action;
/**
* In this case, that the data source can change completely the ListContactAction is good that we have here
* instead in the action module, so if we change the data source for instance we add a database where we have
* some contacts, this interface, in a possible module "data" it would be implemented there so the domain could
* work with it even knowing anything of the implementation.
*/
public interface ListContactsAction {
interface DataCallback { | void onDataLoaded(List<ContactEntity> contactEntityList); |
CesarValiente/PermissionsSample | domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
| import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction; | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java
import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction; | private ThreadExecutor threadExecutor; |
CesarValiente/PermissionsSample | domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
| import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction;
private ThreadExecutor threadExecutor; | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java
import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction;
private ThreadExecutor threadExecutor; | private PostExecutionThread postExecutionThread; |
CesarValiente/PermissionsSample | domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
| import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction;
private ThreadExecutor threadExecutor;
private PostExecutionThread postExecutionThread;
private UiCallbacks uiUiCallbacks; | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java
import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction;
private ThreadExecutor threadExecutor;
private PostExecutionThread postExecutionThread;
private UiCallbacks uiUiCallbacks; | private DataCallback dataCallback; |
CesarValiente/PermissionsSample | domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
| import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction;
private ThreadExecutor threadExecutor;
private PostExecutionThread postExecutionThread;
private UiCallbacks uiUiCallbacks;
private DataCallback dataCallback;
public ListContactsUseCaseImpl(ListContactsAction listContactsAction, ThreadExecutor threadExecutor,
PostExecutionThread postExecutionThread) {
this.listContactsAction = listContactsAction;
this.threadExecutor = threadExecutor;
this.postExecutionThread = postExecutionThread;
}
@Override
public void execute(final UiCallbacks uiCallbacks) {
this.uiUiCallbacks = uiCallbacks;
dataCallback = new DataCallback() {
@Override | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/PostExecutionThread.java
// public interface PostExecutionThread {
// /**
// * Causes the {@link Runnable} to be added to the message queue of the Main UI Thread
// * of the application.
// *
// * @param runnable {@link Runnable} to be executed.
// */
// void post(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/executor/ThreadExecutor.java
// public interface ThreadExecutor {
//
// void execute(Runnable runnable);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
// public interface ListContactsUseCase extends UseCase {
//
// interface UiCallbacks {
// void onComplete(List<ContactEntity> contactEntity);
//
// void onError(String error);
// }
//
// void execute(UiCallbacks uiCallbacks);
//
// }
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/impl/ListContactsUseCaseImpl.java
import java.util.List;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction.DataCallback;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionsample.domain.executor.PostExecutionThread;
import com.cesarvaliente.permissionsample.domain.executor.ThreadExecutor;
import com.cesarvaliente.permissionsample.domain.usecase.ListContactsUseCase;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionsample.domain.usecase.impl;
/**
* Created by Cesar on 19/09/15.
*/
public class ListContactsUseCaseImpl implements ListContactsUseCase {
private ListContactsAction listContactsAction;
private ThreadExecutor threadExecutor;
private PostExecutionThread postExecutionThread;
private UiCallbacks uiUiCallbacks;
private DataCallback dataCallback;
public ListContactsUseCaseImpl(ListContactsAction listContactsAction, ThreadExecutor threadExecutor,
PostExecutionThread postExecutionThread) {
this.listContactsAction = listContactsAction;
this.threadExecutor = threadExecutor;
this.postExecutionThread = postExecutionThread;
}
@Override
public void execute(final UiCallbacks uiCallbacks) {
this.uiUiCallbacks = uiCallbacks;
dataCallback = new DataCallback() {
@Override | public void onDataLoaded(final List<ContactEntity> contactEntityList) { |
CesarValiente/PermissionsSample | action/src/main/java/com/cesarvaliente/permissionssample/action/impl/permission/ActivityPermissionActionImpl.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isMarshmallowOrHigher() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
// && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// return false;
// } else {
// return true;
// }
// }
// }
| import android.app.Activity;
import android.content.pm.PackageManager;
import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.action.utils.CommonUtils; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.action.impl.permission;
/**
* Created by Cesar on 24/09/15.
*/
class ActivityPermissionActionImpl implements PermissionAction {
private Activity activity;
public ActivityPermissionActionImpl(Activity activity) {
this.activity = activity;
}
@Override
public boolean hasSelfPermission(String permission) { | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/PermissionAction.java
// public interface PermissionAction {
//
// boolean hasSelfPermission(String permission);
//
// void requestPermission(String permission, int requestCode);
//
// boolean shouldShowRequestPermissionRationale(String permission);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/utils/CommonUtils.java
// public class CommonUtils {
//
// public static boolean isMarshmallowOrHigher() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
// && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// return false;
// } else {
// return true;
// }
// }
// }
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/impl/permission/ActivityPermissionActionImpl.java
import android.app.Activity;
import android.content.pm.PackageManager;
import com.cesarvaliente.permissionssample.action.PermissionAction;
import com.cesarvaliente.permissionssample.action.utils.CommonUtils;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.action.impl.permission;
/**
* Created by Cesar on 24/09/15.
*/
class ActivityPermissionActionImpl implements PermissionAction {
private Activity activity;
public ActivityPermissionActionImpl(Activity activity) {
this.activity = activity;
}
@Override
public boolean hasSelfPermission(String permission) { | if (!CommonUtils.isMarshmallowOrHigher()) { |
CesarValiente/PermissionsSample | app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contactlist/ContactListView.java | // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
| import java.util.List;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel; | package com.cesarvaliente.permissionssample.presentation.view.contactlist;
/**
* Created by Cesar on 08/09/15.
*/
public interface ContactListView {
void showProgressDialog();
void hideShowProgressDialog();
| // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contactlist/ContactListView.java
import java.util.List;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
package com.cesarvaliente.permissionssample.presentation.view.contactlist;
/**
* Created by Cesar on 08/09/15.
*/
public interface ContactListView {
void showProgressDialog();
void hideShowProgressDialog();
| void updateAdapter(List<ContactModel> contacts); |
CesarValiente/PermissionsSample | action/src/main/java/com/cesarvaliente/permissionssample/action/impl/ListListContactsActionImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/ContactData.java
// public class ContactData {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactData(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactData --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/mapper/ContactDataMapper.java
// public class ContactDataMapper {
//
// public static ContactEntity transform(ContactData contactData) {
// if (contactData == null) {
// throw new IllegalArgumentException("Contact can not be null");
// }
// ContactEntity contactEntity = new ContactEntity(contactData.getId(), contactData.getName(), contactData
// .getPhone());
// contactEntity.setEmail(contactData.getEmail());
//
// return contactEntity;
// }
//
// public static List<ContactEntity> transform(List<ContactData> contactDataList) {
// if (contactDataList == null) {
// throw new IllegalArgumentException("Contact list can not be null");
// }
// List<ContactEntity> contactModels = new ArrayList<>(contactDataList.size());
// for (ContactData contact : contactDataList) {
// ContactEntity contactModel = transform(contact);
// contactModels.add(contactModel);
// }
// return contactModels;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.text.TextUtils;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionssample.action.data.ContactData;
import com.cesarvaliente.permissionssample.action.data.mapper.ContactDataMapper; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.action.impl;
/**
* Created by Cesar on 23/09/15.
*/
public class ListListContactsActionImpl implements ListContactsAction {
private Context context;
public ListListContactsActionImpl(Context context) {
this.context = context;
}
@Override
public void getPhoneBookContacts(DataCallback dataCallback) { | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/ContactData.java
// public class ContactData {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactData(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactData --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/mapper/ContactDataMapper.java
// public class ContactDataMapper {
//
// public static ContactEntity transform(ContactData contactData) {
// if (contactData == null) {
// throw new IllegalArgumentException("Contact can not be null");
// }
// ContactEntity contactEntity = new ContactEntity(contactData.getId(), contactData.getName(), contactData
// .getPhone());
// contactEntity.setEmail(contactData.getEmail());
//
// return contactEntity;
// }
//
// public static List<ContactEntity> transform(List<ContactData> contactDataList) {
// if (contactDataList == null) {
// throw new IllegalArgumentException("Contact list can not be null");
// }
// List<ContactEntity> contactModels = new ArrayList<>(contactDataList.size());
// for (ContactData contact : contactDataList) {
// ContactEntity contactModel = transform(contact);
// contactModels.add(contactModel);
// }
// return contactModels;
// }
// }
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/impl/ListListContactsActionImpl.java
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.text.TextUtils;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionssample.action.data.ContactData;
import com.cesarvaliente.permissionssample.action.data.mapper.ContactDataMapper;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.action.impl;
/**
* Created by Cesar on 23/09/15.
*/
public class ListListContactsActionImpl implements ListContactsAction {
private Context context;
public ListListContactsActionImpl(Context context) {
this.context = context;
}
@Override
public void getPhoneBookContacts(DataCallback dataCallback) { | List<ContactData> contactDataList = new ArrayList<>(); |
CesarValiente/PermissionsSample | action/src/main/java/com/cesarvaliente/permissionssample/action/impl/ListListContactsActionImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/ContactData.java
// public class ContactData {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactData(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactData --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/mapper/ContactDataMapper.java
// public class ContactDataMapper {
//
// public static ContactEntity transform(ContactData contactData) {
// if (contactData == null) {
// throw new IllegalArgumentException("Contact can not be null");
// }
// ContactEntity contactEntity = new ContactEntity(contactData.getId(), contactData.getName(), contactData
// .getPhone());
// contactEntity.setEmail(contactData.getEmail());
//
// return contactEntity;
// }
//
// public static List<ContactEntity> transform(List<ContactData> contactDataList) {
// if (contactDataList == null) {
// throw new IllegalArgumentException("Contact list can not be null");
// }
// List<ContactEntity> contactModels = new ArrayList<>(contactDataList.size());
// for (ContactData contact : contactDataList) {
// ContactEntity contactModel = transform(contact);
// contactModels.add(contactModel);
// }
// return contactModels;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.text.TextUtils;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionssample.action.data.ContactData;
import com.cesarvaliente.permissionssample.action.data.mapper.ContactDataMapper; | do {
String contactId = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Contacts._ID));
Cursor emails = getEmailsCursor(contactId);
Cursor phones = getPHoneCursor(contactId);
if (isCursorValid(emails) && isCursorValid(phones)) {
String name = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Data.DISPLAY_NAME));
String emailAddress = emails.getString(emails.getColumnIndex(ContactsContract
.CommonDataKinds.Email.DATA));
String phone = phones.getString(phones.getColumnIndex(
ContactsContract.CommonDataKinds.Phone.NUMBER));
if (!TextUtils.isEmpty(phone)) {
ContactData contactData = new ContactData(contactId, name, phone);
contactData.setEmail(emailAddress);
contactDataList.add(contactData);
}
}
closeCursor(emails);
closeCursor(phones);
} while (contactsCursor.moveToNext());
}
closeCursor(contactsCursor);
notifyOnSuccess(contactDataList, dataCallback);
}
private void notifyOnSuccess(List<ContactData> contactDataList, DataCallback dataCallback) { | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/ContactData.java
// public class ContactData {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactData(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactData --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/mapper/ContactDataMapper.java
// public class ContactDataMapper {
//
// public static ContactEntity transform(ContactData contactData) {
// if (contactData == null) {
// throw new IllegalArgumentException("Contact can not be null");
// }
// ContactEntity contactEntity = new ContactEntity(contactData.getId(), contactData.getName(), contactData
// .getPhone());
// contactEntity.setEmail(contactData.getEmail());
//
// return contactEntity;
// }
//
// public static List<ContactEntity> transform(List<ContactData> contactDataList) {
// if (contactDataList == null) {
// throw new IllegalArgumentException("Contact list can not be null");
// }
// List<ContactEntity> contactModels = new ArrayList<>(contactDataList.size());
// for (ContactData contact : contactDataList) {
// ContactEntity contactModel = transform(contact);
// contactModels.add(contactModel);
// }
// return contactModels;
// }
// }
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/impl/ListListContactsActionImpl.java
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.text.TextUtils;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionssample.action.data.ContactData;
import com.cesarvaliente.permissionssample.action.data.mapper.ContactDataMapper;
do {
String contactId = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Contacts._ID));
Cursor emails = getEmailsCursor(contactId);
Cursor phones = getPHoneCursor(contactId);
if (isCursorValid(emails) && isCursorValid(phones)) {
String name = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Data.DISPLAY_NAME));
String emailAddress = emails.getString(emails.getColumnIndex(ContactsContract
.CommonDataKinds.Email.DATA));
String phone = phones.getString(phones.getColumnIndex(
ContactsContract.CommonDataKinds.Phone.NUMBER));
if (!TextUtils.isEmpty(phone)) {
ContactData contactData = new ContactData(contactId, name, phone);
contactData.setEmail(emailAddress);
contactDataList.add(contactData);
}
}
closeCursor(emails);
closeCursor(phones);
} while (contactsCursor.moveToNext());
}
closeCursor(contactsCursor);
notifyOnSuccess(contactDataList, dataCallback);
}
private void notifyOnSuccess(List<ContactData> contactDataList, DataCallback dataCallback) { | List<ContactEntity> contactEntityList = ContactDataMapper.transform(contactDataList); |
CesarValiente/PermissionsSample | action/src/main/java/com/cesarvaliente/permissionssample/action/impl/ListListContactsActionImpl.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/ContactData.java
// public class ContactData {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactData(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactData --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/mapper/ContactDataMapper.java
// public class ContactDataMapper {
//
// public static ContactEntity transform(ContactData contactData) {
// if (contactData == null) {
// throw new IllegalArgumentException("Contact can not be null");
// }
// ContactEntity contactEntity = new ContactEntity(contactData.getId(), contactData.getName(), contactData
// .getPhone());
// contactEntity.setEmail(contactData.getEmail());
//
// return contactEntity;
// }
//
// public static List<ContactEntity> transform(List<ContactData> contactDataList) {
// if (contactDataList == null) {
// throw new IllegalArgumentException("Contact list can not be null");
// }
// List<ContactEntity> contactModels = new ArrayList<>(contactDataList.size());
// for (ContactData contact : contactDataList) {
// ContactEntity contactModel = transform(contact);
// contactModels.add(contactModel);
// }
// return contactModels;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.text.TextUtils;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionssample.action.data.ContactData;
import com.cesarvaliente.permissionssample.action.data.mapper.ContactDataMapper; | do {
String contactId = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Contacts._ID));
Cursor emails = getEmailsCursor(contactId);
Cursor phones = getPHoneCursor(contactId);
if (isCursorValid(emails) && isCursorValid(phones)) {
String name = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Data.DISPLAY_NAME));
String emailAddress = emails.getString(emails.getColumnIndex(ContactsContract
.CommonDataKinds.Email.DATA));
String phone = phones.getString(phones.getColumnIndex(
ContactsContract.CommonDataKinds.Phone.NUMBER));
if (!TextUtils.isEmpty(phone)) {
ContactData contactData = new ContactData(contactId, name, phone);
contactData.setEmail(emailAddress);
contactDataList.add(contactData);
}
}
closeCursor(emails);
closeCursor(phones);
} while (contactsCursor.moveToNext());
}
closeCursor(contactsCursor);
notifyOnSuccess(contactDataList, dataCallback);
}
private void notifyOnSuccess(List<ContactData> contactDataList, DataCallback dataCallback) { | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/action/ListContactsAction.java
// public interface ListContactsAction {
//
// interface DataCallback {
// void onDataLoaded(List<ContactEntity> contactEntityList);
// }
//
// void getPhoneBookContacts(DataCallback dataCallback);
// }
//
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/ContactData.java
// public class ContactData {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactData(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactData --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/data/mapper/ContactDataMapper.java
// public class ContactDataMapper {
//
// public static ContactEntity transform(ContactData contactData) {
// if (contactData == null) {
// throw new IllegalArgumentException("Contact can not be null");
// }
// ContactEntity contactEntity = new ContactEntity(contactData.getId(), contactData.getName(), contactData
// .getPhone());
// contactEntity.setEmail(contactData.getEmail());
//
// return contactEntity;
// }
//
// public static List<ContactEntity> transform(List<ContactData> contactDataList) {
// if (contactDataList == null) {
// throw new IllegalArgumentException("Contact list can not be null");
// }
// List<ContactEntity> contactModels = new ArrayList<>(contactDataList.size());
// for (ContactData contact : contactDataList) {
// ContactEntity contactModel = transform(contact);
// contactModels.add(contactModel);
// }
// return contactModels;
// }
// }
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/impl/ListListContactsActionImpl.java
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.text.TextUtils;
import com.cesarvaliente.permissionsample.domain.action.ListContactsAction;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
import com.cesarvaliente.permissionssample.action.data.ContactData;
import com.cesarvaliente.permissionssample.action.data.mapper.ContactDataMapper;
do {
String contactId = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Contacts._ID));
Cursor emails = getEmailsCursor(contactId);
Cursor phones = getPHoneCursor(contactId);
if (isCursorValid(emails) && isCursorValid(phones)) {
String name = contactsCursor.getString(contactsCursor.getColumnIndex(
ContactsContract.Data.DISPLAY_NAME));
String emailAddress = emails.getString(emails.getColumnIndex(ContactsContract
.CommonDataKinds.Email.DATA));
String phone = phones.getString(phones.getColumnIndex(
ContactsContract.CommonDataKinds.Phone.NUMBER));
if (!TextUtils.isEmpty(phone)) {
ContactData contactData = new ContactData(contactId, name, phone);
contactData.setEmail(emailAddress);
contactDataList.add(contactData);
}
}
closeCursor(emails);
closeCursor(phones);
} while (contactsCursor.moveToNext());
}
closeCursor(contactsCursor);
notifyOnSuccess(contactDataList, dataCallback);
}
private void notifyOnSuccess(List<ContactData> contactDataList, DataCallback dataCallback) { | List<ContactEntity> contactEntityList = ContactDataMapper.transform(contactDataList); |
CesarValiente/PermissionsSample | domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
| import java.util.List;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity; | /**
* Copyright (C) 2015 Fernando Cejas Open Source Project
*
* 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.cesarvaliente.permissionsample.domain.usecase;
/**
* Created by Cesar on 24/09/15.
*/
public interface ListContactsUseCase extends UseCase {
interface UiCallbacks { | // Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/entity/ContactEntity.java
// public class ContactEntity {
//
// private String id;
// private String name;
// private String email;
// private String phone;
//
// public ContactEntity(String id, String name, String phone) {
// this.id = id;
// this.name = name;
// this.phone = phone;
// }
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("ContactEntity --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
// }
// Path: domain/src/main/java/com/cesarvaliente/permissionsample/domain/usecase/ListContactsUseCase.java
import java.util.List;
import com.cesarvaliente.permissionsample.domain.entity.ContactEntity;
/**
* Copyright (C) 2015 Fernando Cejas Open Source Project
*
* 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.cesarvaliente.permissionsample.domain.usecase;
/**
* Created by Cesar on 24/09/15.
*/
public interface ListContactsUseCase extends UseCase {
interface UiCallbacks { | void onComplete(List<ContactEntity> contactEntity); |
CesarValiente/PermissionsSample | app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contactlist/recyclerview/Adapter.java | // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/utils/ImageUtils.java
// public class ImageUtils {
//
// public static void loadImage(Context context, Uri uri, ImageView imageView, int width, int height) {
// Picasso.with(context).load(uri).placeholder(R.mipmap.ic_launcher).resize(width, height).into(imageView);
// }
//
// }
| import java.util.List;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.cesarvaliente.permissionssample.R;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
import com.cesarvaliente.permissionssample.presentation.utils.ImageUtils; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.view.contactlist.recyclerview;
/**
* Created by Cesar on 06/09/15.
*/
public class Adapter extends RecyclerView.Adapter<Adapter.ContactViewHolder> {
private Context context; | // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/utils/ImageUtils.java
// public class ImageUtils {
//
// public static void loadImage(Context context, Uri uri, ImageView imageView, int width, int height) {
// Picasso.with(context).load(uri).placeholder(R.mipmap.ic_launcher).resize(width, height).into(imageView);
// }
//
// }
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contactlist/recyclerview/Adapter.java
import java.util.List;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.cesarvaliente.permissionssample.R;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
import com.cesarvaliente.permissionssample.presentation.utils.ImageUtils;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.view.contactlist.recyclerview;
/**
* Created by Cesar on 06/09/15.
*/
public class Adapter extends RecyclerView.Adapter<Adapter.ContactViewHolder> {
private Context context; | private List<ContactModel> contactsList; |
CesarValiente/PermissionsSample | app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contactlist/recyclerview/Adapter.java | // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/utils/ImageUtils.java
// public class ImageUtils {
//
// public static void loadImage(Context context, Uri uri, ImageView imageView, int width, int height) {
// Picasso.with(context).load(uri).placeholder(R.mipmap.ic_launcher).resize(width, height).into(imageView);
// }
//
// }
| import java.util.List;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.cesarvaliente.permissionssample.R;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
import com.cesarvaliente.permissionssample.presentation.utils.ImageUtils; | /**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.view.contactlist.recyclerview;
/**
* Created by Cesar on 06/09/15.
*/
public class Adapter extends RecyclerView.Adapter<Adapter.ContactViewHolder> {
private Context context;
private List<ContactModel> contactsList;
public Adapter(Context context, List<ContactModel> contactsList) {
this.context = context;
this.contactsList = contactsList;
}
@Override
public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.contact_cardview, parent, false);
return new ContactViewHolder(view);
}
@Override
public void onBindViewHolder(ContactViewHolder holder, int position) {
ContactModel contact = contactsList.get(position);
holder.name.setText(contact.getName());
holder.email.setText(contact.getEmail());
holder.phone.setText(contact.getPhone());
int width = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_width);
int height = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_height); | // Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/model/ContactModel.java
// public class ContactModel implements Parcelable {
//
// private String name;
// private String email;
// private String phone;
// private Uri imageUri;
//
// public ContactModel(String name, String phone) {
// this.name = name;
// this.phone = phone;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
//
// public Uri getImageUri() {
// return imageUri;
// }
//
// public void setImageUri(Uri imageUri) {
// this.imageUri = imageUri;
// }
//
// @Override
// public String toString() {
// StringBuilder builder = new StringBuilder("Contact --> ");
// builder.append(name).append(" - ").append(email).append(" - ").append(phone);
// return builder.toString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeString(this.name);
// dest.writeString(this.email);
// dest.writeString(this.phone);
// dest.writeParcelable(this.imageUri, 0);
// }
//
// private ContactModel(Parcel in) {
// this.name = in.readString();
// this.email = in.readString();
// this.phone = in.readString();
// this.imageUri = in.readParcelable(Uri.class.getClassLoader());
// }
//
// public static final Creator<ContactModel> CREATOR = new Creator<ContactModel>() {
// public ContactModel createFromParcel(Parcel source) {
// return new ContactModel(source);
// }
//
// public ContactModel[] newArray(int size) {
// return new ContactModel[size];
// }
// };
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/utils/ImageUtils.java
// public class ImageUtils {
//
// public static void loadImage(Context context, Uri uri, ImageView imageView, int width, int height) {
// Picasso.with(context).load(uri).placeholder(R.mipmap.ic_launcher).resize(width, height).into(imageView);
// }
//
// }
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contactlist/recyclerview/Adapter.java
import java.util.List;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import com.cesarvaliente.permissionssample.R;
import com.cesarvaliente.permissionssample.presentation.model.ContactModel;
import com.cesarvaliente.permissionssample.presentation.utils.ImageUtils;
/**
* Copyright (C) 2015 Cesar Valiente ([email protected])
*
* 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.cesarvaliente.permissionssample.presentation.view.contactlist.recyclerview;
/**
* Created by Cesar on 06/09/15.
*/
public class Adapter extends RecyclerView.Adapter<Adapter.ContactViewHolder> {
private Context context;
private List<ContactModel> contactsList;
public Adapter(Context context, List<ContactModel> contactsList) {
this.context = context;
this.contactsList = contactsList;
}
@Override
public ContactViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.contact_cardview, parent, false);
return new ContactViewHolder(view);
}
@Override
public void onBindViewHolder(ContactViewHolder holder, int position) {
ContactModel contact = contactsList.get(position);
holder.name.setText(contact.getName());
holder.email.setText(contact.getEmail());
holder.phone.setText(contact.getPhone());
int width = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_width);
int height = context.getResources().getDimensionPixelOffset(R.dimen.contacts_photo_height); | ImageUtils.loadImage(context, contact.getImageUri(), holder.photo, width, height); |
CesarValiente/PermissionsSample | app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/ContactPresenter.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/SMSAction.java
// public interface SMSAction {
// String SMS_SENT = "SMS_SENT";
// String SMS_DELIVERED = "SMS_DELIVERED";
//
// void sendSMS(String phoneNumber, String message);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCase.java
// public interface ImageUseCase extends UseCase {
//
// interface Callbacks {
// void onComplete(boolean result);
//
// void onError(String message);
// }
//
// void execute(android.net.Uri imageUri, String contactName, Callbacks callbacks);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contact/ContactView.java
// public interface ContactView {
// void imageSaved(boolean result);
// }
| import android.net.Uri;
import com.cesarvaliente.permissionssample.action.SMSAction;
import com.cesarvaliente.permissionssample.action.usecase.ImageUseCase;
import com.cesarvaliente.permissionssample.presentation.view.contact.ContactView; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 12/09/15.
*/
public class ContactPresenter {
private ContactView contactView; | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/SMSAction.java
// public interface SMSAction {
// String SMS_SENT = "SMS_SENT";
// String SMS_DELIVERED = "SMS_DELIVERED";
//
// void sendSMS(String phoneNumber, String message);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCase.java
// public interface ImageUseCase extends UseCase {
//
// interface Callbacks {
// void onComplete(boolean result);
//
// void onError(String message);
// }
//
// void execute(android.net.Uri imageUri, String contactName, Callbacks callbacks);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contact/ContactView.java
// public interface ContactView {
// void imageSaved(boolean result);
// }
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/ContactPresenter.java
import android.net.Uri;
import com.cesarvaliente.permissionssample.action.SMSAction;
import com.cesarvaliente.permissionssample.action.usecase.ImageUseCase;
import com.cesarvaliente.permissionssample.presentation.view.contact.ContactView;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 12/09/15.
*/
public class ContactPresenter {
private ContactView contactView; | private ImageUseCase useCase; |
CesarValiente/PermissionsSample | app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/ContactPresenter.java | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/SMSAction.java
// public interface SMSAction {
// String SMS_SENT = "SMS_SENT";
// String SMS_DELIVERED = "SMS_DELIVERED";
//
// void sendSMS(String phoneNumber, String message);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCase.java
// public interface ImageUseCase extends UseCase {
//
// interface Callbacks {
// void onComplete(boolean result);
//
// void onError(String message);
// }
//
// void execute(android.net.Uri imageUri, String contactName, Callbacks callbacks);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contact/ContactView.java
// public interface ContactView {
// void imageSaved(boolean result);
// }
| import android.net.Uri;
import com.cesarvaliente.permissionssample.action.SMSAction;
import com.cesarvaliente.permissionssample.action.usecase.ImageUseCase;
import com.cesarvaliente.permissionssample.presentation.view.contact.ContactView; | /**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 12/09/15.
*/
public class ContactPresenter {
private ContactView contactView;
private ImageUseCase useCase; | // Path: action/src/main/java/com/cesarvaliente/permissionssample/action/SMSAction.java
// public interface SMSAction {
// String SMS_SENT = "SMS_SENT";
// String SMS_DELIVERED = "SMS_DELIVERED";
//
// void sendSMS(String phoneNumber, String message);
// }
//
// Path: action/src/main/java/com/cesarvaliente/permissionssample/action/usecase/ImageUseCase.java
// public interface ImageUseCase extends UseCase {
//
// interface Callbacks {
// void onComplete(boolean result);
//
// void onError(String message);
// }
//
// void execute(android.net.Uri imageUri, String contactName, Callbacks callbacks);
// }
//
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/view/contact/ContactView.java
// public interface ContactView {
// void imageSaved(boolean result);
// }
// Path: app/src/main/java/com/cesarvaliente/permissionssample/presentation/presenter/ContactPresenter.java
import android.net.Uri;
import com.cesarvaliente.permissionssample.action.SMSAction;
import com.cesarvaliente.permissionssample.action.usecase.ImageUseCase;
import com.cesarvaliente.permissionssample.presentation.view.contact.ContactView;
/**
* Copyright (C) 2015 Cesar Valiente based in the code of Fernando Cejas
* https://github.com/android10/Android-CleanArchitecture
*
* 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.cesarvaliente.permissionssample.presentation.presenter;
/**
* Created by Cesar on 12/09/15.
*/
public class ContactPresenter {
private ContactView contactView;
private ImageUseCase useCase; | private SMSAction smsAction; |
cocaine/cocaine-framework-java | cocaine-client/src/test/java/cocaine/msgpack/ServiceInfoTemplateTest.java | // Path: cocaine-client/src/main/java/cocaine/ServiceInfo.java
// public class ServiceInfo {
//
// private final String name;
// private final SocketAddress endpoint;
// private final ServiceApi api;
//
// public ServiceInfo(String name, SocketAddress endpoint, ServiceApi api) {
// this.name = name;
// this.endpoint = endpoint;
// this.api = api;
// }
//
// public String getName() {
// return name;
// }
//
// public SocketAddress getEndpoint() {
// return endpoint;
// }
//
// public ServiceApi getApi() {
// return api;
// }
//
// @Override
// public String toString() {
// return "Service: " + name + "; Endpoint: " + endpoint + "; Service API: { " + api.toString() + " }";
// }
// }
| import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import cocaine.ServiceInfo;
import org.junit.Assert;
import org.junit.Test;
import org.msgpack.MessagePack; | package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class ServiceInfoTemplateTest {
@Test
public void read() throws IOException {
String service = "locator";
SocketAddress endpoint = new InetSocketAddress("localhost", 3456);
long session = 0L;
Map<Integer, String> api = Collections.singletonMap(0, "invoke");
MessagePack pack = new MessagePack();
pack.register(SocketAddress.class, SocketAddressTemplate.getInstance());
byte[] bytes = pack.write(Arrays.asList(endpoint, session, api));
| // Path: cocaine-client/src/main/java/cocaine/ServiceInfo.java
// public class ServiceInfo {
//
// private final String name;
// private final SocketAddress endpoint;
// private final ServiceApi api;
//
// public ServiceInfo(String name, SocketAddress endpoint, ServiceApi api) {
// this.name = name;
// this.endpoint = endpoint;
// this.api = api;
// }
//
// public String getName() {
// return name;
// }
//
// public SocketAddress getEndpoint() {
// return endpoint;
// }
//
// public ServiceApi getApi() {
// return api;
// }
//
// @Override
// public String toString() {
// return "Service: " + name + "; Endpoint: " + endpoint + "; Service API: { " + api.toString() + " }";
// }
// }
// Path: cocaine-client/src/test/java/cocaine/msgpack/ServiceInfoTemplateTest.java
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import cocaine.ServiceInfo;
import org.junit.Assert;
import org.junit.Test;
import org.msgpack.MessagePack;
package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class ServiceInfoTemplateTest {
@Test
public void read() throws IOException {
String service = "locator";
SocketAddress endpoint = new InetSocketAddress("localhost", 3456);
long session = 0L;
Map<Integer, String> api = Collections.singletonMap(0, "invoke");
MessagePack pack = new MessagePack();
pack.register(SocketAddress.class, SocketAddressTemplate.getInstance());
byte[] bytes = pack.write(Arrays.asList(endpoint, session, api));
| ServiceInfo result = pack.read(bytes, ServiceInfoTemplate.create(service)); |
cocaine/cocaine-framework-java | cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java | // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer; | package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
| // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
// Path: cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer;
package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
| Class<? extends CocaineSerializer> serializer() default MessagePackSerializer.class; |
cocaine/cocaine-framework-java | cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java | // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer; | package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
| // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
// Path: cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer;
package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
| Class<? extends CocaineSerializer> serializer() default MessagePackSerializer.class; |
cocaine/cocaine-framework-java | cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java | // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer; | package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
Class<? extends CocaineSerializer> serializer() default MessagePackSerializer.class;
| // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
// Path: cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer;
package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
Class<? extends CocaineSerializer> serializer() default MessagePackSerializer.class;
| Class<? extends CocaineDeserializer> deserializer() default MessagePackDeserializer.class; |
cocaine/cocaine-framework-java | cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java | // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
| import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer; | package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
Class<? extends CocaineSerializer> serializer() default MessagePackSerializer.class;
| // Path: cocaine-services/src/main/java/cocaine/CocaineDeserializer.java
// public interface CocaineDeserializer {
//
// <T> T deserialize(byte[] bytes, Type type) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/CocaineSerializer.java
// public interface CocaineSerializer {
//
// byte[] serialize(Parameter[] parameters, Object[] values) throws IOException;
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackDeserializer.java
// public class MessagePackDeserializer implements CocaineDeserializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackDeserializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public <T> T deserialize(byte[] bytes, Type type) throws IOException {
// Template<T> template = (Template<T>) messagePack.lookup(type);
// return messagePack.read(bytes, template);
// }
//
// }
//
// Path: cocaine-services/src/main/java/cocaine/MessagePackSerializer.java
// public class MessagePackSerializer extends BaseSerializer {
//
// private final MessagePack messagePack;
//
// @Inject
// public MessagePackSerializer(MessagePack messagePack) {
// this.messagePack = messagePack;
// }
//
// @Override
// public byte[] serialize(Object data) throws IOException {
// return messagePack.write(data);
// }
//
// }
// Path: cocaine-services/src/main/java/cocaine/annotations/CocaineMethod.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import cocaine.CocaineDeserializer;
import cocaine.CocaineSerializer;
import cocaine.MessagePackDeserializer;
import cocaine.MessagePackSerializer;
package cocaine.annotations;
/**
* @author Anton Bobukh <[email protected]>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface CocaineMethod {
String value() default "";
Class<? extends CocaineSerializer> serializer() default MessagePackSerializer.class;
| Class<? extends CocaineDeserializer> deserializer() default MessagePackDeserializer.class; |
cocaine/cocaine-framework-java | cocaine-client/src/main/java/cocaine/netty/MessageDecoder.java | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/msgpack/MessageTemplate.java
// public final class MessageTemplate extends AbstractTemplate<Message> {
//
// private static final Template<Message> instance = new MessageTemplate();
//
// private MessageTemplate() { }
//
// public static Template<Message> getInstance() {
// return instance;
// }
//
// @Override
// public void write(Packer packer, Message message, boolean required) throws IOException {
// packer.writeArrayBegin(3);
// packer.write(message.getType().value());
// packer.write(message.getSession());
//
// switch (message.getType()) {
// case HANDSHAKE: {
// HandshakeMessage handshakeMessage = (HandshakeMessage) message;
// packer.writeArrayBegin(1);
// UUIDTemplate.getInstance().write(packer, handshakeMessage.getId());
// packer.writeArrayEnd();
// break;
// }
// case TERMINATE: {
// TerminateMessage terminateMessage = (TerminateMessage) message;
// packer.writeArrayBegin(2);
// packer.write(terminateMessage.getReason().value());
// packer.write(terminateMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case INVOKE: {
// InvokeMessage invokeMessage = (InvokeMessage) message;
// packer.writeArrayBegin(1);
// packer.write(invokeMessage.getEvent());
// packer.writeArrayEnd();
// break;
// }
// case CHUNK: {
// ChunkMessage chunkMessage = (ChunkMessage) message;
// packer.writeArrayBegin(1);
// packer.write(chunkMessage.getData());
// packer.writeArrayEnd();
// break;
// }
// case ERROR: {
// ErrorMessage errorMessage = (ErrorMessage) message;
// packer.writeArrayBegin(2);
// packer.write(errorMessage.getCode());
// packer.write(errorMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case HEARTBEAT:
// case CHOKE: {
// packer.writeArrayBegin(0);
// packer.writeArrayEnd();
// break;
// }
// }
//
// packer.writeArrayEnd();
// }
//
// @Override
// public Message read(Unpacker unpacker, Message message, boolean required) throws IOException {
// Message result;
//
// unpacker.readArrayBegin();
// MessageType type = MessageType.fromValue(unpacker.readInt());
// long session = unpacker.readLong();
//
// unpacker.readArrayBegin();
// switch (type) {
// case HANDSHAKE: {
// UUID id = unpacker.read(UUIDTemplate.getInstance());
// result = Messages.handshake(id);
// break;
// }
// case HEARTBEAT: {
// result = Messages.heartbeat();
// break;
// }
// case TERMINATE: {
// TerminateMessage.Reason reason = TerminateMessage.Reason.fromValue(unpacker.readInt());
// String msg = unpacker.readString();
// result = Messages.terminate(reason, msg);
// break;
// }
// case INVOKE: {
// String event = unpacker.readString();
// result = Messages.invoke(session, event);
// break;
// }
// case CHUNK: {
// byte[] data = unpacker.readByteArray();
// result = Messages.chunk(session, data);
// break;
// }
// case ERROR: {
// int code = unpacker.readInt();
// String msg = unpacker.readString();
// result = Messages.error(session, code, msg);
// break;
// }
// case CHOKE: {
// result = Messages.choke(session);
// break;
// }
// default: {
// throw new IllegalArgumentException("Unknown message type: " + type.name());
// }
// }
// unpacker.readArrayEnd();
// unpacker.readArrayEnd();
//
// return result;
// }
//
// }
| import java.io.EOFException;
import java.nio.ByteBuffer;
import java.util.List;
import cocaine.message.Message;
import cocaine.msgpack.MessageTemplate;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.apache.log4j.Logger;
import org.msgpack.MessagePack; | package cocaine.netty;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageDecoder extends ByteToMessageDecoder {
private static final Logger logger = Logger.getLogger(MessageDecoder.class);
private final MessagePack pack;
public MessageDecoder(MessagePack pack) {
this.pack = pack;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
logger.debug("Decoding message");
in.markReaderIndex();
ByteBuffer buffer = in.nioBuffer();
try { | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/msgpack/MessageTemplate.java
// public final class MessageTemplate extends AbstractTemplate<Message> {
//
// private static final Template<Message> instance = new MessageTemplate();
//
// private MessageTemplate() { }
//
// public static Template<Message> getInstance() {
// return instance;
// }
//
// @Override
// public void write(Packer packer, Message message, boolean required) throws IOException {
// packer.writeArrayBegin(3);
// packer.write(message.getType().value());
// packer.write(message.getSession());
//
// switch (message.getType()) {
// case HANDSHAKE: {
// HandshakeMessage handshakeMessage = (HandshakeMessage) message;
// packer.writeArrayBegin(1);
// UUIDTemplate.getInstance().write(packer, handshakeMessage.getId());
// packer.writeArrayEnd();
// break;
// }
// case TERMINATE: {
// TerminateMessage terminateMessage = (TerminateMessage) message;
// packer.writeArrayBegin(2);
// packer.write(terminateMessage.getReason().value());
// packer.write(terminateMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case INVOKE: {
// InvokeMessage invokeMessage = (InvokeMessage) message;
// packer.writeArrayBegin(1);
// packer.write(invokeMessage.getEvent());
// packer.writeArrayEnd();
// break;
// }
// case CHUNK: {
// ChunkMessage chunkMessage = (ChunkMessage) message;
// packer.writeArrayBegin(1);
// packer.write(chunkMessage.getData());
// packer.writeArrayEnd();
// break;
// }
// case ERROR: {
// ErrorMessage errorMessage = (ErrorMessage) message;
// packer.writeArrayBegin(2);
// packer.write(errorMessage.getCode());
// packer.write(errorMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case HEARTBEAT:
// case CHOKE: {
// packer.writeArrayBegin(0);
// packer.writeArrayEnd();
// break;
// }
// }
//
// packer.writeArrayEnd();
// }
//
// @Override
// public Message read(Unpacker unpacker, Message message, boolean required) throws IOException {
// Message result;
//
// unpacker.readArrayBegin();
// MessageType type = MessageType.fromValue(unpacker.readInt());
// long session = unpacker.readLong();
//
// unpacker.readArrayBegin();
// switch (type) {
// case HANDSHAKE: {
// UUID id = unpacker.read(UUIDTemplate.getInstance());
// result = Messages.handshake(id);
// break;
// }
// case HEARTBEAT: {
// result = Messages.heartbeat();
// break;
// }
// case TERMINATE: {
// TerminateMessage.Reason reason = TerminateMessage.Reason.fromValue(unpacker.readInt());
// String msg = unpacker.readString();
// result = Messages.terminate(reason, msg);
// break;
// }
// case INVOKE: {
// String event = unpacker.readString();
// result = Messages.invoke(session, event);
// break;
// }
// case CHUNK: {
// byte[] data = unpacker.readByteArray();
// result = Messages.chunk(session, data);
// break;
// }
// case ERROR: {
// int code = unpacker.readInt();
// String msg = unpacker.readString();
// result = Messages.error(session, code, msg);
// break;
// }
// case CHOKE: {
// result = Messages.choke(session);
// break;
// }
// default: {
// throw new IllegalArgumentException("Unknown message type: " + type.name());
// }
// }
// unpacker.readArrayEnd();
// unpacker.readArrayEnd();
//
// return result;
// }
//
// }
// Path: cocaine-client/src/main/java/cocaine/netty/MessageDecoder.java
import java.io.EOFException;
import java.nio.ByteBuffer;
import java.util.List;
import cocaine.message.Message;
import cocaine.msgpack.MessageTemplate;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.apache.log4j.Logger;
import org.msgpack.MessagePack;
package cocaine.netty;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageDecoder extends ByteToMessageDecoder {
private static final Logger logger = Logger.getLogger(MessageDecoder.class);
private final MessagePack pack;
public MessageDecoder(MessagePack pack) {
this.pack = pack;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
logger.debug("Decoding message");
in.markReaderIndex();
ByteBuffer buffer = in.nioBuffer();
try { | Message message = pack.read(buffer, MessageTemplate.getInstance()); |
cocaine/cocaine-framework-java | cocaine-client/src/main/java/cocaine/netty/MessageDecoder.java | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/msgpack/MessageTemplate.java
// public final class MessageTemplate extends AbstractTemplate<Message> {
//
// private static final Template<Message> instance = new MessageTemplate();
//
// private MessageTemplate() { }
//
// public static Template<Message> getInstance() {
// return instance;
// }
//
// @Override
// public void write(Packer packer, Message message, boolean required) throws IOException {
// packer.writeArrayBegin(3);
// packer.write(message.getType().value());
// packer.write(message.getSession());
//
// switch (message.getType()) {
// case HANDSHAKE: {
// HandshakeMessage handshakeMessage = (HandshakeMessage) message;
// packer.writeArrayBegin(1);
// UUIDTemplate.getInstance().write(packer, handshakeMessage.getId());
// packer.writeArrayEnd();
// break;
// }
// case TERMINATE: {
// TerminateMessage terminateMessage = (TerminateMessage) message;
// packer.writeArrayBegin(2);
// packer.write(terminateMessage.getReason().value());
// packer.write(terminateMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case INVOKE: {
// InvokeMessage invokeMessage = (InvokeMessage) message;
// packer.writeArrayBegin(1);
// packer.write(invokeMessage.getEvent());
// packer.writeArrayEnd();
// break;
// }
// case CHUNK: {
// ChunkMessage chunkMessage = (ChunkMessage) message;
// packer.writeArrayBegin(1);
// packer.write(chunkMessage.getData());
// packer.writeArrayEnd();
// break;
// }
// case ERROR: {
// ErrorMessage errorMessage = (ErrorMessage) message;
// packer.writeArrayBegin(2);
// packer.write(errorMessage.getCode());
// packer.write(errorMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case HEARTBEAT:
// case CHOKE: {
// packer.writeArrayBegin(0);
// packer.writeArrayEnd();
// break;
// }
// }
//
// packer.writeArrayEnd();
// }
//
// @Override
// public Message read(Unpacker unpacker, Message message, boolean required) throws IOException {
// Message result;
//
// unpacker.readArrayBegin();
// MessageType type = MessageType.fromValue(unpacker.readInt());
// long session = unpacker.readLong();
//
// unpacker.readArrayBegin();
// switch (type) {
// case HANDSHAKE: {
// UUID id = unpacker.read(UUIDTemplate.getInstance());
// result = Messages.handshake(id);
// break;
// }
// case HEARTBEAT: {
// result = Messages.heartbeat();
// break;
// }
// case TERMINATE: {
// TerminateMessage.Reason reason = TerminateMessage.Reason.fromValue(unpacker.readInt());
// String msg = unpacker.readString();
// result = Messages.terminate(reason, msg);
// break;
// }
// case INVOKE: {
// String event = unpacker.readString();
// result = Messages.invoke(session, event);
// break;
// }
// case CHUNK: {
// byte[] data = unpacker.readByteArray();
// result = Messages.chunk(session, data);
// break;
// }
// case ERROR: {
// int code = unpacker.readInt();
// String msg = unpacker.readString();
// result = Messages.error(session, code, msg);
// break;
// }
// case CHOKE: {
// result = Messages.choke(session);
// break;
// }
// default: {
// throw new IllegalArgumentException("Unknown message type: " + type.name());
// }
// }
// unpacker.readArrayEnd();
// unpacker.readArrayEnd();
//
// return result;
// }
//
// }
| import java.io.EOFException;
import java.nio.ByteBuffer;
import java.util.List;
import cocaine.message.Message;
import cocaine.msgpack.MessageTemplate;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.apache.log4j.Logger;
import org.msgpack.MessagePack; | package cocaine.netty;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageDecoder extends ByteToMessageDecoder {
private static final Logger logger = Logger.getLogger(MessageDecoder.class);
private final MessagePack pack;
public MessageDecoder(MessagePack pack) {
this.pack = pack;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
logger.debug("Decoding message");
in.markReaderIndex();
ByteBuffer buffer = in.nioBuffer();
try { | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/msgpack/MessageTemplate.java
// public final class MessageTemplate extends AbstractTemplate<Message> {
//
// private static final Template<Message> instance = new MessageTemplate();
//
// private MessageTemplate() { }
//
// public static Template<Message> getInstance() {
// return instance;
// }
//
// @Override
// public void write(Packer packer, Message message, boolean required) throws IOException {
// packer.writeArrayBegin(3);
// packer.write(message.getType().value());
// packer.write(message.getSession());
//
// switch (message.getType()) {
// case HANDSHAKE: {
// HandshakeMessage handshakeMessage = (HandshakeMessage) message;
// packer.writeArrayBegin(1);
// UUIDTemplate.getInstance().write(packer, handshakeMessage.getId());
// packer.writeArrayEnd();
// break;
// }
// case TERMINATE: {
// TerminateMessage terminateMessage = (TerminateMessage) message;
// packer.writeArrayBegin(2);
// packer.write(terminateMessage.getReason().value());
// packer.write(terminateMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case INVOKE: {
// InvokeMessage invokeMessage = (InvokeMessage) message;
// packer.writeArrayBegin(1);
// packer.write(invokeMessage.getEvent());
// packer.writeArrayEnd();
// break;
// }
// case CHUNK: {
// ChunkMessage chunkMessage = (ChunkMessage) message;
// packer.writeArrayBegin(1);
// packer.write(chunkMessage.getData());
// packer.writeArrayEnd();
// break;
// }
// case ERROR: {
// ErrorMessage errorMessage = (ErrorMessage) message;
// packer.writeArrayBegin(2);
// packer.write(errorMessage.getCode());
// packer.write(errorMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case HEARTBEAT:
// case CHOKE: {
// packer.writeArrayBegin(0);
// packer.writeArrayEnd();
// break;
// }
// }
//
// packer.writeArrayEnd();
// }
//
// @Override
// public Message read(Unpacker unpacker, Message message, boolean required) throws IOException {
// Message result;
//
// unpacker.readArrayBegin();
// MessageType type = MessageType.fromValue(unpacker.readInt());
// long session = unpacker.readLong();
//
// unpacker.readArrayBegin();
// switch (type) {
// case HANDSHAKE: {
// UUID id = unpacker.read(UUIDTemplate.getInstance());
// result = Messages.handshake(id);
// break;
// }
// case HEARTBEAT: {
// result = Messages.heartbeat();
// break;
// }
// case TERMINATE: {
// TerminateMessage.Reason reason = TerminateMessage.Reason.fromValue(unpacker.readInt());
// String msg = unpacker.readString();
// result = Messages.terminate(reason, msg);
// break;
// }
// case INVOKE: {
// String event = unpacker.readString();
// result = Messages.invoke(session, event);
// break;
// }
// case CHUNK: {
// byte[] data = unpacker.readByteArray();
// result = Messages.chunk(session, data);
// break;
// }
// case ERROR: {
// int code = unpacker.readInt();
// String msg = unpacker.readString();
// result = Messages.error(session, code, msg);
// break;
// }
// case CHOKE: {
// result = Messages.choke(session);
// break;
// }
// default: {
// throw new IllegalArgumentException("Unknown message type: " + type.name());
// }
// }
// unpacker.readArrayEnd();
// unpacker.readArrayEnd();
//
// return result;
// }
//
// }
// Path: cocaine-client/src/main/java/cocaine/netty/MessageDecoder.java
import java.io.EOFException;
import java.nio.ByteBuffer;
import java.util.List;
import cocaine.message.Message;
import cocaine.msgpack.MessageTemplate;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.apache.log4j.Logger;
import org.msgpack.MessagePack;
package cocaine.netty;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageDecoder extends ByteToMessageDecoder {
private static final Logger logger = Logger.getLogger(MessageDecoder.class);
private final MessagePack pack;
public MessageDecoder(MessagePack pack) {
this.pack = pack;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
logger.debug("Decoding message");
in.markReaderIndex();
ByteBuffer buffer = in.nioBuffer();
try { | Message message = pack.read(buffer, MessageTemplate.getInstance()); |
cocaine/cocaine-framework-java | cocaine-worker/src/main/java/cocaine/WorkerSessions.java | // Path: cocaine-core/src/main/java/cocaine/message/ErrorMessage.java
// public final class ErrorMessage extends Message {
//
// public static final class Code {
//
// // No handler for requested event
// public static final int ENOHANDLER = 200;
// // Invocation failed
// public static final int EINVFAILED = 212;
// // Service is disconnected
// public static final int ESRVDISCON = 220;
//
// private Code() { }
// }
//
// private final int code;
// private final String message;
//
// public ErrorMessage(long session, int code, String message) {
// super(MessageType.ERROR, session);
// this.code = code;
// this.message = Preconditions.checkNotNull(message, "Error message can not be null");
// }
//
// public int getCode() {
// return code;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "ErrorMessage/" + getSession() + ": " + code + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// ErrorMessage that = (ErrorMessage) o;
// return code == that.code && message.equals(that.message);
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + code;
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
| import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import cocaine.message.ErrorMessage;
import org.apache.log4j.Logger;
import rx.Observable;
import rx.Observer;
import rx.subjects.PublishSubject;
import rx.subjects.ReplaySubject;
import rx.subjects.Subject; | public long getId() {
return id;
}
public Observable<byte[]> getInput() {
return input;
}
public Observer<byte[]> getOutput() {
return output;
}
}
private static final class Writer implements Observer<byte[]> {
private final long session;
private final Worker worker;
public Writer(long session, Worker worker) {
this.session = session;
this.worker = worker;
}
@Override
public void onCompleted() {
this.worker.sendChoke(session);
}
@Override
public void onError(Throwable error) { | // Path: cocaine-core/src/main/java/cocaine/message/ErrorMessage.java
// public final class ErrorMessage extends Message {
//
// public static final class Code {
//
// // No handler for requested event
// public static final int ENOHANDLER = 200;
// // Invocation failed
// public static final int EINVFAILED = 212;
// // Service is disconnected
// public static final int ESRVDISCON = 220;
//
// private Code() { }
// }
//
// private final int code;
// private final String message;
//
// public ErrorMessage(long session, int code, String message) {
// super(MessageType.ERROR, session);
// this.code = code;
// this.message = Preconditions.checkNotNull(message, "Error message can not be null");
// }
//
// public int getCode() {
// return code;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "ErrorMessage/" + getSession() + ": " + code + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// ErrorMessage that = (ErrorMessage) o;
// return code == that.code && message.equals(that.message);
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + code;
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
// Path: cocaine-worker/src/main/java/cocaine/WorkerSessions.java
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import cocaine.message.ErrorMessage;
import org.apache.log4j.Logger;
import rx.Observable;
import rx.Observer;
import rx.subjects.PublishSubject;
import rx.subjects.ReplaySubject;
import rx.subjects.Subject;
public long getId() {
return id;
}
public Observable<byte[]> getInput() {
return input;
}
public Observer<byte[]> getOutput() {
return output;
}
}
private static final class Writer implements Observer<byte[]> {
private final long session;
private final Worker worker;
public Writer(long session, Worker worker) {
this.session = session;
this.worker = worker;
}
@Override
public void onCompleted() {
this.worker.sendChoke(session);
}
@Override
public void onError(Throwable error) { | this.worker.sendError(session, ErrorMessage.Code.EINVFAILED, error.getMessage()); |
cocaine/cocaine-framework-java | cocaine-core/src/test/java/cocaine/msgpack/MessageTemplateTest.java | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/Messages.java
// public final class Messages {
//
// public static Message handshake(UUID id) {
// return new HandshakeMessage(id);
// }
//
// public static Message heartbeat() {
// return new HeartbeatMessage();
// }
//
// public static Message terminate(TerminateMessage.Reason reason, String message) {
// return new TerminateMessage(reason, message);
// }
//
// public static Message invoke(long session, String event) {
// return new InvokeMessage(session, event);
// }
//
// public static Message chunk(long session, byte[] data) {
// return new ChunkMessage(session, data);
// }
//
// public static Message choke(long session) {
// return new ChokeMessage(session);
// }
//
// public static Message error(long session, int code, String message) {
// return new ErrorMessage(session, code, message);
// }
//
// private Messages() { }
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/TerminateMessage.java
// public final class TerminateMessage extends Message {
//
// public static enum Reason {
//
// NORMAL(1),
// ABNORMAL(2),
// ;
//
// private static final Map<Integer, Reason> mapping =
// Maps.uniqueIndex(Arrays.asList(Reason.values()), Reason.valueF());
//
// private final int value;
//
// private Reason(int value) {
// this.value = value;
// }
//
// public int value() {
// return value;
// }
//
// public static Reason fromValue(int value) {
// Reason result = mapping.get(value);
// if (result == null) {
// throw new IllegalArgumentException("Reason " + value + " does not exist");
// }
// return result;
// }
//
// public static Function<Reason, Integer> valueF() {
// return new Function<Reason, Integer>() {
// @Override
// public Integer apply(Reason reason) {
// return reason.value();
// }
// };
// }
// }
//
// private final Reason reason;
// private final String message;
//
// public TerminateMessage(Reason reason, String message) {
// super(MessageType.TERMINATE);
// this.reason = Preconditions.checkNotNull(reason, "Termination reason can not be null");
// this.message = Preconditions.checkNotNull(message, "Message can not be null");
// }
//
// public Reason getReason() {
// return reason;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "TerminateMessage/" + getSession() + ": " + reason.name() + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// TerminateMessage that = (TerminateMessage) o;
// return message.equals(that.message) && reason == that.reason;
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + reason.hashCode();
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
| import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
import cocaine.message.Message;
import cocaine.message.Messages;
import cocaine.message.TerminateMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.msgpack.MessagePack; | package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageTemplateTest {
private MessagePack pack;
@Before
public void setUp() {
this.pack = new MessagePack();
this.pack.register(UUID.class, UUIDTemplate.getInstance());
}
@Test
public void writeHandshakeMessage() throws IOException {
UUID uuid = UUID.randomUUID(); | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/Messages.java
// public final class Messages {
//
// public static Message handshake(UUID id) {
// return new HandshakeMessage(id);
// }
//
// public static Message heartbeat() {
// return new HeartbeatMessage();
// }
//
// public static Message terminate(TerminateMessage.Reason reason, String message) {
// return new TerminateMessage(reason, message);
// }
//
// public static Message invoke(long session, String event) {
// return new InvokeMessage(session, event);
// }
//
// public static Message chunk(long session, byte[] data) {
// return new ChunkMessage(session, data);
// }
//
// public static Message choke(long session) {
// return new ChokeMessage(session);
// }
//
// public static Message error(long session, int code, String message) {
// return new ErrorMessage(session, code, message);
// }
//
// private Messages() { }
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/TerminateMessage.java
// public final class TerminateMessage extends Message {
//
// public static enum Reason {
//
// NORMAL(1),
// ABNORMAL(2),
// ;
//
// private static final Map<Integer, Reason> mapping =
// Maps.uniqueIndex(Arrays.asList(Reason.values()), Reason.valueF());
//
// private final int value;
//
// private Reason(int value) {
// this.value = value;
// }
//
// public int value() {
// return value;
// }
//
// public static Reason fromValue(int value) {
// Reason result = mapping.get(value);
// if (result == null) {
// throw new IllegalArgumentException("Reason " + value + " does not exist");
// }
// return result;
// }
//
// public static Function<Reason, Integer> valueF() {
// return new Function<Reason, Integer>() {
// @Override
// public Integer apply(Reason reason) {
// return reason.value();
// }
// };
// }
// }
//
// private final Reason reason;
// private final String message;
//
// public TerminateMessage(Reason reason, String message) {
// super(MessageType.TERMINATE);
// this.reason = Preconditions.checkNotNull(reason, "Termination reason can not be null");
// this.message = Preconditions.checkNotNull(message, "Message can not be null");
// }
//
// public Reason getReason() {
// return reason;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "TerminateMessage/" + getSession() + ": " + reason.name() + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// TerminateMessage that = (TerminateMessage) o;
// return message.equals(that.message) && reason == that.reason;
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + reason.hashCode();
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
// Path: cocaine-core/src/test/java/cocaine/msgpack/MessageTemplateTest.java
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
import cocaine.message.Message;
import cocaine.message.Messages;
import cocaine.message.TerminateMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.msgpack.MessagePack;
package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageTemplateTest {
private MessagePack pack;
@Before
public void setUp() {
this.pack = new MessagePack();
this.pack.register(UUID.class, UUIDTemplate.getInstance());
}
@Test
public void writeHandshakeMessage() throws IOException {
UUID uuid = UUID.randomUUID(); | Message msg = Messages.handshake(uuid); |
cocaine/cocaine-framework-java | cocaine-core/src/test/java/cocaine/msgpack/MessageTemplateTest.java | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/Messages.java
// public final class Messages {
//
// public static Message handshake(UUID id) {
// return new HandshakeMessage(id);
// }
//
// public static Message heartbeat() {
// return new HeartbeatMessage();
// }
//
// public static Message terminate(TerminateMessage.Reason reason, String message) {
// return new TerminateMessage(reason, message);
// }
//
// public static Message invoke(long session, String event) {
// return new InvokeMessage(session, event);
// }
//
// public static Message chunk(long session, byte[] data) {
// return new ChunkMessage(session, data);
// }
//
// public static Message choke(long session) {
// return new ChokeMessage(session);
// }
//
// public static Message error(long session, int code, String message) {
// return new ErrorMessage(session, code, message);
// }
//
// private Messages() { }
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/TerminateMessage.java
// public final class TerminateMessage extends Message {
//
// public static enum Reason {
//
// NORMAL(1),
// ABNORMAL(2),
// ;
//
// private static final Map<Integer, Reason> mapping =
// Maps.uniqueIndex(Arrays.asList(Reason.values()), Reason.valueF());
//
// private final int value;
//
// private Reason(int value) {
// this.value = value;
// }
//
// public int value() {
// return value;
// }
//
// public static Reason fromValue(int value) {
// Reason result = mapping.get(value);
// if (result == null) {
// throw new IllegalArgumentException("Reason " + value + " does not exist");
// }
// return result;
// }
//
// public static Function<Reason, Integer> valueF() {
// return new Function<Reason, Integer>() {
// @Override
// public Integer apply(Reason reason) {
// return reason.value();
// }
// };
// }
// }
//
// private final Reason reason;
// private final String message;
//
// public TerminateMessage(Reason reason, String message) {
// super(MessageType.TERMINATE);
// this.reason = Preconditions.checkNotNull(reason, "Termination reason can not be null");
// this.message = Preconditions.checkNotNull(message, "Message can not be null");
// }
//
// public Reason getReason() {
// return reason;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "TerminateMessage/" + getSession() + ": " + reason.name() + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// TerminateMessage that = (TerminateMessage) o;
// return message.equals(that.message) && reason == that.reason;
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + reason.hashCode();
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
| import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
import cocaine.message.Message;
import cocaine.message.Messages;
import cocaine.message.TerminateMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.msgpack.MessagePack; | package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageTemplateTest {
private MessagePack pack;
@Before
public void setUp() {
this.pack = new MessagePack();
this.pack.register(UUID.class, UUIDTemplate.getInstance());
}
@Test
public void writeHandshakeMessage() throws IOException {
UUID uuid = UUID.randomUUID(); | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/Messages.java
// public final class Messages {
//
// public static Message handshake(UUID id) {
// return new HandshakeMessage(id);
// }
//
// public static Message heartbeat() {
// return new HeartbeatMessage();
// }
//
// public static Message terminate(TerminateMessage.Reason reason, String message) {
// return new TerminateMessage(reason, message);
// }
//
// public static Message invoke(long session, String event) {
// return new InvokeMessage(session, event);
// }
//
// public static Message chunk(long session, byte[] data) {
// return new ChunkMessage(session, data);
// }
//
// public static Message choke(long session) {
// return new ChokeMessage(session);
// }
//
// public static Message error(long session, int code, String message) {
// return new ErrorMessage(session, code, message);
// }
//
// private Messages() { }
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/TerminateMessage.java
// public final class TerminateMessage extends Message {
//
// public static enum Reason {
//
// NORMAL(1),
// ABNORMAL(2),
// ;
//
// private static final Map<Integer, Reason> mapping =
// Maps.uniqueIndex(Arrays.asList(Reason.values()), Reason.valueF());
//
// private final int value;
//
// private Reason(int value) {
// this.value = value;
// }
//
// public int value() {
// return value;
// }
//
// public static Reason fromValue(int value) {
// Reason result = mapping.get(value);
// if (result == null) {
// throw new IllegalArgumentException("Reason " + value + " does not exist");
// }
// return result;
// }
//
// public static Function<Reason, Integer> valueF() {
// return new Function<Reason, Integer>() {
// @Override
// public Integer apply(Reason reason) {
// return reason.value();
// }
// };
// }
// }
//
// private final Reason reason;
// private final String message;
//
// public TerminateMessage(Reason reason, String message) {
// super(MessageType.TERMINATE);
// this.reason = Preconditions.checkNotNull(reason, "Termination reason can not be null");
// this.message = Preconditions.checkNotNull(message, "Message can not be null");
// }
//
// public Reason getReason() {
// return reason;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "TerminateMessage/" + getSession() + ": " + reason.name() + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// TerminateMessage that = (TerminateMessage) o;
// return message.equals(that.message) && reason == that.reason;
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + reason.hashCode();
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
// Path: cocaine-core/src/test/java/cocaine/msgpack/MessageTemplateTest.java
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
import cocaine.message.Message;
import cocaine.message.Messages;
import cocaine.message.TerminateMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.msgpack.MessagePack;
package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageTemplateTest {
private MessagePack pack;
@Before
public void setUp() {
this.pack = new MessagePack();
this.pack.register(UUID.class, UUIDTemplate.getInstance());
}
@Test
public void writeHandshakeMessage() throws IOException {
UUID uuid = UUID.randomUUID(); | Message msg = Messages.handshake(uuid); |
cocaine/cocaine-framework-java | cocaine-core/src/test/java/cocaine/msgpack/MessageTemplateTest.java | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/Messages.java
// public final class Messages {
//
// public static Message handshake(UUID id) {
// return new HandshakeMessage(id);
// }
//
// public static Message heartbeat() {
// return new HeartbeatMessage();
// }
//
// public static Message terminate(TerminateMessage.Reason reason, String message) {
// return new TerminateMessage(reason, message);
// }
//
// public static Message invoke(long session, String event) {
// return new InvokeMessage(session, event);
// }
//
// public static Message chunk(long session, byte[] data) {
// return new ChunkMessage(session, data);
// }
//
// public static Message choke(long session) {
// return new ChokeMessage(session);
// }
//
// public static Message error(long session, int code, String message) {
// return new ErrorMessage(session, code, message);
// }
//
// private Messages() { }
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/TerminateMessage.java
// public final class TerminateMessage extends Message {
//
// public static enum Reason {
//
// NORMAL(1),
// ABNORMAL(2),
// ;
//
// private static final Map<Integer, Reason> mapping =
// Maps.uniqueIndex(Arrays.asList(Reason.values()), Reason.valueF());
//
// private final int value;
//
// private Reason(int value) {
// this.value = value;
// }
//
// public int value() {
// return value;
// }
//
// public static Reason fromValue(int value) {
// Reason result = mapping.get(value);
// if (result == null) {
// throw new IllegalArgumentException("Reason " + value + " does not exist");
// }
// return result;
// }
//
// public static Function<Reason, Integer> valueF() {
// return new Function<Reason, Integer>() {
// @Override
// public Integer apply(Reason reason) {
// return reason.value();
// }
// };
// }
// }
//
// private final Reason reason;
// private final String message;
//
// public TerminateMessage(Reason reason, String message) {
// super(MessageType.TERMINATE);
// this.reason = Preconditions.checkNotNull(reason, "Termination reason can not be null");
// this.message = Preconditions.checkNotNull(message, "Message can not be null");
// }
//
// public Reason getReason() {
// return reason;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "TerminateMessage/" + getSession() + ": " + reason.name() + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// TerminateMessage that = (TerminateMessage) o;
// return message.equals(that.message) && reason == that.reason;
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + reason.hashCode();
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
| import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
import cocaine.message.Message;
import cocaine.message.Messages;
import cocaine.message.TerminateMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.msgpack.MessagePack; | package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageTemplateTest {
private MessagePack pack;
@Before
public void setUp() {
this.pack = new MessagePack();
this.pack.register(UUID.class, UUIDTemplate.getInstance());
}
@Test
public void writeHandshakeMessage() throws IOException {
UUID uuid = UUID.randomUUID();
Message msg = Messages.handshake(uuid);
byte[] bytes = pack.write(Arrays.asList(0, 0, Arrays.asList(uuid)));
byte[] result = pack.write(msg, MessageTemplate.getInstance());
Assert.assertArrayEquals(bytes, result);
}
@Test
public void writeHeartbeatMessage() throws IOException {
Message msg = Messages.heartbeat();
byte[] bytes = pack.write(Arrays.asList(1, 0, Arrays.asList()));
byte[] result = pack.write(msg, MessageTemplate.getInstance());
Assert.assertArrayEquals(bytes, result);
}
@Test
public void writeTerminateMessage() throws IOException {
String message = "PANIC!"; | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/Messages.java
// public final class Messages {
//
// public static Message handshake(UUID id) {
// return new HandshakeMessage(id);
// }
//
// public static Message heartbeat() {
// return new HeartbeatMessage();
// }
//
// public static Message terminate(TerminateMessage.Reason reason, String message) {
// return new TerminateMessage(reason, message);
// }
//
// public static Message invoke(long session, String event) {
// return new InvokeMessage(session, event);
// }
//
// public static Message chunk(long session, byte[] data) {
// return new ChunkMessage(session, data);
// }
//
// public static Message choke(long session) {
// return new ChokeMessage(session);
// }
//
// public static Message error(long session, int code, String message) {
// return new ErrorMessage(session, code, message);
// }
//
// private Messages() { }
// }
//
// Path: cocaine-core/src/main/java/cocaine/message/TerminateMessage.java
// public final class TerminateMessage extends Message {
//
// public static enum Reason {
//
// NORMAL(1),
// ABNORMAL(2),
// ;
//
// private static final Map<Integer, Reason> mapping =
// Maps.uniqueIndex(Arrays.asList(Reason.values()), Reason.valueF());
//
// private final int value;
//
// private Reason(int value) {
// this.value = value;
// }
//
// public int value() {
// return value;
// }
//
// public static Reason fromValue(int value) {
// Reason result = mapping.get(value);
// if (result == null) {
// throw new IllegalArgumentException("Reason " + value + " does not exist");
// }
// return result;
// }
//
// public static Function<Reason, Integer> valueF() {
// return new Function<Reason, Integer>() {
// @Override
// public Integer apply(Reason reason) {
// return reason.value();
// }
// };
// }
// }
//
// private final Reason reason;
// private final String message;
//
// public TerminateMessage(Reason reason, String message) {
// super(MessageType.TERMINATE);
// this.reason = Preconditions.checkNotNull(reason, "Termination reason can not be null");
// this.message = Preconditions.checkNotNull(message, "Message can not be null");
// }
//
// public Reason getReason() {
// return reason;
// }
//
// public String getMessage() {
// return message;
// }
//
// @Override
// public String toString() {
// return "TerminateMessage/" + getSession() + ": " + reason.name() + " - " + message;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
// if (!super.equals(o)) {
// return false;
// }
//
// TerminateMessage that = (TerminateMessage) o;
// return message.equals(that.message) && reason == that.reason;
// }
//
// @Override
// public int hashCode() {
// int result = super.hashCode();
// result = 31 * result + reason.hashCode();
// result = 31 * result + message.hashCode();
// return result;
// }
//
// }
// Path: cocaine-core/src/test/java/cocaine/msgpack/MessageTemplateTest.java
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
import cocaine.message.Message;
import cocaine.message.Messages;
import cocaine.message.TerminateMessage;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.msgpack.MessagePack;
package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageTemplateTest {
private MessagePack pack;
@Before
public void setUp() {
this.pack = new MessagePack();
this.pack.register(UUID.class, UUIDTemplate.getInstance());
}
@Test
public void writeHandshakeMessage() throws IOException {
UUID uuid = UUID.randomUUID();
Message msg = Messages.handshake(uuid);
byte[] bytes = pack.write(Arrays.asList(0, 0, Arrays.asList(uuid)));
byte[] result = pack.write(msg, MessageTemplate.getInstance());
Assert.assertArrayEquals(bytes, result);
}
@Test
public void writeHeartbeatMessage() throws IOException {
Message msg = Messages.heartbeat();
byte[] bytes = pack.write(Arrays.asList(1, 0, Arrays.asList()));
byte[] result = pack.write(msg, MessageTemplate.getInstance());
Assert.assertArrayEquals(bytes, result);
}
@Test
public void writeTerminateMessage() throws IOException {
String message = "PANIC!"; | Message msg = Messages.terminate(TerminateMessage.Reason.NORMAL, message); |
cocaine/cocaine-framework-java | cocaine-client/src/main/java/cocaine/netty/MessageEncoder.java | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/msgpack/MessageTemplate.java
// public final class MessageTemplate extends AbstractTemplate<Message> {
//
// private static final Template<Message> instance = new MessageTemplate();
//
// private MessageTemplate() { }
//
// public static Template<Message> getInstance() {
// return instance;
// }
//
// @Override
// public void write(Packer packer, Message message, boolean required) throws IOException {
// packer.writeArrayBegin(3);
// packer.write(message.getType().value());
// packer.write(message.getSession());
//
// switch (message.getType()) {
// case HANDSHAKE: {
// HandshakeMessage handshakeMessage = (HandshakeMessage) message;
// packer.writeArrayBegin(1);
// UUIDTemplate.getInstance().write(packer, handshakeMessage.getId());
// packer.writeArrayEnd();
// break;
// }
// case TERMINATE: {
// TerminateMessage terminateMessage = (TerminateMessage) message;
// packer.writeArrayBegin(2);
// packer.write(terminateMessage.getReason().value());
// packer.write(terminateMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case INVOKE: {
// InvokeMessage invokeMessage = (InvokeMessage) message;
// packer.writeArrayBegin(1);
// packer.write(invokeMessage.getEvent());
// packer.writeArrayEnd();
// break;
// }
// case CHUNK: {
// ChunkMessage chunkMessage = (ChunkMessage) message;
// packer.writeArrayBegin(1);
// packer.write(chunkMessage.getData());
// packer.writeArrayEnd();
// break;
// }
// case ERROR: {
// ErrorMessage errorMessage = (ErrorMessage) message;
// packer.writeArrayBegin(2);
// packer.write(errorMessage.getCode());
// packer.write(errorMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case HEARTBEAT:
// case CHOKE: {
// packer.writeArrayBegin(0);
// packer.writeArrayEnd();
// break;
// }
// }
//
// packer.writeArrayEnd();
// }
//
// @Override
// public Message read(Unpacker unpacker, Message message, boolean required) throws IOException {
// Message result;
//
// unpacker.readArrayBegin();
// MessageType type = MessageType.fromValue(unpacker.readInt());
// long session = unpacker.readLong();
//
// unpacker.readArrayBegin();
// switch (type) {
// case HANDSHAKE: {
// UUID id = unpacker.read(UUIDTemplate.getInstance());
// result = Messages.handshake(id);
// break;
// }
// case HEARTBEAT: {
// result = Messages.heartbeat();
// break;
// }
// case TERMINATE: {
// TerminateMessage.Reason reason = TerminateMessage.Reason.fromValue(unpacker.readInt());
// String msg = unpacker.readString();
// result = Messages.terminate(reason, msg);
// break;
// }
// case INVOKE: {
// String event = unpacker.readString();
// result = Messages.invoke(session, event);
// break;
// }
// case CHUNK: {
// byte[] data = unpacker.readByteArray();
// result = Messages.chunk(session, data);
// break;
// }
// case ERROR: {
// int code = unpacker.readInt();
// String msg = unpacker.readString();
// result = Messages.error(session, code, msg);
// break;
// }
// case CHOKE: {
// result = Messages.choke(session);
// break;
// }
// default: {
// throw new IllegalArgumentException("Unknown message type: " + type.name());
// }
// }
// unpacker.readArrayEnd();
// unpacker.readArrayEnd();
//
// return result;
// }
//
// }
| import cocaine.message.Message;
import cocaine.msgpack.MessageTemplate;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.apache.log4j.Logger;
import org.msgpack.MessagePack; | package cocaine.netty;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageEncoder extends MessageToByteEncoder<Message> {
private static final Logger logger = Logger.getLogger(MessageEncoder.class);
private final MessagePack pack;
public MessageEncoder(MessagePack pack) {
super(Message.class);
this.pack = pack;
}
@Override
protected void encode(ChannelHandlerContext ctx, Message msg, ByteBuf out) throws Exception {
logger.debug("Encoding message: " + msg); | // Path: cocaine-core/src/main/java/cocaine/message/Message.java
// public abstract class Message {
//
// private static final long SYSTEM_SESSION = 0L;
//
// private final MessageType type;
// private final long session;
//
// protected Message(MessageType type, long session) {
// this.type = type;
// this.session = session;
// }
//
// protected Message(MessageType type) {
// this(type, SYSTEM_SESSION);
// }
//
// public MessageType getType() {
// return type;
// }
//
// public long getSession() {
// return session;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) {
// return true;
// }
// if (o == null || getClass() != o.getClass()) {
// return false;
// }
//
// Message message = (Message) o;
// return session == message.session && type == message.type;
// }
//
// @Override
// public int hashCode() {
// int result = type.hashCode();
// result = 31 * result + (int) (session ^ (session >>> 32));
// return result;
// }
//
// }
//
// Path: cocaine-core/src/main/java/cocaine/msgpack/MessageTemplate.java
// public final class MessageTemplate extends AbstractTemplate<Message> {
//
// private static final Template<Message> instance = new MessageTemplate();
//
// private MessageTemplate() { }
//
// public static Template<Message> getInstance() {
// return instance;
// }
//
// @Override
// public void write(Packer packer, Message message, boolean required) throws IOException {
// packer.writeArrayBegin(3);
// packer.write(message.getType().value());
// packer.write(message.getSession());
//
// switch (message.getType()) {
// case HANDSHAKE: {
// HandshakeMessage handshakeMessage = (HandshakeMessage) message;
// packer.writeArrayBegin(1);
// UUIDTemplate.getInstance().write(packer, handshakeMessage.getId());
// packer.writeArrayEnd();
// break;
// }
// case TERMINATE: {
// TerminateMessage terminateMessage = (TerminateMessage) message;
// packer.writeArrayBegin(2);
// packer.write(terminateMessage.getReason().value());
// packer.write(terminateMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case INVOKE: {
// InvokeMessage invokeMessage = (InvokeMessage) message;
// packer.writeArrayBegin(1);
// packer.write(invokeMessage.getEvent());
// packer.writeArrayEnd();
// break;
// }
// case CHUNK: {
// ChunkMessage chunkMessage = (ChunkMessage) message;
// packer.writeArrayBegin(1);
// packer.write(chunkMessage.getData());
// packer.writeArrayEnd();
// break;
// }
// case ERROR: {
// ErrorMessage errorMessage = (ErrorMessage) message;
// packer.writeArrayBegin(2);
// packer.write(errorMessage.getCode());
// packer.write(errorMessage.getMessage());
// packer.writeArrayEnd();
// break;
// }
// case HEARTBEAT:
// case CHOKE: {
// packer.writeArrayBegin(0);
// packer.writeArrayEnd();
// break;
// }
// }
//
// packer.writeArrayEnd();
// }
//
// @Override
// public Message read(Unpacker unpacker, Message message, boolean required) throws IOException {
// Message result;
//
// unpacker.readArrayBegin();
// MessageType type = MessageType.fromValue(unpacker.readInt());
// long session = unpacker.readLong();
//
// unpacker.readArrayBegin();
// switch (type) {
// case HANDSHAKE: {
// UUID id = unpacker.read(UUIDTemplate.getInstance());
// result = Messages.handshake(id);
// break;
// }
// case HEARTBEAT: {
// result = Messages.heartbeat();
// break;
// }
// case TERMINATE: {
// TerminateMessage.Reason reason = TerminateMessage.Reason.fromValue(unpacker.readInt());
// String msg = unpacker.readString();
// result = Messages.terminate(reason, msg);
// break;
// }
// case INVOKE: {
// String event = unpacker.readString();
// result = Messages.invoke(session, event);
// break;
// }
// case CHUNK: {
// byte[] data = unpacker.readByteArray();
// result = Messages.chunk(session, data);
// break;
// }
// case ERROR: {
// int code = unpacker.readInt();
// String msg = unpacker.readString();
// result = Messages.error(session, code, msg);
// break;
// }
// case CHOKE: {
// result = Messages.choke(session);
// break;
// }
// default: {
// throw new IllegalArgumentException("Unknown message type: " + type.name());
// }
// }
// unpacker.readArrayEnd();
// unpacker.readArrayEnd();
//
// return result;
// }
//
// }
// Path: cocaine-client/src/main/java/cocaine/netty/MessageEncoder.java
import cocaine.message.Message;
import cocaine.msgpack.MessageTemplate;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.apache.log4j.Logger;
import org.msgpack.MessagePack;
package cocaine.netty;
/**
* @author Anton Bobukh <[email protected]>
*/
public class MessageEncoder extends MessageToByteEncoder<Message> {
private static final Logger logger = Logger.getLogger(MessageEncoder.class);
private final MessagePack pack;
public MessageEncoder(MessagePack pack) {
super(Message.class);
this.pack = pack;
}
@Override
protected void encode(ChannelHandlerContext ctx, Message msg, ByteBuf out) throws Exception {
logger.debug("Encoding message: " + msg); | out.writeBytes(pack.write(msg, MessageTemplate.getInstance())); |
cocaine/cocaine-framework-java | cocaine-client/src/main/java/cocaine/msgpack/ServiceInfoTemplate.java | // Path: cocaine-client/src/main/java/cocaine/ServiceApi.java
// public class ServiceApi {
//
// private final String name;
// private final ImmutableMap<String, Integer> api;
//
// public ServiceApi(String name, ImmutableMap<String, Integer> api) {
// this.name = name;
// this.api = api;
// }
//
// public static ServiceApi of(String name, String method, int id) {
// return new ServiceApi(name, ImmutableMap.of(method, id));
// }
//
// public static ServiceApi of(String name, ImmutableMap<String, Integer> methods) {
// return new ServiceApi(name, methods);
// }
//
// public int getMethod(String method) {
// Integer number = api.get(method);
// if (number == null) {
// throw new UnknownServiceMethodException(name, method);
// }
// return number;
// }
//
// @Override
// public String toString() {
// return "Service: " + name + "; Service API: { "
// + Joiner.on(", ").withKeyValueSeparator(": ").join(api) + " }";
// }
// }
//
// Path: cocaine-client/src/main/java/cocaine/ServiceInfo.java
// public class ServiceInfo {
//
// private final String name;
// private final SocketAddress endpoint;
// private final ServiceApi api;
//
// public ServiceInfo(String name, SocketAddress endpoint, ServiceApi api) {
// this.name = name;
// this.endpoint = endpoint;
// this.api = api;
// }
//
// public String getName() {
// return name;
// }
//
// public SocketAddress getEndpoint() {
// return endpoint;
// }
//
// public ServiceApi getApi() {
// return api;
// }
//
// @Override
// public String toString() {
// return "Service: " + name + "; Endpoint: " + endpoint + "; Service API: { " + api.toString() + " }";
// }
// }
| import java.io.IOException;
import java.net.SocketAddress;
import java.util.Map;
import cocaine.ServiceApi;
import cocaine.ServiceInfo;
import com.google.common.collect.ImmutableBiMap;
import org.msgpack.packer.Packer;
import org.msgpack.template.AbstractTemplate;
import org.msgpack.template.Template;
import org.msgpack.template.Templates;
import org.msgpack.unpacker.Unpacker; | package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class ServiceInfoTemplate extends AbstractTemplate<ServiceInfo> {
private final String name;
private ServiceInfoTemplate(String name) {
this.name = name;
}
public static Template<ServiceInfo> create(String name) {
return new ServiceInfoTemplate(name);
}
@Override
public void write(Packer packer, ServiceInfo service, boolean required) throws IOException {
throw new UnsupportedOperationException(ServiceInfo.class.getSimpleName()
+ " can not be encoded by " + ServiceInfoTemplate.class.getSimpleName());
}
@Override
public ServiceInfo read(Unpacker unpacker, ServiceInfo service, boolean required) throws IOException {
unpacker.readArrayBegin();
SocketAddress endpoint = unpacker.read(SocketAddressTemplate.getInstance());
unpacker.readInt();
Map<Integer, String> api = unpacker.read(Templates.tMap(Templates.TInteger, Templates.TString));
unpacker.readArrayEnd();
| // Path: cocaine-client/src/main/java/cocaine/ServiceApi.java
// public class ServiceApi {
//
// private final String name;
// private final ImmutableMap<String, Integer> api;
//
// public ServiceApi(String name, ImmutableMap<String, Integer> api) {
// this.name = name;
// this.api = api;
// }
//
// public static ServiceApi of(String name, String method, int id) {
// return new ServiceApi(name, ImmutableMap.of(method, id));
// }
//
// public static ServiceApi of(String name, ImmutableMap<String, Integer> methods) {
// return new ServiceApi(name, methods);
// }
//
// public int getMethod(String method) {
// Integer number = api.get(method);
// if (number == null) {
// throw new UnknownServiceMethodException(name, method);
// }
// return number;
// }
//
// @Override
// public String toString() {
// return "Service: " + name + "; Service API: { "
// + Joiner.on(", ").withKeyValueSeparator(": ").join(api) + " }";
// }
// }
//
// Path: cocaine-client/src/main/java/cocaine/ServiceInfo.java
// public class ServiceInfo {
//
// private final String name;
// private final SocketAddress endpoint;
// private final ServiceApi api;
//
// public ServiceInfo(String name, SocketAddress endpoint, ServiceApi api) {
// this.name = name;
// this.endpoint = endpoint;
// this.api = api;
// }
//
// public String getName() {
// return name;
// }
//
// public SocketAddress getEndpoint() {
// return endpoint;
// }
//
// public ServiceApi getApi() {
// return api;
// }
//
// @Override
// public String toString() {
// return "Service: " + name + "; Endpoint: " + endpoint + "; Service API: { " + api.toString() + " }";
// }
// }
// Path: cocaine-client/src/main/java/cocaine/msgpack/ServiceInfoTemplate.java
import java.io.IOException;
import java.net.SocketAddress;
import java.util.Map;
import cocaine.ServiceApi;
import cocaine.ServiceInfo;
import com.google.common.collect.ImmutableBiMap;
import org.msgpack.packer.Packer;
import org.msgpack.template.AbstractTemplate;
import org.msgpack.template.Template;
import org.msgpack.template.Templates;
import org.msgpack.unpacker.Unpacker;
package cocaine.msgpack;
/**
* @author Anton Bobukh <[email protected]>
*/
public class ServiceInfoTemplate extends AbstractTemplate<ServiceInfo> {
private final String name;
private ServiceInfoTemplate(String name) {
this.name = name;
}
public static Template<ServiceInfo> create(String name) {
return new ServiceInfoTemplate(name);
}
@Override
public void write(Packer packer, ServiceInfo service, boolean required) throws IOException {
throw new UnsupportedOperationException(ServiceInfo.class.getSimpleName()
+ " can not be encoded by " + ServiceInfoTemplate.class.getSimpleName());
}
@Override
public ServiceInfo read(Unpacker unpacker, ServiceInfo service, boolean required) throws IOException {
unpacker.readArrayBegin();
SocketAddress endpoint = unpacker.read(SocketAddressTemplate.getInstance());
unpacker.readInt();
Map<Integer, String> api = unpacker.read(Templates.tMap(Templates.TInteger, Templates.TString));
unpacker.readArrayEnd();
| return new ServiceInfo(name, endpoint, ServiceApi.of(name, ImmutableBiMap.copyOf(api).inverse())); |
cocaine/cocaine-framework-java | cocaine-client/src/main/java/cocaine/Service.java | // Path: cocaine-client/src/main/java/cocaine/netty/ServiceMessageHandler.java
// public class ServiceMessageHandler extends ChannelInboundHandlerAdapter {
//
// private static final Logger logger = Logger.getLogger(ServiceMessageHandler.class);
//
// private final String service;
// private final Sessions sessions;
//
// public ServiceMessageHandler(String service, Sessions sessions) {
// this.service = service;
// this.sessions = sessions;
// }
//
// @Override
// public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// logger.info("Handling message: " + msg);
//
// Message message = (Message) msg;
// long session = message.getSession();
//
// switch (message.getType()) {
// case CHUNK: {
// ChunkMessage chunk = (ChunkMessage) msg;
// sessions.onChunk(session, chunk.getData());
// break;
// }
// case CHOKE: {
// sessions.onCompleted(session);
// break;
// }
// case ERROR: {
// ErrorMessage error = (ErrorMessage) msg;
// sessions.onError(session, new ServiceErrorException(service, error.getMessage(), error.getCode()));
// break;
// }
// default: {
// sessions.onError(session, new UnexpectedServiceMessageException(service, message));
// break;
// }
// }
// }
//
// @Override
// public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// sessions.onCompleted();
// }
// }
| import java.io.IOException;
import java.net.SocketAddress;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import cocaine.netty.ServiceMessageHandler;
import com.google.common.base.Joiner;
import com.google.common.base.Supplier;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import org.apache.log4j.Logger;
import org.msgpack.MessagePackable;
import org.msgpack.packer.Packer;
import org.msgpack.unpacker.Unpacker;
import rx.Observable; | package cocaine;
/**
* @author Anton Bobukh <[email protected]>
*/
public class Service implements AutoCloseable {
private static final Logger logger = Logger.getLogger(Service.class);
private final String name;
private final ServiceApi api;
private final Sessions sessions;
private AtomicBoolean closed;
private Channel channel;
private Service(String name, ServiceApi api, Bootstrap bootstrap, Supplier<SocketAddress> endpoint) {
this.name = name;
this.sessions = new Sessions(name);
this.api = api;
this.closed = new AtomicBoolean(false); | // Path: cocaine-client/src/main/java/cocaine/netty/ServiceMessageHandler.java
// public class ServiceMessageHandler extends ChannelInboundHandlerAdapter {
//
// private static final Logger logger = Logger.getLogger(ServiceMessageHandler.class);
//
// private final String service;
// private final Sessions sessions;
//
// public ServiceMessageHandler(String service, Sessions sessions) {
// this.service = service;
// this.sessions = sessions;
// }
//
// @Override
// public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// logger.info("Handling message: " + msg);
//
// Message message = (Message) msg;
// long session = message.getSession();
//
// switch (message.getType()) {
// case CHUNK: {
// ChunkMessage chunk = (ChunkMessage) msg;
// sessions.onChunk(session, chunk.getData());
// break;
// }
// case CHOKE: {
// sessions.onCompleted(session);
// break;
// }
// case ERROR: {
// ErrorMessage error = (ErrorMessage) msg;
// sessions.onError(session, new ServiceErrorException(service, error.getMessage(), error.getCode()));
// break;
// }
// default: {
// sessions.onError(session, new UnexpectedServiceMessageException(service, message));
// break;
// }
// }
// }
//
// @Override
// public void channelInactive(ChannelHandlerContext ctx) throws Exception {
// sessions.onCompleted();
// }
// }
// Path: cocaine-client/src/main/java/cocaine/Service.java
import java.io.IOException;
import java.net.SocketAddress;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import cocaine.netty.ServiceMessageHandler;
import com.google.common.base.Joiner;
import com.google.common.base.Supplier;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import org.apache.log4j.Logger;
import org.msgpack.MessagePackable;
import org.msgpack.packer.Packer;
import org.msgpack.unpacker.Unpacker;
import rx.Observable;
package cocaine;
/**
* @author Anton Bobukh <[email protected]>
*/
public class Service implements AutoCloseable {
private static final Logger logger = Logger.getLogger(Service.class);
private final String name;
private final ServiceApi api;
private final Sessions sessions;
private AtomicBoolean closed;
private Channel channel;
private Service(String name, ServiceApi api, Bootstrap bootstrap, Supplier<SocketAddress> endpoint) {
this.name = name;
this.sessions = new Sessions(name);
this.api = api;
this.closed = new AtomicBoolean(false); | connect(bootstrap, endpoint, new ServiceMessageHandler(name, sessions)); |
cocaine/cocaine-framework-java | cocaine-worker-archetype/src/main/resources/archetype-resources/src/main/java/Application.java | // Path: cocaine-worker/src/main/java/cocaine/Runner.java
// public final class Runner {
//
// private static final Logger logger = Logger.getLogger(Runner.class);
//
// public static void run(Map<String, EventHandler> handlers, String[] args) {
// WorkerOptions options = new WorkerOptions();
// new JCommander(options).parse(args);
//
// logger.info("Running " + options.getApplication() + " application:\n " + printHandlers(handlers));
//
// try (Worker worker = new Worker(options, handlers)) {
// worker.run();
// worker.join();
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// }
// }
//
// public static void run(Object container, String[] args) {
// Method[] methods = container.getClass().getDeclaredMethods();
// Map<String, EventHandler> handlers = new HashMap<>();
// for (Method method : methods) {
// Handler handler = method.getAnnotation(Handler.class);
// if (handler != null) {
// String name = handler.value().isEmpty() ? method.getName() : handler.value();
// handlers.put(name, MethodEventHandler.wrap(container, method));
// }
// }
// Runner.run(handlers, args);
// }
//
// private static String printHandlers(Map<String, EventHandler> handlers) {
// return Joiner.on("\n ").withKeyValueSeparator(": ")
// .join(Maps.transformValues(handlers, new Function<EventHandler, String>() {
// @Override
// public String apply(EventHandler handler) {
// return handler.getClass().getName();
// }
// }));
// }
//
// private static final class MethodEventHandler implements EventHandler {
//
// private final Method method;
// private final Object container;
//
// private MethodEventHandler(Method method, Object container) {
// this.method = method;
// this.container = container;
// }
//
// public static MethodEventHandler wrap(Object container, Method method) {
// return new MethodEventHandler(method, container);
// }
//
// @Override
// public void handle(Observable<byte[]> request, Observer<byte[]> response) throws Exception {
// method.invoke(container, request, response);
// }
//
// }
//
// private Runner() { }
//
// }
| import java.util.Arrays;
import cocaine.Handler;
import cocaine.Runner;
import org.apache.log4j.Logger;
import rx.Observable;
import rx.Observer; | package ${package};
public class Application {
private static final Logger logger = Logger.getLogger(Application.class);
@Handler("echo")
public void echo(Observable<byte[]> request, final Observer<byte[]> response) {
request.subscribe(new Observer<byte[]>() {
@Override
public void onCompleted() {
logger.info("onCompleted");
response.onCompleted();
}
@Override
public void onError(Throwable e) {
logger.info("onError: " + e);
response.onError(e);
}
@Override
public void onNext(byte[] bytes) {
logger.info("onNext: " + Arrays.toString(bytes));
response.onNext(bytes);
}
});
}
public static void main(String[] args) { | // Path: cocaine-worker/src/main/java/cocaine/Runner.java
// public final class Runner {
//
// private static final Logger logger = Logger.getLogger(Runner.class);
//
// public static void run(Map<String, EventHandler> handlers, String[] args) {
// WorkerOptions options = new WorkerOptions();
// new JCommander(options).parse(args);
//
// logger.info("Running " + options.getApplication() + " application:\n " + printHandlers(handlers));
//
// try (Worker worker = new Worker(options, handlers)) {
// worker.run();
// worker.join();
// } catch (Exception e) {
// logger.error(e.getMessage(), e);
// }
// }
//
// public static void run(Object container, String[] args) {
// Method[] methods = container.getClass().getDeclaredMethods();
// Map<String, EventHandler> handlers = new HashMap<>();
// for (Method method : methods) {
// Handler handler = method.getAnnotation(Handler.class);
// if (handler != null) {
// String name = handler.value().isEmpty() ? method.getName() : handler.value();
// handlers.put(name, MethodEventHandler.wrap(container, method));
// }
// }
// Runner.run(handlers, args);
// }
//
// private static String printHandlers(Map<String, EventHandler> handlers) {
// return Joiner.on("\n ").withKeyValueSeparator(": ")
// .join(Maps.transformValues(handlers, new Function<EventHandler, String>() {
// @Override
// public String apply(EventHandler handler) {
// return handler.getClass().getName();
// }
// }));
// }
//
// private static final class MethodEventHandler implements EventHandler {
//
// private final Method method;
// private final Object container;
//
// private MethodEventHandler(Method method, Object container) {
// this.method = method;
// this.container = container;
// }
//
// public static MethodEventHandler wrap(Object container, Method method) {
// return new MethodEventHandler(method, container);
// }
//
// @Override
// public void handle(Observable<byte[]> request, Observer<byte[]> response) throws Exception {
// method.invoke(container, request, response);
// }
//
// }
//
// private Runner() { }
//
// }
// Path: cocaine-worker-archetype/src/main/resources/archetype-resources/src/main/java/Application.java
import java.util.Arrays;
import cocaine.Handler;
import cocaine.Runner;
import org.apache.log4j.Logger;
import rx.Observable;
import rx.Observer;
package ${package};
public class Application {
private static final Logger logger = Logger.getLogger(Application.class);
@Handler("echo")
public void echo(Observable<byte[]> request, final Observer<byte[]> response) {
request.subscribe(new Observer<byte[]>() {
@Override
public void onCompleted() {
logger.info("onCompleted");
response.onCompleted();
}
@Override
public void onError(Throwable e) {
logger.info("onError: " + e);
response.onError(e);
}
@Override
public void onNext(byte[] bytes) {
logger.info("onNext: " + Arrays.toString(bytes));
response.onNext(bytes);
}
});
}
public static void main(String[] args) { | Runner.run(new Application(), args); |
Phonemetra/TurboLauncher | app/src/main/java/com/phonemetra/turbo/launcher/FolderIcon.java | // Path: app/src/main/java/com/phonemetra/turbo/launcher/DropTarget.java
// class DragObject {
// public int x = -1;
// public int y = -1;
//
// /** X offset from the upper-left corner of the cell to where we touched. */
// public int xOffset = -1;
//
// /** Y offset from the upper-left corner of the cell to where we touched. */
// public int yOffset = -1;
//
// /**
// * This indicates whether a drag is in final stages, either drop or
// * cancel. It differentiates onDragExit, since this is called when the
// * drag is ending, above the current drag target, or when the drag moves
// * off the current drag object.
// */
// public boolean dragComplete = false;
//
// /** The view that moves around while you drag. */
// public DragView dragView = null;
//
// /** The data associated with the object being dragged */
// public Object dragInfo = null;
//
// /** Where the drag originated */
// public DragSource dragSource = null;
//
// /** Post drag animation runnable */
// public Runnable postAnimationRunnable = null;
//
// /** Indicates that the drag operation was cancelled */
// public boolean cancelled = false;
//
// /**
// * Defers removing the DragView from the DragLayer until after the drop
// * animation.
// */
// public boolean deferDragViewCleanupPostAnimation = true;
//
// public DragObject() {
// }
// }
//
// Path: app/src/main/java/com/phonemetra/turbo/launcher/FolderInfo.java
// interface FolderListener {
// public void onAdd(ShortcutInfo item);
// public void onRemove(ShortcutInfo item);
// public void onTitleChanged(CharSequence title);
// public void onItemsChanged();
// }
| import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Looper;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.phonemetra.turbo.launcher.DropTarget.DragObject;
import com.phonemetra.turbo.launcher.FolderInfo.FolderListener;
import com.phonemetra.turbo.launcher.R;
import java.util.ArrayList; | // position as the first item in the preview
animateFirstItem(animateDrawable, INITIAL_ITEM_ANIMATION_DURATION, false, null);
addItem(destInfo);
// This will animate the dragView (srcView) into the new folder
onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, postAnimationRunnable, null);
}
public void performDestroyAnimation(final View finalView, Runnable onCompleteRunnable) {
Drawable animateDrawable = ((TextView) finalView).getCompoundDrawables()[1];
computePreviewDrawingParams(animateDrawable.getIntrinsicWidth(),
finalView.getMeasuredWidth());
// This will animate the first item from it's position as an icon into its
// position as the first item in the preview
animateFirstItem(animateDrawable, FINAL_ITEM_ANIMATION_DURATION, true,
onCompleteRunnable);
}
public void onDragExit(Object dragInfo) {
onDragExit();
}
public void onDragExit() {
mFolderRingAnimator.animateToNaturalState();
mOpenAlarm.cancelAlarm();
}
private void onDrop(final ShortcutInfo item, DragView animateView, Rect finalRect,
float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable, | // Path: app/src/main/java/com/phonemetra/turbo/launcher/DropTarget.java
// class DragObject {
// public int x = -1;
// public int y = -1;
//
// /** X offset from the upper-left corner of the cell to where we touched. */
// public int xOffset = -1;
//
// /** Y offset from the upper-left corner of the cell to where we touched. */
// public int yOffset = -1;
//
// /**
// * This indicates whether a drag is in final stages, either drop or
// * cancel. It differentiates onDragExit, since this is called when the
// * drag is ending, above the current drag target, or when the drag moves
// * off the current drag object.
// */
// public boolean dragComplete = false;
//
// /** The view that moves around while you drag. */
// public DragView dragView = null;
//
// /** The data associated with the object being dragged */
// public Object dragInfo = null;
//
// /** Where the drag originated */
// public DragSource dragSource = null;
//
// /** Post drag animation runnable */
// public Runnable postAnimationRunnable = null;
//
// /** Indicates that the drag operation was cancelled */
// public boolean cancelled = false;
//
// /**
// * Defers removing the DragView from the DragLayer until after the drop
// * animation.
// */
// public boolean deferDragViewCleanupPostAnimation = true;
//
// public DragObject() {
// }
// }
//
// Path: app/src/main/java/com/phonemetra/turbo/launcher/FolderInfo.java
// interface FolderListener {
// public void onAdd(ShortcutInfo item);
// public void onRemove(ShortcutInfo item);
// public void onTitleChanged(CharSequence title);
// public void onItemsChanged();
// }
// Path: app/src/main/java/com/phonemetra/turbo/launcher/FolderIcon.java
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Looper;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.phonemetra.turbo.launcher.DropTarget.DragObject;
import com.phonemetra.turbo.launcher.FolderInfo.FolderListener;
import com.phonemetra.turbo.launcher.R;
import java.util.ArrayList;
// position as the first item in the preview
animateFirstItem(animateDrawable, INITIAL_ITEM_ANIMATION_DURATION, false, null);
addItem(destInfo);
// This will animate the dragView (srcView) into the new folder
onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, postAnimationRunnable, null);
}
public void performDestroyAnimation(final View finalView, Runnable onCompleteRunnable) {
Drawable animateDrawable = ((TextView) finalView).getCompoundDrawables()[1];
computePreviewDrawingParams(animateDrawable.getIntrinsicWidth(),
finalView.getMeasuredWidth());
// This will animate the first item from it's position as an icon into its
// position as the first item in the preview
animateFirstItem(animateDrawable, FINAL_ITEM_ANIMATION_DURATION, true,
onCompleteRunnable);
}
public void onDragExit(Object dragInfo) {
onDragExit();
}
public void onDragExit() {
mFolderRingAnimator.animateToNaturalState();
mOpenAlarm.cancelAlarm();
}
private void onDrop(final ShortcutInfo item, DragView animateView, Rect finalRect,
float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable, | DragObject d) { |
Phonemetra/TurboLauncher | app/src/main/java/com/phonemetra/turbo/launcher/ThemeChangedReceiver.java | // Path: app/src/main/java/com/phonemetra/turbo/launcher/WidgetPreviewLoader.java
// final static String DB_NAME = "widgetpreviews.db";
| import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import java.io.File;
import static com.phonemetra.turbo.launcher.WidgetPreviewLoader.CacheDb.DB_NAME; | /*
* Copyright (C) 2014 Phonemetra
*
* 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.phonemetra.turbo.launcher;
public class ThemeChangedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
LauncherAppState app = LauncherAppState.getInstance();
clearWidgetPreviewCache(context);
app.recreateWidgetPreviewDb();
app.getIconCache().flush();
app.getModel().forceReload();
}
private void clearWidgetPreviewCache(Context context) {
File[] files = context.getCacheDir().listFiles();
if (files != null) {
for (File f : files) { | // Path: app/src/main/java/com/phonemetra/turbo/launcher/WidgetPreviewLoader.java
// final static String DB_NAME = "widgetpreviews.db";
// Path: app/src/main/java/com/phonemetra/turbo/launcher/ThemeChangedReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import java.io.File;
import static com.phonemetra.turbo.launcher.WidgetPreviewLoader.CacheDb.DB_NAME;
/*
* Copyright (C) 2014 Phonemetra
*
* 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.phonemetra.turbo.launcher;
public class ThemeChangedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
LauncherAppState app = LauncherAppState.getInstance();
clearWidgetPreviewCache(context);
app.recreateWidgetPreviewDb();
app.getIconCache().flush();
app.getModel().forceReload();
}
private void clearWidgetPreviewCache(Context context) {
File[] files = context.getCacheDir().listFiles();
if (files != null) {
for (File f : files) { | if (!f.isDirectory() && f.getName().startsWith(DB_NAME)) f.delete(); |
Phonemetra/TurboLauncher | app/src/main/java/com/phonemetra/turbo/launcher/DragSource.java | // Path: app/src/main/java/com/phonemetra/turbo/launcher/DropTarget.java
// class DragObject {
// public int x = -1;
// public int y = -1;
//
// /** X offset from the upper-left corner of the cell to where we touched. */
// public int xOffset = -1;
//
// /** Y offset from the upper-left corner of the cell to where we touched. */
// public int yOffset = -1;
//
// /**
// * This indicates whether a drag is in final stages, either drop or
// * cancel. It differentiates onDragExit, since this is called when the
// * drag is ending, above the current drag target, or when the drag moves
// * off the current drag object.
// */
// public boolean dragComplete = false;
//
// /** The view that moves around while you drag. */
// public DragView dragView = null;
//
// /** The data associated with the object being dragged */
// public Object dragInfo = null;
//
// /** Where the drag originated */
// public DragSource dragSource = null;
//
// /** Post drag animation runnable */
// public Runnable postAnimationRunnable = null;
//
// /** Indicates that the drag operation was cancelled */
// public boolean cancelled = false;
//
// /**
// * Defers removing the DragView from the DragLayer until after the drop
// * animation.
// */
// public boolean deferDragViewCleanupPostAnimation = true;
//
// public DragObject() {
// }
// }
| import android.view.View;
import com.phonemetra.turbo.launcher.DropTarget.DragObject; | /*
* Copyright (C) 2008 The Android Open Source Project
*
* 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.phonemetra.turbo.launcher;
/**
* Interface defining an object that can originate a drag.
*
*/
public interface DragSource {
/**
* @return whether items dragged from this source supports
*/
boolean supportsFlingToDelete();
/**
* @return whether items dragged from this source supports 'App Info'
*/
boolean supportsAppInfoDropTarget();
/**
* @return whether items dragged from this source supports 'Delete' drop target (e.g. to remove
* a shortcut.
*/
boolean supportsDeleteDropTarget();
/*
* @return the scale of the icons over the workspace icon size
*/
float getIntrinsicIconScaleFactor();
/**
* A callback specifically made back to the source after an item from this source has been flung
* to be deleted on a DropTarget. In such a situation, this method will be called after
* onDropCompleted, and more importantly, after the fling animation has completed.
*/
void onFlingToDeleteCompleted();
/**
* A callback made back to the source after an item from this source has been dropped on a
* DropTarget.
*/ | // Path: app/src/main/java/com/phonemetra/turbo/launcher/DropTarget.java
// class DragObject {
// public int x = -1;
// public int y = -1;
//
// /** X offset from the upper-left corner of the cell to where we touched. */
// public int xOffset = -1;
//
// /** Y offset from the upper-left corner of the cell to where we touched. */
// public int yOffset = -1;
//
// /**
// * This indicates whether a drag is in final stages, either drop or
// * cancel. It differentiates onDragExit, since this is called when the
// * drag is ending, above the current drag target, or when the drag moves
// * off the current drag object.
// */
// public boolean dragComplete = false;
//
// /** The view that moves around while you drag. */
// public DragView dragView = null;
//
// /** The data associated with the object being dragged */
// public Object dragInfo = null;
//
// /** Where the drag originated */
// public DragSource dragSource = null;
//
// /** Post drag animation runnable */
// public Runnable postAnimationRunnable = null;
//
// /** Indicates that the drag operation was cancelled */
// public boolean cancelled = false;
//
// /**
// * Defers removing the DragView from the DragLayer until after the drop
// * animation.
// */
// public boolean deferDragViewCleanupPostAnimation = true;
//
// public DragObject() {
// }
// }
// Path: app/src/main/java/com/phonemetra/turbo/launcher/DragSource.java
import android.view.View;
import com.phonemetra.turbo.launcher.DropTarget.DragObject;
/*
* Copyright (C) 2008 The Android Open Source Project
*
* 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.phonemetra.turbo.launcher;
/**
* Interface defining an object that can originate a drag.
*
*/
public interface DragSource {
/**
* @return whether items dragged from this source supports
*/
boolean supportsFlingToDelete();
/**
* @return whether items dragged from this source supports 'App Info'
*/
boolean supportsAppInfoDropTarget();
/**
* @return whether items dragged from this source supports 'Delete' drop target (e.g. to remove
* a shortcut.
*/
boolean supportsDeleteDropTarget();
/*
* @return the scale of the icons over the workspace icon size
*/
float getIntrinsicIconScaleFactor();
/**
* A callback specifically made back to the source after an item from this source has been flung
* to be deleted on a DropTarget. In such a situation, this method will be called after
* onDropCompleted, and more importantly, after the fling animation has completed.
*/
void onFlingToDeleteCompleted();
/**
* A callback made back to the source after an item from this source has been dropped on a
* DropTarget.
*/ | void onDropCompleted(View target, DragObject d, boolean isFlingToDelete, boolean success); |
msgpack/msgpack-java | msgpack-core/src/main/java/org/msgpack/value/ValueFactory.java | // Path: msgpack-core/src/main/java/org/msgpack/value/impl/ImmutableTimestampValueImpl.java
// public class ImmutableTimestampValueImpl
// extends AbstractImmutableValue
// implements ImmutableExtensionValue, ImmutableTimestampValue
// {
// private final Instant instant;
// private byte[] data;
//
// public ImmutableTimestampValueImpl(Instant timestamp)
// {
// this.instant = timestamp;
// }
//
// @Override
// public boolean isTimestampValue()
// {
// return true;
// }
//
// @Override
// public byte getType()
// {
// return EXT_TIMESTAMP;
// }
//
// @Override
// public ValueType getValueType()
// {
// // Note: Future version should return ValueType.TIMESTAMP instead.
// return ValueType.EXTENSION;
// }
//
// @Override
// public ImmutableTimestampValue immutableValue()
// {
// return this;
// }
//
// @Override
// public ImmutableExtensionValue asExtensionValue()
// {
// return this;
// }
//
// @Override
// public ImmutableTimestampValue asTimestampValue()
// {
// return this;
// }
//
// @Override
// public byte[] getData()
// {
// if (data == null) {
// // See MessagePacker.packTimestampImpl
// byte[] bytes;
// long sec = getEpochSecond();
// int nsec = getNano();
// if (sec >>> 34 == 0) {
// long data64 = (nsec << 34) | sec;
// if ((data64 & 0xffffffff00000000L) == 0L) {
// bytes = new byte[4];
// MessageBuffer.wrap(bytes).putInt(0, (int) sec);
// }
// else {
// bytes = new byte[8];
// MessageBuffer.wrap(bytes).putLong(0, data64);
// }
// }
// else {
// bytes = new byte[12];
// MessageBuffer buffer = MessageBuffer.wrap(bytes);
// buffer.putInt(0, nsec);
// buffer.putLong(4, sec);
// }
// data = bytes;
// }
// return data;
// }
//
// @Override
// public long getEpochSecond()
// {
// return instant.getEpochSecond();
// }
//
// @Override
// public int getNano()
// {
// return instant.getNano();
// }
//
// @Override
// public long toEpochMillis()
// {
// return instant.toEpochMilli();
// }
//
// @Override
// public Instant toInstant()
// {
// return instant;
// }
//
// @Override
// public void writeTo(MessagePacker packer)
// throws IOException
// {
// packer.packTimestamp(instant);
// }
//
// @Override
// public boolean equals(Object o)
// {
// // Implements same behavior with ImmutableExtensionValueImpl.
// if (o == this) {
// return true;
// }
// if (!(o instanceof Value)) {
// return false;
// }
// Value v = (Value) o;
//
// if (!v.isExtensionValue()) {
// return false;
// }
// ExtensionValue ev = v.asExtensionValue();
//
// // Here should use isTimestampValue and asTimestampValue instead. However, because
// // adding these methods to Value interface can't keep backward compatibility without
// // using "default" keyword since Java 7, here uses instanceof of and cast instead.
// if (ev instanceof TimestampValue) {
// TimestampValue tv = (TimestampValue) ev;
// return instant.equals(tv.toInstant());
// }
// else {
// return EXT_TIMESTAMP == ev.getType() && Arrays.equals(getData(), ev.getData());
// }
// }
//
// @Override
// public int hashCode()
// {
// // Implements same behavior with ImmutableExtensionValueImpl.
// int hash = EXT_TIMESTAMP;
// hash *= 31;
// hash = instant.hashCode();
// return hash;
// }
//
// @Override
// public String toJson()
// {
// return "\"" + toInstant().toString() + "\"";
// }
//
// @Override
// public String toString()
// {
// return toInstant().toString();
// }
// }
| import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.msgpack.value.impl.ImmutableArrayValueImpl;
import org.msgpack.value.impl.ImmutableBigIntegerValueImpl;
import org.msgpack.value.impl.ImmutableBinaryValueImpl;
import org.msgpack.value.impl.ImmutableBooleanValueImpl;
import org.msgpack.value.impl.ImmutableDoubleValueImpl;
import org.msgpack.value.impl.ImmutableExtensionValueImpl;
import org.msgpack.value.impl.ImmutableLongValueImpl;
import org.msgpack.value.impl.ImmutableMapValueImpl;
import org.msgpack.value.impl.ImmutableNilValueImpl;
import org.msgpack.value.impl.ImmutableStringValueImpl;
import org.msgpack.value.impl.ImmutableTimestampValueImpl;
import java.math.BigInteger;
import java.time.Instant;
import java.util.AbstractMap; | public MapBuilder put(Value key, Value value)
{
map.put(key, value);
return this;
}
public MapBuilder putAll(Iterable<? extends Map.Entry<? extends Value, ? extends Value>> entries)
{
for (Map.Entry<? extends Value, ? extends Value> entry : entries) {
put(entry.getKey(), entry.getValue());
}
return this;
}
public MapBuilder putAll(Map<? extends Value, ? extends Value> map)
{
for (Map.Entry<? extends Value, ? extends Value> entry : map.entrySet()) {
put(entry);
}
return this;
}
}
public static ImmutableExtensionValue newExtension(byte type, byte[] data)
{
return new ImmutableExtensionValueImpl(type, data);
}
public static ImmutableTimestampValue newTimestamp(Instant timestamp)
{ | // Path: msgpack-core/src/main/java/org/msgpack/value/impl/ImmutableTimestampValueImpl.java
// public class ImmutableTimestampValueImpl
// extends AbstractImmutableValue
// implements ImmutableExtensionValue, ImmutableTimestampValue
// {
// private final Instant instant;
// private byte[] data;
//
// public ImmutableTimestampValueImpl(Instant timestamp)
// {
// this.instant = timestamp;
// }
//
// @Override
// public boolean isTimestampValue()
// {
// return true;
// }
//
// @Override
// public byte getType()
// {
// return EXT_TIMESTAMP;
// }
//
// @Override
// public ValueType getValueType()
// {
// // Note: Future version should return ValueType.TIMESTAMP instead.
// return ValueType.EXTENSION;
// }
//
// @Override
// public ImmutableTimestampValue immutableValue()
// {
// return this;
// }
//
// @Override
// public ImmutableExtensionValue asExtensionValue()
// {
// return this;
// }
//
// @Override
// public ImmutableTimestampValue asTimestampValue()
// {
// return this;
// }
//
// @Override
// public byte[] getData()
// {
// if (data == null) {
// // See MessagePacker.packTimestampImpl
// byte[] bytes;
// long sec = getEpochSecond();
// int nsec = getNano();
// if (sec >>> 34 == 0) {
// long data64 = (nsec << 34) | sec;
// if ((data64 & 0xffffffff00000000L) == 0L) {
// bytes = new byte[4];
// MessageBuffer.wrap(bytes).putInt(0, (int) sec);
// }
// else {
// bytes = new byte[8];
// MessageBuffer.wrap(bytes).putLong(0, data64);
// }
// }
// else {
// bytes = new byte[12];
// MessageBuffer buffer = MessageBuffer.wrap(bytes);
// buffer.putInt(0, nsec);
// buffer.putLong(4, sec);
// }
// data = bytes;
// }
// return data;
// }
//
// @Override
// public long getEpochSecond()
// {
// return instant.getEpochSecond();
// }
//
// @Override
// public int getNano()
// {
// return instant.getNano();
// }
//
// @Override
// public long toEpochMillis()
// {
// return instant.toEpochMilli();
// }
//
// @Override
// public Instant toInstant()
// {
// return instant;
// }
//
// @Override
// public void writeTo(MessagePacker packer)
// throws IOException
// {
// packer.packTimestamp(instant);
// }
//
// @Override
// public boolean equals(Object o)
// {
// // Implements same behavior with ImmutableExtensionValueImpl.
// if (o == this) {
// return true;
// }
// if (!(o instanceof Value)) {
// return false;
// }
// Value v = (Value) o;
//
// if (!v.isExtensionValue()) {
// return false;
// }
// ExtensionValue ev = v.asExtensionValue();
//
// // Here should use isTimestampValue and asTimestampValue instead. However, because
// // adding these methods to Value interface can't keep backward compatibility without
// // using "default" keyword since Java 7, here uses instanceof of and cast instead.
// if (ev instanceof TimestampValue) {
// TimestampValue tv = (TimestampValue) ev;
// return instant.equals(tv.toInstant());
// }
// else {
// return EXT_TIMESTAMP == ev.getType() && Arrays.equals(getData(), ev.getData());
// }
// }
//
// @Override
// public int hashCode()
// {
// // Implements same behavior with ImmutableExtensionValueImpl.
// int hash = EXT_TIMESTAMP;
// hash *= 31;
// hash = instant.hashCode();
// return hash;
// }
//
// @Override
// public String toJson()
// {
// return "\"" + toInstant().toString() + "\"";
// }
//
// @Override
// public String toString()
// {
// return toInstant().toString();
// }
// }
// Path: msgpack-core/src/main/java/org/msgpack/value/ValueFactory.java
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.msgpack.value.impl.ImmutableArrayValueImpl;
import org.msgpack.value.impl.ImmutableBigIntegerValueImpl;
import org.msgpack.value.impl.ImmutableBinaryValueImpl;
import org.msgpack.value.impl.ImmutableBooleanValueImpl;
import org.msgpack.value.impl.ImmutableDoubleValueImpl;
import org.msgpack.value.impl.ImmutableExtensionValueImpl;
import org.msgpack.value.impl.ImmutableLongValueImpl;
import org.msgpack.value.impl.ImmutableMapValueImpl;
import org.msgpack.value.impl.ImmutableNilValueImpl;
import org.msgpack.value.impl.ImmutableStringValueImpl;
import org.msgpack.value.impl.ImmutableTimestampValueImpl;
import java.math.BigInteger;
import java.time.Instant;
import java.util.AbstractMap;
public MapBuilder put(Value key, Value value)
{
map.put(key, value);
return this;
}
public MapBuilder putAll(Iterable<? extends Map.Entry<? extends Value, ? extends Value>> entries)
{
for (Map.Entry<? extends Value, ? extends Value> entry : entries) {
put(entry.getKey(), entry.getValue());
}
return this;
}
public MapBuilder putAll(Map<? extends Value, ? extends Value> map)
{
for (Map.Entry<? extends Value, ? extends Value> entry : map.entrySet()) {
put(entry);
}
return this;
}
}
public static ImmutableExtensionValue newExtension(byte type, byte[] data)
{
return new ImmutableExtensionValueImpl(type, data);
}
public static ImmutableTimestampValue newTimestamp(Instant timestamp)
{ | return new ImmutableTimestampValueImpl(timestamp); |
msgpack/msgpack-java | msgpack-core/src/main/java/org/msgpack/value/impl/AbstractImmutableValue.java | // Path: msgpack-core/src/main/java/org/msgpack/value/ImmutableTimestampValue.java
// public interface ImmutableTimestampValue
// extends TimestampValue, ImmutableValue
// {
// }
//
// Path: msgpack-core/src/main/java/org/msgpack/value/ImmutableValue.java
// public interface ImmutableValue
// extends Value
// {
// @Override
// public ImmutableNilValue asNilValue();
//
// @Override
// public ImmutableBooleanValue asBooleanValue();
//
// @Override
// public ImmutableIntegerValue asIntegerValue();
//
// @Override
// public ImmutableFloatValue asFloatValue();
//
// @Override
// public ImmutableArrayValue asArrayValue();
//
// @Override
// public ImmutableMapValue asMapValue();
//
// @Override
// public ImmutableRawValue asRawValue();
//
// @Override
// public ImmutableBinaryValue asBinaryValue();
//
// @Override
// public ImmutableStringValue asStringValue();
//
// @Override
// public ImmutableTimestampValue asTimestampValue();
// }
| import org.msgpack.core.MessageTypeCastException;
import org.msgpack.value.ImmutableArrayValue;
import org.msgpack.value.ImmutableBinaryValue;
import org.msgpack.value.ImmutableBooleanValue;
import org.msgpack.value.ImmutableExtensionValue;
import org.msgpack.value.ImmutableFloatValue;
import org.msgpack.value.ImmutableIntegerValue;
import org.msgpack.value.ImmutableMapValue;
import org.msgpack.value.ImmutableNilValue;
import org.msgpack.value.ImmutableNumberValue;
import org.msgpack.value.ImmutableRawValue;
import org.msgpack.value.ImmutableStringValue;
import org.msgpack.value.ImmutableTimestampValue;
import org.msgpack.value.ImmutableValue; | public ImmutableBinaryValue asBinaryValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableStringValue asStringValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableArrayValue asArrayValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableMapValue asMapValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableExtensionValue asExtensionValue()
{
throw new MessageTypeCastException();
}
@Override | // Path: msgpack-core/src/main/java/org/msgpack/value/ImmutableTimestampValue.java
// public interface ImmutableTimestampValue
// extends TimestampValue, ImmutableValue
// {
// }
//
// Path: msgpack-core/src/main/java/org/msgpack/value/ImmutableValue.java
// public interface ImmutableValue
// extends Value
// {
// @Override
// public ImmutableNilValue asNilValue();
//
// @Override
// public ImmutableBooleanValue asBooleanValue();
//
// @Override
// public ImmutableIntegerValue asIntegerValue();
//
// @Override
// public ImmutableFloatValue asFloatValue();
//
// @Override
// public ImmutableArrayValue asArrayValue();
//
// @Override
// public ImmutableMapValue asMapValue();
//
// @Override
// public ImmutableRawValue asRawValue();
//
// @Override
// public ImmutableBinaryValue asBinaryValue();
//
// @Override
// public ImmutableStringValue asStringValue();
//
// @Override
// public ImmutableTimestampValue asTimestampValue();
// }
// Path: msgpack-core/src/main/java/org/msgpack/value/impl/AbstractImmutableValue.java
import org.msgpack.core.MessageTypeCastException;
import org.msgpack.value.ImmutableArrayValue;
import org.msgpack.value.ImmutableBinaryValue;
import org.msgpack.value.ImmutableBooleanValue;
import org.msgpack.value.ImmutableExtensionValue;
import org.msgpack.value.ImmutableFloatValue;
import org.msgpack.value.ImmutableIntegerValue;
import org.msgpack.value.ImmutableMapValue;
import org.msgpack.value.ImmutableNilValue;
import org.msgpack.value.ImmutableNumberValue;
import org.msgpack.value.ImmutableRawValue;
import org.msgpack.value.ImmutableStringValue;
import org.msgpack.value.ImmutableTimestampValue;
import org.msgpack.value.ImmutableValue;
public ImmutableBinaryValue asBinaryValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableStringValue asStringValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableArrayValue asArrayValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableMapValue asMapValue()
{
throw new MessageTypeCastException();
}
@Override
public ImmutableExtensionValue asExtensionValue()
{
throw new MessageTypeCastException();
}
@Override | public ImmutableTimestampValue asTimestampValue() |
Lomeli12/Equivalency | src/main/java/net/lomeli/equivalency/recipes/UniversalRecipes.java | // Path: src/main/java/net/lomeli/equivalency/api/TransmutationHelper.java
// public class TransmutationHelper {
// public static final String ITEM_LOC = "com.pahimar.ee3.init.ModItems";
// public static final int WILDCARD = Short.MAX_VALUE;
//
// public static List<ItemStack> transmutationStones = new ArrayList<ItemStack>();
//
// /**
// * Registers the Minium and Philosopher's Stone to Equivalency, DO NOT use
// * for addon recipes.
// */
// public static void addStones() {
// addTransmucationStone(getItem("stoneMinium", ITEM_LOC));
// addTransmucationStone(getItem("stonePhilosophers", ITEM_LOC));
// }
//
// public static void addTransmucationStone(ItemStack stack) {
// if (stack != null)
// transmutationStones.add(stack);
// }
//
// /**
// * Allows one to add their own recipes. Should be use on the
// * FMLPostInitializationEvent.
// *
// * @param output
// * @param input
// */
// public static void apiRecipe(ItemStack output, Object... input) {
// if (transmutationStones.isEmpty())
// addStones();
//
// for (ItemStack stone : transmutationStones) {
// addRecipe(output, stone, input);
// }
// }
//
// /**
// * Used by Equvalency to add recipes. If adding custom recipe, use apiRecipe
// * method instead.
// *
// * @param output
// * @param input
// */
// public static void addRecipe(ItemStack output, Object... input) {
// if (!transmutationStones.isEmpty()) {
// for (ItemStack stone : transmutationStones) {
// Object[] inputs = new Object[input.length + 1];
// System.arraycopy(input, 0, inputs, 0, input.length);
// inputs[input.length] = new ItemStack(stone.getItem(), 1, WILDCARD);
//
// GameRegistry.addRecipe(new ShapelessOreRecipe(output, inputs));
// }
// }
// }
//
// /**
// * Used by Equvalency to add recipes. Only use this if you need to do
// * OreDictionary recipes, and always use ShapelessOreRecipe. If you use a
// * custom IRecipe, include an instance of a transmutation stone
// *
// * @param recipe
// */
// public static void addRecipe(IRecipe recipe) {
// if (recipe instanceof ShapelessOreRecipe) {
// ShapelessOreRecipe oreRecipe = (ShapelessOreRecipe) recipe;
// if (!transmutationStones.isEmpty()) {
// for (ItemStack stone : transmutationStones) {
// try {
// ShapelessOreRecipe newRecipe = oreRecipe;
// Field inputs = getHackedField(2, newRecipe);
// Method add = ArrayList.class.getDeclaredMethod("add", Object.class);
// add.invoke(inputs, stone);
// inputs.set(newRecipe, inputs);
// GameRegistry.addRecipe(newRecipe);
// } catch (Exception e) {
// }
// }
// }
//
// } else
// GameRegistry.addRecipe(recipe);
// }
//
// /**
// * Used by Equvalency to add recipes. If adding custom recipe, use apiRecipe
// * method instead.
// *
// * @param output
// * @param input
// */
// public static void addRecipe(Item output, Object... input) {
// addRecipe(new ItemStack(output), input);
// }
//
// /**
// * Used by Equvalency to add recipes. If adding custom recipe, use apiRecipe
// * method instead.
// *
// * @param output
// * @param input
// */
// public static void addRecipe(Block output, Object... input) {
// addRecipe(new ItemStack(output), input);
// }
//
// /**
// * Copied and updated from EE3 for easier recipe registering.
// *
// * @param input
// * @param stone
// * @param fuel
// */
// public static void addSmeltingRecipe(ItemStack input, ItemStack stone, ItemStack fuel) {
// ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(input);
//
// if (input == null || input.getItem() == null || result == null)
// return;
//
// Object[] list = new Object[9];
// list[0] = stone;
// list[1] = fuel;
//
// for (int i = 2; i < 9; i++) {
// list[i] = new ItemStack(input.getItem(), 1, input.getItemDamage());
// }
//
// if (result.stackSize * 7 <= result.getItem().getItemStackLimit(result))
// GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.stackSize * 7, result.getItemDamage()), list);
// else
// GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.getItem().getItemStackLimit(result), result.getItemDamage()), list);
// }
//
// private static Field getHackedField(int i, Object obj) {
// Field f = obj.getClass().getDeclaredFields()[i];
// f.setAccessible(true);
// return f;
// }
//
// public static ItemStack getItem(String itemString, String itemClassLoc) {
// ItemStack item = null;
//
// try {
// String itemClass = itemClassLoc;
// Object obj = Class.forName(itemClass).getField(itemString).get(null);
// if (obj instanceof Item)
// item = new ItemStack((Item) obj);
// else if (obj instanceof ItemStack)
// item = (ItemStack) obj;
//
// } catch (Exception ex) {
// FMLLog.warning("Could not retrieve item identified by: " + itemString);
// }
// return item;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import net.lomeli.equivalency.api.TransmutationHelper; | package net.lomeli.equivalency.recipes;
public class UniversalRecipes {
public static List<ItemStack> uranium = new ArrayList<ItemStack>();
public static void loadRecipes() {
if (!uranium.isEmpty() && OreDictionary.getOres("uranium").isEmpty()) {
for (ItemStack uraniumDrop : uranium) {
OreDictionary.registerOre("uranium", uraniumDrop.getItem());
}
}
if (!OreDictionary.getOres("ingotTin").isEmpty()) {
if (!OreDictionary.getOres("ingotAluminum").isEmpty()) { | // Path: src/main/java/net/lomeli/equivalency/api/TransmutationHelper.java
// public class TransmutationHelper {
// public static final String ITEM_LOC = "com.pahimar.ee3.init.ModItems";
// public static final int WILDCARD = Short.MAX_VALUE;
//
// public static List<ItemStack> transmutationStones = new ArrayList<ItemStack>();
//
// /**
// * Registers the Minium and Philosopher's Stone to Equivalency, DO NOT use
// * for addon recipes.
// */
// public static void addStones() {
// addTransmucationStone(getItem("stoneMinium", ITEM_LOC));
// addTransmucationStone(getItem("stonePhilosophers", ITEM_LOC));
// }
//
// public static void addTransmucationStone(ItemStack stack) {
// if (stack != null)
// transmutationStones.add(stack);
// }
//
// /**
// * Allows one to add their own recipes. Should be use on the
// * FMLPostInitializationEvent.
// *
// * @param output
// * @param input
// */
// public static void apiRecipe(ItemStack output, Object... input) {
// if (transmutationStones.isEmpty())
// addStones();
//
// for (ItemStack stone : transmutationStones) {
// addRecipe(output, stone, input);
// }
// }
//
// /**
// * Used by Equvalency to add recipes. If adding custom recipe, use apiRecipe
// * method instead.
// *
// * @param output
// * @param input
// */
// public static void addRecipe(ItemStack output, Object... input) {
// if (!transmutationStones.isEmpty()) {
// for (ItemStack stone : transmutationStones) {
// Object[] inputs = new Object[input.length + 1];
// System.arraycopy(input, 0, inputs, 0, input.length);
// inputs[input.length] = new ItemStack(stone.getItem(), 1, WILDCARD);
//
// GameRegistry.addRecipe(new ShapelessOreRecipe(output, inputs));
// }
// }
// }
//
// /**
// * Used by Equvalency to add recipes. Only use this if you need to do
// * OreDictionary recipes, and always use ShapelessOreRecipe. If you use a
// * custom IRecipe, include an instance of a transmutation stone
// *
// * @param recipe
// */
// public static void addRecipe(IRecipe recipe) {
// if (recipe instanceof ShapelessOreRecipe) {
// ShapelessOreRecipe oreRecipe = (ShapelessOreRecipe) recipe;
// if (!transmutationStones.isEmpty()) {
// for (ItemStack stone : transmutationStones) {
// try {
// ShapelessOreRecipe newRecipe = oreRecipe;
// Field inputs = getHackedField(2, newRecipe);
// Method add = ArrayList.class.getDeclaredMethod("add", Object.class);
// add.invoke(inputs, stone);
// inputs.set(newRecipe, inputs);
// GameRegistry.addRecipe(newRecipe);
// } catch (Exception e) {
// }
// }
// }
//
// } else
// GameRegistry.addRecipe(recipe);
// }
//
// /**
// * Used by Equvalency to add recipes. If adding custom recipe, use apiRecipe
// * method instead.
// *
// * @param output
// * @param input
// */
// public static void addRecipe(Item output, Object... input) {
// addRecipe(new ItemStack(output), input);
// }
//
// /**
// * Used by Equvalency to add recipes. If adding custom recipe, use apiRecipe
// * method instead.
// *
// * @param output
// * @param input
// */
// public static void addRecipe(Block output, Object... input) {
// addRecipe(new ItemStack(output), input);
// }
//
// /**
// * Copied and updated from EE3 for easier recipe registering.
// *
// * @param input
// * @param stone
// * @param fuel
// */
// public static void addSmeltingRecipe(ItemStack input, ItemStack stone, ItemStack fuel) {
// ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(input);
//
// if (input == null || input.getItem() == null || result == null)
// return;
//
// Object[] list = new Object[9];
// list[0] = stone;
// list[1] = fuel;
//
// for (int i = 2; i < 9; i++) {
// list[i] = new ItemStack(input.getItem(), 1, input.getItemDamage());
// }
//
// if (result.stackSize * 7 <= result.getItem().getItemStackLimit(result))
// GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.stackSize * 7, result.getItemDamage()), list);
// else
// GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.getItem().getItemStackLimit(result), result.getItemDamage()), list);
// }
//
// private static Field getHackedField(int i, Object obj) {
// Field f = obj.getClass().getDeclaredFields()[i];
// f.setAccessible(true);
// return f;
// }
//
// public static ItemStack getItem(String itemString, String itemClassLoc) {
// ItemStack item = null;
//
// try {
// String itemClass = itemClassLoc;
// Object obj = Class.forName(itemClass).getField(itemString).get(null);
// if (obj instanceof Item)
// item = new ItemStack((Item) obj);
// else if (obj instanceof ItemStack)
// item = (ItemStack) obj;
//
// } catch (Exception ex) {
// FMLLog.warning("Could not retrieve item identified by: " + itemString);
// }
// return item;
// }
// }
// Path: src/main/java/net/lomeli/equivalency/recipes/UniversalRecipes.java
import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import net.lomeli.equivalency.api.TransmutationHelper;
package net.lomeli.equivalency.recipes;
public class UniversalRecipes {
public static List<ItemStack> uranium = new ArrayList<ItemStack>();
public static void loadRecipes() {
if (!uranium.isEmpty() && OreDictionary.getOres("uranium").isEmpty()) {
for (ItemStack uraniumDrop : uranium) {
OreDictionary.registerOre("uranium", uraniumDrop.getItem());
}
}
if (!OreDictionary.getOres("ingotTin").isEmpty()) {
if (!OreDictionary.getOres("ingotAluminum").isEmpty()) { | TransmutationHelper.addRecipe(OreDictionary.getOres("ingotAluminum").get(0), "ingotTin", "ingotTin", "ingotTin", |
Lomeli12/Equivalency | src/api/java/appeng/api/features/IRecipeHandlerRegistry.java | // Path: src/api/java/appeng/api/recipes/ICraftHandler.java
// public interface ICraftHandler
// {
//
// /**
// * Called when your recipe handler receives a newly parsed list of inputs/outputs.
// *
// * @param input
// * @param output
// * @throws RecipeError
// */
// public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError;
//
// /**
// * called when all recipes are parsed, and your required to register your recipe.
// *
// * @throws RegistrationError
// * @throws MissingIngredientError
// */
// public void register() throws RegistrationError, MissingIngredientError;
//
// }
//
// Path: src/api/java/appeng/api/recipes/IRecipeHandler.java
// public interface IRecipeHandler
// {
//
// /**
// * Call when you want to read recipes in from a file based on a loader
// *
// * @param loader
// * @param path
// */
// void parseRecipes(IRecipeLoader loader, String path);
//
// /**
// * this loads the read recipes into minecraft.
// */
// void registerHandlers();
//
// }
| import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IRecipeHandler;
import appeng.api.recipes.ISubItemResolver; | package appeng.api.features;
public interface IRecipeHandlerRegistry
{
/**
* Add a new Recipe Handler to the parser.
*
* MUST BE CALLED IN PRE-INIT
*
* @param name
* @param handler
*/ | // Path: src/api/java/appeng/api/recipes/ICraftHandler.java
// public interface ICraftHandler
// {
//
// /**
// * Called when your recipe handler receives a newly parsed list of inputs/outputs.
// *
// * @param input
// * @param output
// * @throws RecipeError
// */
// public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError;
//
// /**
// * called when all recipes are parsed, and your required to register your recipe.
// *
// * @throws RegistrationError
// * @throws MissingIngredientError
// */
// public void register() throws RegistrationError, MissingIngredientError;
//
// }
//
// Path: src/api/java/appeng/api/recipes/IRecipeHandler.java
// public interface IRecipeHandler
// {
//
// /**
// * Call when you want to read recipes in from a file based on a loader
// *
// * @param loader
// * @param path
// */
// void parseRecipes(IRecipeLoader loader, String path);
//
// /**
// * this loads the read recipes into minecraft.
// */
// void registerHandlers();
//
// }
// Path: src/api/java/appeng/api/features/IRecipeHandlerRegistry.java
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IRecipeHandler;
import appeng.api.recipes.ISubItemResolver;
package appeng.api.features;
public interface IRecipeHandlerRegistry
{
/**
* Add a new Recipe Handler to the parser.
*
* MUST BE CALLED IN PRE-INIT
*
* @param name
* @param handler
*/ | void addNewCraftHandler(String name, Class<? extends ICraftHandler> handler); |
Lomeli12/Equivalency | src/api/java/appeng/api/features/IRecipeHandlerRegistry.java | // Path: src/api/java/appeng/api/recipes/ICraftHandler.java
// public interface ICraftHandler
// {
//
// /**
// * Called when your recipe handler receives a newly parsed list of inputs/outputs.
// *
// * @param input
// * @param output
// * @throws RecipeError
// */
// public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError;
//
// /**
// * called when all recipes are parsed, and your required to register your recipe.
// *
// * @throws RegistrationError
// * @throws MissingIngredientError
// */
// public void register() throws RegistrationError, MissingIngredientError;
//
// }
//
// Path: src/api/java/appeng/api/recipes/IRecipeHandler.java
// public interface IRecipeHandler
// {
//
// /**
// * Call when you want to read recipes in from a file based on a loader
// *
// * @param loader
// * @param path
// */
// void parseRecipes(IRecipeLoader loader, String path);
//
// /**
// * this loads the read recipes into minecraft.
// */
// void registerHandlers();
//
// }
| import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IRecipeHandler;
import appeng.api.recipes.ISubItemResolver; | package appeng.api.features;
public interface IRecipeHandlerRegistry
{
/**
* Add a new Recipe Handler to the parser.
*
* MUST BE CALLED IN PRE-INIT
*
* @param name
* @param handler
*/
void addNewCraftHandler(String name, Class<? extends ICraftHandler> handler);
/**
* Add a new resolver to the parser.
*
* MUST BE CALLED IN PRE-INIT
*
* @param sir
*/
void addNewSubItemResolver(ISubItemResolver sir);
/**
* @param name
* @return A recipe handler by name, returns null on failure.
*/
ICraftHandler getCraftHandlerFor(String name);
/**
* @return a new recipe handler, which can be used to parse, and read recipe files.
*/ | // Path: src/api/java/appeng/api/recipes/ICraftHandler.java
// public interface ICraftHandler
// {
//
// /**
// * Called when your recipe handler receives a newly parsed list of inputs/outputs.
// *
// * @param input
// * @param output
// * @throws RecipeError
// */
// public void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeError;
//
// /**
// * called when all recipes are parsed, and your required to register your recipe.
// *
// * @throws RegistrationError
// * @throws MissingIngredientError
// */
// public void register() throws RegistrationError, MissingIngredientError;
//
// }
//
// Path: src/api/java/appeng/api/recipes/IRecipeHandler.java
// public interface IRecipeHandler
// {
//
// /**
// * Call when you want to read recipes in from a file based on a loader
// *
// * @param loader
// * @param path
// */
// void parseRecipes(IRecipeLoader loader, String path);
//
// /**
// * this loads the read recipes into minecraft.
// */
// void registerHandlers();
//
// }
// Path: src/api/java/appeng/api/features/IRecipeHandlerRegistry.java
import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IRecipeHandler;
import appeng.api.recipes.ISubItemResolver;
package appeng.api.features;
public interface IRecipeHandlerRegistry
{
/**
* Add a new Recipe Handler to the parser.
*
* MUST BE CALLED IN PRE-INIT
*
* @param name
* @param handler
*/
void addNewCraftHandler(String name, Class<? extends ICraftHandler> handler);
/**
* Add a new resolver to the parser.
*
* MUST BE CALLED IN PRE-INIT
*
* @param sir
*/
void addNewSubItemResolver(ISubItemResolver sir);
/**
* @param name
* @return A recipe handler by name, returns null on failure.
*/
ICraftHandler getCraftHandlerFor(String name);
/**
* @return a new recipe handler, which can be used to parse, and read recipe files.
*/ | public IRecipeHandler createNewRecipehandler(); |
Lomeli12/Equivalency | src/api/java/appeng/api/features/IP2PTunnelRegistry.java | // Path: src/api/java/appeng/api/config/TunnelType.java
// public enum TunnelType
// {
// ME, // Network Tunnel
// BC_POWER, // MJ Tunnel
// IC2_POWER, // EU Tunnel
// RF_POWER, // RF Tunnel
// REDSTONE, // Redstone Tunnel
// FLUID, // Fluid Tunnel
// ITEM // Item Tunnel
// }
| import net.minecraft.item.ItemStack;
import appeng.api.config.TunnelType; | package appeng.api.features;
/**
* A Registry for how p2p Tunnels are attuned
*/
public interface IP2PTunnelRegistry
{
/**
* Allows third parties to register items from their mod as potential
* attunements for AE's P2P Tunnels
*
* @param trigger
* - the item which triggers attunement
* @param type
* - the type of tunnel
*/ | // Path: src/api/java/appeng/api/config/TunnelType.java
// public enum TunnelType
// {
// ME, // Network Tunnel
// BC_POWER, // MJ Tunnel
// IC2_POWER, // EU Tunnel
// RF_POWER, // RF Tunnel
// REDSTONE, // Redstone Tunnel
// FLUID, // Fluid Tunnel
// ITEM // Item Tunnel
// }
// Path: src/api/java/appeng/api/features/IP2PTunnelRegistry.java
import net.minecraft.item.ItemStack;
import appeng.api.config.TunnelType;
package appeng.api.features;
/**
* A Registry for how p2p Tunnels are attuned
*/
public interface IP2PTunnelRegistry
{
/**
* Allows third parties to register items from their mod as potential
* attunements for AE's P2P Tunnels
*
* @param trigger
* - the item which triggers attunement
* @param type
* - the type of tunnel
*/ | public abstract void addNewAttunement(ItemStack trigger, TunnelType type); |
Lomeli12/Equivalency | src/api/java/mantle/world/WorldHelper.java | // Path: src/api/java/mantle/common/ComparisonHelper.java
// public class ComparisonHelper
// {
// public static boolean areEquivalent (Item item, Block block)
// {
// //TODO figure this out!!!
// return item.equals(block);
// }
//
// public static boolean areEquivalent (Block block1, Block block2)
// {
// //TODO figure this out!!!
// return block1.equals(block2);
// }
//
// public static boolean areEquivalent (Item item1, Item item2)
// {
// //TODO figure this out!!!
// return item1.equals(item2);
// }
//
// public static boolean areEquivalent (ItemStack is1, ItemStack is2)
// {
// //TODO figure this out!!!
// return is1.getItem().equals(is2.getItem());
// }
// }
| import mantle.common.ComparisonHelper;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; | package mantle.world;
public class WorldHelper
{
@Deprecated
public static boolean setBlockToAirBool (World w, int x, int y, int z)
{
return setBlockToAir(w, x, y, z);
}
public static boolean setBlockToAir (World w, int x, int y, int z)
{
return w.setBlock(x, y, z, Blocks.air, 0, 0);
}
public static boolean isAirBlock (IBlockAccess access, int x, int y, int z)
{ | // Path: src/api/java/mantle/common/ComparisonHelper.java
// public class ComparisonHelper
// {
// public static boolean areEquivalent (Item item, Block block)
// {
// //TODO figure this out!!!
// return item.equals(block);
// }
//
// public static boolean areEquivalent (Block block1, Block block2)
// {
// //TODO figure this out!!!
// return block1.equals(block2);
// }
//
// public static boolean areEquivalent (Item item1, Item item2)
// {
// //TODO figure this out!!!
// return item1.equals(item2);
// }
//
// public static boolean areEquivalent (ItemStack is1, ItemStack is2)
// {
// //TODO figure this out!!!
// return is1.getItem().equals(is2.getItem());
// }
// }
// Path: src/api/java/mantle/world/WorldHelper.java
import mantle.common.ComparisonHelper;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
package mantle.world;
public class WorldHelper
{
@Deprecated
public static boolean setBlockToAirBool (World w, int x, int y, int z)
{
return setBlockToAir(w, x, y, z);
}
public static boolean setBlockToAir (World w, int x, int y, int z)
{
return w.setBlock(x, y, z, Blocks.air, 0, 0);
}
public static boolean isAirBlock (IBlockAccess access, int x, int y, int z)
{ | return ComparisonHelper.areEquivalent(access.getBlock(x, y, z), Blocks.air); |
Lomeli12/Equivalency | src/api/java/tconstruct/library/crafting/CastingRecipe.java | // Path: src/api/java/tconstruct/library/client/FluidRenderProperties.java
// public class FluidRenderProperties
// {
//
// //Constant defaults
// public static final FluidRenderProperties DEFAULT_TABLE = new FluidRenderProperties(Applications.TABLE);
// public static final FluidRenderProperties DEFAULT_BASIN = new FluidRenderProperties(Applications.BASIN);
//
// public float minHeight, maxHeight, minX, maxX, minZ, maxZ;
//
// public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ)
// {
// this.minHeight = minHeight;
// this.maxHeight = maxHeight;
// this.minX = minX;
// this.maxX = maxX;
// this.minZ = minZ;
// this.maxZ = maxZ;
// }
//
// public FluidRenderProperties(float minHeight, float maxHeight, Applications defaults)
// {
// this(minHeight, maxHeight, defaults.minX, defaults.maxX, defaults.minZ, defaults.maxZ);
// }
//
// public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, Applications defaults)
// {
// this(minHeight, maxHeight, minX, maxX, defaults.minZ, defaults.maxZ);
// }
//
// public FluidRenderProperties(Applications defaults, float minX, float maxX)
// {
// this(defaults.minHeight, defaults.maxHeight, minX, maxX, defaults.minZ, defaults.maxZ);
// }
//
// public FluidRenderProperties(Applications defaults, float minX, float maxX, float minZ, float maxZ)
// {
// this(defaults.minHeight, defaults.maxHeight, minX, maxX, minZ, maxZ);
// }
//
// public FluidRenderProperties(Applications defaults)
// {
// this(defaults.minHeight, defaults.maxHeight, defaults.minX, defaults.maxX, defaults.minZ, defaults.maxZ);
// }
//
// public static enum Applications
// {
// TABLE(0.9375F, 1F, 0.0625F, 0.9375F, 0.062F, 0.9375F), BASIN(0.25F, 0.95F, 0.0625F, 0.9375F, 0.0625F, 0.9375F);
//
// public float minHeight, maxHeight, minX, maxX, minZ, maxZ;
//
// Applications(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ)
// {
// this.minHeight = minHeight;
// this.maxHeight = maxHeight;
// this.minX = minX;
// this.maxX = maxX;
// this.minZ = minZ;
// this.maxZ = maxZ;
// }
// }
// }
| import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.client.FluidRenderProperties; | package tconstruct.library.crafting;
public class CastingRecipe
{
public ItemStack output;
public FluidStack castingMetal;
public ItemStack cast;
public boolean consumeCast;
public int coolTime; | // Path: src/api/java/tconstruct/library/client/FluidRenderProperties.java
// public class FluidRenderProperties
// {
//
// //Constant defaults
// public static final FluidRenderProperties DEFAULT_TABLE = new FluidRenderProperties(Applications.TABLE);
// public static final FluidRenderProperties DEFAULT_BASIN = new FluidRenderProperties(Applications.BASIN);
//
// public float minHeight, maxHeight, minX, maxX, minZ, maxZ;
//
// public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ)
// {
// this.minHeight = minHeight;
// this.maxHeight = maxHeight;
// this.minX = minX;
// this.maxX = maxX;
// this.minZ = minZ;
// this.maxZ = maxZ;
// }
//
// public FluidRenderProperties(float minHeight, float maxHeight, Applications defaults)
// {
// this(minHeight, maxHeight, defaults.minX, defaults.maxX, defaults.minZ, defaults.maxZ);
// }
//
// public FluidRenderProperties(float minHeight, float maxHeight, float minX, float maxX, Applications defaults)
// {
// this(minHeight, maxHeight, minX, maxX, defaults.minZ, defaults.maxZ);
// }
//
// public FluidRenderProperties(Applications defaults, float minX, float maxX)
// {
// this(defaults.minHeight, defaults.maxHeight, minX, maxX, defaults.minZ, defaults.maxZ);
// }
//
// public FluidRenderProperties(Applications defaults, float minX, float maxX, float minZ, float maxZ)
// {
// this(defaults.minHeight, defaults.maxHeight, minX, maxX, minZ, maxZ);
// }
//
// public FluidRenderProperties(Applications defaults)
// {
// this(defaults.minHeight, defaults.maxHeight, defaults.minX, defaults.maxX, defaults.minZ, defaults.maxZ);
// }
//
// public static enum Applications
// {
// TABLE(0.9375F, 1F, 0.0625F, 0.9375F, 0.062F, 0.9375F), BASIN(0.25F, 0.95F, 0.0625F, 0.9375F, 0.0625F, 0.9375F);
//
// public float minHeight, maxHeight, minX, maxX, minZ, maxZ;
//
// Applications(float minHeight, float maxHeight, float minX, float maxX, float minZ, float maxZ)
// {
// this.minHeight = minHeight;
// this.maxHeight = maxHeight;
// this.minX = minX;
// this.maxX = maxX;
// this.minZ = minZ;
// this.maxZ = maxZ;
// }
// }
// }
// Path: src/api/java/tconstruct/library/crafting/CastingRecipe.java
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.client.FluidRenderProperties;
package tconstruct.library.crafting;
public class CastingRecipe
{
public ItemStack output;
public FluidStack castingMetal;
public ItemStack cast;
public boolean consumeCast;
public int coolTime; | public FluidRenderProperties fluidRenderProperties; |
Lomeli12/Equivalency | src/api/java/tconstruct/library/util/IPattern.java | // Path: src/api/java/tconstruct/library/crafting/PatternBuilder.java
// public class MaterialSet
// {
// public final ItemStack shard;
// public final ItemStack rod;
// public final int materialID;
//
// public MaterialSet(ItemStack s, ItemStack r, int id)
// {
// shard = s;
// rod = r;
// materialID = id;
// }
// }
| import net.minecraft.item.ItemStack;
import tconstruct.library.crafting.PatternBuilder.MaterialSet; | package tconstruct.library.util;
public interface IPattern
{
public int getPatternCost (ItemStack pattern);
| // Path: src/api/java/tconstruct/library/crafting/PatternBuilder.java
// public class MaterialSet
// {
// public final ItemStack shard;
// public final ItemStack rod;
// public final int materialID;
//
// public MaterialSet(ItemStack s, ItemStack r, int id)
// {
// shard = s;
// rod = r;
// materialID = id;
// }
// }
// Path: src/api/java/tconstruct/library/util/IPattern.java
import net.minecraft.item.ItemStack;
import tconstruct.library.crafting.PatternBuilder.MaterialSet;
package tconstruct.library.util;
public interface IPattern
{
public int getPatternCost (ItemStack pattern);
| public ItemStack getPatternOutput (ItemStack pattern, ItemStack input, MaterialSet set); |
Lomeli12/Equivalency | src/api/java/appeng/api/networking/IGrid.java | // Path: src/api/java/appeng/api/networking/events/MENetworkEvent.java
// public class MENetworkEvent
// {
//
// private int visited = 0;
// private boolean canceled = false;
//
// /**
// * Call to prevent AE from posting the event to any further objects.
// */
// public void cancel()
// {
// canceled = true;
// }
//
// /**
// * called by AE after each object is called to cancel any future calls.
// *
// * @return
// */
// public boolean isCanceled()
// {
// return canceled;
// }
//
// /**
// * the number of objects that were visited by the event.
// *
// * @return
// */
// public int getVisitedObjects()
// {
// return visited;
// }
//
// /**
// * Called by AE after iterating the event subscribers.
// *
// * @param v
// */
// public void setVisitedObjects(int v)
// {
// visited = v;
// }
// }
| import appeng.api.networking.events.MENetworkEvent;
import appeng.api.util.IReadOnlyCollection; | package appeng.api.networking;
/**
* Gives you access to Grid based information.
*
* Don't Implement.
*/
public interface IGrid
{
/**
* Get Access to various grid modules
*
* @param iface
* @return the IGridCache you requested.
*/
public <C extends IGridCache> C getCache(Class<? extends IGridCache> iface);
/**
* Post an event into the network event bus.
*
* @param ev
* - event to post
* @return returns ev back to original poster
*/ | // Path: src/api/java/appeng/api/networking/events/MENetworkEvent.java
// public class MENetworkEvent
// {
//
// private int visited = 0;
// private boolean canceled = false;
//
// /**
// * Call to prevent AE from posting the event to any further objects.
// */
// public void cancel()
// {
// canceled = true;
// }
//
// /**
// * called by AE after each object is called to cancel any future calls.
// *
// * @return
// */
// public boolean isCanceled()
// {
// return canceled;
// }
//
// /**
// * the number of objects that were visited by the event.
// *
// * @return
// */
// public int getVisitedObjects()
// {
// return visited;
// }
//
// /**
// * Called by AE after iterating the event subscribers.
// *
// * @param v
// */
// public void setVisitedObjects(int v)
// {
// visited = v;
// }
// }
// Path: src/api/java/appeng/api/networking/IGrid.java
import appeng.api.networking.events.MENetworkEvent;
import appeng.api.util.IReadOnlyCollection;
package appeng.api.networking;
/**
* Gives you access to Grid based information.
*
* Don't Implement.
*/
public interface IGrid
{
/**
* Get Access to various grid modules
*
* @param iface
* @return the IGridCache you requested.
*/
public <C extends IGridCache> C getCache(Class<? extends IGridCache> iface);
/**
* Post an event into the network event bus.
*
* @param ev
* - event to post
* @return returns ev back to original poster
*/ | public MENetworkEvent postEvent(MENetworkEvent ev); |
Lomeli12/Equivalency | src/api/java/appeng/api/definitions/Parts.java | // Path: src/api/java/appeng/api/util/AEColoredItemDefinition.java
// public interface AEColoredItemDefinition
// {
//
// /**
// * @return the {@link Block} Implementation if applicable
// */
// Block block(AEColor color);
//
// /**
// * @return the {@link Item} Implementation if applicable
// */
// Item item(AEColor color);
//
// /**
// * @return the {@link TileEntity} Class if applicable.
// */
// Class<? extends TileEntity> entity(AEColor color);
//
// /**
// * @return an {@link ItemStack} with specified quantity of this item.
// */
// ItemStack stack(AEColor color, int stackSize);
//
// /**
// * @param stackSize
// * - stack size of the result.
// * @return an array of all colors.
// */
// ItemStack[] allStacks(int stackSize);
//
// /**
// * Compare {@link ItemStack} with this {@link AEItemDefinition}
// *
// * @param comparableItem
// * @return true if the item stack is a matching item.
// */
// boolean sameAs(AEColor color, ItemStack comparableItem);
//
// }
| import appeng.api.util.AEColoredItemDefinition;
import appeng.api.util.AEItemDefinition; | package appeng.api.definitions;
public class Parts
{
| // Path: src/api/java/appeng/api/util/AEColoredItemDefinition.java
// public interface AEColoredItemDefinition
// {
//
// /**
// * @return the {@link Block} Implementation if applicable
// */
// Block block(AEColor color);
//
// /**
// * @return the {@link Item} Implementation if applicable
// */
// Item item(AEColor color);
//
// /**
// * @return the {@link TileEntity} Class if applicable.
// */
// Class<? extends TileEntity> entity(AEColor color);
//
// /**
// * @return an {@link ItemStack} with specified quantity of this item.
// */
// ItemStack stack(AEColor color, int stackSize);
//
// /**
// * @param stackSize
// * - stack size of the result.
// * @return an array of all colors.
// */
// ItemStack[] allStacks(int stackSize);
//
// /**
// * Compare {@link ItemStack} with this {@link AEItemDefinition}
// *
// * @param comparableItem
// * @return true if the item stack is a matching item.
// */
// boolean sameAs(AEColor color, ItemStack comparableItem);
//
// }
// Path: src/api/java/appeng/api/definitions/Parts.java
import appeng.api.util.AEColoredItemDefinition;
import appeng.api.util.AEItemDefinition;
package appeng.api.definitions;
public class Parts
{
| public AEColoredItemDefinition partCableSmart; |
Lomeli12/Equivalency | src/api/java/appeng/api/storage/ICellHandler.java | // Path: src/api/java/appeng/api/implementations/tiles/IChestOrDrive.java
// public interface IChestOrDrive extends ICellContainer, IGridHost, IOrientable
// {
//
// /**
// * @return how many slots are available. Chest has 1, Drive has 10.
// */
// int getCellCount();
//
// /**
// * 0 - cell is missing.
// *
// * 1 - green,
// *
// * 2 - orange,
// *
// * 3 - red
// *
// * @param slot
// * @return status of the slot, one of the above indices.
// */
// int getCellStatus(int slot);
//
// /**
// * @return if the device is online you should check this before providing any other information.
// */
// boolean isPowered();
//
// /**
// * @param slot
// * @return is the cell currently blinking to show activity.
// */
// boolean isCellBlinking(int slot);
//
// }
| import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import appeng.api.implementations.tiles.IChestOrDrive;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; | package appeng.api.storage;
/**
* Registration record for {@link ICellRegistry}
*/
public interface ICellHandler
{
/**
* return true if the provided item is handled by your cell handler. ( AE May choose to skip this method, and just
* request a handler )
*
* @param is
* @return return true, if getCellHandler will not return null.
*/
boolean isCell(ItemStack is);
/**
* If you cannot handle the provided item, return null
*
* @param is
* a storage cell item.
*
* @return a new IMEHandler for the provided item
*/
IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel channel);
/**
* @return the ME Chest texture for this storage cell type, should be 10x10 with 3px of transparent padding on a
* 16x16 texture, null is valid if your cell cannot be used in the ME Chest. refer to the assets for
* examples and colors.
*/
@SideOnly(Side.CLIENT)
IIcon getTopTexture();
/**
*
* Called when the storage cell is planed in an ME Chest and the user tries to open the terminal side, if your item
* is not available via ME Chests simply tell the user they can't use it, or something, other wise you should open
* your gui and display the cell to the user.
*
* @param player
* @param chest
* @param cellHandler
* @param inv
* @param is
* @param chan
*/ | // Path: src/api/java/appeng/api/implementations/tiles/IChestOrDrive.java
// public interface IChestOrDrive extends ICellContainer, IGridHost, IOrientable
// {
//
// /**
// * @return how many slots are available. Chest has 1, Drive has 10.
// */
// int getCellCount();
//
// /**
// * 0 - cell is missing.
// *
// * 1 - green,
// *
// * 2 - orange,
// *
// * 3 - red
// *
// * @param slot
// * @return status of the slot, one of the above indices.
// */
// int getCellStatus(int slot);
//
// /**
// * @return if the device is online you should check this before providing any other information.
// */
// boolean isPowered();
//
// /**
// * @param slot
// * @return is the cell currently blinking to show activity.
// */
// boolean isCellBlinking(int slot);
//
// }
// Path: src/api/java/appeng/api/storage/ICellHandler.java
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import appeng.api.implementations.tiles.IChestOrDrive;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
package appeng.api.storage;
/**
* Registration record for {@link ICellRegistry}
*/
public interface ICellHandler
{
/**
* return true if the provided item is handled by your cell handler. ( AE May choose to skip this method, and just
* request a handler )
*
* @param is
* @return return true, if getCellHandler will not return null.
*/
boolean isCell(ItemStack is);
/**
* If you cannot handle the provided item, return null
*
* @param is
* a storage cell item.
*
* @return a new IMEHandler for the provided item
*/
IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel channel);
/**
* @return the ME Chest texture for this storage cell type, should be 10x10 with 3px of transparent padding on a
* 16x16 texture, null is valid if your cell cannot be used in the ME Chest. refer to the assets for
* examples and colors.
*/
@SideOnly(Side.CLIENT)
IIcon getTopTexture();
/**
*
* Called when the storage cell is planed in an ME Chest and the user tries to open the terminal side, if your item
* is not available via ME Chests simply tell the user they can't use it, or something, other wise you should open
* your gui and display the cell to the user.
*
* @param player
* @param chest
* @param cellHandler
* @param inv
* @param is
* @param chan
*/ | void openChestGui(EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan); |
Lomeli12/Equivalency | src/api/java/appeng/api/features/IRegistryContainer.java | // Path: src/api/java/appeng/api/movable/IMovableRegistry.java
// public interface IMovableRegistry
// {
//
// /**
// * White list your tile entity with the registry.
// *
// * You can also use the IMC, FMLInterModComms.sendMessage(
// * "AppliedEnergistics", "movabletile", "appeng.common.AppEngTile" );
// *
// * If you tile is handled with IMovableHandler or IMovableTile you do not
// * need to white list it.
// */
// void whiteListTileEntity(Class<? extends TileEntity> c);
//
// /**
// * @param te
// * @return true if the tile has accepted your request to move it
// */
// boolean askToMove(TileEntity te);
//
// /**
// * tells the tile you are done moving it.
// *
// * @param te
// */
// void doneMoving(TileEntity te);
//
// /**
// * add a new handler movable handler.
// *
// * @param handler
// */
// void addHandler(IMovableHandler handler);
//
// /**
// * handlers are used to perform movement, this allows you to override AE's
// * internal version.
// *
// * only valid after askToMove(...) = true
// *
// * @param te
// * @return
// */
// IMovableHandler getHandler(TileEntity te);
//
// /**
// * @return a copy of the default handler
// */
// IMovableHandler getDefaultHandler();
//
// }
//
// Path: src/api/java/appeng/api/storage/ICellRegistry.java
// public interface ICellRegistry
// {
//
// /**
// * Register a new handler.
// *
// * @param handler
// */
// void addCellHandler(ICellHandler handler);
//
// /**
// * return true, if you can get a InventoryHandler for the item passed.
// *
// * @param is
// * @return true if the provided item, can be handled by a handler in AE, ( AE May choose to skip this and just get
// * the handler instead. )
// */
// boolean isCellHandled(ItemStack is);
//
// /**
// * get the handler, for the requested type.
// *
// * @param is
// * @return the handler registered for this item type.
// */
// ICellHandler getHandler(ItemStack is);
//
// /**
// * returns an IMEInventoryHandler for the provided item.
// *
// * @param is
// * @return new IMEInventoryHandler, or null if there isn't one.
// */
// IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel chan);
//
// }
| import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IExternalStorageRegistry; | package appeng.api.features;
public interface IRegistryContainer
{
/**
* Use the movable registry to white list your tiles.
*/ | // Path: src/api/java/appeng/api/movable/IMovableRegistry.java
// public interface IMovableRegistry
// {
//
// /**
// * White list your tile entity with the registry.
// *
// * You can also use the IMC, FMLInterModComms.sendMessage(
// * "AppliedEnergistics", "movabletile", "appeng.common.AppEngTile" );
// *
// * If you tile is handled with IMovableHandler or IMovableTile you do not
// * need to white list it.
// */
// void whiteListTileEntity(Class<? extends TileEntity> c);
//
// /**
// * @param te
// * @return true if the tile has accepted your request to move it
// */
// boolean askToMove(TileEntity te);
//
// /**
// * tells the tile you are done moving it.
// *
// * @param te
// */
// void doneMoving(TileEntity te);
//
// /**
// * add a new handler movable handler.
// *
// * @param handler
// */
// void addHandler(IMovableHandler handler);
//
// /**
// * handlers are used to perform movement, this allows you to override AE's
// * internal version.
// *
// * only valid after askToMove(...) = true
// *
// * @param te
// * @return
// */
// IMovableHandler getHandler(TileEntity te);
//
// /**
// * @return a copy of the default handler
// */
// IMovableHandler getDefaultHandler();
//
// }
//
// Path: src/api/java/appeng/api/storage/ICellRegistry.java
// public interface ICellRegistry
// {
//
// /**
// * Register a new handler.
// *
// * @param handler
// */
// void addCellHandler(ICellHandler handler);
//
// /**
// * return true, if you can get a InventoryHandler for the item passed.
// *
// * @param is
// * @return true if the provided item, can be handled by a handler in AE, ( AE May choose to skip this and just get
// * the handler instead. )
// */
// boolean isCellHandled(ItemStack is);
//
// /**
// * get the handler, for the requested type.
// *
// * @param is
// * @return the handler registered for this item type.
// */
// ICellHandler getHandler(ItemStack is);
//
// /**
// * returns an IMEInventoryHandler for the provided item.
// *
// * @param is
// * @return new IMEInventoryHandler, or null if there isn't one.
// */
// IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel chan);
//
// }
// Path: src/api/java/appeng/api/features/IRegistryContainer.java
import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IExternalStorageRegistry;
package appeng.api.features;
public interface IRegistryContainer
{
/**
* Use the movable registry to white list your tiles.
*/ | IMovableRegistry moveable(); |
Lomeli12/Equivalency | src/api/java/appeng/api/features/IRegistryContainer.java | // Path: src/api/java/appeng/api/movable/IMovableRegistry.java
// public interface IMovableRegistry
// {
//
// /**
// * White list your tile entity with the registry.
// *
// * You can also use the IMC, FMLInterModComms.sendMessage(
// * "AppliedEnergistics", "movabletile", "appeng.common.AppEngTile" );
// *
// * If you tile is handled with IMovableHandler or IMovableTile you do not
// * need to white list it.
// */
// void whiteListTileEntity(Class<? extends TileEntity> c);
//
// /**
// * @param te
// * @return true if the tile has accepted your request to move it
// */
// boolean askToMove(TileEntity te);
//
// /**
// * tells the tile you are done moving it.
// *
// * @param te
// */
// void doneMoving(TileEntity te);
//
// /**
// * add a new handler movable handler.
// *
// * @param handler
// */
// void addHandler(IMovableHandler handler);
//
// /**
// * handlers are used to perform movement, this allows you to override AE's
// * internal version.
// *
// * only valid after askToMove(...) = true
// *
// * @param te
// * @return
// */
// IMovableHandler getHandler(TileEntity te);
//
// /**
// * @return a copy of the default handler
// */
// IMovableHandler getDefaultHandler();
//
// }
//
// Path: src/api/java/appeng/api/storage/ICellRegistry.java
// public interface ICellRegistry
// {
//
// /**
// * Register a new handler.
// *
// * @param handler
// */
// void addCellHandler(ICellHandler handler);
//
// /**
// * return true, if you can get a InventoryHandler for the item passed.
// *
// * @param is
// * @return true if the provided item, can be handled by a handler in AE, ( AE May choose to skip this and just get
// * the handler instead. )
// */
// boolean isCellHandled(ItemStack is);
//
// /**
// * get the handler, for the requested type.
// *
// * @param is
// * @return the handler registered for this item type.
// */
// ICellHandler getHandler(ItemStack is);
//
// /**
// * returns an IMEInventoryHandler for the provided item.
// *
// * @param is
// * @return new IMEInventoryHandler, or null if there isn't one.
// */
// IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel chan);
//
// }
| import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IExternalStorageRegistry; | package appeng.api.features;
public interface IRegistryContainer
{
/**
* Use the movable registry to white list your tiles.
*/
IMovableRegistry moveable();
/**
* Add new Grid Caches for use during run time, only use during loading phase.
*/
IGridCacheRegistry gridCache();
/**
* Add additional storage bus handlers to improve interplay with mod blocks that contains special inventories that
* function unlike vanilla chests. AE uses this internally for barrels, dsu's, quantum chests, AE Networks and more.
*/
IExternalStorageRegistry externalStorage();
/**
* Add additional special comparison functionality, AE Uses this internally for Bees.
*/
ISpecialComparisonRegistry specialComparson();
/**
* Lets you register your items as wireless terminals
*/
IWirelessTermRegistery wireless();
/**
* Allows you to register new cell types, these will function in drives
*/ | // Path: src/api/java/appeng/api/movable/IMovableRegistry.java
// public interface IMovableRegistry
// {
//
// /**
// * White list your tile entity with the registry.
// *
// * You can also use the IMC, FMLInterModComms.sendMessage(
// * "AppliedEnergistics", "movabletile", "appeng.common.AppEngTile" );
// *
// * If you tile is handled with IMovableHandler or IMovableTile you do not
// * need to white list it.
// */
// void whiteListTileEntity(Class<? extends TileEntity> c);
//
// /**
// * @param te
// * @return true if the tile has accepted your request to move it
// */
// boolean askToMove(TileEntity te);
//
// /**
// * tells the tile you are done moving it.
// *
// * @param te
// */
// void doneMoving(TileEntity te);
//
// /**
// * add a new handler movable handler.
// *
// * @param handler
// */
// void addHandler(IMovableHandler handler);
//
// /**
// * handlers are used to perform movement, this allows you to override AE's
// * internal version.
// *
// * only valid after askToMove(...) = true
// *
// * @param te
// * @return
// */
// IMovableHandler getHandler(TileEntity te);
//
// /**
// * @return a copy of the default handler
// */
// IMovableHandler getDefaultHandler();
//
// }
//
// Path: src/api/java/appeng/api/storage/ICellRegistry.java
// public interface ICellRegistry
// {
//
// /**
// * Register a new handler.
// *
// * @param handler
// */
// void addCellHandler(ICellHandler handler);
//
// /**
// * return true, if you can get a InventoryHandler for the item passed.
// *
// * @param is
// * @return true if the provided item, can be handled by a handler in AE, ( AE May choose to skip this and just get
// * the handler instead. )
// */
// boolean isCellHandled(ItemStack is);
//
// /**
// * get the handler, for the requested type.
// *
// * @param is
// * @return the handler registered for this item type.
// */
// ICellHandler getHandler(ItemStack is);
//
// /**
// * returns an IMEInventoryHandler for the provided item.
// *
// * @param is
// * @return new IMEInventoryHandler, or null if there isn't one.
// */
// IMEInventoryHandler getCellInventory(ItemStack is, StorageChannel chan);
//
// }
// Path: src/api/java/appeng/api/features/IRegistryContainer.java
import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IExternalStorageRegistry;
package appeng.api.features;
public interface IRegistryContainer
{
/**
* Use the movable registry to white list your tiles.
*/
IMovableRegistry moveable();
/**
* Add new Grid Caches for use during run time, only use during loading phase.
*/
IGridCacheRegistry gridCache();
/**
* Add additional storage bus handlers to improve interplay with mod blocks that contains special inventories that
* function unlike vanilla chests. AE uses this internally for barrels, dsu's, quantum chests, AE Networks and more.
*/
IExternalStorageRegistry externalStorage();
/**
* Add additional special comparison functionality, AE Uses this internally for Bees.
*/
ISpecialComparisonRegistry specialComparson();
/**
* Lets you register your items as wireless terminals
*/
IWirelessTermRegistery wireless();
/**
* Allows you to register new cell types, these will function in drives
*/ | ICellRegistry cell(); |
Lomeli12/Equivalency | src/api/java/appeng/api/storage/IStorageHelper.java | // Path: src/api/java/appeng/api/networking/energy/IEnergySource.java
// public interface IEnergySource
// {
//
// /**
// * Extract power from the network.
// *
// * @param amt
// * @param mode
// * should the action be simulated or performed?
// * @return returns extracted power.
// */
// public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier);
//
// }
//
// Path: src/api/java/appeng/api/storage/data/IAEItemStack.java
// public interface IAEItemStack extends IAEStack<IAEItemStack>
// {
//
// /**
// * creates a standard MC ItemStack for the item.
// *
// * @return new ItemStack
// */
// public ItemStack getItemStack();
//
// /**
// * create a AE Item clone
// *
// * @return the copy
// */
// @Override
// public IAEItemStack copy();
//
// /**
// * is there NBT Data for this item?
// *
// * @return if there is
// */
// boolean hasTagCompound();
//
// /**
// * Combines two IAEItemStacks via addition.
// *
// * @param option
// * to add to the current one.
// */
// @Override
// void add(IAEItemStack option);
//
// /**
// * quick way to get access to the MC Item Definition.
// *
// * @return
// */
// Item getItem();
//
// /**
// * @return the items damage value
// */
// int getItemDamage();
//
// /**
// * Compare the Ore Dictionary ID for this to another item.
// */
// boolean sameOre(IAEItemStack is);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(IAEItemStack otherStack);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(ItemStack stored);
// }
//
// Path: src/api/java/appeng/api/storage/data/IItemList.java
// public interface IItemList<StackType extends IAEStack> extends Iterable<StackType>
// {
//
// /**
// * add a stack to the list stackSize is used to add to stackSize, this will merge the stack with an item already in
// * the list if found.
// *
// * @param option
// */
// public void addStorage(StackType option); // adds a stack as stored
//
// /**
// * add a stack to the list as craftable, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void addCrafting(StackType option);
//
// /**
// * add a stack to the list, stack size is used to add to requstable, this will merge the stack with an item already
// * in the list if found.
// *
// * @param option
// */
// public void addRequestable(StackType option); // adds a stack as requestable
//
// /**
// * add a stack to the list, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void add(StackType option); // adds stack as is
//
// /**
// * @return the first item in the list
// */
// StackType getFirstItem();
//
// /**
// * @param i
// * @return a stack equivalent to the stack passed in, but with the correct stack size information, or null if its
// * not present
// */
// StackType findPrecise(StackType i);
//
// /**
// * @param input
// * @return a list of relevant fuzzy matched stacks
// */
// public Collection<StackType> findFuzzy(StackType input, FuzzyMode fuzzy);
//
// /**
// * @return the number of items in the list
// */
// int size();
//
// /**
// * allows you to iterate the list.
// */
// @Override
// public Iterator<StackType> iterator();
//
// /**
// * @return true if there are no items in the list
// */
// public boolean isEmpty();
//
// /**
// * resets stack sizes to 0.
// */
// void resetStatus();
//
// }
| import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; | package appeng.api.storage;
public interface IStorageHelper
{
/**
* @param is
* An ItemStack
*
* @return a new instance of {@link IAEItemStack} from a MC {@link ItemStack}
*/ | // Path: src/api/java/appeng/api/networking/energy/IEnergySource.java
// public interface IEnergySource
// {
//
// /**
// * Extract power from the network.
// *
// * @param amt
// * @param mode
// * should the action be simulated or performed?
// * @return returns extracted power.
// */
// public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier);
//
// }
//
// Path: src/api/java/appeng/api/storage/data/IAEItemStack.java
// public interface IAEItemStack extends IAEStack<IAEItemStack>
// {
//
// /**
// * creates a standard MC ItemStack for the item.
// *
// * @return new ItemStack
// */
// public ItemStack getItemStack();
//
// /**
// * create a AE Item clone
// *
// * @return the copy
// */
// @Override
// public IAEItemStack copy();
//
// /**
// * is there NBT Data for this item?
// *
// * @return if there is
// */
// boolean hasTagCompound();
//
// /**
// * Combines two IAEItemStacks via addition.
// *
// * @param option
// * to add to the current one.
// */
// @Override
// void add(IAEItemStack option);
//
// /**
// * quick way to get access to the MC Item Definition.
// *
// * @return
// */
// Item getItem();
//
// /**
// * @return the items damage value
// */
// int getItemDamage();
//
// /**
// * Compare the Ore Dictionary ID for this to another item.
// */
// boolean sameOre(IAEItemStack is);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(IAEItemStack otherStack);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(ItemStack stored);
// }
//
// Path: src/api/java/appeng/api/storage/data/IItemList.java
// public interface IItemList<StackType extends IAEStack> extends Iterable<StackType>
// {
//
// /**
// * add a stack to the list stackSize is used to add to stackSize, this will merge the stack with an item already in
// * the list if found.
// *
// * @param option
// */
// public void addStorage(StackType option); // adds a stack as stored
//
// /**
// * add a stack to the list as craftable, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void addCrafting(StackType option);
//
// /**
// * add a stack to the list, stack size is used to add to requstable, this will merge the stack with an item already
// * in the list if found.
// *
// * @param option
// */
// public void addRequestable(StackType option); // adds a stack as requestable
//
// /**
// * add a stack to the list, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void add(StackType option); // adds stack as is
//
// /**
// * @return the first item in the list
// */
// StackType getFirstItem();
//
// /**
// * @param i
// * @return a stack equivalent to the stack passed in, but with the correct stack size information, or null if its
// * not present
// */
// StackType findPrecise(StackType i);
//
// /**
// * @param input
// * @return a list of relevant fuzzy matched stacks
// */
// public Collection<StackType> findFuzzy(StackType input, FuzzyMode fuzzy);
//
// /**
// * @return the number of items in the list
// */
// int size();
//
// /**
// * allows you to iterate the list.
// */
// @Override
// public Iterator<StackType> iterator();
//
// /**
// * @return true if there are no items in the list
// */
// public boolean isEmpty();
//
// /**
// * resets stack sizes to 0.
// */
// void resetStatus();
//
// }
// Path: src/api/java/appeng/api/storage/IStorageHelper.java
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
package appeng.api.storage;
public interface IStorageHelper
{
/**
* @param is
* An ItemStack
*
* @return a new instance of {@link IAEItemStack} from a MC {@link ItemStack}
*/ | IAEItemStack createItemStack(ItemStack is); |
Lomeli12/Equivalency | src/api/java/appeng/api/storage/IStorageHelper.java | // Path: src/api/java/appeng/api/networking/energy/IEnergySource.java
// public interface IEnergySource
// {
//
// /**
// * Extract power from the network.
// *
// * @param amt
// * @param mode
// * should the action be simulated or performed?
// * @return returns extracted power.
// */
// public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier);
//
// }
//
// Path: src/api/java/appeng/api/storage/data/IAEItemStack.java
// public interface IAEItemStack extends IAEStack<IAEItemStack>
// {
//
// /**
// * creates a standard MC ItemStack for the item.
// *
// * @return new ItemStack
// */
// public ItemStack getItemStack();
//
// /**
// * create a AE Item clone
// *
// * @return the copy
// */
// @Override
// public IAEItemStack copy();
//
// /**
// * is there NBT Data for this item?
// *
// * @return if there is
// */
// boolean hasTagCompound();
//
// /**
// * Combines two IAEItemStacks via addition.
// *
// * @param option
// * to add to the current one.
// */
// @Override
// void add(IAEItemStack option);
//
// /**
// * quick way to get access to the MC Item Definition.
// *
// * @return
// */
// Item getItem();
//
// /**
// * @return the items damage value
// */
// int getItemDamage();
//
// /**
// * Compare the Ore Dictionary ID for this to another item.
// */
// boolean sameOre(IAEItemStack is);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(IAEItemStack otherStack);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(ItemStack stored);
// }
//
// Path: src/api/java/appeng/api/storage/data/IItemList.java
// public interface IItemList<StackType extends IAEStack> extends Iterable<StackType>
// {
//
// /**
// * add a stack to the list stackSize is used to add to stackSize, this will merge the stack with an item already in
// * the list if found.
// *
// * @param option
// */
// public void addStorage(StackType option); // adds a stack as stored
//
// /**
// * add a stack to the list as craftable, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void addCrafting(StackType option);
//
// /**
// * add a stack to the list, stack size is used to add to requstable, this will merge the stack with an item already
// * in the list if found.
// *
// * @param option
// */
// public void addRequestable(StackType option); // adds a stack as requestable
//
// /**
// * add a stack to the list, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void add(StackType option); // adds stack as is
//
// /**
// * @return the first item in the list
// */
// StackType getFirstItem();
//
// /**
// * @param i
// * @return a stack equivalent to the stack passed in, but with the correct stack size information, or null if its
// * not present
// */
// StackType findPrecise(StackType i);
//
// /**
// * @param input
// * @return a list of relevant fuzzy matched stacks
// */
// public Collection<StackType> findFuzzy(StackType input, FuzzyMode fuzzy);
//
// /**
// * @return the number of items in the list
// */
// int size();
//
// /**
// * allows you to iterate the list.
// */
// @Override
// public Iterator<StackType> iterator();
//
// /**
// * @return true if there are no items in the list
// */
// public boolean isEmpty();
//
// /**
// * resets stack sizes to 0.
// */
// void resetStatus();
//
// }
| import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; | package appeng.api.storage;
public interface IStorageHelper
{
/**
* @param is
* An ItemStack
*
* @return a new instance of {@link IAEItemStack} from a MC {@link ItemStack}
*/
IAEItemStack createItemStack(ItemStack is);
/**
* @param is
* A FluidStack
*
* @return a new instance of {@link IAEFluidStack} from a Forge {@link FluidStack}
*/
IAEFluidStack createFluidStack(FluidStack is);
/**
* @return a new instance of {@link IItemList} for items
*/ | // Path: src/api/java/appeng/api/networking/energy/IEnergySource.java
// public interface IEnergySource
// {
//
// /**
// * Extract power from the network.
// *
// * @param amt
// * @param mode
// * should the action be simulated or performed?
// * @return returns extracted power.
// */
// public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier);
//
// }
//
// Path: src/api/java/appeng/api/storage/data/IAEItemStack.java
// public interface IAEItemStack extends IAEStack<IAEItemStack>
// {
//
// /**
// * creates a standard MC ItemStack for the item.
// *
// * @return new ItemStack
// */
// public ItemStack getItemStack();
//
// /**
// * create a AE Item clone
// *
// * @return the copy
// */
// @Override
// public IAEItemStack copy();
//
// /**
// * is there NBT Data for this item?
// *
// * @return if there is
// */
// boolean hasTagCompound();
//
// /**
// * Combines two IAEItemStacks via addition.
// *
// * @param option
// * to add to the current one.
// */
// @Override
// void add(IAEItemStack option);
//
// /**
// * quick way to get access to the MC Item Definition.
// *
// * @return
// */
// Item getItem();
//
// /**
// * @return the items damage value
// */
// int getItemDamage();
//
// /**
// * Compare the Ore Dictionary ID for this to another item.
// */
// boolean sameOre(IAEItemStack is);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(IAEItemStack otherStack);
//
// /**
// * compare the item/damage/nbt of the stack.
// *
// * @param otherStack
// * @return
// */
// boolean isSameType(ItemStack stored);
// }
//
// Path: src/api/java/appeng/api/storage/data/IItemList.java
// public interface IItemList<StackType extends IAEStack> extends Iterable<StackType>
// {
//
// /**
// * add a stack to the list stackSize is used to add to stackSize, this will merge the stack with an item already in
// * the list if found.
// *
// * @param option
// */
// public void addStorage(StackType option); // adds a stack as stored
//
// /**
// * add a stack to the list as craftable, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void addCrafting(StackType option);
//
// /**
// * add a stack to the list, stack size is used to add to requstable, this will merge the stack with an item already
// * in the list if found.
// *
// * @param option
// */
// public void addRequestable(StackType option); // adds a stack as requestable
//
// /**
// * add a stack to the list, this will merge the stack with an item already in the list if found.
// *
// * @param option
// */
// public void add(StackType option); // adds stack as is
//
// /**
// * @return the first item in the list
// */
// StackType getFirstItem();
//
// /**
// * @param i
// * @return a stack equivalent to the stack passed in, but with the correct stack size information, or null if its
// * not present
// */
// StackType findPrecise(StackType i);
//
// /**
// * @param input
// * @return a list of relevant fuzzy matched stacks
// */
// public Collection<StackType> findFuzzy(StackType input, FuzzyMode fuzzy);
//
// /**
// * @return the number of items in the list
// */
// int size();
//
// /**
// * allows you to iterate the list.
// */
// @Override
// public Iterator<StackType> iterator();
//
// /**
// * @return true if there are no items in the list
// */
// public boolean isEmpty();
//
// /**
// * resets stack sizes to 0.
// */
// void resetStatus();
//
// }
// Path: src/api/java/appeng/api/storage/IStorageHelper.java
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
package appeng.api.storage;
public interface IStorageHelper
{
/**
* @param is
* An ItemStack
*
* @return a new instance of {@link IAEItemStack} from a MC {@link ItemStack}
*/
IAEItemStack createItemStack(ItemStack is);
/**
* @param is
* A FluidStack
*
* @return a new instance of {@link IAEFluidStack} from a Forge {@link FluidStack}
*/
IAEFluidStack createFluidStack(FluidStack is);
/**
* @return a new instance of {@link IItemList} for items
*/ | IItemList<IAEItemStack> createItemList(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.