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
|
---|---|---|---|---|---|---|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfNodeMsgDao.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfNodeMsg.java
// public class XxlConfNodeMsg {
//
// private int id;
// private Date addtime;
// private String env;
// private String key;
// private String value;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Date getAddtime() {
// return addtime;
// }
//
// public void setAddtime(Date addtime) {
// this.addtime = addtime;
// }
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
|
import com.xxl.conf.admin.core.model.XxlConfNodeMsg;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
|
package com.xxl.conf.admin.dao;
/**
* Created by xuxueli on 16/10/8.
*/
@Mapper
public interface XxlConfNodeMsgDao {
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfNodeMsg.java
// public class XxlConfNodeMsg {
//
// private int id;
// private Date addtime;
// private String env;
// private String key;
// private String value;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public Date getAddtime() {
// return addtime;
// }
//
// public void setAddtime(Date addtime) {
// this.addtime = addtime;
// }
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfNodeMsgDao.java
import com.xxl.conf.admin.core.model.XxlConfNodeMsg;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
package com.xxl.conf.admin.dao;
/**
* Created by xuxueli on 16/10/8.
*/
@Mapper
public interface XxlConfNodeMsgDao {
|
public void add(XxlConfNodeMsg xxlConfNode);
|
xuxueli/xxl-conf
|
xxl-conf-samples/xxl-conf-sample-frameless/src/main/java/com.xxl.conf.sample.frameless/conf/FrameLessXxlConfConfig.java
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/factory/XxlConfBaseFactory.java
// public class XxlConfBaseFactory {
//
//
// /**
// * init
// *
// * @param adminAddress
// * @param env
// */
// public static void init(String adminAddress, String env, String accessToken, String mirrorfile) {
// // init
// XxlConfRemoteConf.init(adminAddress, env, accessToken); // init remote util
// XxlConfMirrorConf.init(mirrorfile); // init mirror util
// XxlConfLocalCacheConf.init(); // init cache + thread, cycle refresh + monitor
//
// XxlConfListenerFactory.addListener(null, new BeanRefreshXxlConfListener()); // listener all key change
//
// }
//
// /**
// * destory
// */
// public static void destroy() {
// XxlConfLocalCacheConf.destroy(); // destroy
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/util/PropUtil.java
// public class PropUtil {
// private static Logger logger = LoggerFactory.getLogger(PropUtil.class);
//
// /**
// * load prop
// *
// * @param propertyFileName disk path when start with "file:", other classpath
// * @return
// */
// public static Properties loadProp(String propertyFileName) {
//
// // disk path
// if (propertyFileName.startsWith("file:")) {
// propertyFileName = propertyFileName.substring("file:".length());
// return loadFileProp(propertyFileName);
// } else {
// return loadClassPathProp(propertyFileName);
// }
// }
//
// public static Properties loadClassPathProp(String propertyFileName) {
//
// InputStream in = null;
// try {
// in = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFileName);
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// public static Properties loadFileProp(String propertyFileName) {
// InputStream in = null;
// try {
// // load file location, disk
// File file = new File(propertyFileName);
// if (!file.exists()) {
// return null;
// }
//
// URL url = new File(propertyFileName).toURI().toURL();
// in = new FileInputStream(url.getPath());
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// /**
// * write prop to disk
// *
// * @param properties
// * @param filePathName
// * @return
// */
// public static boolean writeFileProp(Properties properties, String filePathName){
// FileOutputStream fileOutputStream = null;
// try {
//
// // mk file
// File file = new File(filePathName);
// if (!file.exists()) {
// file.getParentFile().mkdirs();
// }
//
// // write data
// fileOutputStream = new FileOutputStream(file, false);
// properties.store(new OutputStreamWriter(fileOutputStream, "utf-8"), null);
// //properties.store(new FileWriter(filePathName), null);
// return true;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// return false;
// } finally {
// if (fileOutputStream != null) {
// try {
// fileOutputStream.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// }
//
// }
|
import com.xxl.conf.core.factory.XxlConfBaseFactory;
import com.xxl.conf.core.util.PropUtil;
import java.util.Properties;
|
package com.xxl.conf.sample.frameless.conf;
/**
* @author xuxueli 2018-10-31 19:05:43
*/
public class FrameLessXxlConfConfig {
/**
* init
*/
public static void init() {
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/factory/XxlConfBaseFactory.java
// public class XxlConfBaseFactory {
//
//
// /**
// * init
// *
// * @param adminAddress
// * @param env
// */
// public static void init(String adminAddress, String env, String accessToken, String mirrorfile) {
// // init
// XxlConfRemoteConf.init(adminAddress, env, accessToken); // init remote util
// XxlConfMirrorConf.init(mirrorfile); // init mirror util
// XxlConfLocalCacheConf.init(); // init cache + thread, cycle refresh + monitor
//
// XxlConfListenerFactory.addListener(null, new BeanRefreshXxlConfListener()); // listener all key change
//
// }
//
// /**
// * destory
// */
// public static void destroy() {
// XxlConfLocalCacheConf.destroy(); // destroy
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/util/PropUtil.java
// public class PropUtil {
// private static Logger logger = LoggerFactory.getLogger(PropUtil.class);
//
// /**
// * load prop
// *
// * @param propertyFileName disk path when start with "file:", other classpath
// * @return
// */
// public static Properties loadProp(String propertyFileName) {
//
// // disk path
// if (propertyFileName.startsWith("file:")) {
// propertyFileName = propertyFileName.substring("file:".length());
// return loadFileProp(propertyFileName);
// } else {
// return loadClassPathProp(propertyFileName);
// }
// }
//
// public static Properties loadClassPathProp(String propertyFileName) {
//
// InputStream in = null;
// try {
// in = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFileName);
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// public static Properties loadFileProp(String propertyFileName) {
// InputStream in = null;
// try {
// // load file location, disk
// File file = new File(propertyFileName);
// if (!file.exists()) {
// return null;
// }
//
// URL url = new File(propertyFileName).toURI().toURL();
// in = new FileInputStream(url.getPath());
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// /**
// * write prop to disk
// *
// * @param properties
// * @param filePathName
// * @return
// */
// public static boolean writeFileProp(Properties properties, String filePathName){
// FileOutputStream fileOutputStream = null;
// try {
//
// // mk file
// File file = new File(filePathName);
// if (!file.exists()) {
// file.getParentFile().mkdirs();
// }
//
// // write data
// fileOutputStream = new FileOutputStream(file, false);
// properties.store(new OutputStreamWriter(fileOutputStream, "utf-8"), null);
// //properties.store(new FileWriter(filePathName), null);
// return true;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// return false;
// } finally {
// if (fileOutputStream != null) {
// try {
// fileOutputStream.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// }
//
// }
// Path: xxl-conf-samples/xxl-conf-sample-frameless/src/main/java/com.xxl.conf.sample.frameless/conf/FrameLessXxlConfConfig.java
import com.xxl.conf.core.factory.XxlConfBaseFactory;
import com.xxl.conf.core.util.PropUtil;
import java.util.Properties;
package com.xxl.conf.sample.frameless.conf;
/**
* @author xuxueli 2018-10-31 19:05:43
*/
public class FrameLessXxlConfConfig {
/**
* init
*/
public static void init() {
|
Properties prop = PropUtil.loadProp("xxl-conf.properties");
|
xuxueli/xxl-conf
|
xxl-conf-samples/xxl-conf-sample-frameless/src/main/java/com.xxl.conf.sample.frameless/conf/FrameLessXxlConfConfig.java
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/factory/XxlConfBaseFactory.java
// public class XxlConfBaseFactory {
//
//
// /**
// * init
// *
// * @param adminAddress
// * @param env
// */
// public static void init(String adminAddress, String env, String accessToken, String mirrorfile) {
// // init
// XxlConfRemoteConf.init(adminAddress, env, accessToken); // init remote util
// XxlConfMirrorConf.init(mirrorfile); // init mirror util
// XxlConfLocalCacheConf.init(); // init cache + thread, cycle refresh + monitor
//
// XxlConfListenerFactory.addListener(null, new BeanRefreshXxlConfListener()); // listener all key change
//
// }
//
// /**
// * destory
// */
// public static void destroy() {
// XxlConfLocalCacheConf.destroy(); // destroy
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/util/PropUtil.java
// public class PropUtil {
// private static Logger logger = LoggerFactory.getLogger(PropUtil.class);
//
// /**
// * load prop
// *
// * @param propertyFileName disk path when start with "file:", other classpath
// * @return
// */
// public static Properties loadProp(String propertyFileName) {
//
// // disk path
// if (propertyFileName.startsWith("file:")) {
// propertyFileName = propertyFileName.substring("file:".length());
// return loadFileProp(propertyFileName);
// } else {
// return loadClassPathProp(propertyFileName);
// }
// }
//
// public static Properties loadClassPathProp(String propertyFileName) {
//
// InputStream in = null;
// try {
// in = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFileName);
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// public static Properties loadFileProp(String propertyFileName) {
// InputStream in = null;
// try {
// // load file location, disk
// File file = new File(propertyFileName);
// if (!file.exists()) {
// return null;
// }
//
// URL url = new File(propertyFileName).toURI().toURL();
// in = new FileInputStream(url.getPath());
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// /**
// * write prop to disk
// *
// * @param properties
// * @param filePathName
// * @return
// */
// public static boolean writeFileProp(Properties properties, String filePathName){
// FileOutputStream fileOutputStream = null;
// try {
//
// // mk file
// File file = new File(filePathName);
// if (!file.exists()) {
// file.getParentFile().mkdirs();
// }
//
// // write data
// fileOutputStream = new FileOutputStream(file, false);
// properties.store(new OutputStreamWriter(fileOutputStream, "utf-8"), null);
// //properties.store(new FileWriter(filePathName), null);
// return true;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// return false;
// } finally {
// if (fileOutputStream != null) {
// try {
// fileOutputStream.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// }
//
// }
|
import com.xxl.conf.core.factory.XxlConfBaseFactory;
import com.xxl.conf.core.util.PropUtil;
import java.util.Properties;
|
package com.xxl.conf.sample.frameless.conf;
/**
* @author xuxueli 2018-10-31 19:05:43
*/
public class FrameLessXxlConfConfig {
/**
* init
*/
public static void init() {
Properties prop = PropUtil.loadProp("xxl-conf.properties");
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/factory/XxlConfBaseFactory.java
// public class XxlConfBaseFactory {
//
//
// /**
// * init
// *
// * @param adminAddress
// * @param env
// */
// public static void init(String adminAddress, String env, String accessToken, String mirrorfile) {
// // init
// XxlConfRemoteConf.init(adminAddress, env, accessToken); // init remote util
// XxlConfMirrorConf.init(mirrorfile); // init mirror util
// XxlConfLocalCacheConf.init(); // init cache + thread, cycle refresh + monitor
//
// XxlConfListenerFactory.addListener(null, new BeanRefreshXxlConfListener()); // listener all key change
//
// }
//
// /**
// * destory
// */
// public static void destroy() {
// XxlConfLocalCacheConf.destroy(); // destroy
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/util/PropUtil.java
// public class PropUtil {
// private static Logger logger = LoggerFactory.getLogger(PropUtil.class);
//
// /**
// * load prop
// *
// * @param propertyFileName disk path when start with "file:", other classpath
// * @return
// */
// public static Properties loadProp(String propertyFileName) {
//
// // disk path
// if (propertyFileName.startsWith("file:")) {
// propertyFileName = propertyFileName.substring("file:".length());
// return loadFileProp(propertyFileName);
// } else {
// return loadClassPathProp(propertyFileName);
// }
// }
//
// public static Properties loadClassPathProp(String propertyFileName) {
//
// InputStream in = null;
// try {
// in = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFileName);
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// public static Properties loadFileProp(String propertyFileName) {
// InputStream in = null;
// try {
// // load file location, disk
// File file = new File(propertyFileName);
// if (!file.exists()) {
// return null;
// }
//
// URL url = new File(propertyFileName).toURI().toURL();
// in = new FileInputStream(url.getPath());
// if (in == null) {
// return null;
// }
//
// Properties prop = new Properties();
// prop.load(new InputStreamReader(in, "utf-8"));
// return prop;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// } finally {
// if (in != null) {
// try {
// in.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// return null;
// }
//
//
// /**
// * write prop to disk
// *
// * @param properties
// * @param filePathName
// * @return
// */
// public static boolean writeFileProp(Properties properties, String filePathName){
// FileOutputStream fileOutputStream = null;
// try {
//
// // mk file
// File file = new File(filePathName);
// if (!file.exists()) {
// file.getParentFile().mkdirs();
// }
//
// // write data
// fileOutputStream = new FileOutputStream(file, false);
// properties.store(new OutputStreamWriter(fileOutputStream, "utf-8"), null);
// //properties.store(new FileWriter(filePathName), null);
// return true;
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// return false;
// } finally {
// if (fileOutputStream != null) {
// try {
// fileOutputStream.close();
// } catch (IOException e) {
// logger.error(e.getMessage(), e);
// }
// }
// }
// }
//
// }
// Path: xxl-conf-samples/xxl-conf-sample-frameless/src/main/java/com.xxl.conf.sample.frameless/conf/FrameLessXxlConfConfig.java
import com.xxl.conf.core.factory.XxlConfBaseFactory;
import com.xxl.conf.core.util.PropUtil;
import java.util.Properties;
package com.xxl.conf.sample.frameless.conf;
/**
* @author xuxueli 2018-10-31 19:05:43
*/
public class FrameLessXxlConfConfig {
/**
* init
*/
public static void init() {
Properties prop = PropUtil.loadProp("xxl-conf.properties");
|
XxlConfBaseFactory.init(
|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfNodeLogDao.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfNodeLog.java
// public class XxlConfNodeLog {
//
// private String env;
// private String key; // 配置Key
// private String title; // 配置描述
// private String value; // 配置Value
// private Date addtime; // 操作时间
// private String optuser; // 操作人
//
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public Date getAddtime() {
// return addtime;
// }
//
// public void setAddtime(Date addtime) {
// this.addtime = addtime;
// }
//
// public String getOptuser() {
// return optuser;
// }
//
// public void setOptuser(String optuser) {
// this.optuser = optuser;
// }
// }
|
import com.xxl.conf.admin.core.model.XxlConfNodeLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
|
package com.xxl.conf.admin.dao;
/**
* Created by xuxueli on 16/10/8.
*/
@Mapper
public interface XxlConfNodeLogDao {
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfNodeLog.java
// public class XxlConfNodeLog {
//
// private String env;
// private String key; // 配置Key
// private String title; // 配置描述
// private String value; // 配置Value
// private Date addtime; // 操作时间
// private String optuser; // 操作人
//
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getKey() {
// return key;
// }
//
// public void setKey(String key) {
// this.key = key;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public Date getAddtime() {
// return addtime;
// }
//
// public void setAddtime(Date addtime) {
// this.addtime = addtime;
// }
//
// public String getOptuser() {
// return optuser;
// }
//
// public void setOptuser(String optuser) {
// this.optuser = optuser;
// }
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfNodeLogDao.java
import com.xxl.conf.admin.core.model.XxlConfNodeLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
package com.xxl.conf.admin.dao;
/**
* Created by xuxueli on 16/10/8.
*/
@Mapper
public interface XxlConfNodeLogDao {
|
public List<XxlConfNodeLog> findByKey(@Param("env") String env, @Param("key") String key);
|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfUserDao.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfUser.java
// public class XxlConfUser {
//
// private String username;
// private String password;
// private int permission; // 权限:0-普通用户、1-管理员
// private String permissionData; // 权限配置数据, 格式 "appname#env,appname#env02"
//
// 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 int getPermission() {
// return permission;
// }
//
// public void setPermission(int permission) {
// this.permission = permission;
// }
//
// public String getPermissionData() {
// return permissionData;
// }
//
// public void setPermissionData(String permissionData) {
// this.permissionData = permissionData;
// }
//
// }
|
import com.xxl.conf.admin.core.model.XxlConfUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
|
package com.xxl.conf.admin.dao;
/**
* @author xuxueli 2018-03-01
*/
@Mapper
public interface XxlConfUserDao {
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfUser.java
// public class XxlConfUser {
//
// private String username;
// private String password;
// private int permission; // 权限:0-普通用户、1-管理员
// private String permissionData; // 权限配置数据, 格式 "appname#env,appname#env02"
//
// 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 int getPermission() {
// return permission;
// }
//
// public void setPermission(int permission) {
// this.permission = permission;
// }
//
// public String getPermissionData() {
// return permissionData;
// }
//
// public void setPermissionData(String permissionData) {
// this.permissionData = permissionData;
// }
//
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfUserDao.java
import com.xxl.conf.admin.core.model.XxlConfUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
package com.xxl.conf.admin.dao;
/**
* @author xuxueli 2018-03-01
*/
@Mapper
public interface XxlConfUserDao {
|
public List<XxlConfUser> pageList(@Param("offset") int offset,
|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/PermissionInterceptor.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfUser.java
// public class XxlConfUser {
//
// private String username;
// private String password;
// private int permission; // 权限:0-普通用户、1-管理员
// private String permissionData; // 权限配置数据, 格式 "appname#env,appname#env02"
//
// 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 int getPermission() {
// return permission;
// }
//
// public void setPermission(int permission) {
// this.permission = permission;
// }
//
// public String getPermissionData() {
// return permissionData;
// }
//
// public void setPermissionData(String permissionData) {
// this.permissionData = permissionData;
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/service/impl/LoginService.java
// @Configuration
// public class LoginService {
//
// public static final String LOGIN_IDENTITY = "XXL_CONF_LOGIN_IDENTITY";
//
// @Resource
// private XxlConfUserDao xxlConfUserDao;
//
// private String makeToken(XxlConfUser xxlConfUser){
// String tokenJson = JacksonUtil.writeValueAsString(xxlConfUser);
// String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16);
// return tokenHex;
// }
// private XxlConfUser parseToken(String tokenHex){
// XxlConfUser xxlConfUser = null;
// if (tokenHex != null) {
// String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5)
// xxlConfUser = JacksonUtil.readValue(tokenJson, XxlConfUser.class);
// }
// return xxlConfUser;
// }
//
// /**
// * login
// *
// * @param response
// * @param usernameParam
// * @param passwordParam
// * @param ifRemember
// * @return
// */
// public ReturnT<String> login(HttpServletResponse response, String usernameParam, String passwordParam, boolean ifRemember){
//
// XxlConfUser xxlConfUser = xxlConfUserDao.load(usernameParam);
// if (xxlConfUser == null) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String passwordParamMd5 = DigestUtils.md5DigestAsHex(passwordParam.getBytes());
// if (!xxlConfUser.getPassword().equals(passwordParamMd5)) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String loginToken = makeToken(xxlConfUser);
//
// // do login
// CookieUtil.set(response, LOGIN_IDENTITY, loginToken, ifRemember);
// return ReturnT.SUCCESS;
// }
//
// /**
// * logout
// *
// * @param request
// * @param response
// */
// public void logout(HttpServletRequest request, HttpServletResponse response){
// CookieUtil.remove(request, response, LOGIN_IDENTITY);
// }
//
// /**
// * logout
// *
// * @param request
// * @return
// */
// public XxlConfUser ifLogin(HttpServletRequest request){
// String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY);
// if (cookieToken != null) {
// XxlConfUser cookieUser = parseToken(cookieToken);
// if (cookieUser != null) {
// XxlConfUser dbUser = xxlConfUserDao.load(cookieUser.getUsername());
// if (dbUser != null) {
// if (cookieUser.getPassword().equals(dbUser.getPassword())) {
// return dbUser;
// }
// }
// }
// }
// return null;
// }
//
// }
|
import com.xxl.conf.admin.controller.annotation.PermessionLimit;
import com.xxl.conf.admin.core.model.XxlConfUser;
import com.xxl.conf.admin.service.impl.LoginService;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
|
package com.xxl.conf.admin.controller.interceptor;
/**
* 权限拦截, 简易版
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class PermissionInterceptor extends HandlerInterceptorAdapter {
@Resource
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfUser.java
// public class XxlConfUser {
//
// private String username;
// private String password;
// private int permission; // 权限:0-普通用户、1-管理员
// private String permissionData; // 权限配置数据, 格式 "appname#env,appname#env02"
//
// 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 int getPermission() {
// return permission;
// }
//
// public void setPermission(int permission) {
// this.permission = permission;
// }
//
// public String getPermissionData() {
// return permissionData;
// }
//
// public void setPermissionData(String permissionData) {
// this.permissionData = permissionData;
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/service/impl/LoginService.java
// @Configuration
// public class LoginService {
//
// public static final String LOGIN_IDENTITY = "XXL_CONF_LOGIN_IDENTITY";
//
// @Resource
// private XxlConfUserDao xxlConfUserDao;
//
// private String makeToken(XxlConfUser xxlConfUser){
// String tokenJson = JacksonUtil.writeValueAsString(xxlConfUser);
// String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16);
// return tokenHex;
// }
// private XxlConfUser parseToken(String tokenHex){
// XxlConfUser xxlConfUser = null;
// if (tokenHex != null) {
// String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5)
// xxlConfUser = JacksonUtil.readValue(tokenJson, XxlConfUser.class);
// }
// return xxlConfUser;
// }
//
// /**
// * login
// *
// * @param response
// * @param usernameParam
// * @param passwordParam
// * @param ifRemember
// * @return
// */
// public ReturnT<String> login(HttpServletResponse response, String usernameParam, String passwordParam, boolean ifRemember){
//
// XxlConfUser xxlConfUser = xxlConfUserDao.load(usernameParam);
// if (xxlConfUser == null) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String passwordParamMd5 = DigestUtils.md5DigestAsHex(passwordParam.getBytes());
// if (!xxlConfUser.getPassword().equals(passwordParamMd5)) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String loginToken = makeToken(xxlConfUser);
//
// // do login
// CookieUtil.set(response, LOGIN_IDENTITY, loginToken, ifRemember);
// return ReturnT.SUCCESS;
// }
//
// /**
// * logout
// *
// * @param request
// * @param response
// */
// public void logout(HttpServletRequest request, HttpServletResponse response){
// CookieUtil.remove(request, response, LOGIN_IDENTITY);
// }
//
// /**
// * logout
// *
// * @param request
// * @return
// */
// public XxlConfUser ifLogin(HttpServletRequest request){
// String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY);
// if (cookieToken != null) {
// XxlConfUser cookieUser = parseToken(cookieToken);
// if (cookieUser != null) {
// XxlConfUser dbUser = xxlConfUserDao.load(cookieUser.getUsername());
// if (dbUser != null) {
// if (cookieUser.getPassword().equals(dbUser.getPassword())) {
// return dbUser;
// }
// }
// }
// }
// return null;
// }
//
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/PermissionInterceptor.java
import com.xxl.conf.admin.controller.annotation.PermessionLimit;
import com.xxl.conf.admin.core.model.XxlConfUser;
import com.xxl.conf.admin.service.impl.LoginService;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
package com.xxl.conf.admin.controller.interceptor;
/**
* 权限拦截, 简易版
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class PermissionInterceptor extends HandlerInterceptorAdapter {
@Resource
|
private LoginService loginService;
|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/PermissionInterceptor.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfUser.java
// public class XxlConfUser {
//
// private String username;
// private String password;
// private int permission; // 权限:0-普通用户、1-管理员
// private String permissionData; // 权限配置数据, 格式 "appname#env,appname#env02"
//
// 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 int getPermission() {
// return permission;
// }
//
// public void setPermission(int permission) {
// this.permission = permission;
// }
//
// public String getPermissionData() {
// return permissionData;
// }
//
// public void setPermissionData(String permissionData) {
// this.permissionData = permissionData;
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/service/impl/LoginService.java
// @Configuration
// public class LoginService {
//
// public static final String LOGIN_IDENTITY = "XXL_CONF_LOGIN_IDENTITY";
//
// @Resource
// private XxlConfUserDao xxlConfUserDao;
//
// private String makeToken(XxlConfUser xxlConfUser){
// String tokenJson = JacksonUtil.writeValueAsString(xxlConfUser);
// String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16);
// return tokenHex;
// }
// private XxlConfUser parseToken(String tokenHex){
// XxlConfUser xxlConfUser = null;
// if (tokenHex != null) {
// String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5)
// xxlConfUser = JacksonUtil.readValue(tokenJson, XxlConfUser.class);
// }
// return xxlConfUser;
// }
//
// /**
// * login
// *
// * @param response
// * @param usernameParam
// * @param passwordParam
// * @param ifRemember
// * @return
// */
// public ReturnT<String> login(HttpServletResponse response, String usernameParam, String passwordParam, boolean ifRemember){
//
// XxlConfUser xxlConfUser = xxlConfUserDao.load(usernameParam);
// if (xxlConfUser == null) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String passwordParamMd5 = DigestUtils.md5DigestAsHex(passwordParam.getBytes());
// if (!xxlConfUser.getPassword().equals(passwordParamMd5)) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String loginToken = makeToken(xxlConfUser);
//
// // do login
// CookieUtil.set(response, LOGIN_IDENTITY, loginToken, ifRemember);
// return ReturnT.SUCCESS;
// }
//
// /**
// * logout
// *
// * @param request
// * @param response
// */
// public void logout(HttpServletRequest request, HttpServletResponse response){
// CookieUtil.remove(request, response, LOGIN_IDENTITY);
// }
//
// /**
// * logout
// *
// * @param request
// * @return
// */
// public XxlConfUser ifLogin(HttpServletRequest request){
// String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY);
// if (cookieToken != null) {
// XxlConfUser cookieUser = parseToken(cookieToken);
// if (cookieUser != null) {
// XxlConfUser dbUser = xxlConfUserDao.load(cookieUser.getUsername());
// if (dbUser != null) {
// if (cookieUser.getPassword().equals(dbUser.getPassword())) {
// return dbUser;
// }
// }
// }
// }
// return null;
// }
//
// }
|
import com.xxl.conf.admin.controller.annotation.PermessionLimit;
import com.xxl.conf.admin.core.model.XxlConfUser;
import com.xxl.conf.admin.service.impl.LoginService;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
|
package com.xxl.conf.admin.controller.interceptor;
/**
* 权限拦截, 简易版
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class PermissionInterceptor extends HandlerInterceptorAdapter {
@Resource
private LoginService loginService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (!(handler instanceof HandlerMethod)) {
return super.preHandle(request, response, handler);
}
// if need login
boolean needLogin = true;
boolean needAdminuser = false;
HandlerMethod method = (HandlerMethod)handler;
PermessionLimit permission = method.getMethodAnnotation(PermessionLimit.class);
if (permission!=null) {
needLogin = permission.limit();
needAdminuser = permission.adminuser();
}
if (needLogin) {
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfUser.java
// public class XxlConfUser {
//
// private String username;
// private String password;
// private int permission; // 权限:0-普通用户、1-管理员
// private String permissionData; // 权限配置数据, 格式 "appname#env,appname#env02"
//
// 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 int getPermission() {
// return permission;
// }
//
// public void setPermission(int permission) {
// this.permission = permission;
// }
//
// public String getPermissionData() {
// return permissionData;
// }
//
// public void setPermissionData(String permissionData) {
// this.permissionData = permissionData;
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/service/impl/LoginService.java
// @Configuration
// public class LoginService {
//
// public static final String LOGIN_IDENTITY = "XXL_CONF_LOGIN_IDENTITY";
//
// @Resource
// private XxlConfUserDao xxlConfUserDao;
//
// private String makeToken(XxlConfUser xxlConfUser){
// String tokenJson = JacksonUtil.writeValueAsString(xxlConfUser);
// String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16);
// return tokenHex;
// }
// private XxlConfUser parseToken(String tokenHex){
// XxlConfUser xxlConfUser = null;
// if (tokenHex != null) {
// String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5)
// xxlConfUser = JacksonUtil.readValue(tokenJson, XxlConfUser.class);
// }
// return xxlConfUser;
// }
//
// /**
// * login
// *
// * @param response
// * @param usernameParam
// * @param passwordParam
// * @param ifRemember
// * @return
// */
// public ReturnT<String> login(HttpServletResponse response, String usernameParam, String passwordParam, boolean ifRemember){
//
// XxlConfUser xxlConfUser = xxlConfUserDao.load(usernameParam);
// if (xxlConfUser == null) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String passwordParamMd5 = DigestUtils.md5DigestAsHex(passwordParam.getBytes());
// if (!xxlConfUser.getPassword().equals(passwordParamMd5)) {
// return new ReturnT<String>(500, "账号或密码错误");
// }
//
// String loginToken = makeToken(xxlConfUser);
//
// // do login
// CookieUtil.set(response, LOGIN_IDENTITY, loginToken, ifRemember);
// return ReturnT.SUCCESS;
// }
//
// /**
// * logout
// *
// * @param request
// * @param response
// */
// public void logout(HttpServletRequest request, HttpServletResponse response){
// CookieUtil.remove(request, response, LOGIN_IDENTITY);
// }
//
// /**
// * logout
// *
// * @param request
// * @return
// */
// public XxlConfUser ifLogin(HttpServletRequest request){
// String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY);
// if (cookieToken != null) {
// XxlConfUser cookieUser = parseToken(cookieToken);
// if (cookieUser != null) {
// XxlConfUser dbUser = xxlConfUserDao.load(cookieUser.getUsername());
// if (dbUser != null) {
// if (cookieUser.getPassword().equals(dbUser.getPassword())) {
// return dbUser;
// }
// }
// }
// }
// return null;
// }
//
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/PermissionInterceptor.java
import com.xxl.conf.admin.controller.annotation.PermessionLimit;
import com.xxl.conf.admin.core.model.XxlConfUser;
import com.xxl.conf.admin.service.impl.LoginService;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
package com.xxl.conf.admin.controller.interceptor;
/**
* 权限拦截, 简易版
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class PermissionInterceptor extends HandlerInterceptorAdapter {
@Resource
private LoginService loginService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (!(handler instanceof HandlerMethod)) {
return super.preHandle(request, response, handler);
}
// if need login
boolean needLogin = true;
boolean needAdminuser = false;
HandlerMethod method = (HandlerMethod)handler;
PermessionLimit permission = method.getMethodAnnotation(PermessionLimit.class);
if (permission!=null) {
needLogin = permission.limit();
needAdminuser = permission.adminuser();
}
if (needLogin) {
|
XxlConfUser loginUser = loginService.ifLogin(request);
|
xuxueli/xxl-conf
|
xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/MainModule.java
|
// Path: xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/config/NutzSetup.java
// public class NutzSetup implements Setup {
// private Logger logger = LoggerFactory.getLogger(NutzSetup.class);
//
// @Override
// public void init(NutConfig cfg) {
// Properties prop = PropUtil.loadProp("xxl-conf.properties");
//
// XxlConfBaseFactory.init(
// prop.getProperty("xxl.conf.admin.address"),
// prop.getProperty("xxl.conf.env"),
// prop.getProperty("xxl.conf.access.token"),
// prop.getProperty("xxl.conf.mirrorfile"));
// }
//
// @Override
// public void destroy(NutConfig cfg) {
// XxlConfBaseFactory.destroy();
// }
//
// }
|
import com.xxl.conf.sample.nutz.config.NutzSetup;
import org.nutz.mvc.annotation.*;
import org.nutz.mvc.ioc.provider.ComboIocProvider;
|
package com.xxl.conf.sample.nutz;
/**
* nutz module
*
* @author xuxueli 2018-05-24
*/
@IocBy(type = ComboIocProvider.class,
args = {"*org.nutz.ioc.loader.annotation.AnnotationIocLoader",
"com.xxl.conf.sample.nutz"})
@Encoding(input = "utf-8", output = "utf-8")
@Modules(scanPackage = true)
@Localization("msg")
@Ok("json")
@Fail("json")
|
// Path: xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/config/NutzSetup.java
// public class NutzSetup implements Setup {
// private Logger logger = LoggerFactory.getLogger(NutzSetup.class);
//
// @Override
// public void init(NutConfig cfg) {
// Properties prop = PropUtil.loadProp("xxl-conf.properties");
//
// XxlConfBaseFactory.init(
// prop.getProperty("xxl.conf.admin.address"),
// prop.getProperty("xxl.conf.env"),
// prop.getProperty("xxl.conf.access.token"),
// prop.getProperty("xxl.conf.mirrorfile"));
// }
//
// @Override
// public void destroy(NutConfig cfg) {
// XxlConfBaseFactory.destroy();
// }
//
// }
// Path: xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/MainModule.java
import com.xxl.conf.sample.nutz.config.NutzSetup;
import org.nutz.mvc.annotation.*;
import org.nutz.mvc.ioc.provider.ComboIocProvider;
package com.xxl.conf.sample.nutz;
/**
* nutz module
*
* @author xuxueli 2018-05-24
*/
@IocBy(type = ComboIocProvider.class,
args = {"*org.nutz.ioc.loader.annotation.AnnotationIocLoader",
"com.xxl.conf.sample.nutz"})
@Encoding(input = "utf-8", output = "utf-8")
@Modules(scanPackage = true)
@Localization("msg")
@Ok("json")
@Fail("json")
|
@SetupBy(NutzSetup.class)
|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/EnvInterceptor.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfEnv.java
// public class XxlConfEnv {
//
// private String env; // Env
// private String title; // 环境名称
// private int order;
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public int getOrder() {
// return order;
// }
//
// public void setOrder(int order) {
// this.order = order;
// }
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/util/CookieUtil.java
// public class CookieUtil {
//
// // 默认缓存时间,单位/秒, 2H
// private static final int COOKIE_MAX_AGE = 60 * 60 * 2;
// // 保存路径,根路径
// private static final String COOKIE_PATH = "/";
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param ifRemember
// */
// public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) {
// int age = ifRemember?COOKIE_MAX_AGE:-1;
// set(response, key, value, null, COOKIE_PATH, age, true);
// }
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param maxAge
// */
// private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) {
// Cookie cookie = new Cookie(key, value);
// if (domain != null) {
// cookie.setDomain(domain);
// }
// cookie.setPath(path);
// cookie.setMaxAge(maxAge);
// cookie.setHttpOnly(isHttpOnly);
// response.addCookie(cookie);
// }
//
// /**
// * 查询value
// *
// * @param request
// * @param key
// * @return
// */
// public static String getValue(HttpServletRequest request, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// return cookie.getValue();
// }
// return null;
// }
//
// /**
// * 查询Cookie
// *
// * @param request
// * @param key
// */
// private static Cookie get(HttpServletRequest request, String key) {
// Cookie[] arr_cookie = request.getCookies();
// if (arr_cookie != null && arr_cookie.length > 0) {
// for (Cookie cookie : arr_cookie) {
// if (cookie.getName().equals(key)) {
// return cookie;
// }
// }
// }
// return null;
// }
//
// /**
// * 删除Cookie
// *
// * @param request
// * @param response
// * @param key
// */
// public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// set(response, key, "", null, COOKIE_PATH, 0, true);
// }
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfEnvDao.java
// @Mapper
// public interface XxlConfEnvDao {
//
// public List<XxlConfEnv> findAll();
//
// public int save(XxlConfEnv xxlConfEnv);
//
// public int update(XxlConfEnv xxlConfEnv);
//
// public int delete(@Param("env") String env);
//
// public XxlConfEnv load(@Param("env") String env);
//
// }
|
import com.xxl.conf.admin.core.model.XxlConfEnv;
import com.xxl.conf.admin.core.util.CookieUtil;
import com.xxl.conf.admin.dao.XxlConfEnvDao;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
|
package com.xxl.conf.admin.controller.interceptor;
/**
* push cookies to model as cookieMap
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class EnvInterceptor extends HandlerInterceptorAdapter {
public static final String CURRENT_ENV = "XXL_CONF_CURRENT_ENV";
@Resource
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfEnv.java
// public class XxlConfEnv {
//
// private String env; // Env
// private String title; // 环境名称
// private int order;
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public int getOrder() {
// return order;
// }
//
// public void setOrder(int order) {
// this.order = order;
// }
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/util/CookieUtil.java
// public class CookieUtil {
//
// // 默认缓存时间,单位/秒, 2H
// private static final int COOKIE_MAX_AGE = 60 * 60 * 2;
// // 保存路径,根路径
// private static final String COOKIE_PATH = "/";
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param ifRemember
// */
// public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) {
// int age = ifRemember?COOKIE_MAX_AGE:-1;
// set(response, key, value, null, COOKIE_PATH, age, true);
// }
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param maxAge
// */
// private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) {
// Cookie cookie = new Cookie(key, value);
// if (domain != null) {
// cookie.setDomain(domain);
// }
// cookie.setPath(path);
// cookie.setMaxAge(maxAge);
// cookie.setHttpOnly(isHttpOnly);
// response.addCookie(cookie);
// }
//
// /**
// * 查询value
// *
// * @param request
// * @param key
// * @return
// */
// public static String getValue(HttpServletRequest request, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// return cookie.getValue();
// }
// return null;
// }
//
// /**
// * 查询Cookie
// *
// * @param request
// * @param key
// */
// private static Cookie get(HttpServletRequest request, String key) {
// Cookie[] arr_cookie = request.getCookies();
// if (arr_cookie != null && arr_cookie.length > 0) {
// for (Cookie cookie : arr_cookie) {
// if (cookie.getName().equals(key)) {
// return cookie;
// }
// }
// }
// return null;
// }
//
// /**
// * 删除Cookie
// *
// * @param request
// * @param response
// * @param key
// */
// public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// set(response, key, "", null, COOKIE_PATH, 0, true);
// }
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfEnvDao.java
// @Mapper
// public interface XxlConfEnvDao {
//
// public List<XxlConfEnv> findAll();
//
// public int save(XxlConfEnv xxlConfEnv);
//
// public int update(XxlConfEnv xxlConfEnv);
//
// public int delete(@Param("env") String env);
//
// public XxlConfEnv load(@Param("env") String env);
//
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/EnvInterceptor.java
import com.xxl.conf.admin.core.model.XxlConfEnv;
import com.xxl.conf.admin.core.util.CookieUtil;
import com.xxl.conf.admin.dao.XxlConfEnvDao;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
package com.xxl.conf.admin.controller.interceptor;
/**
* push cookies to model as cookieMap
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class EnvInterceptor extends HandlerInterceptorAdapter {
public static final String CURRENT_ENV = "XXL_CONF_CURRENT_ENV";
@Resource
|
private XxlConfEnvDao xxlConfEnvDao;
|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/EnvInterceptor.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfEnv.java
// public class XxlConfEnv {
//
// private String env; // Env
// private String title; // 环境名称
// private int order;
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public int getOrder() {
// return order;
// }
//
// public void setOrder(int order) {
// this.order = order;
// }
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/util/CookieUtil.java
// public class CookieUtil {
//
// // 默认缓存时间,单位/秒, 2H
// private static final int COOKIE_MAX_AGE = 60 * 60 * 2;
// // 保存路径,根路径
// private static final String COOKIE_PATH = "/";
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param ifRemember
// */
// public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) {
// int age = ifRemember?COOKIE_MAX_AGE:-1;
// set(response, key, value, null, COOKIE_PATH, age, true);
// }
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param maxAge
// */
// private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) {
// Cookie cookie = new Cookie(key, value);
// if (domain != null) {
// cookie.setDomain(domain);
// }
// cookie.setPath(path);
// cookie.setMaxAge(maxAge);
// cookie.setHttpOnly(isHttpOnly);
// response.addCookie(cookie);
// }
//
// /**
// * 查询value
// *
// * @param request
// * @param key
// * @return
// */
// public static String getValue(HttpServletRequest request, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// return cookie.getValue();
// }
// return null;
// }
//
// /**
// * 查询Cookie
// *
// * @param request
// * @param key
// */
// private static Cookie get(HttpServletRequest request, String key) {
// Cookie[] arr_cookie = request.getCookies();
// if (arr_cookie != null && arr_cookie.length > 0) {
// for (Cookie cookie : arr_cookie) {
// if (cookie.getName().equals(key)) {
// return cookie;
// }
// }
// }
// return null;
// }
//
// /**
// * 删除Cookie
// *
// * @param request
// * @param response
// * @param key
// */
// public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// set(response, key, "", null, COOKIE_PATH, 0, true);
// }
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfEnvDao.java
// @Mapper
// public interface XxlConfEnvDao {
//
// public List<XxlConfEnv> findAll();
//
// public int save(XxlConfEnv xxlConfEnv);
//
// public int update(XxlConfEnv xxlConfEnv);
//
// public int delete(@Param("env") String env);
//
// public XxlConfEnv load(@Param("env") String env);
//
// }
|
import com.xxl.conf.admin.core.model.XxlConfEnv;
import com.xxl.conf.admin.core.util.CookieUtil;
import com.xxl.conf.admin.dao.XxlConfEnvDao;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
|
package com.xxl.conf.admin.controller.interceptor;
/**
* push cookies to model as cookieMap
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class EnvInterceptor extends HandlerInterceptorAdapter {
public static final String CURRENT_ENV = "XXL_CONF_CURRENT_ENV";
@Resource
private XxlConfEnvDao xxlConfEnvDao;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// env list
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfEnv.java
// public class XxlConfEnv {
//
// private String env; // Env
// private String title; // 环境名称
// private int order;
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public int getOrder() {
// return order;
// }
//
// public void setOrder(int order) {
// this.order = order;
// }
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/util/CookieUtil.java
// public class CookieUtil {
//
// // 默认缓存时间,单位/秒, 2H
// private static final int COOKIE_MAX_AGE = 60 * 60 * 2;
// // 保存路径,根路径
// private static final String COOKIE_PATH = "/";
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param ifRemember
// */
// public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) {
// int age = ifRemember?COOKIE_MAX_AGE:-1;
// set(response, key, value, null, COOKIE_PATH, age, true);
// }
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param maxAge
// */
// private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) {
// Cookie cookie = new Cookie(key, value);
// if (domain != null) {
// cookie.setDomain(domain);
// }
// cookie.setPath(path);
// cookie.setMaxAge(maxAge);
// cookie.setHttpOnly(isHttpOnly);
// response.addCookie(cookie);
// }
//
// /**
// * 查询value
// *
// * @param request
// * @param key
// * @return
// */
// public static String getValue(HttpServletRequest request, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// return cookie.getValue();
// }
// return null;
// }
//
// /**
// * 查询Cookie
// *
// * @param request
// * @param key
// */
// private static Cookie get(HttpServletRequest request, String key) {
// Cookie[] arr_cookie = request.getCookies();
// if (arr_cookie != null && arr_cookie.length > 0) {
// for (Cookie cookie : arr_cookie) {
// if (cookie.getName().equals(key)) {
// return cookie;
// }
// }
// }
// return null;
// }
//
// /**
// * 删除Cookie
// *
// * @param request
// * @param response
// * @param key
// */
// public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// set(response, key, "", null, COOKIE_PATH, 0, true);
// }
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfEnvDao.java
// @Mapper
// public interface XxlConfEnvDao {
//
// public List<XxlConfEnv> findAll();
//
// public int save(XxlConfEnv xxlConfEnv);
//
// public int update(XxlConfEnv xxlConfEnv);
//
// public int delete(@Param("env") String env);
//
// public XxlConfEnv load(@Param("env") String env);
//
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/EnvInterceptor.java
import com.xxl.conf.admin.core.model.XxlConfEnv;
import com.xxl.conf.admin.core.util.CookieUtil;
import com.xxl.conf.admin.dao.XxlConfEnvDao;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
package com.xxl.conf.admin.controller.interceptor;
/**
* push cookies to model as cookieMap
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class EnvInterceptor extends HandlerInterceptorAdapter {
public static final String CURRENT_ENV = "XXL_CONF_CURRENT_ENV";
@Resource
private XxlConfEnvDao xxlConfEnvDao;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// env list
|
List<XxlConfEnv> envList = xxlConfEnvDao.findAll();
|
xuxueli/xxl-conf
|
xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/EnvInterceptor.java
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfEnv.java
// public class XxlConfEnv {
//
// private String env; // Env
// private String title; // 环境名称
// private int order;
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public int getOrder() {
// return order;
// }
//
// public void setOrder(int order) {
// this.order = order;
// }
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/util/CookieUtil.java
// public class CookieUtil {
//
// // 默认缓存时间,单位/秒, 2H
// private static final int COOKIE_MAX_AGE = 60 * 60 * 2;
// // 保存路径,根路径
// private static final String COOKIE_PATH = "/";
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param ifRemember
// */
// public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) {
// int age = ifRemember?COOKIE_MAX_AGE:-1;
// set(response, key, value, null, COOKIE_PATH, age, true);
// }
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param maxAge
// */
// private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) {
// Cookie cookie = new Cookie(key, value);
// if (domain != null) {
// cookie.setDomain(domain);
// }
// cookie.setPath(path);
// cookie.setMaxAge(maxAge);
// cookie.setHttpOnly(isHttpOnly);
// response.addCookie(cookie);
// }
//
// /**
// * 查询value
// *
// * @param request
// * @param key
// * @return
// */
// public static String getValue(HttpServletRequest request, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// return cookie.getValue();
// }
// return null;
// }
//
// /**
// * 查询Cookie
// *
// * @param request
// * @param key
// */
// private static Cookie get(HttpServletRequest request, String key) {
// Cookie[] arr_cookie = request.getCookies();
// if (arr_cookie != null && arr_cookie.length > 0) {
// for (Cookie cookie : arr_cookie) {
// if (cookie.getName().equals(key)) {
// return cookie;
// }
// }
// }
// return null;
// }
//
// /**
// * 删除Cookie
// *
// * @param request
// * @param response
// * @param key
// */
// public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// set(response, key, "", null, COOKIE_PATH, 0, true);
// }
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfEnvDao.java
// @Mapper
// public interface XxlConfEnvDao {
//
// public List<XxlConfEnv> findAll();
//
// public int save(XxlConfEnv xxlConfEnv);
//
// public int update(XxlConfEnv xxlConfEnv);
//
// public int delete(@Param("env") String env);
//
// public XxlConfEnv load(@Param("env") String env);
//
// }
|
import com.xxl.conf.admin.core.model.XxlConfEnv;
import com.xxl.conf.admin.core.util.CookieUtil;
import com.xxl.conf.admin.dao.XxlConfEnvDao;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
|
package com.xxl.conf.admin.controller.interceptor;
/**
* push cookies to model as cookieMap
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class EnvInterceptor extends HandlerInterceptorAdapter {
public static final String CURRENT_ENV = "XXL_CONF_CURRENT_ENV";
@Resource
private XxlConfEnvDao xxlConfEnvDao;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// env list
List<XxlConfEnv> envList = xxlConfEnvDao.findAll();
if (envList==null || envList.size()==0) {
throw new RuntimeException("系统异常,获取Env数据失败");
}
// current env
String currentEnv = envList.get(0).getEnv();
|
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/model/XxlConfEnv.java
// public class XxlConfEnv {
//
// private String env; // Env
// private String title; // 环境名称
// private int order;
//
// public String getEnv() {
// return env;
// }
//
// public void setEnv(String env) {
// this.env = env;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public int getOrder() {
// return order;
// }
//
// public void setOrder(int order) {
// this.order = order;
// }
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/core/util/CookieUtil.java
// public class CookieUtil {
//
// // 默认缓存时间,单位/秒, 2H
// private static final int COOKIE_MAX_AGE = 60 * 60 * 2;
// // 保存路径,根路径
// private static final String COOKIE_PATH = "/";
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param ifRemember
// */
// public static void set(HttpServletResponse response, String key, String value, boolean ifRemember) {
// int age = ifRemember?COOKIE_MAX_AGE:-1;
// set(response, key, value, null, COOKIE_PATH, age, true);
// }
//
// /**
// * 保存
// *
// * @param response
// * @param key
// * @param value
// * @param maxAge
// */
// private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) {
// Cookie cookie = new Cookie(key, value);
// if (domain != null) {
// cookie.setDomain(domain);
// }
// cookie.setPath(path);
// cookie.setMaxAge(maxAge);
// cookie.setHttpOnly(isHttpOnly);
// response.addCookie(cookie);
// }
//
// /**
// * 查询value
// *
// * @param request
// * @param key
// * @return
// */
// public static String getValue(HttpServletRequest request, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// return cookie.getValue();
// }
// return null;
// }
//
// /**
// * 查询Cookie
// *
// * @param request
// * @param key
// */
// private static Cookie get(HttpServletRequest request, String key) {
// Cookie[] arr_cookie = request.getCookies();
// if (arr_cookie != null && arr_cookie.length > 0) {
// for (Cookie cookie : arr_cookie) {
// if (cookie.getName().equals(key)) {
// return cookie;
// }
// }
// }
// return null;
// }
//
// /**
// * 删除Cookie
// *
// * @param request
// * @param response
// * @param key
// */
// public static void remove(HttpServletRequest request, HttpServletResponse response, String key) {
// Cookie cookie = get(request, key);
// if (cookie != null) {
// set(response, key, "", null, COOKIE_PATH, 0, true);
// }
// }
//
// }
//
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/dao/XxlConfEnvDao.java
// @Mapper
// public interface XxlConfEnvDao {
//
// public List<XxlConfEnv> findAll();
//
// public int save(XxlConfEnv xxlConfEnv);
//
// public int update(XxlConfEnv xxlConfEnv);
//
// public int delete(@Param("env") String env);
//
// public XxlConfEnv load(@Param("env") String env);
//
// }
// Path: xxl-conf-admin/src/main/java/com/xxl/conf/admin/controller/interceptor/EnvInterceptor.java
import com.xxl.conf.admin.core.model.XxlConfEnv;
import com.xxl.conf.admin.core.util.CookieUtil;
import com.xxl.conf.admin.dao.XxlConfEnvDao;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
package com.xxl.conf.admin.controller.interceptor;
/**
* push cookies to model as cookieMap
* @author xuxueli 2015-12-12 18:09:04
*/
@Component
public class EnvInterceptor extends HandlerInterceptorAdapter {
public static final String CURRENT_ENV = "XXL_CONF_CURRENT_ENV";
@Resource
private XxlConfEnvDao xxlConfEnvDao;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// env list
List<XxlConfEnv> envList = xxlConfEnvDao.findAll();
if (envList==null || envList.size()==0) {
throw new RuntimeException("系统异常,获取Env数据失败");
}
// current env
String currentEnv = envList.get(0).getEnv();
|
String currentEnvCookie = CookieUtil.getValue(request, CURRENT_ENV);
|
xuxueli/xxl-conf
|
xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/module/IndexModule.java
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/XxlConfClient.java
// public class XxlConfClient {
//
// public static String get(String key, String defaultVal) {
// return XxlConfLocalCacheConf.get(key, defaultVal);
// }
//
// /**
// * get conf (string)
// *
// * @param key
// * @return
// */
// public static String get(String key) {
// return get(key, null);
// }
//
// /**
// * get conf (boolean)
// *
// * @param key
// * @return
// */
// public static boolean getBoolean(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Boolean.valueOf(value);
// }
//
// /**
// * get conf (short)
// *
// * @param key
// * @return
// */
// public static short getShort(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Short.valueOf(value);
// }
//
// /**
// * get conf (int)
// *
// * @param key
// * @return
// */
// public static int getInt(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Integer.valueOf(value);
// }
//
// /**
// * get conf (long)
// *
// * @param key
// * @return
// */
// public static long getLong(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Long.valueOf(value);
// }
//
// /**
// * get conf (float)
// *
// * @param key
// * @return
// */
// public static float getFloat(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Float.valueOf(value);
// }
//
// /**
// * get conf (double)
// *
// * @param key
// * @return
// */
// public static double getDouble(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Double.valueOf(value);
// }
//
// /**
// * add listener with xxl conf change
// *
// * @param key
// * @param xxlConfListener
// * @return
// */
// public static boolean addListener(String key, XxlConfListener xxlConfListener){
// return XxlConfListenerFactory.addListener(key, xxlConfListener);
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/listener/XxlConfListener.java
// public interface XxlConfListener {
//
// /**
// * invoke when first-use or conf-change
// *
// * @param key
// */
// public void onChange(String key, String value) throws Exception;
//
// }
|
import com.xxl.conf.core.XxlConfClient;
import com.xxl.conf.core.listener.XxlConfListener;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package com.xxl.conf.sample.nutz.module;
/**
* @author xuxueli 2018-05-24
*/
@IocBean
public class IndexModule {
private static Logger logger = LoggerFactory.getLogger(IndexModule.class);
static {
/**
* 配置变更监听示例:可开发Listener逻辑,监听配置变更事件;可据此实现动态刷新JDBC连接池等高级功能;
*/
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/XxlConfClient.java
// public class XxlConfClient {
//
// public static String get(String key, String defaultVal) {
// return XxlConfLocalCacheConf.get(key, defaultVal);
// }
//
// /**
// * get conf (string)
// *
// * @param key
// * @return
// */
// public static String get(String key) {
// return get(key, null);
// }
//
// /**
// * get conf (boolean)
// *
// * @param key
// * @return
// */
// public static boolean getBoolean(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Boolean.valueOf(value);
// }
//
// /**
// * get conf (short)
// *
// * @param key
// * @return
// */
// public static short getShort(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Short.valueOf(value);
// }
//
// /**
// * get conf (int)
// *
// * @param key
// * @return
// */
// public static int getInt(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Integer.valueOf(value);
// }
//
// /**
// * get conf (long)
// *
// * @param key
// * @return
// */
// public static long getLong(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Long.valueOf(value);
// }
//
// /**
// * get conf (float)
// *
// * @param key
// * @return
// */
// public static float getFloat(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Float.valueOf(value);
// }
//
// /**
// * get conf (double)
// *
// * @param key
// * @return
// */
// public static double getDouble(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Double.valueOf(value);
// }
//
// /**
// * add listener with xxl conf change
// *
// * @param key
// * @param xxlConfListener
// * @return
// */
// public static boolean addListener(String key, XxlConfListener xxlConfListener){
// return XxlConfListenerFactory.addListener(key, xxlConfListener);
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/listener/XxlConfListener.java
// public interface XxlConfListener {
//
// /**
// * invoke when first-use or conf-change
// *
// * @param key
// */
// public void onChange(String key, String value) throws Exception;
//
// }
// Path: xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/module/IndexModule.java
import com.xxl.conf.core.XxlConfClient;
import com.xxl.conf.core.listener.XxlConfListener;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.xxl.conf.sample.nutz.module;
/**
* @author xuxueli 2018-05-24
*/
@IocBean
public class IndexModule {
private static Logger logger = LoggerFactory.getLogger(IndexModule.class);
static {
/**
* 配置变更监听示例:可开发Listener逻辑,监听配置变更事件;可据此实现动态刷新JDBC连接池等高级功能;
*/
|
XxlConfClient.addListener("default.key01", new XxlConfListener(){
|
xuxueli/xxl-conf
|
xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/module/IndexModule.java
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/XxlConfClient.java
// public class XxlConfClient {
//
// public static String get(String key, String defaultVal) {
// return XxlConfLocalCacheConf.get(key, defaultVal);
// }
//
// /**
// * get conf (string)
// *
// * @param key
// * @return
// */
// public static String get(String key) {
// return get(key, null);
// }
//
// /**
// * get conf (boolean)
// *
// * @param key
// * @return
// */
// public static boolean getBoolean(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Boolean.valueOf(value);
// }
//
// /**
// * get conf (short)
// *
// * @param key
// * @return
// */
// public static short getShort(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Short.valueOf(value);
// }
//
// /**
// * get conf (int)
// *
// * @param key
// * @return
// */
// public static int getInt(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Integer.valueOf(value);
// }
//
// /**
// * get conf (long)
// *
// * @param key
// * @return
// */
// public static long getLong(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Long.valueOf(value);
// }
//
// /**
// * get conf (float)
// *
// * @param key
// * @return
// */
// public static float getFloat(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Float.valueOf(value);
// }
//
// /**
// * get conf (double)
// *
// * @param key
// * @return
// */
// public static double getDouble(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Double.valueOf(value);
// }
//
// /**
// * add listener with xxl conf change
// *
// * @param key
// * @param xxlConfListener
// * @return
// */
// public static boolean addListener(String key, XxlConfListener xxlConfListener){
// return XxlConfListenerFactory.addListener(key, xxlConfListener);
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/listener/XxlConfListener.java
// public interface XxlConfListener {
//
// /**
// * invoke when first-use or conf-change
// *
// * @param key
// */
// public void onChange(String key, String value) throws Exception;
//
// }
|
import com.xxl.conf.core.XxlConfClient;
import com.xxl.conf.core.listener.XxlConfListener;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package com.xxl.conf.sample.nutz.module;
/**
* @author xuxueli 2018-05-24
*/
@IocBean
public class IndexModule {
private static Logger logger = LoggerFactory.getLogger(IndexModule.class);
static {
/**
* 配置变更监听示例:可开发Listener逻辑,监听配置变更事件;可据此实现动态刷新JDBC连接池等高级功能;
*/
|
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/XxlConfClient.java
// public class XxlConfClient {
//
// public static String get(String key, String defaultVal) {
// return XxlConfLocalCacheConf.get(key, defaultVal);
// }
//
// /**
// * get conf (string)
// *
// * @param key
// * @return
// */
// public static String get(String key) {
// return get(key, null);
// }
//
// /**
// * get conf (boolean)
// *
// * @param key
// * @return
// */
// public static boolean getBoolean(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Boolean.valueOf(value);
// }
//
// /**
// * get conf (short)
// *
// * @param key
// * @return
// */
// public static short getShort(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Short.valueOf(value);
// }
//
// /**
// * get conf (int)
// *
// * @param key
// * @return
// */
// public static int getInt(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Integer.valueOf(value);
// }
//
// /**
// * get conf (long)
// *
// * @param key
// * @return
// */
// public static long getLong(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Long.valueOf(value);
// }
//
// /**
// * get conf (float)
// *
// * @param key
// * @return
// */
// public static float getFloat(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Float.valueOf(value);
// }
//
// /**
// * get conf (double)
// *
// * @param key
// * @return
// */
// public static double getDouble(String key) {
// String value = get(key, null);
// if (value == null) {
// throw new XxlConfException("config key [" + key + "] does not exist");
// }
// return Double.valueOf(value);
// }
//
// /**
// * add listener with xxl conf change
// *
// * @param key
// * @param xxlConfListener
// * @return
// */
// public static boolean addListener(String key, XxlConfListener xxlConfListener){
// return XxlConfListenerFactory.addListener(key, xxlConfListener);
// }
//
// }
//
// Path: xxl-conf-core/src/main/java/com/xxl/conf/core/listener/XxlConfListener.java
// public interface XxlConfListener {
//
// /**
// * invoke when first-use or conf-change
// *
// * @param key
// */
// public void onChange(String key, String value) throws Exception;
//
// }
// Path: xxl-conf-samples/xxl-conf-sample-nutz/src/main/java/com/xxl/conf/sample/nutz/module/IndexModule.java
import com.xxl.conf.core.XxlConfClient;
import com.xxl.conf.core.listener.XxlConfListener;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.xxl.conf.sample.nutz.module;
/**
* @author xuxueli 2018-05-24
*/
@IocBean
public class IndexModule {
private static Logger logger = LoggerFactory.getLogger(IndexModule.class);
static {
/**
* 配置变更监听示例:可开发Listener逻辑,监听配置变更事件;可据此实现动态刷新JDBC连接池等高级功能;
*/
|
XxlConfClient.addListener("default.key01", new XxlConfListener(){
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Tree {
private static HashMap<String, TreeNode> trees = new HashMap<>();
// Tree.Create(treeName, [rootValue, [childTreeValue...]])
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Tree {
private static HashMap<String, TreeNode> trees = new HashMap<>();
// Tree.Create(treeName, [rootValue, [childTreeValue...]])
|
public static Value Create(ArrayList<Value> args) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Tree {
private static HashMap<String, TreeNode> trees = new HashMap<>();
// Tree.Create(treeName, [rootValue, [childTreeValue...]])
public static Value Create(ArrayList<Value> args) {
if (args.size() == 0) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Tree {
private static HashMap<String, TreeNode> trees = new HashMap<>();
// Tree.Create(treeName, [rootValue, [childTreeValue...]])
public static Value Create(ArrayList<Value> args) {
if (args.size() == 0) {
|
throw new InterpretException("Error in # of Arguments: " + args.size());
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
return null;
}
//Tree.RemoveAllChildren(treeName)
public static Value RemoveAllChildren(ArrayList<Value> args){
//args size check
if(args.size() != 1)
throw new InterpretException("Error in # of Arguments: " + args.size());
//get tree
String treeRef = args.get(0).toString();
if(!trees.containsKey(treeRef)){
return null;
}
TreeNode treeNode = trees.get(treeRef);
treeNode.removeAllChildren();
return null;
}
//Tree.GetValue(treeName)
//return : rootValue
public static Value GetValue(ArrayList<Value> args) {
//args size check
if(args.size() != 1)
throw new InterpretException("Error in # of Arguments: " + args.size());
//get tree
String treeName = args.get(0).toString();
if(!trees.containsKey(treeName)){
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
return null;
}
//Tree.RemoveAllChildren(treeName)
public static Value RemoveAllChildren(ArrayList<Value> args){
//args size check
if(args.size() != 1)
throw new InterpretException("Error in # of Arguments: " + args.size());
//get tree
String treeRef = args.get(0).toString();
if(!trees.containsKey(treeRef)){
return null;
}
TreeNode treeNode = trees.get(treeRef);
treeNode.removeAllChildren();
return null;
}
//Tree.GetValue(treeName)
//return : rootValue
public static Value GetValue(ArrayList<Value> args) {
//args size check
if(args.size() != 1)
throw new InterpretException("Error in # of Arguments: " + args.size());
//get tree
String treeName = args.get(0).toString();
if(!trees.containsKey(treeName)){
|
return new StrV("");
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
//get index
int index;
try{
index = Integer.parseInt(args.get(1).toString());
}catch(NumberFormatException e){
throw new InterpretException("Error in index of Arguments: " + args.get(1) + " is not number");
}
//get
TreeNode child = treeNode.getChildAt(index);
if(child != null){
String newTreeName = args.get(2).toString();
if(trees.containsKey(newTreeName))
trees.remove(treeName);
trees.put(newTreeName, child);
}
return null;
}
//Tree.GetNumberOfChildren(treeName)
public static Value GetNumberOfChildren(ArrayList<Value> args) {
//args size check
if(args.size() != 1){
throw new InterpretException("Error in # of Arguments: " + args.size());
}
//get tree
String treeName = args.get(0).toString();
if(!trees.containsKey(treeName)){
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Tree.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
//get index
int index;
try{
index = Integer.parseInt(args.get(1).toString());
}catch(NumberFormatException e){
throw new InterpretException("Error in index of Arguments: " + args.get(1) + " is not number");
}
//get
TreeNode child = treeNode.getChildAt(index);
if(child != null){
String newTreeName = args.get(2).toString();
if(trees.containsKey(newTreeName))
trees.remove(treeName);
trees.put(newTreeName, child);
}
return null;
}
//Tree.GetNumberOfChildren(treeName)
public static Value GetNumberOfChildren(ArrayList<Value> args) {
//args size check
if(args.size() != 1){
throw new InterpretException("Error in # of Arguments: " + args.size());
}
//get tree
String treeName = args.get(0).toString();
if(!trees.containsKey(treeName)){
|
return new DoubleV(0);
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Dictionary.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Dictionary { // 옥스퍼드사전 이용
private static String u;
private static String app_id = "";
private static String app_key = "";
private static StringBuilder def = new StringBuilder(); // 토탈정의
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Dictionary.java
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Dictionary { // 옥스퍼드사전 이용
private static String u;
private static String app_id = "";
private static String app_key = "";
private static StringBuilder def = new StringBuilder(); // 토탈정의
|
public static Value GetDefinition(ArrayList<Value> args) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Dictionary.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Dictionary { // 옥스퍼드사전 이용
private static String u;
private static String app_id = "";
private static String app_key = "";
private static StringBuilder def = new StringBuilder(); // 토탈정의
public static Value GetDefinition(ArrayList<Value> args) {
// 해당하는 단어의 정의를 가져옴
u = "https://od-api.oxforddictionaries.com:443/api/v1/entries/en/";
if (args.size() == 1) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Dictionary.java
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Dictionary { // 옥스퍼드사전 이용
private static String u;
private static String app_id = "";
private static String app_key = "";
private static StringBuilder def = new StringBuilder(); // 토탈정의
public static Value GetDefinition(ArrayList<Value> args) {
// 해당하는 단어의 정의를 가져옴
u = "https://od-api.oxforddictionaries.com:443/api/v1/entries/en/";
if (args.size() == 1) {
|
if(args.get(0) instanceof StrV || args.get(0) instanceof DoubleV) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Dictionary.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Dictionary { // 옥스퍼드사전 이용
private static String u;
private static String app_id = "";
private static String app_key = "";
private static StringBuilder def = new StringBuilder(); // 토탈정의
public static Value GetDefinition(ArrayList<Value> args) {
// 해당하는 단어의 정의를 가져옴
u = "https://od-api.oxforddictionaries.com:443/api/v1/entries/en/";
if (args.size() == 1) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Dictionary.java
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Dictionary { // 옥스퍼드사전 이용
private static String u;
private static String app_id = "";
private static String app_key = "";
private static StringBuilder def = new StringBuilder(); // 토탈정의
public static Value GetDefinition(ArrayList<Value> args) {
// 해당하는 단어의 정의를 가져옴
u = "https://od-api.oxforddictionaries.com:443/api/v1/entries/en/";
if (args.size() == 1) {
|
if(args.get(0) instanceof StrV || args.get(0) instanceof DoubleV) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Mouse.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Robot;
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Mouse {
public static void HideCursor(ArrayList<Value> args) {
// 화면상의 커서를 숨김
if(args.size() == 0) {
GraphicsWindow.HideCursor();
}
else
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Mouse.java
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Robot;
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Mouse {
public static void HideCursor(ArrayList<Value> args) {
// 화면상의 커서를 숨김
if(args.size() == 0) {
GraphicsWindow.HideCursor();
}
else
|
throw new InterpretException("Unexpected # of args " + args.size());
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Mouse.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Robot;
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Mouse {
public static void HideCursor(ArrayList<Value> args) {
// 화면상의 커서를 숨김
if(args.size() == 0) {
GraphicsWindow.HideCursor();
}
else
throw new InterpretException("Unexpected # of args " + args.size());
}
public static void ShowCursor(ArrayList<Value> args) {
// 화면상의 커서를 보여줌
if(args.size() == 0) {
GraphicsWindow.ShowCursor();
}
else
throw new InterpretException("Unexpected # of args " + args.size());
}
private static void mouseXSetting(int mousex) {
try {
Robot robot = new Robot();
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Mouse.java
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Robot;
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Mouse {
public static void HideCursor(ArrayList<Value> args) {
// 화면상의 커서를 숨김
if(args.size() == 0) {
GraphicsWindow.HideCursor();
}
else
throw new InterpretException("Unexpected # of args " + args.size());
}
public static void ShowCursor(ArrayList<Value> args) {
// 화면상의 커서를 보여줌
if(args.size() == 0) {
GraphicsWindow.ShowCursor();
}
else
throw new InterpretException("Unexpected # of args " + args.size());
}
private static void mouseXSetting(int mousex) {
try {
Robot robot = new Robot();
|
MouseX = new DoubleV(mousex);
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Stack.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Stack
{
static
{
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Stack.java
import java.util.ArrayList;
import java.util.HashMap;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Stack
{
static
{
|
stacks = new HashMap<String, java.util.Stack<Value>>();
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Stack.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Stack
{
static
{
stacks = new HashMap<String, java.util.Stack<Value>>();
}
private static HashMap<String, java.util.Stack<Value>> stacks;
//Stack.PushValue(stackName, value) - push in stack
public static Value PushValue(ArrayList<Value> args)
{
//check args_number
if (args.size() == 2)
{
//parameter
String stackName = args.get(0).toString(); //arg1
Value value = args.get(1); //arg2
java.util.Stack<Value> stack = stacks.get(stackName);
//if stackName is not in stacks..
if (stack==null)
{
stacks.put(stackName, new java.util.Stack<Value>());
stack = stacks.get(stackName);
}
//push
stack.push(value);
//return nothing
return null;
}
else
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Stack.java
import java.util.ArrayList;
import java.util.HashMap;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Stack
{
static
{
stacks = new HashMap<String, java.util.Stack<Value>>();
}
private static HashMap<String, java.util.Stack<Value>> stacks;
//Stack.PushValue(stackName, value) - push in stack
public static Value PushValue(ArrayList<Value> args)
{
//check args_number
if (args.size() == 2)
{
//parameter
String stackName = args.get(0).toString(); //arg1
Value value = args.get(1); //arg2
java.util.Stack<Value> stack = stacks.get(stackName);
//if stackName is not in stacks..
if (stack==null)
{
stacks.put(stackName, new java.util.Stack<Value>());
stack = stacks.get(stackName);
}
//push
stack.push(value);
//return nothing
return null;
}
else
|
throw new InterpretException("Error in # of Arguments: " + args.size());
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Stack.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.Value;
|
stacks.put(stackName, new java.util.Stack<Value>());
stack = stacks.get(stackName);
}
//push
stack.push(value);
//return nothing
return null;
}
else
throw new InterpretException("Error in # of Arguments: " + args.size());
}
//Stack.GetCount(stackName)
//return number of items in stack
public static Value GetCount(ArrayList<Value> args)
{
//check args_number
if (args.size() == 1)
{
//parameter
String stackName = args.get(0).toString(); //arg1
java.util.Stack<Value> stack = stacks.get(stackName);
//if stackName is not in stacks..
if (stack==null)
{
// not make new stack with name. just return 0
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Stack.java
import java.util.ArrayList;
import java.util.HashMap;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.Value;
stacks.put(stackName, new java.util.Stack<Value>());
stack = stacks.get(stackName);
}
//push
stack.push(value);
//return nothing
return null;
}
else
throw new InterpretException("Error in # of Arguments: " + args.size());
}
//Stack.GetCount(stackName)
//return number of items in stack
public static Value GetCount(ArrayList<Value> args)
{
//check args_number
if (args.size() == 1)
{
//parameter
String stackName = args.get(0).toString(); //arg1
java.util.Stack<Value> stack = stacks.get(stackName);
//if stackName is not in stacks..
if (stack==null)
{
// not make new stack with name. just return 0
|
return new DoubleV(0);
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Controls.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Controls {
public static Value AddButton(ArrayList<Value> args) {
// caption, left, top
// GraphicsWindow에 버튼을 추가한 창을 반환
if (args.size() == 3) {
String caption;
int left, top;
// caption check
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Controls.java
import java.util.ArrayList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Controls {
public static Value AddButton(ArrayList<Value> args) {
// caption, left, top
// GraphicsWindow에 버튼을 추가한 창을 반환
if (args.size() == 3) {
String caption;
int left, top;
// caption check
|
if (args.get(0) instanceof StrV || args.get(0) instanceof DoubleV)
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Controls.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Controls {
public static Value AddButton(ArrayList<Value> args) {
// caption, left, top
// GraphicsWindow에 버튼을 추가한 창을 반환
if (args.size() == 3) {
String caption;
int left, top;
// caption check
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Controls.java
import java.util.ArrayList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Controls {
public static Value AddButton(ArrayList<Value> args) {
// caption, left, top
// GraphicsWindow에 버튼을 추가한 창을 반환
if (args.size() == 3) {
String caption;
int left, top;
// caption check
|
if (args.get(0) instanceof StrV || args.get(0) instanceof DoubleV)
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Controls.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Controls {
public static Value AddButton(ArrayList<Value> args) {
// caption, left, top
// GraphicsWindow에 버튼을 추가한 창을 반환
if (args.size() == 3) {
String caption;
int left, top;
// caption check
if (args.get(0) instanceof StrV || args.get(0) instanceof DoubleV)
caption = args.get(0).toString();
else
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Controls.java
import java.util.ArrayList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Controls {
public static Value AddButton(ArrayList<Value> args) {
// caption, left, top
// GraphicsWindow에 버튼을 추가한 창을 반환
if (args.size() == 3) {
String caption;
int left, top;
// caption check
if (args.get(0) instanceof StrV || args.get(0) instanceof DoubleV)
caption = args.get(0).toString();
else
|
throw new InterpretException("Unexpected type " + args.get(0));
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Text.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Text {
// Text.Append(text1, text2)
// Appends two text inputs and returns the result as another text.
// This operation is particularly useful when dealing with unknown text in variables
// which could accidentally be treated as numbers and get added, instead of getting appended.
public static Value Append(ArrayList<Value> args) {
String str_arg0 = new String();
String str_arg1 = new String();
if (args.size() == 2) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Text.java
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Text {
// Text.Append(text1, text2)
// Appends two text inputs and returns the result as another text.
// This operation is particularly useful when dealing with unknown text in variables
// which could accidentally be treated as numbers and get added, instead of getting appended.
public static Value Append(ArrayList<Value> args) {
String str_arg0 = new String();
String str_arg1 = new String();
if (args.size() == 2) {
|
if (args.get(0) instanceof DoubleV) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Text.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Text {
// Text.Append(text1, text2)
// Appends two text inputs and returns the result as another text.
// This operation is particularly useful when dealing with unknown text in variables
// which could accidentally be treated as numbers and get added, instead of getting appended.
public static Value Append(ArrayList<Value> args) {
String str_arg0 = new String();
String str_arg1 = new String();
if (args.size() == 2) {
if (args.get(0) instanceof DoubleV) {
str_arg0 = args.get(0).toString();
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Text.java
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Text {
// Text.Append(text1, text2)
// Appends two text inputs and returns the result as another text.
// This operation is particularly useful when dealing with unknown text in variables
// which could accidentally be treated as numbers and get added, instead of getting appended.
public static Value Append(ArrayList<Value> args) {
String str_arg0 = new String();
String str_arg1 = new String();
if (args.size() == 2) {
if (args.get(0) instanceof DoubleV) {
str_arg0 = args.get(0).toString();
|
} else if (args.get(0) instanceof StrV) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Text.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Text {
// Text.Append(text1, text2)
// Appends two text inputs and returns the result as another text.
// This operation is particularly useful when dealing with unknown text in variables
// which could accidentally be treated as numbers and get added, instead of getting appended.
public static Value Append(ArrayList<Value> args) {
String str_arg0 = new String();
String str_arg1 = new String();
if (args.size() == 2) {
if (args.get(0) instanceof DoubleV) {
str_arg0 = args.get(0).toString();
} else if (args.get(0) instanceof StrV) {
str_arg0 = ((StrV) args.get(0)).getValue();
} else {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Text.java
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Text {
// Text.Append(text1, text2)
// Appends two text inputs and returns the result as another text.
// This operation is particularly useful when dealing with unknown text in variables
// which could accidentally be treated as numbers and get added, instead of getting appended.
public static Value Append(ArrayList<Value> args) {
String str_arg0 = new String();
String str_arg1 = new String();
if (args.size() == 2) {
if (args.get(0) instanceof DoubleV) {
str_arg0 = args.get(0).toString();
} else if (args.get(0) instanceof StrV) {
str_arg0 = ((StrV) args.get(0)).getValue();
} else {
|
throw new InterpretException("Append : Unexpected 1st argument");
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Desktop.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.awt.Toolkit;
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Desktop {
public static Value Width;
public static Value Height;
static {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Desktop.java
import java.awt.Toolkit;
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Desktop {
public static Value Width;
public static Value Height;
static {
|
Width = new DoubleV(
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Video.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import javax.swing.SwingUtilities;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;
|
package com.coducation.smallbasic.lib;
public class Video {
public static Value Play(ArrayList<Value> args){
new NativeDiscovery().discover();
String id;
GraphicsWindow.AddCanvas();
if(args.size() == 0){
id = GraphicsWindow.GetID();
}else if(args.size() == 1){
Value arg = args.get(0);
String s = arg.toString();
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Video.java
import java.util.ArrayList;
import javax.swing.SwingUtilities;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;
package com.coducation.smallbasic.lib;
public class Video {
public static Value Play(ArrayList<Value> args){
new NativeDiscovery().discover();
String id;
GraphicsWindow.AddCanvas();
if(args.size() == 0){
id = GraphicsWindow.GetID();
}else if(args.size() == 1){
Value arg = args.get(0);
String s = arg.toString();
|
if(arg instanceof StrV){
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Video.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import javax.swing.SwingUtilities;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;
|
package com.coducation.smallbasic.lib;
public class Video {
public static Value Play(ArrayList<Value> args){
new NativeDiscovery().discover();
String id;
GraphicsWindow.AddCanvas();
if(args.size() == 0){
id = GraphicsWindow.GetID();
}else if(args.size() == 1){
Value arg = args.get(0);
String s = arg.toString();
if(arg instanceof StrV){
}
else
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Video.java
import java.util.ArrayList;
import javax.swing.SwingUtilities;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;
package com.coducation.smallbasic.lib;
public class Video {
public static Value Play(ArrayList<Value> args){
new NativeDiscovery().discover();
String id;
GraphicsWindow.AddCanvas();
if(args.size() == 0){
id = GraphicsWindow.GetID();
}else if(args.size() == 1){
Value arg = args.get(0);
String s = arg.toString();
if(arg instanceof StrV){
}
else
|
throw new InterpretException("Not String Value for filePath" + arg);
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Math.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Math {
public final static Value Pi = new DoubleV(java.lang.Math.PI);
// Gets the absolute value of the given number.
// For example, -32.233 will return 32.233.
public static Value Abs(ArrayList<Value> args) {
double dbl_arg;
if (args.size() == 1) {
if (args.get(0) instanceof DoubleV) {
dbl_arg = ((DoubleV) args.get(0)).getValue();
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Math.java
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Math {
public final static Value Pi = new DoubleV(java.lang.Math.PI);
// Gets the absolute value of the given number.
// For example, -32.233 will return 32.233.
public static Value Abs(ArrayList<Value> args) {
double dbl_arg;
if (args.size() == 1) {
if (args.get(0) instanceof DoubleV) {
dbl_arg = ((DoubleV) args.get(0)).getValue();
|
} else if (args.get(0) instanceof StrV) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Math.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Math {
public final static Value Pi = new DoubleV(java.lang.Math.PI);
// Gets the absolute value of the given number.
// For example, -32.233 will return 32.233.
public static Value Abs(ArrayList<Value> args) {
double dbl_arg;
if (args.size() == 1) {
if (args.get(0) instanceof DoubleV) {
dbl_arg = ((DoubleV) args.get(0)).getValue();
} else if (args.get(0) instanceof StrV) {
String arg = ((StrV) args.get(0)).getValue();
try {
dbl_arg = new StrV(arg).parseDouble();
} catch (NumberFormatException e) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Math.java
import java.util.ArrayList;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Math {
public final static Value Pi = new DoubleV(java.lang.Math.PI);
// Gets the absolute value of the given number.
// For example, -32.233 will return 32.233.
public static Value Abs(ArrayList<Value> args) {
double dbl_arg;
if (args.size() == 1) {
if (args.get(0) instanceof DoubleV) {
dbl_arg = ((DoubleV) args.get(0)).getValue();
} else if (args.get(0) instanceof StrV) {
String arg = ((StrV) args.get(0)).getValue();
try {
dbl_arg = new StrV(arg).parseDouble();
} catch (NumberFormatException e) {
|
throw new InterpretException("Abs : Unexpected StrV arg : " + arg);
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Flickr.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Flickr {
private static String u;
private static String photourl= "";
private static String api_key= "";
private final static int max = 4001;
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Flickr.java
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Flickr {
private static String u;
private static String photourl= "";
private static String api_key= "";
private final static int max = 4001;
|
public static Value GetPictureOfMoment(ArrayList<Value> args) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Clock.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Clock {
public static Value Date; // = new DoubleV(new Date().getDate());
public static Value Day; // = new DoubleV(new Date().getDay());
public static Value ElapsedMilliseconds;
public static Value Hour; // = new DoubleV(new Date().getHours());
public static Value Millisecond;
public static Value Minute; // = new DoubleV(new Date().getMinutes());
public static Value Month; // = new DoubleV(new Date().getMonth());
public static Value Second; // = new DoubleV(new Date().getSeconds());
public static Value Time; // = new StrV(new Date().getYear() + "-" + new Date().getMonth() + "-" + new Date().getDate());
public static Value WeekDay; // = new DoubleV(Calendar.DAY_OF_WEEK);
public static Value Year; // = new DoubleV(new Date().getYear());
public static void notifyFieldAssign(String fieldName) {
}
public static void notifyFieldRead(String fieldName) {
Calendar currentCal = Calendar.getInstance();
if ("Date".equalsIgnoreCase(fieldName)) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Clock.java
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Clock {
public static Value Date; // = new DoubleV(new Date().getDate());
public static Value Day; // = new DoubleV(new Date().getDay());
public static Value ElapsedMilliseconds;
public static Value Hour; // = new DoubleV(new Date().getHours());
public static Value Millisecond;
public static Value Minute; // = new DoubleV(new Date().getMinutes());
public static Value Month; // = new DoubleV(new Date().getMonth());
public static Value Second; // = new DoubleV(new Date().getSeconds());
public static Value Time; // = new StrV(new Date().getYear() + "-" + new Date().getMonth() + "-" + new Date().getDate());
public static Value WeekDay; // = new DoubleV(Calendar.DAY_OF_WEEK);
public static Value Year; // = new DoubleV(new Date().getYear());
public static void notifyFieldAssign(String fieldName) {
}
public static void notifyFieldRead(String fieldName) {
Calendar currentCal = Calendar.getInstance();
if ("Date".equalsIgnoreCase(fieldName)) {
|
Date = new DoubleV(currentCal.get(Calendar.DATE));
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Clock.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
}
public static void notifyFieldRead(String fieldName) {
Calendar currentCal = Calendar.getInstance();
if ("Date".equalsIgnoreCase(fieldName)) {
Date = new DoubleV(currentCal.get(Calendar.DATE));
}
else if ("Day".equalsIgnoreCase(fieldName)) {
Day = new DoubleV(currentCal.get(Calendar.DAY_OF_MONTH));
}
else if ("ElapsedMilliseconds".equalsIgnoreCase(fieldName)) {
ElapsedMilliseconds = new DoubleV(currentCal.getTimeInMillis());
}
else if ("Hour".equalsIgnoreCase(fieldName)) {
Hour = new DoubleV(currentCal.get(Calendar.HOUR_OF_DAY));
}
else if ("Millisecond".equalsIgnoreCase(fieldName)) {
Millisecond = new DoubleV(currentCal.get(Calendar.MILLISECOND));
}
else if ("Minute".equalsIgnoreCase(fieldName)) {
Minute = new DoubleV(currentCal.get(Calendar.MINUTE));
}
else if ("Month".equalsIgnoreCase(fieldName)) {
Month = new DoubleV(currentCal.get(Calendar.MONTH));
}
else if ("Second".equalsIgnoreCase(fieldName)) {
Second = new DoubleV(currentCal.get(Calendar.SECOND));
}
else if ("Time".equalsIgnoreCase(fieldName)) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Clock.java
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
}
public static void notifyFieldRead(String fieldName) {
Calendar currentCal = Calendar.getInstance();
if ("Date".equalsIgnoreCase(fieldName)) {
Date = new DoubleV(currentCal.get(Calendar.DATE));
}
else if ("Day".equalsIgnoreCase(fieldName)) {
Day = new DoubleV(currentCal.get(Calendar.DAY_OF_MONTH));
}
else if ("ElapsedMilliseconds".equalsIgnoreCase(fieldName)) {
ElapsedMilliseconds = new DoubleV(currentCal.getTimeInMillis());
}
else if ("Hour".equalsIgnoreCase(fieldName)) {
Hour = new DoubleV(currentCal.get(Calendar.HOUR_OF_DAY));
}
else if ("Millisecond".equalsIgnoreCase(fieldName)) {
Millisecond = new DoubleV(currentCal.get(Calendar.MILLISECOND));
}
else if ("Minute".equalsIgnoreCase(fieldName)) {
Minute = new DoubleV(currentCal.get(Calendar.MINUTE));
}
else if ("Month".equalsIgnoreCase(fieldName)) {
Month = new DoubleV(currentCal.get(Calendar.MONTH));
}
else if ("Second".equalsIgnoreCase(fieldName)) {
Second = new DoubleV(currentCal.get(Calendar.SECOND));
}
else if ("Time".equalsIgnoreCase(fieldName)) {
|
Time = new StrV(
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Network.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Network {
public static Value DownloadFile(ArrayList<Value> args) {
// 네트워크상의 파일을 로칼상의 임시파일로 다운로드하여 임시파일이름을 반환
String path = "";
if (args.size() == 1) {
try {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Network.java
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Network {
public static Value DownloadFile(ArrayList<Value> args) {
// 네트워크상의 파일을 로칼상의 임시파일로 다운로드하여 임시파일이름을 반환
String path = "";
if (args.size() == 1) {
try {
|
if(args.get(0) instanceof StrV) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Network.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Network {
public static Value DownloadFile(ArrayList<Value> args) {
// 네트워크상의 파일을 로칼상의 임시파일로 다운로드하여 임시파일이름을 반환
String path = "";
if (args.size() == 1) {
try {
if(args.get(0) instanceof StrV) {
URL url = new URL(args.get(0).toString());
InputStreamReader isr = new InputStreamReader(url.openStream(), "UTF-8");
java.io.File tmp = java.io.File.createTempFile("tmp", null);
path = tmp.getCanonicalPath();
OutputStreamWriter osr = new OutputStreamWriter(new FileOutputStream(path), "UTF-8");
int a;
while((a = isr.read())!=-1) {
osr.write((char)a);
}
}
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Network.java
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Network {
public static Value DownloadFile(ArrayList<Value> args) {
// 네트워크상의 파일을 로칼상의 임시파일로 다운로드하여 임시파일이름을 반환
String path = "";
if (args.size() == 1) {
try {
if(args.get(0) instanceof StrV) {
URL url = new URL(args.get(0).toString());
InputStreamReader isr = new InputStreamReader(url.openStream(), "UTF-8");
java.io.File tmp = java.io.File.createTempFile("tmp", null);
path = tmp.getCanonicalPath();
OutputStreamWriter osr = new OutputStreamWriter(new FileOutputStream(path), "UTF-8");
int a;
while((a = isr.read())!=-1) {
osr.write((char)a);
}
}
|
else throw new InterpretException("DownloadFile: Unexpected arg(0)");
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Hamster.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import org.roboid.runtime.Runner;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Hamster
{
//Rotate(speed) - 시계방향으로 speed(-100 ~ 100 [%], 0: 정지)로 회전
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Hamster.java
import java.util.ArrayList;
import java.util.HashMap;
import org.roboid.runtime.Runner;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Hamster
{
//Rotate(speed) - 시계방향으로 speed(-100 ~ 100 [%], 0: 정지)로 회전
|
public static void Rotate(ArrayList<Value> args)
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Hamster.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import org.roboid.runtime.Runner;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Hamster
{
//Rotate(speed) - 시계방향으로 speed(-100 ~ 100 [%], 0: 정지)로 회전
public static void Rotate(ArrayList<Value> args)
{
if (args.size() == 1)
MultiRotate(changeToMultiArgs(args));
else
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Hamster.java
import java.util.ArrayList;
import java.util.HashMap;
import org.roboid.runtime.Runner;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Hamster
{
//Rotate(speed) - 시계방향으로 speed(-100 ~ 100 [%], 0: 정지)로 회전
public static void Rotate(ArrayList<Value> args)
{
if (args.size() == 1)
MultiRotate(changeToMultiArgs(args));
else
|
throw new InterpretException("Error in # of Arguments: " + args.size());
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Hamster.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import org.roboid.runtime.Runner;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
else
throw new InterpretException("Error in # of Arguments: " + args.size());
}
//SignalStrength(hamsterID)
public static Value MultiSignalStrength(ArrayList<Value> args)
{
if(args.size() == 1)
{
initialCallCheck();
int hamsterID;
try
{
// 첫번째 인자
String arg = args.get(0).toString();
hamsterID = (int)Double.parseDouble(arg);
}
catch (NumberFormatException e)
{
throw new InterpretException("Unexpected type " + args.get(0));
}
// 햄스터연결 확인
if(hamsterID >= connectedHamsterNum || hamsterID < 0)
return null;
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Hamster.java
import java.util.ArrayList;
import java.util.HashMap;
import org.roboid.runtime.Runner;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
else
throw new InterpretException("Error in # of Arguments: " + args.size());
}
//SignalStrength(hamsterID)
public static Value MultiSignalStrength(ArrayList<Value> args)
{
if(args.size() == 1)
{
initialCallCheck();
int hamsterID;
try
{
// 첫번째 인자
String arg = args.get(0).toString();
hamsterID = (int)Double.parseDouble(arg);
}
catch (NumberFormatException e)
{
throw new InterpretException("Unexpected type " + args.get(0));
}
// 햄스터연결 확인
if(hamsterID >= connectedHamsterNum || hamsterID < 0)
return null;
|
return new DoubleV(hamster.get(hamsterID).signalStrength());
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Sound.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jfugue.player.Player;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class Sound {
public static Value PlayClick(ArrayList<Value> args){
if(args.size()==0){
if(st != null)
{
st.interrupt();
}
st = new SoundThread("resource\\click.wav");
st.start();
return null;
}
else
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Sound.java
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jfugue.player.Player;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class Sound {
public static Value PlayClick(ArrayList<Value> args){
if(args.size()==0){
if(st != null)
{
st.interrupt();
}
st = new SoundThread("resource\\click.wav");
st.start();
return null;
}
else
|
throw new InterpretException("Error in # of Arguments: " + args.size());
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/Sound.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jfugue.player.Player;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
return null;
}else {
String note = String.valueOf(o.charAt(0));
String dur = String.valueOf(o.charAt(1));
String duration = notesDuration(dur);
player.play(note+"1"+duration);
}
}else {
String result = "";
for(int i = 0; i < arr.length; i++) {
String note = String.valueOf(arr[i].charAt(0));
String dur = String.valueOf(arr[i].charAt(1));
String duration = notesDuration(dur);
result += note+"1"+duration+" ";
}
player.play(result);
}
}
}
else {
throw new InterpretException("Error in # of Arguments: " + args.size());
}
return null;
}
public static Value Play(ArrayList<Value> args) throws URISyntaxException{
if(args.size()==1){
Value arg = args.get(0);
String s;
|
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/Sound.java
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
import org.jfugue.player.Player;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
return null;
}else {
String note = String.valueOf(o.charAt(0));
String dur = String.valueOf(o.charAt(1));
String duration = notesDuration(dur);
player.play(note+"1"+duration);
}
}else {
String result = "";
for(int i = 0; i < arr.length; i++) {
String note = String.valueOf(arr[i].charAt(0));
String dur = String.valueOf(arr[i].charAt(1));
String duration = notesDuration(dur);
result += note+"1"+duration+" ";
}
player.play(result);
}
}
}
else {
throw new InterpretException("Error in # of Arguments: " + args.size());
}
return null;
}
public static Value Play(ArrayList<Value> args) throws URISyntaxException{
if(args.size()==1){
Value arg = args.get(0);
String s;
|
if(arg instanceof StrV){
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/Eval.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/util/Util.java
// public class Util {
// public static String throwableToStacktrace(Throwable e) {
// StringWriter sw = new StringWriter();
// e.printStackTrace(new PrintWriter(sw));
// String exceptionAsString = sw.toString();
// return exceptionAsString;
// }
// }
|
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import com.coducation.smallbasic.util.Util;
|
// End
}
public void eval(BasicBlockEnv bbEnv, Env env, Assign assignStmt) {
Expr lhs = assignStmt.getLSide();
Expr rhs = assignStmt.getRSide();
// Value v1 = eval(env, lhs);
Value v2 = eval(env, rhs);
// Assigning an array is done by copy.
if (v2 instanceof ArrayV) {
v2 = ((ArrayV)v2).copy();
}
if (lhs instanceof Var) {
env.put(((Var) lhs).getVarName(), v2);
} else if (lhs instanceof PropertyExpr) {
try {
String clzName = ((PropertyExpr) lhs).getObj();
Class clz = getClass(clzName);
Field fld = clz.getField(((PropertyExpr) lhs).getName());
fld.set(null, v2);
// After any field assignment, invoke notifyFieldAssign for
// Library to know
// the change of the field value.
Method mth = clz.getMethod(notifyFieldAssign, String.class);
mth.invoke(null, ((PropertyExpr) lhs).getName());
} catch (NoSuchFieldException e) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/util/Util.java
// public class Util {
// public static String throwableToStacktrace(Throwable e) {
// StringWriter sw = new StringWriter();
// e.printStackTrace(new PrintWriter(sw));
// String exceptionAsString = sw.toString();
// return exceptionAsString;
// }
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/Eval.java
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import com.coducation.smallbasic.util.Util;
// End
}
public void eval(BasicBlockEnv bbEnv, Env env, Assign assignStmt) {
Expr lhs = assignStmt.getLSide();
Expr rhs = assignStmt.getRSide();
// Value v1 = eval(env, lhs);
Value v2 = eval(env, rhs);
// Assigning an array is done by copy.
if (v2 instanceof ArrayV) {
v2 = ((ArrayV)v2).copy();
}
if (lhs instanceof Var) {
env.put(((Var) lhs).getVarName(), v2);
} else if (lhs instanceof PropertyExpr) {
try {
String clzName = ((PropertyExpr) lhs).getObj();
Class clz = getClass(clzName);
Field fld = clz.getField(((PropertyExpr) lhs).getName());
fld.set(null, v2);
// After any field assignment, invoke notifyFieldAssign for
// Library to know
// the change of the field value.
Method mth = clz.getMethod(notifyFieldAssign, String.class);
mth.invoke(null, ((PropertyExpr) lhs).getName());
} catch (NoSuchFieldException e) {
|
throw new InterpretException("Assign : " + Util.throwableToStacktrace(e), ((PropertyExpr) lhs).getName(), lhs.lineno(), lhs.charat());
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class ImageList {
private static HashMap<String, Image> image_list = new HashMap<>();
private static int key = 1 ;
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class ImageList {
private static HashMap<String, Image> image_list = new HashMap<>();
private static int key = 1 ;
|
public static Value LoadImage(ArrayList<Value> args){
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class ImageList {
private static HashMap<String, Image> image_list = new HashMap<>();
private static int key = 1 ;
public static Value LoadImage(ArrayList<Value> args){
String str_arg;
if (args.size() == 1) {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class ImageList {
private static HashMap<String, Image> image_list = new HashMap<>();
private static int key = 1 ;
public static Value LoadImage(ArrayList<Value> args){
String str_arg;
if (args.size() == 1) {
|
if (args.get(0) instanceof StrV) {
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
package com.coducation.smallbasic.lib;
public class ImageList {
private static HashMap<String, Image> image_list = new HashMap<>();
private static int key = 1 ;
public static Value LoadImage(ArrayList<Value> args){
String str_arg;
if (args.size() == 1) {
if (args.get(0) instanceof StrV) {
str_arg = ((StrV) args.get(0)).getValue();
} else {
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
package com.coducation.smallbasic.lib;
public class ImageList {
private static HashMap<String, Image> image_list = new HashMap<>();
private static int key = 1 ;
public static Value LoadImage(ArrayList<Value> args){
String str_arg;
if (args.size() == 1) {
if (args.get(0) instanceof StrV) {
str_arg = ((StrV) args.get(0)).getValue();
} else {
|
throw new InterpretException("LoadImage : Unexpected arg");
|
kwanghoon/MySmallBasic
|
MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
|
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
|
img = new ImageIcon(str_arg).getImage();
image_list.put("ImageList" + key, img);
}
return new StrV("ImageList" + key++);
}
public static Value GetWidthOfImage(ArrayList<Value> args){
String str_arg;
if (args.size() == 1) {
if (args.get(0) instanceof StrV) {
str_arg = ((StrV) args.get(0)).getValue();
} else {
throw new InterpretException("GetWidthOfImage : Unexpected arg");
}
} else
throw new InterpretException("GetWidthOfImage : Unexpected # of args: " + args.size());
|
// Path: MySmallBasic/src/com/coducation/smallbasic/DoubleV.java
// public class DoubleV extends Value {
//
// public DoubleV(double value) {
// this.value = value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public double getValue() {
// return value;
// }
//
// @Override
// public double getNumber() {
// return value;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof DoubleV)
// return this.value == ((DoubleV) arg0).value;
// else
// return false;
// }
//
// public String toString() {
// int i = (int) value;
// if(i == value)
// return i + "";
// else
// return value + "";
// }
//
// private double value;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/InterpretException.java
// public class InterpretException extends RuntimeException {
// public InterpretException(String message) {
// this(message, "", -1, -1);
// }
// public InterpretException(String message, boolean programend) {
// this(message, programend, "", -1, -1);
// }
// public InterpretException(String message, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = false;
// }
// public InterpretException(String message, boolean programend, String culprit, int linenum, int colnum) {
// this.message = message;
// this.linenum = linenum;
// this.colnum = colnum;
// this.culprit = culprit;
// this.ProgramEnd = programend;
// }
//
// public String getMessage() {
// return message;
// }
// public int getLinenum() {
// return linenum;
// }
// public int getColnum() {
// return colnum;
// }
// public String getCulprit() {
// return culprit;
// }
//
// public boolean getProgramEnd() {
// return ProgramEnd;
// }
//
// private String message;
// private int linenum;
// private int colnum;
// private String culprit;
// private boolean ProgramEnd;
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/StrV.java
// public class StrV extends Value {
//
// public StrV(){
// v = "";
// }
//
// public StrV(double d){
// v = d+"";
// }
//
// public StrV(String str){
// v = str;
// }
//
// public String getValue(){
// return v;
// }
//
// @Override
// public boolean equals(Object arg0) {
// if(arg0 instanceof StrV)
// return this.v == ((StrV) arg0).v;
// else
// return false;
// }
//
// public boolean isNumber() {
// try {
// if ("".equals(v))
// return true;
//
// Double.parseDouble(v);
// return true;
// } catch(NumberFormatException e) {
// return false;
// }
// }
//
// public double parseDouble() {
// if ("".equals(v))
// return 0;
// else
// return Double.parseDouble(v);
// }
//
// @Override
// public double getNumber() {
// return parseDouble();
// }
//
// public String toString() {
// return v;
// }
//
// private String v;
//
// }
//
// Path: MySmallBasic/src/com/coducation/smallbasic/Value.java
// public abstract class Value {
// public abstract String toString();
// // TODO : 비우는게 맞나..?
//
// public abstract double getNumber();
// }
// Path: MySmallBasic/src/com/coducation/smallbasic/lib/ImageList.java
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import com.coducation.smallbasic.DoubleV;
import com.coducation.smallbasic.InterpretException;
import com.coducation.smallbasic.StrV;
import com.coducation.smallbasic.Value;
img = new ImageIcon(str_arg).getImage();
image_list.put("ImageList" + key, img);
}
return new StrV("ImageList" + key++);
}
public static Value GetWidthOfImage(ArrayList<Value> args){
String str_arg;
if (args.size() == 1) {
if (args.get(0) instanceof StrV) {
str_arg = ((StrV) args.get(0)).getValue();
} else {
throw new InterpretException("GetWidthOfImage : Unexpected arg");
}
} else
throw new InterpretException("GetWidthOfImage : Unexpected # of args: " + args.size());
|
return new DoubleV(image_list.get(str_arg).getWidth(null));
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/local_settings/Bookmarks.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
// public final String ip;
// public String displayName;
// private final Integer sshPort;
// public final Integer vlcPort;
// private String password;
// private String lastPath;
//
// public Server(String ip, Integer vlcPort, Integer sshPort) {
// this.ip = ip;
// this.vlcPort = vlcPort;
// this.sshPort = sshPort;
// this.password = "";
// this.displayName = null;
// }
//
// public void setDisplayName(final String name) {
// this.displayName = name;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getFullDisplayName() {
// if (displayName != null) {
// return displayName + " (" + ip + ")";
// } else {
// return ip + ":" + vlcPort;
// }
// }
//
// public void setPassword(final String password) {
// this.password = password;
// }
// public String getPassword() {
// return password;
// }
//
// public void setLastPath(String lastPath) { this.lastPath = lastPath; }
// public String getLastPath() { return this.lastPath; }
// }
|
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;
|
package com.nicolasbrailo.vlcfreemote.local_settings;
public class Bookmarks extends LocalSettings {
private static final int DB_VERSION = 1;
private static final String DB_NAME = "bookmarks.db";
private static final String TABLE_NAME = "bookmarks";
private static final String COLUMN_IP = "ip";
private static final String COLUMN_VLCPORT = "port";
private static final String COLUMN_PATH = "path";
public Bookmarks(Context context) {
super(context, DB_NAME, DB_VERSION);
}
@Override
protected String getDeleteTableSQL() {
return "DROP TABLE IF EXISTS " + TABLE_NAME;
}
@Override
protected String getCreateTableSQL() {
return "CREATE TABLE " + TABLE_NAME + " (" +
COLUMN_IP + " VARCHAR(15), " +
COLUMN_VLCPORT + " INTEGER, " +
COLUMN_PATH + " TEXT, " +
"PRIMARY KEY ("+ COLUMN_IP + "," + COLUMN_VLCPORT + ", " + COLUMN_PATH + ") " +
" )";
}
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
// public final String ip;
// public String displayName;
// private final Integer sshPort;
// public final Integer vlcPort;
// private String password;
// private String lastPath;
//
// public Server(String ip, Integer vlcPort, Integer sshPort) {
// this.ip = ip;
// this.vlcPort = vlcPort;
// this.sshPort = sshPort;
// this.password = "";
// this.displayName = null;
// }
//
// public void setDisplayName(final String name) {
// this.displayName = name;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getFullDisplayName() {
// if (displayName != null) {
// return displayName + " (" + ip + ")";
// } else {
// return ip + ":" + vlcPort;
// }
// }
//
// public void setPassword(final String password) {
// this.password = password;
// }
// public String getPassword() {
// return password;
// }
//
// public void setLastPath(String lastPath) { this.lastPath = lastPath; }
// public String getLastPath() { return this.lastPath; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/local_settings/Bookmarks.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;
package com.nicolasbrailo.vlcfreemote.local_settings;
public class Bookmarks extends LocalSettings {
private static final int DB_VERSION = 1;
private static final String DB_NAME = "bookmarks.db";
private static final String TABLE_NAME = "bookmarks";
private static final String COLUMN_IP = "ip";
private static final String COLUMN_VLCPORT = "port";
private static final String COLUMN_PATH = "path";
public Bookmarks(Context context) {
super(context, DB_NAME, DB_VERSION);
}
@Override
protected String getDeleteTableSQL() {
return "DROP TABLE IF EXISTS " + TABLE_NAME;
}
@Override
protected String getCreateTableSQL() {
return "CREATE TABLE " + TABLE_NAME + " (" +
COLUMN_IP + " VARCHAR(15), " +
COLUMN_VLCPORT + " INTEGER, " +
COLUMN_PATH + " TEXT, " +
"PRIMARY KEY ("+ COLUMN_IP + "," + COLUMN_VLCPORT + ", " + COLUMN_PATH + ") " +
" )";
}
|
public void addBookmark(final Server srv, final String path) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_SetVolume.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
|
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
|
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_SetVolume extends VlcCommand_ReturnsVlcStatus {
private final String vol_value;
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_SetVolume.java
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_SetVolume extends VlcCommand_ReturnsVlcStatus {
private final String vol_value;
|
public Cmd_SetVolume(int percent, VlcStatus.ObserverRegister cb) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_JumpToPositionPercent.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
|
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
|
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_JumpToPositionPercent extends VlcCommand_ReturnsVlcStatus {
private static final String URL_ENCODED_PERCENT = "%25";
private final String pos;
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_JumpToPositionPercent.java
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_JumpToPositionPercent extends VlcCommand_ReturnsVlcStatus {
private static final String URL_ENCODED_PERCENT = "%25";
private final String pos;
|
public Cmd_JumpToPositionPercent(float percent, VlcStatus.ObserverRegister cb) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_StartPlaying.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
|
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
|
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_StartPlaying extends VlcCommand_ReturnsVlcStatus {
private final String id;
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_StartPlaying.java
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_StartPlaying extends VlcCommand_ReturnsVlcStatus {
private final String id;
|
public Cmd_StartPlaying(Integer id, VlcStatus.ObserverRegister cb) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_JumpRelativePercent.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
|
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
|
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_JumpRelativePercent extends VlcCommand_ReturnsVlcStatus {
private static final String URL_ENCODED_PERCENT = "%25";
private final String jump_value;
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_JumpRelativePercent.java
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_JumpRelativePercent extends VlcCommand_ReturnsVlcStatus {
private static final String URL_ENCODED_PERCENT = "%25";
private final String jump_value;
|
public Cmd_JumpRelativePercent(float percent, VlcStatus.ObserverRegister cb) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/local_settings/PlayedFiles.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
// public final String ip;
// public String displayName;
// private final Integer sshPort;
// public final Integer vlcPort;
// private String password;
// private String lastPath;
//
// public Server(String ip, Integer vlcPort, Integer sshPort) {
// this.ip = ip;
// this.vlcPort = vlcPort;
// this.sshPort = sshPort;
// this.password = "";
// this.displayName = null;
// }
//
// public void setDisplayName(final String name) {
// this.displayName = name;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getFullDisplayName() {
// if (displayName != null) {
// return displayName + " (" + ip + ")";
// } else {
// return ip + ":" + vlcPort;
// }
// }
//
// public void setPassword(final String password) {
// this.password = password;
// }
// public String getPassword() {
// return password;
// }
//
// public void setLastPath(String lastPath) { this.lastPath = lastPath; }
// public String getLastPath() { return this.lastPath; }
// }
|
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;
|
package com.nicolasbrailo.vlcfreemote.local_settings;
public class PlayedFiles extends LocalSettings {
private static final int DB_VERSION = 1;
private static final String DB_NAME = "played_files.db";
private static final String TABLE_NAME = "played_files";
private static final String COLUMN_ID = "id";
private static final String COLUMN_IP = "ip";
private static final String COLUMN_VLCPORT = "port";
private static final String COLUMN_PATH = "path";
private static final int HISTORY_LIMIT = 1000;
public PlayedFiles(Context context) {
super(context, DB_NAME, DB_VERSION);
}
@Override
protected String getDeleteTableSQL() {
return "DROP TABLE IF EXISTS " + TABLE_NAME;
}
@Override
protected String getCreateTableSQL() {
return "CREATE TABLE " + TABLE_NAME + " ( " +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_IP + " VARCHAR(15), " +
COLUMN_VLCPORT + " INTEGER, " +
COLUMN_PATH + " TEXT, " +
" UNIQUE (" + COLUMN_IP + ", " + COLUMN_VLCPORT + ", " + COLUMN_PATH + ") " +
")";
}
/**
* Adds a file to the recently played files list and truncates the list as configured
* @param srv Server on which $path was played
* @param path Path to store
*/
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
// public final String ip;
// public String displayName;
// private final Integer sshPort;
// public final Integer vlcPort;
// private String password;
// private String lastPath;
//
// public Server(String ip, Integer vlcPort, Integer sshPort) {
// this.ip = ip;
// this.vlcPort = vlcPort;
// this.sshPort = sshPort;
// this.password = "";
// this.displayName = null;
// }
//
// public void setDisplayName(final String name) {
// this.displayName = name;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getFullDisplayName() {
// if (displayName != null) {
// return displayName + " (" + ip + ")";
// } else {
// return ip + ":" + vlcPort;
// }
// }
//
// public void setPassword(final String password) {
// this.password = password;
// }
// public String getPassword() {
// return password;
// }
//
// public void setLastPath(String lastPath) { this.lastPath = lastPath; }
// public String getLastPath() { return this.lastPath; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/local_settings/PlayedFiles.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;
package com.nicolasbrailo.vlcfreemote.local_settings;
public class PlayedFiles extends LocalSettings {
private static final int DB_VERSION = 1;
private static final String DB_NAME = "played_files.db";
private static final String TABLE_NAME = "played_files";
private static final String COLUMN_ID = "id";
private static final String COLUMN_IP = "ip";
private static final String COLUMN_VLCPORT = "port";
private static final String COLUMN_PATH = "path";
private static final int HISTORY_LIMIT = 1000;
public PlayedFiles(Context context) {
super(context, DB_NAME, DB_VERSION);
}
@Override
protected String getDeleteTableSQL() {
return "DROP TABLE IF EXISTS " + TABLE_NAME;
}
@Override
protected String getCreateTableSQL() {
return "CREATE TABLE " + TABLE_NAME + " ( " +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_IP + " VARCHAR(15), " +
COLUMN_VLCPORT + " INTEGER, " +
COLUMN_PATH + " TEXT, " +
" UNIQUE (" + COLUMN_IP + ", " + COLUMN_VLCPORT + ", " + COLUMN_PATH + ") " +
")";
}
/**
* Adds a file to the recently played files list and truncates the list as configured
* @param srv Server on which $path was played
* @param path Path to store
*/
|
public void addPlayedFile(final Server srv, final String path) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_AddToPlaylist.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
|
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
|
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_AddToPlaylist extends VlcCommand_ReturnsVlcStatus {
private final String mediaUri;
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_AddToPlaylist.java
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_AddToPlaylist extends VlcCommand_ReturnsVlcStatus {
private final String mediaUri;
|
public Cmd_AddToPlaylist(final String mediaUri, VlcStatus.ObserverRegister cb) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_RemoveFromPlaylist.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
|
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
|
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_RemoveFromPlaylist extends VlcCommand_ReturnsVlcStatus {
private final int id;
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/VlcStatus.java
// public class VlcStatus {
// public interface ObserverRegister {
// Observer getVlcStatusObserver();
// }
//
// public interface Observer {
// void onVlcStatusUpdate(VlcStatus results);
// void onVlcStatusFetchError();
// void onVlcStatusFetchError(String msg);
// }
//
// public int length;
// public float position; // Progress % of the current file
// public int volume;
// public int time;
// public float rate;
// public float audiodelay;
// public float subtitledelay;
// public boolean repeat;
// public boolean loop;
// public boolean random;
// public boolean fullscreen;
// public String state;
// public String currentMedia_filename;
// public String currentMedia_album;
// public String currentMedia_title;
// public String currentMedia_artist;
// public int currentMedia_trackNumber;
// public int currentMedia_tracksTotal;
//
// public static final String HUMAN_READABLE_STATE_PAUSED = "Paused";
// public static final String HUMAN_READABLE_STATE_PLAYING = "Playing";
// public static final String HUMAN_READABLE_STATE_STOPPED = "Stopped";
// public static final String HUMAN_READABLE_STATE_UNKNOW = "?";
//
// public VlcStatus() { state = ""; }
//
// public boolean isStopped() { return state.equals("stopped"); }
//
// public boolean isPlaying() { return state.equals("playing"); }
//
// public String getHumanReadableState() {
// switch (state) {
// case "paused": return HUMAN_READABLE_STATE_PAUSED;
// case "playing": return HUMAN_READABLE_STATE_PLAYING;
// case "stopped": return HUMAN_READABLE_STATE_STOPPED;
// default: return HUMAN_READABLE_STATE_UNKNOW;
// }
// }
//
// public String getCurrentPlayingFile(Resources resources) {
// if (currentMedia_title != null) return currentMedia_title;
// if (currentMedia_filename != null) return currentMedia_filename;
// return String.format(resources.getString(R.string.playing_track_status),
// currentMedia_trackNumber, currentMedia_tracksTotal);
// }
//
// // Vlc's volume seems to go from 0 to 400 (?)
// static public int normalizeVolumeFrom0_100ToVlc(int vlcVolume) { return 4*vlcVolume; }
// static public int normalizeVolumeFromVlcTo0_100(int vlcVolume) { return vlcVolume/4; }
//
// static public float normalizePosFromVlcTo0_100(float pos) { return 100*pos; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/Cmd_RemoveFromPlaylist.java
import com.nicolasbrailo.vlcfreemote.model.VlcStatus;
package com.nicolasbrailo.vlcfreemote.vlc_connector;
public class Cmd_RemoveFromPlaylist extends VlcCommand_ReturnsVlcStatus {
private final int id;
|
public Cmd_RemoveFromPlaylist(int id, VlcStatus.ObserverRegister cb) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/local_settings/RememberedServers.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
// public final String ip;
// public String displayName;
// private final Integer sshPort;
// public final Integer vlcPort;
// private String password;
// private String lastPath;
//
// public Server(String ip, Integer vlcPort, Integer sshPort) {
// this.ip = ip;
// this.vlcPort = vlcPort;
// this.sshPort = sshPort;
// this.password = "";
// this.displayName = null;
// }
//
// public void setDisplayName(final String name) {
// this.displayName = name;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getFullDisplayName() {
// if (displayName != null) {
// return displayName + " (" + ip + ")";
// } else {
// return ip + ":" + vlcPort;
// }
// }
//
// public void setPassword(final String password) {
// this.password = password;
// }
// public String getPassword() {
// return password;
// }
//
// public void setLastPath(String lastPath) { this.lastPath = lastPath; }
// public String getLastPath() { return this.lastPath; }
// }
|
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;
|
COLUMN_VLCPORT + " INTEGER, " +
COLUMN_DISPLAY_NAME + " TEXT, " +
COLUMN_PASS + " TEXT, " +
COLUMN_LAST_USED + " INTEGER, " +
COLUMN_LAST_PATH + " TEXT, " +
"PRIMARY KEY ("+ COLUMN_IP + "," + COLUMN_VLCPORT + ") " +
" )";
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion == 2 && oldVersion == 1) {
db.execSQL("ALTER TABLE " + TABLE_NAME +
" ADD COLUMN " + COLUMN_DISPLAY_NAME + " TEXT");
} else {
Log.e("ServerLocalSettings", "Invalid DB upgrade path. " +
"New version is " + newVersion + ", old is " + oldVersion);
}
}
@Override
protected String getDeleteTableSQL() {
return "DROP TABLE IF EXISTS " + TABLE_NAME;
}
/**
* Remember a server and its settings. Will automatically set the last used flag.
* @param srv Last used server
*/
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
// public final String ip;
// public String displayName;
// private final Integer sshPort;
// public final Integer vlcPort;
// private String password;
// private String lastPath;
//
// public Server(String ip, Integer vlcPort, Integer sshPort) {
// this.ip = ip;
// this.vlcPort = vlcPort;
// this.sshPort = sshPort;
// this.password = "";
// this.displayName = null;
// }
//
// public void setDisplayName(final String name) {
// this.displayName = name;
// }
//
// public String getDisplayName() {
// return displayName;
// }
//
// public String getFullDisplayName() {
// if (displayName != null) {
// return displayName + " (" + ip + ")";
// } else {
// return ip + ":" + vlcPort;
// }
// }
//
// public void setPassword(final String password) {
// this.password = password;
// }
// public String getPassword() {
// return password;
// }
//
// public void setLastPath(String lastPath) { this.lastPath = lastPath; }
// public String getLastPath() { return this.lastPath; }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/local_settings/RememberedServers.java
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;
COLUMN_VLCPORT + " INTEGER, " +
COLUMN_DISPLAY_NAME + " TEXT, " +
COLUMN_PASS + " TEXT, " +
COLUMN_LAST_USED + " INTEGER, " +
COLUMN_LAST_PATH + " TEXT, " +
"PRIMARY KEY ("+ COLUMN_IP + "," + COLUMN_VLCPORT + ") " +
" )";
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion == 2 && oldVersion == 1) {
db.execSQL("ALTER TABLE " + TABLE_NAME +
" ADD COLUMN " + COLUMN_DISPLAY_NAME + " TEXT");
} else {
Log.e("ServerLocalSettings", "Invalid DB upgrade path. " +
"New version is " + newVersion + ", old is " + oldVersion);
}
}
@Override
protected String getDeleteTableSQL() {
return "DROP TABLE IF EXISTS " + TABLE_NAME;
}
/**
* Remember a server and its settings. Will automatically set the last used flag.
* @param srv Last used server
*/
|
public void rememberServer(final Server srv) {
|
nicolasbrailo/VlcFreemote
|
app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/VlcCommand.java
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/http_utils/Wget.java
// public class Wget extends AsyncTask<String, Void, String> {
//
// public interface Callback {
// void onConnectionError(final String message);
// void onResponse(final String result);
// void onAuthFailure();
// void onHttpNotOkResponse();
// }
//
// /**
// * A callback for an observer that's only interested in the task's status and not its result
// */
// public interface CallbackWhenTaskFinished {
// void onTaskFinished();
// }
//
// private static final int CONN_TIMEOUT_MS = 10000;
// private static final int HTTP_RESPONSE_UNAUTHORIZED = 401;
// private static final int HTTP_RESPONSE_OK = 200;
//
// private final String auth;
// private final Callback callback;
// private final CallbackWhenTaskFinished cb2;
// private Exception request_exception;
// private int httpRetCode;
//
// public Wget(final String url, final String auth, Callback callback, CallbackWhenTaskFinished cb2) {
// this.auth = auth;
// this.callback = callback;
// this.cb2 = cb2;
// this.request_exception = null;
// this.execute(url);
// }
//
// private HttpURLConnection getConnection(final String url) throws IOException {
// HttpURLConnection conn = (HttpURLConnection) (new URL(url)).openConnection();
// conn.setReadTimeout(CONN_TIMEOUT_MS);
// conn.setConnectTimeout(CONN_TIMEOUT_MS);
// conn.setRequestMethod("GET");
// conn.setRequestProperty("Authorization", auth);
// conn.setDoInput(true);
// conn.connect();
// return conn;
// }
//
// private String readAll(HttpURLConnection conn) throws IOException {
// InputStream is = null;
//
// try {
// is = conn.getInputStream();
// java.util.Scanner s = new java.util.Scanner(is, "UTF-8").useDelimiter("\\A");
// return s.hasNext() ? s.next() : "";
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // Not much we can do
// }
// }
// }
// }
//
// @Override
// protected String doInBackground(String... urls) {
// try {
// HttpURLConnection conn = getConnection(urls[0]);
// httpRetCode = conn.getResponseCode();
// return readAll(conn);
//
// } catch (IOException e) {
// request_exception = e;
// return null;
// }
// }
//
// @Override
// protected void onPostExecute(String result) {
// // Let an observer know they're free to schedule new tasks
// cb2.onTaskFinished();
//
// if (request_exception != null) {
// callback.onConnectionError(request_exception.getMessage());
// } else if (httpRetCode == HTTP_RESPONSE_UNAUTHORIZED) {
// callback.onAuthFailure();
// } else if (httpRetCode == HTTP_RESPONSE_OK) {
// callback.onResponse(result);
// } else {
// callback.onHttpNotOkResponse();
// }
// }
// }
|
import com.nicolasbrailo.vlcfreemote.vlc_connector.http_utils.Wget;
|
package com.nicolasbrailo.vlcfreemote.vlc_connector;
/**
* Encapsulates a Vlc command.
*/
public interface VlcCommand {
/**
* A callback to invoke on generic failure conditions (ie connection fail, system fail, etc)
* The idea is to write command-specific callbacks on each command implementation and have an
* object with this interface handle generic cases which are not meaningful for any specific
* command (eg there's no meaningful answer from a DirList command to an OOM error)
*/
interface GeneralCallback {
/**
* Invoked when VLC responds to an http request with a 401 status code (unauthorized)
*/
void onAuthError();
/**
* Invoked whenever the connection to a remote vlc server failed for whatever reason.
*/
void onConnectionError(final String msg);
/**
* Invoked when a command couldn't be completed due to a system error (eg failed to
* load a dyn library, error on the sql query to create a schema... stuff that means
* system error or application bug). Usually the reasonable thing to do is log en error
* and crash, or at least disconnect.
* @param e: Found exception (may be null if not applicable)
*/
void onSystemError(Exception e);
}
/**
* Should return a URI for a Vlc http command, with no server. (EG: requests/foo.xml)
* @return URI
*/
String getCommandPath();
/**
* Constructs a callback to handle the output of a Vlc command
* @param generalCallback A callback for events that don't pertain this command.
* @return A callback that wraps the general one and dispatches events as needed
*/
|
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/http_utils/Wget.java
// public class Wget extends AsyncTask<String, Void, String> {
//
// public interface Callback {
// void onConnectionError(final String message);
// void onResponse(final String result);
// void onAuthFailure();
// void onHttpNotOkResponse();
// }
//
// /**
// * A callback for an observer that's only interested in the task's status and not its result
// */
// public interface CallbackWhenTaskFinished {
// void onTaskFinished();
// }
//
// private static final int CONN_TIMEOUT_MS = 10000;
// private static final int HTTP_RESPONSE_UNAUTHORIZED = 401;
// private static final int HTTP_RESPONSE_OK = 200;
//
// private final String auth;
// private final Callback callback;
// private final CallbackWhenTaskFinished cb2;
// private Exception request_exception;
// private int httpRetCode;
//
// public Wget(final String url, final String auth, Callback callback, CallbackWhenTaskFinished cb2) {
// this.auth = auth;
// this.callback = callback;
// this.cb2 = cb2;
// this.request_exception = null;
// this.execute(url);
// }
//
// private HttpURLConnection getConnection(final String url) throws IOException {
// HttpURLConnection conn = (HttpURLConnection) (new URL(url)).openConnection();
// conn.setReadTimeout(CONN_TIMEOUT_MS);
// conn.setConnectTimeout(CONN_TIMEOUT_MS);
// conn.setRequestMethod("GET");
// conn.setRequestProperty("Authorization", auth);
// conn.setDoInput(true);
// conn.connect();
// return conn;
// }
//
// private String readAll(HttpURLConnection conn) throws IOException {
// InputStream is = null;
//
// try {
// is = conn.getInputStream();
// java.util.Scanner s = new java.util.Scanner(is, "UTF-8").useDelimiter("\\A");
// return s.hasNext() ? s.next() : "";
// } finally {
// if (is != null) {
// try {
// is.close();
// } catch (IOException e) {
// // Not much we can do
// }
// }
// }
// }
//
// @Override
// protected String doInBackground(String... urls) {
// try {
// HttpURLConnection conn = getConnection(urls[0]);
// httpRetCode = conn.getResponseCode();
// return readAll(conn);
//
// } catch (IOException e) {
// request_exception = e;
// return null;
// }
// }
//
// @Override
// protected void onPostExecute(String result) {
// // Let an observer know they're free to schedule new tasks
// cb2.onTaskFinished();
//
// if (request_exception != null) {
// callback.onConnectionError(request_exception.getMessage());
// } else if (httpRetCode == HTTP_RESPONSE_UNAUTHORIZED) {
// callback.onAuthFailure();
// } else if (httpRetCode == HTTP_RESPONSE_OK) {
// callback.onResponse(result);
// } else {
// callback.onHttpNotOkResponse();
// }
// }
// }
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/vlc_connector/VlcCommand.java
import com.nicolasbrailo.vlcfreemote.vlc_connector.http_utils.Wget;
package com.nicolasbrailo.vlcfreemote.vlc_connector;
/**
* Encapsulates a Vlc command.
*/
public interface VlcCommand {
/**
* A callback to invoke on generic failure conditions (ie connection fail, system fail, etc)
* The idea is to write command-specific callbacks on each command implementation and have an
* object with this interface handle generic cases which are not meaningful for any specific
* command (eg there's no meaningful answer from a DirList command to an OOM error)
*/
interface GeneralCallback {
/**
* Invoked when VLC responds to an http request with a 401 status code (unauthorized)
*/
void onAuthError();
/**
* Invoked whenever the connection to a remote vlc server failed for whatever reason.
*/
void onConnectionError(final String msg);
/**
* Invoked when a command couldn't be completed due to a system error (eg failed to
* load a dyn library, error on the sql query to create a schema... stuff that means
* system error or application bug). Usually the reasonable thing to do is log en error
* and crash, or at least disconnect.
* @param e: Found exception (may be null if not applicable)
*/
void onSystemError(Exception e);
}
/**
* Should return a URI for a Vlc http command, with no server. (EG: requests/foo.xml)
* @return URI
*/
String getCommandPath();
/**
* Constructs a callback to handle the output of a Vlc command
* @param generalCallback A callback for events that don't pertain this command.
* @return A callback that wraps the general one and dispatches events as needed
*/
|
Wget.Callback getWgetCallback(final GeneralCallback generalCallback);
|
luciofm/ifican
|
app/src/main/java/com/luciofm/ifican/app/ui/TouchFeedbackCodeFragment.java
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
|
import android.os.Bundle;
import android.app.Fragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.util.IOUtils;
import com.luciofm.ifican.app.util.Utils;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
|
package com.luciofm.ifican.app.ui;
/**
* A simple {@link Fragment} subclass.
*
*/
public class TouchFeedbackCodeFragment extends BaseFragment {
@InjectView(R.id.container2)
View container;
@InjectView(R.id.text2)
TextView text2;
@InjectView(R.id.text3)
TextView text3;
@InjectView(R.id.text4)
TextView text4;
private int currentStep;
public TouchFeedbackCodeFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.inject(this, v);
text4.setText(Html.fromHtml(IOUtils.readFile(getActivity(), "source/touch_anim.xml.html")));
currentStep = 1;
return v;
}
@Override
public void onNextPressed() {
switch (++currentStep) {
case 2:
container.setVisibility(View.VISIBLE);
break;
case 3:
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
// Path: app/src/main/java/com/luciofm/ifican/app/ui/TouchFeedbackCodeFragment.java
import android.os.Bundle;
import android.app.Fragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.util.IOUtils;
import com.luciofm.ifican.app.util.Utils;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
package com.luciofm.ifican.app.ui;
/**
* A simple {@link Fragment} subclass.
*
*/
public class TouchFeedbackCodeFragment extends BaseFragment {
@InjectView(R.id.container2)
View container;
@InjectView(R.id.text2)
TextView text2;
@InjectView(R.id.text3)
TextView text3;
@InjectView(R.id.text4)
TextView text4;
private int currentStep;
public TouchFeedbackCodeFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.inject(this, v);
text4.setText(Html.fromHtml(IOUtils.readFile(getActivity(), "source/touch_anim.xml.html")));
currentStep = 1;
return v;
}
@Override
public void onNextPressed() {
switch (++currentStep) {
case 2:
container.setVisibility(View.VISIBLE);
break;
case 3:
|
Utils.dispatchTouch(text2, 300);
|
luciofm/ifican
|
app/src/main/java/com/luciofm/ifican/app/ui/ActivityTransitionsCodeFragment.java
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/ActivityFinishEvent.java
// public class ActivityFinishEvent {
// }
//
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
|
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.IfICan;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.XFractionProperty;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.ActivityFinishEvent;
import com.luciofm.ifican.app.util.Dog;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.util.ViewInfo;
import com.squareup.otto.Subscribe;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
|
switch (++currentStep) {
case 2:
//Utils.dispatchTouch(grid.getChildAt(grid.getChildCount() - 1));
int position = new Random().nextInt(grid.getChildCount());
clickListener.onItemClick(grid, grid.getChildAt(position), position, 0);
break;
case 3:
((MainActivity) getActivity()).nextFragment();
break;
}
}
AdapterView.OnItemClickListener clickListener = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Dog dog = (Dog) view.getTag();
ViewInfo info = new ViewInfo(view, position);
currentView = view;
currentView.animate().alpha(0f).setDuration(50);
currentPosition = position;
Intent intent = new Intent(getActivity(), TransitionActivity.class);
intent.putExtra("DOG", dog);
intent.putExtra("INFO", info);
startActivityForResult(intent, REQUEST_CODE);
getActivity().overridePendingTransition(0, 0);
}
};
@Subscribe
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/ActivityFinishEvent.java
// public class ActivityFinishEvent {
// }
//
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
// Path: app/src/main/java/com/luciofm/ifican/app/ui/ActivityTransitionsCodeFragment.java
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.IfICan;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.XFractionProperty;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.ActivityFinishEvent;
import com.luciofm.ifican.app.util.Dog;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.util.ViewInfo;
import com.squareup.otto.Subscribe;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
switch (++currentStep) {
case 2:
//Utils.dispatchTouch(grid.getChildAt(grid.getChildCount() - 1));
int position = new Random().nextInt(grid.getChildCount());
clickListener.onItemClick(grid, grid.getChildAt(position), position, 0);
break;
case 3:
((MainActivity) getActivity()).nextFragment();
break;
}
}
AdapterView.OnItemClickListener clickListener = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Dog dog = (Dog) view.getTag();
ViewInfo info = new ViewInfo(view, position);
currentView = view;
currentView.animate().alpha(0f).setDuration(50);
currentPosition = position;
Intent intent = new Intent(getActivity(), TransitionActivity.class);
intent.putExtra("DOG", dog);
intent.putExtra("INFO", info);
startActivityForResult(intent, REQUEST_CODE);
getActivity().overridePendingTransition(0, 0);
}
};
@Subscribe
|
public void onActivityFinishedEvent(ActivityFinishEvent event) {
|
luciofm/ifican
|
app/src/main/java/com/luciofm/ifican/app/ui/ActivityTransitionsCodeFragment.java
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/ActivityFinishEvent.java
// public class ActivityFinishEvent {
// }
//
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
|
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.IfICan;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.XFractionProperty;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.ActivityFinishEvent;
import com.luciofm.ifican.app.util.Dog;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.util.ViewInfo;
import com.squareup.otto.Subscribe;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
|
clickListener.onItemClick(grid, grid.getChildAt(position), position, 0);
break;
case 3:
((MainActivity) getActivity()).nextFragment();
break;
}
}
AdapterView.OnItemClickListener clickListener = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Dog dog = (Dog) view.getTag();
ViewInfo info = new ViewInfo(view, position);
currentView = view;
currentView.animate().alpha(0f).setDuration(50);
currentPosition = position;
Intent intent = new Intent(getActivity(), TransitionActivity.class);
intent.putExtra("DOG", dog);
intent.putExtra("INFO", info);
startActivityForResult(intent, REQUEST_CODE);
getActivity().overridePendingTransition(0, 0);
}
};
@Subscribe
public void onActivityFinishedEvent(ActivityFinishEvent event) {
if (currentView != null) {
currentView.setAlpha(0f);
currentView.animate().alpha(1f)
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/ActivityFinishEvent.java
// public class ActivityFinishEvent {
// }
//
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
// Path: app/src/main/java/com/luciofm/ifican/app/ui/ActivityTransitionsCodeFragment.java
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.IfICan;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.XFractionProperty;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.ActivityFinishEvent;
import com.luciofm.ifican.app.util.Dog;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.util.ViewInfo;
import com.squareup.otto.Subscribe;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
clickListener.onItemClick(grid, grid.getChildAt(position), position, 0);
break;
case 3:
((MainActivity) getActivity()).nextFragment();
break;
}
}
AdapterView.OnItemClickListener clickListener = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Dog dog = (Dog) view.getTag();
ViewInfo info = new ViewInfo(view, position);
currentView = view;
currentView.animate().alpha(0f).setDuration(50);
currentPosition = position;
Intent intent = new Intent(getActivity(), TransitionActivity.class);
intent.putExtra("DOG", dog);
intent.putExtra("INFO", info);
startActivityForResult(intent, REQUEST_CODE);
getActivity().overridePendingTransition(0, 0);
}
};
@Subscribe
public void onActivityFinishedEvent(ActivityFinishEvent event) {
if (currentView != null) {
currentView.setAlpha(0f);
currentView.animate().alpha(1f)
|
.setStartDelay(Utils.calcDuration(currentPosition) - 300)
|
luciofm/ifican
|
app/src/main/java/com/luciofm/ifican/app/ui/FeedbackFragment.java
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
|
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.XFractionProperty;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.widget.SquareGridLayout;
import java.io.IOException;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import pl.droidsonroids.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageView;
|
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.inject(this, v);
currentStep = 1;
//text2.setText(Html.fromHtml(IOUtils.readFile(getActivity(), "source/touch_anim.xml.html")));
return v;
}
@Override
public void onNextPressed() {
try {
GifDrawable gifFromResource;
GifImageView gif = new GifImageView(getActivity());
gif.setOnClickListener(clickListener);
ViewGroup.LayoutParams params = new SquareGridLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
getResources().getDimensionPixelSize(R.dimen.grid_heiht));
switch (++currentStep) {
case 2:
container2.setVisibility(View.VISIBLE);
gifFromResource = new GifDrawable(getResources(), R.drawable.feedback1);
gif.setImageDrawable(gifFromResource);
gifFromResource.start();
gif1 = gif;
container2.addView(gif1, 0, params);
break;
case 3:
gif2 = gif;
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
// Path: app/src/main/java/com/luciofm/ifican/app/ui/FeedbackFragment.java
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.XFractionProperty;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.widget.SquareGridLayout;
import java.io.IOException;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import pl.droidsonroids.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageView;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.inject(this, v);
currentStep = 1;
//text2.setText(Html.fromHtml(IOUtils.readFile(getActivity(), "source/touch_anim.xml.html")));
return v;
}
@Override
public void onNextPressed() {
try {
GifDrawable gifFromResource;
GifImageView gif = new GifImageView(getActivity());
gif.setOnClickListener(clickListener);
ViewGroup.LayoutParams params = new SquareGridLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
getResources().getDimensionPixelSize(R.dimen.grid_heiht));
switch (++currentStep) {
case 2:
container2.setVisibility(View.VISIBLE);
gifFromResource = new GifDrawable(getResources(), R.drawable.feedback1);
gif.setImageDrawable(gifFromResource);
gifFromResource.start();
gif1 = gif;
container2.addView(gif1, 0, params);
break;
case 3:
gif2 = gif;
|
Utils.stopGif(gif1);
|
luciofm/ifican
|
app/src/main/java/com/luciofm/ifican/app/ui/TransitionsExampleFragment.java
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
|
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.app.Fragment;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.util.ViewInfo;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import pl.droidsonroids.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageView;
|
public boolean onPreDraw() {
text1.getViewTreeObserver().removeOnPreDrawListener(this);
int[] screenLocation = new int[2];
text1.getLocationOnScreen(screenLocation);
leftDelta = info.left - screenLocation[0];
topDelta = info.top - screenLocation[1];
/* Move text1 to the last screen position */
text1.setTranslationX(leftDelta);
text1.setTranslationY(topDelta);
runEnterAnimation();
/*new Handler().postDelayed(new Runnable() {
@Override
public void run() {
runEnterAnimation();
}
}, 500);*/
return false;
}
});
return v;
}
@Override
public void onNextPressed() {
switch (++currentStep) {
case 2:
gif1.setVisibility(View.VISIBLE);
|
// Path: app/src/main/java/com/luciofm/ifican/app/util/Utils.java
// public class Utils {
//
// private static final int ANIM_DURATION = 800;
//
// private Utils() {
// }
//
// public static void startGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (!drawable.isPlaying()) {
// drawable.reset();
// drawable.start();
// }
// }
//
// public static void stopGif(GifImageView view) {
// GifDrawable drawable = (GifDrawable) view.getDrawable();
// if (drawable.isPlaying())
// drawable.stop();
// }
//
// public static void dispatchTouch(View view) {
// dispatchTouch(view, 200);
// }
//
// public static void dispatchTouch(final View view, final long duration) {
// final long downTime = SystemClock.uptimeMillis();
// final long eventTime = SystemClock.uptimeMillis();
// final float x = 0.0f;
// final float y = 0.0f;
// // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
// final int metaState = 0;
// MotionEvent motionEvent = MotionEvent.obtain(downTime,
// eventTime,
// MotionEvent.ACTION_DOWN,
// x,
// y,
// metaState);
//
// // Dispatch touch event to view
// view.dispatchTouchEvent(motionEvent);
//
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// MotionEvent motionEvent = MotionEvent.obtain(downTime + duration,
// eventTime + duration,
// MotionEvent.ACTION_UP,
// x,
// y,
// metaState);
// view.dispatchTouchEvent(motionEvent);
// }
// }, duration);
// }
//
// public static long calcDuration(int position) {
// int pos = position;
// if (pos >= 4)
// pos -= 4;
// switch (pos) {
// case 1:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.2f));
// case 2:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.3f));
// case 3:
// return (long) (ANIM_DURATION + (ANIM_DURATION * 0.4f));
// default:
// return ANIM_DURATION;
// }
// }
// }
// Path: app/src/main/java/com/luciofm/ifican/app/ui/TransitionsExampleFragment.java
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.app.Fragment;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.luciofm.ifican.app.BaseFragment;
import com.luciofm.ifican.app.R;
import com.luciofm.ifican.app.anim.YFractionProperty;
import com.luciofm.ifican.app.util.Utils;
import com.luciofm.ifican.app.util.ViewInfo;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import pl.droidsonroids.gif.GifDrawable;
import pl.droidsonroids.gif.GifImageView;
public boolean onPreDraw() {
text1.getViewTreeObserver().removeOnPreDrawListener(this);
int[] screenLocation = new int[2];
text1.getLocationOnScreen(screenLocation);
leftDelta = info.left - screenLocation[0];
topDelta = info.top - screenLocation[1];
/* Move text1 to the last screen position */
text1.setTranslationX(leftDelta);
text1.setTranslationY(topDelta);
runEnterAnimation();
/*new Handler().postDelayed(new Runnable() {
@Override
public void run() {
runEnterAnimation();
}
}, 500);*/
return false;
}
});
return v;
}
@Override
public void onNextPressed() {
switch (++currentStep) {
case 2:
gif1.setVisibility(View.VISIBLE);
|
Utils.startGif(gif1);
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/bytecode/ArgumentHolderGenerator.java
|
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
|
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.makeClass;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.makePublicFinal;
import com.lmax.tool.disruptor.Resetable;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtNewConstructor;
import java.util.HashMap;
import java.util.Map;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.addInterface;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.createField;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.createMethod;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.getUniqueIdentifier;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.bytecode;
final class ArgumentHolderGenerator
{
private final ArgumentHolderHelper helper = new ArgumentHolderHelper();
private final ClassPool classPool;
private String generatedClassName;
private Class<?> generatedClass;
private Map<Class<?>, Integer> parameterTypeCounts;
private Map<Class<?>, Character> parameterFieldSuffix = new HashMap<Class<?>, Character>();
public ArgumentHolderGenerator(final ClassPool classPool)
{
this.classPool = classPool;
}
public void createArgumentHolderClass(final Class<?> proxyInterface)
{
final CtClass ctClass = makeClass(classPool, "_argumentHolder_" + proxyInterface.getSimpleName() + "_" + getUniqueIdentifier());
parameterTypeCounts = helper.getParameterTypeCounts(proxyInterface);
createFields(ctClass);
createMethod(ctClass, generateResetMethod());
|
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
// Path: src/main/java/com/lmax/tool/disruptor/bytecode/ArgumentHolderGenerator.java
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.makeClass;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.makePublicFinal;
import com.lmax.tool.disruptor.Resetable;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtNewConstructor;
import java.util.HashMap;
import java.util.Map;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.addInterface;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.createField;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.createMethod;
import static com.lmax.tool.disruptor.bytecode.ByteCodeHelper.getUniqueIdentifier;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.bytecode;
final class ArgumentHolderGenerator
{
private final ArgumentHolderHelper helper = new ArgumentHolderHelper();
private final ClassPool classPool;
private String generatedClassName;
private Class<?> generatedClass;
private Map<Class<?>, Integer> parameterTypeCounts;
private Map<Class<?>, Character> parameterFieldSuffix = new HashMap<Class<?>, Character>();
public ArgumentHolderGenerator(final ClassPool classPool)
{
this.classPool = classPool;
}
public void createArgumentHolderClass(final Class<?> proxyInterface)
{
final CtClass ctClass = makeClass(classPool, "_argumentHolder_" + proxyInterface.getSimpleName() + "_" + getUniqueIdentifier());
parameterTypeCounts = helper.getParameterTypeCounts(proxyInterface);
createFields(ctClass);
createMethod(ctClass, generateResetMethod());
|
addInterface(ctClass, Resetable.class, classPool);
|
LMAX-Exchange/disruptor-proxy
|
src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
// Path: src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
|
final BatchAwareListenerImpl batchAwareListener = new BatchAwareListenerImpl();
|
LMAX-Exchange/disruptor-proxy
|
src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
final BatchAwareListenerImpl batchAwareListener = new BatchAwareListenerImpl();
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
// Path: src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
final BatchAwareListenerImpl batchAwareListener = new BatchAwareListenerImpl();
|
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(batchAwareListener);
|
LMAX-Exchange/disruptor-proxy
|
src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
final BatchAwareListenerImpl batchAwareListener = new BatchAwareListenerImpl();
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
// Path: src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
final BatchAwareListenerImpl batchAwareListener = new BatchAwareListenerImpl();
|
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(batchAwareListener);
|
LMAX-Exchange/disruptor-proxy
|
src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
final BatchAwareListenerImpl batchAwareListener = new BatchAwareListenerImpl();
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(batchAwareListener);
final ProxyMethodInvocation proxyMethodInvocation = new ProxyMethodInvocation();
proxyMethodInvocation.setArgumentHolder(new StubResetable());
proxyMethodInvocation.setInvoker(new NoOpInvoker());
eventHandler.onEvent(proxyMethodInvocation, 17L, true);
assertThat(batchAwareListener.getBatchCount(), is(1));
}
@Test
public void shouldNotNotifyNonBatchListenerOnEndOfBatch() throws Exception
{
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
// Path: src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.handlers;
public final class HandlersTest
{
@Test
public void shouldNotifyBatchListenerOnEndOfBatch() throws Exception
{
final BatchAwareListenerImpl batchAwareListener = new BatchAwareListenerImpl();
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(batchAwareListener);
final ProxyMethodInvocation proxyMethodInvocation = new ProxyMethodInvocation();
proxyMethodInvocation.setArgumentHolder(new StubResetable());
proxyMethodInvocation.setInvoker(new NoOpInvoker());
eventHandler.onEvent(proxyMethodInvocation, 17L, true);
assertThat(batchAwareListener.getBatchCount(), is(1));
}
@Test
public void shouldNotNotifyNonBatchListenerOnEndOfBatch() throws Exception
{
|
final ListenerImpl nonBatchAwareListener = new ListenerImpl();
|
LMAX-Exchange/disruptor-proxy
|
src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
|
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(batchAwareListener);
final ProxyMethodInvocation proxyMethodInvocation = new ProxyMethodInvocation();
proxyMethodInvocation.setArgumentHolder(new StubResetable());
proxyMethodInvocation.setInvoker(new NoOpInvoker());
eventHandler.onEvent(proxyMethodInvocation, 17L, true);
assertThat(batchAwareListener.getBatchCount(), is(1));
}
@Test
public void shouldNotNotifyNonBatchListenerOnEndOfBatch() throws Exception
{
final ListenerImpl nonBatchAwareListener = new ListenerImpl();
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(nonBatchAwareListener);
final ProxyMethodInvocation proxyMethodInvocation = new ProxyMethodInvocation();
proxyMethodInvocation.setArgumentHolder(new StubResetable());
proxyMethodInvocation.setInvoker(new NoOpInvoker());
eventHandler.onEvent(proxyMethodInvocation, 17L, true);
}
private static class NoOpInvoker implements Invoker
{
@Override
public void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder)
{
}
}
|
// Path: src/test/java/com/lmax/tool/disruptor/BatchAwareListenerImpl.java
// public final class BatchAwareListenerImpl implements Listener, BatchListener
// {
// private volatile int batchCount = 0;
//
// @Override
// public void onString(final String value)
// {
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// }
//
// @Override
// public void onVoid()
// {
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// }
//
// public int getBatchCount()
// {
// return batchCount;
// }
//
// @Override
// public void onEndOfBatch()
// {
// batchCount++;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/test/java/com/lmax/tool/disruptor/ListenerImpl.java
// public final class ListenerImpl implements Listener
// {
// private volatile String lastStringValue;
// private volatile int lastIntValue;
// private volatile Float lastFloatValue;
// private volatile int voidInvocationCount;
// private volatile Double[] lastDoubleArray;
// private int mixedArgsInvocationCount;
//
// @Override
// public void onString(final String value)
// {
// lastStringValue = value;
// }
//
// @Override
// public void onFloatAndInt(final Float floatValue, final int intValue)
// {
// lastFloatValue = floatValue;
// lastIntValue = intValue;
// }
//
// @Override
// public void onVoid()
// {
// voidInvocationCount++;
// }
//
// @Override
// public void onObjectArray(final Double[] value)
// {
// lastDoubleArray = value;
// }
//
// @Override
// public void onMixedMultipleArgs(final int int0, final int int1, final String s0, final String s1, final int i2)
// {
// mixedArgsInvocationCount++;
// }
//
// public String getLastStringValue()
// {
// return lastStringValue;
// }
//
// public int getLastIntValue()
// {
// return lastIntValue;
// }
//
// public Float getLastFloatValue()
// {
// return lastFloatValue;
// }
//
// public int getVoidInvocationCount()
// {
// return voidInvocationCount;
// }
//
// public Double[] getLastDoubleArray()
// {
// return lastDoubleArray;
// }
//
// public int getMixedArgsInvocationCount()
// {
// return mixedArgsInvocationCount;
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Resetable.java
// public interface Resetable
// {
// /**
// * Reset this component
// */
// void reset();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
// public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
// {
// return createHandlers(implementation, true);
// }
// Path: src/test/java/com/lmax/tool/disruptor/handlers/HandlersTest.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchAwareListenerImpl;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.ListenerImpl;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import com.lmax.tool.disruptor.Resetable;
import org.junit.Test;
import static com.lmax.tool.disruptor.handlers.Handlers.createSingleImplementationHandlerChain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(batchAwareListener);
final ProxyMethodInvocation proxyMethodInvocation = new ProxyMethodInvocation();
proxyMethodInvocation.setArgumentHolder(new StubResetable());
proxyMethodInvocation.setInvoker(new NoOpInvoker());
eventHandler.onEvent(proxyMethodInvocation, 17L, true);
assertThat(batchAwareListener.getBatchCount(), is(1));
}
@Test
public void shouldNotNotifyNonBatchListenerOnEndOfBatch() throws Exception
{
final ListenerImpl nonBatchAwareListener = new ListenerImpl();
final EventHandler<ProxyMethodInvocation> eventHandler = createSingleImplementationHandlerChain(nonBatchAwareListener);
final ProxyMethodInvocation proxyMethodInvocation = new ProxyMethodInvocation();
proxyMethodInvocation.setArgumentHolder(new StubResetable());
proxyMethodInvocation.setInvoker(new NoOpInvoker());
eventHandler.onEvent(proxyMethodInvocation, 17L, true);
}
private static class NoOpInvoker implements Invoker
{
@Override
public void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder)
{
}
}
|
private static final class StubResetable implements Resetable
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
|
package com.lmax.tool.disruptor.handlers;
public class Handlers
{
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
package com.lmax.tool.disruptor.handlers;
public class Handlers
{
|
public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
|
package com.lmax.tool.disruptor.handlers;
public class Handlers
{
public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, true);
}
public static <T> EventHandler<ProxyMethodInvocation> createMultipleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, false);
}
private static <T> EventHandler<ProxyMethodInvocation> createHandlers(final T implementation, final boolean reset)
{
EventHandler<ProxyMethodInvocation> handler = new InvokerEventHandler<T>(implementation, reset);
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
package com.lmax.tool.disruptor.handlers;
public class Handlers
{
public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, true);
}
public static <T> EventHandler<ProxyMethodInvocation> createMultipleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, false);
}
private static <T> EventHandler<ProxyMethodInvocation> createHandlers(final T implementation, final boolean reset)
{
EventHandler<ProxyMethodInvocation> handler = new InvokerEventHandler<T>(implementation, reset);
|
if (implementation instanceof BatchListener)
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
|
package com.lmax.tool.disruptor.handlers;
public class Handlers
{
public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, true);
}
public static <T> EventHandler<ProxyMethodInvocation> createMultipleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, false);
}
private static <T> EventHandler<ProxyMethodInvocation> createHandlers(final T implementation, final boolean reset)
{
EventHandler<ProxyMethodInvocation> handler = new InvokerEventHandler<T>(implementation, reset);
if (implementation instanceof BatchListener)
{
handler = new EndOfBatchEventHandler((BatchListener) implementation, handler);
}
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/handlers/Handlers.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
package com.lmax.tool.disruptor.handlers;
public class Handlers
{
public static <T> EventHandler<ProxyMethodInvocation> createSingleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, true);
}
public static <T> EventHandler<ProxyMethodInvocation> createMultipleImplementationHandlerChain(final T implementation)
{
return createHandlers(implementation, false);
}
private static <T> EventHandler<ProxyMethodInvocation> createHandlers(final T implementation, final boolean reset)
{
EventHandler<ProxyMethodInvocation> handler = new InvokerEventHandler<T>(implementation, reset);
if (implementation instanceof BatchListener)
{
handler = new EndOfBatchEventHandler((BatchListener) implementation, handler);
}
|
if (implementation instanceof BatchSizeListener)
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/handlers/BatchSizeReportingEventHandler.java
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
|
package com.lmax.tool.disruptor.handlers;
class BatchSizeReportingEventHandler implements EventHandler<ProxyMethodInvocation>
{
private final EventHandler<ProxyMethodInvocation> delegate;
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchSizeListener.java
// public interface BatchSizeListener
// {
//
// /**
// * Will be called at the end of a Disruptor batch
// * @param batchSize The size of the batch
// */
// void onEndOfBatch(int batchSize);
//
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/handlers/BatchSizeReportingEventHandler.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchSizeListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
package com.lmax.tool.disruptor.handlers;
class BatchSizeReportingEventHandler implements EventHandler<ProxyMethodInvocation>
{
private final EventHandler<ProxyMethodInvocation> delegate;
|
private final BatchSizeListener batchSizeListener;
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
|
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
|
private final Map<Method, Invoker> methodToInvokerMap;
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
private final Map<Method, Invoker> methodToInvokerMap;
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
private final Map<Method, Invoker> methodToInvokerMap;
|
private final OverflowStrategy overflowStrategy;
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
private final Map<Method, Invoker> methodToInvokerMap;
private final OverflowStrategy overflowStrategy;
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
private final Map<Method, Invoker> methodToInvokerMap;
private final OverflowStrategy overflowStrategy;
|
private final DropListener dropListener;
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
|
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
private final Map<Method, Invoker> methodToInvokerMap;
private final OverflowStrategy overflowStrategy;
private final DropListener dropListener;
|
// Path: src/main/java/com/lmax/tool/disruptor/DropListener.java
// public interface DropListener
// {
// void onDrop();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/Invoker.java
// public interface Invoker
// {
// void invokeWithArgumentHolder(final Object implementation, final Object argumentHolder);
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/MessagePublicationListener.java
// public interface MessagePublicationListener
// {
// /**
// * Called before message is published to the ringbuffer
// */
// void onPrePublish();
//
// /**
// * Called after message is published to the ringbuffer. Will not be called if using DROP overflow strategy
// * and message is dropped.
// */
// void onPostPublish();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/OverflowStrategy.java
// public enum OverflowStrategy
// {
// /**
// * Block the publishing Thread
// */
// BLOCK,
// /**
// * Discard the message and continue
// */
// DROP
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/reflect/ReflectiveRingBufferInvocationHandler.java
import com.lmax.disruptor.RingBuffer;
import com.lmax.tool.disruptor.DropListener;
import com.lmax.tool.disruptor.Invoker;
import com.lmax.tool.disruptor.MessagePublicationListener;
import com.lmax.tool.disruptor.OverflowStrategy;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;
/*
* Copyright 2015-2016 LMAX Ltd.
*
* 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.lmax.tool.disruptor.reflect;
final class ReflectiveRingBufferInvocationHandler implements InvocationHandler
{
private static final String TO_STRING_METHOD_NAME = "toString";
private final RingBuffer<ProxyMethodInvocation> ringBuffer;
private final Map<Method, Invoker> methodToInvokerMap;
private final OverflowStrategy overflowStrategy;
private final DropListener dropListener;
|
private final MessagePublicationListener messagePublicationListener;
|
LMAX-Exchange/disruptor-proxy
|
src/main/java/com/lmax/tool/disruptor/handlers/EndOfBatchEventHandler.java
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
|
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
|
package com.lmax.tool.disruptor.handlers;
/**
* A Disruptor event handler that will notify the supplied batchListener at the end of a batch
*/
final class EndOfBatchEventHandler implements EventHandler<ProxyMethodInvocation>
{
|
// Path: src/main/java/com/lmax/tool/disruptor/BatchListener.java
// public interface BatchListener
// {
// /**
// * Will be called at the end of a Disruptor batch
// */
// void onEndOfBatch();
// }
//
// Path: src/main/java/com/lmax/tool/disruptor/ProxyMethodInvocation.java
// public final class ProxyMethodInvocation
// {
// private Invoker invoker;
// private Resetable argumentHolder;
//
// public Invoker getInvoker()
// {
// return invoker;
// }
//
// public void setInvoker(final Invoker invoker)
// {
// this.invoker = invoker;
// }
//
// public void setArgumentHolder(final Resetable argumentHolder)
// {
// this.argumentHolder = argumentHolder;
// }
//
// public Object getArgumentHolder()
// {
// return argumentHolder;
// }
//
// public void reset()
// {
// argumentHolder.reset();
// }
// }
// Path: src/main/java/com/lmax/tool/disruptor/handlers/EndOfBatchEventHandler.java
import com.lmax.disruptor.EventHandler;
import com.lmax.tool.disruptor.BatchListener;
import com.lmax.tool.disruptor.ProxyMethodInvocation;
package com.lmax.tool.disruptor.handlers;
/**
* A Disruptor event handler that will notify the supplied batchListener at the end of a batch
*/
final class EndOfBatchEventHandler implements EventHandler<ProxyMethodInvocation>
{
|
private final BatchListener batchListener;
|
kennylbj/concurrent-java
|
src/main/java/producerconsumer/semaphore/SemaphoreConsumer.java
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Consumer.java
// public interface Consumer<E> {
// //consume a element of type E
// void consume(E e);
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
|
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Consumer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.Semaphore;
|
package producerconsumer.semaphore;
/**
* Created by kennylbj on 16/9/10.
* Consumer implemented by Semaphore
*/
public class SemaphoreConsumer implements Consumer<Item>, Runnable {
@GuardedBy("buffer")
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Consumer.java
// public interface Consumer<E> {
// //consume a element of type E
// void consume(E e);
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
// Path: src/main/java/producerconsumer/semaphore/SemaphoreConsumer.java
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Consumer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.Semaphore;
package producerconsumer.semaphore;
/**
* Created by kennylbj on 16/9/10.
* Consumer implemented by Semaphore
*/
public class SemaphoreConsumer implements Consumer<Item>, Runnable {
@GuardedBy("buffer")
|
private final Buffer<Item> buffer;
|
kennylbj/concurrent-java
|
src/main/java/guava/cache/Cache.java
|
// Path: src/main/java/guava/cache/resource/Resource.java
// public interface Resource {
//
// // compute a resource from a given key
// // the computation could be time consuming
// Resource compute(String key);
//
// // release the related resource it hold on
// void release();
//
// // check whether this resource is valid
// boolean isValid();
//
// // memory usage this resource occupied
// int memoryUsage();
// }
//
// Path: src/main/java/guava/cache/resource/ResourceBuilder.java
// public class ResourceBuilder {
// // build a resource by the given key
// public static Resource build(String key) {
// return new ResourceImpl().compute(key);
// }
//
// }
|
import com.google.common.cache.*;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
import guava.cache.resource.Resource;
import guava.cache.resource.ResourceBuilder;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
|
package guava.cache;
public class Cache {
private static final ExecutorService executor = Executors.newFixedThreadPool(4);
public static void main(String[] args) {
|
// Path: src/main/java/guava/cache/resource/Resource.java
// public interface Resource {
//
// // compute a resource from a given key
// // the computation could be time consuming
// Resource compute(String key);
//
// // release the related resource it hold on
// void release();
//
// // check whether this resource is valid
// boolean isValid();
//
// // memory usage this resource occupied
// int memoryUsage();
// }
//
// Path: src/main/java/guava/cache/resource/ResourceBuilder.java
// public class ResourceBuilder {
// // build a resource by the given key
// public static Resource build(String key) {
// return new ResourceImpl().compute(key);
// }
//
// }
// Path: src/main/java/guava/cache/Cache.java
import com.google.common.cache.*;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
import guava.cache.resource.Resource;
import guava.cache.resource.ResourceBuilder;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
package guava.cache;
public class Cache {
private static final ExecutorService executor = Executors.newFixedThreadPool(4);
public static void main(String[] args) {
|
LoadingCache<String, Resource> resources = CacheBuilder.newBuilder()
|
kennylbj/concurrent-java
|
src/main/java/guava/cache/Cache.java
|
// Path: src/main/java/guava/cache/resource/Resource.java
// public interface Resource {
//
// // compute a resource from a given key
// // the computation could be time consuming
// Resource compute(String key);
//
// // release the related resource it hold on
// void release();
//
// // check whether this resource is valid
// boolean isValid();
//
// // memory usage this resource occupied
// int memoryUsage();
// }
//
// Path: src/main/java/guava/cache/resource/ResourceBuilder.java
// public class ResourceBuilder {
// // build a resource by the given key
// public static Resource build(String key) {
// return new ResourceImpl().compute(key);
// }
//
// }
|
import com.google.common.cache.*;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
import guava.cache.resource.Resource;
import guava.cache.resource.ResourceBuilder;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
|
package guava.cache;
public class Cache {
private static final ExecutorService executor = Executors.newFixedThreadPool(4);
public static void main(String[] args) {
LoadingCache<String, Resource> resources = CacheBuilder.newBuilder()
// max memory size
.maximumWeight(1000)
// memory usage each item occupy
.weigher((Weigher<String, Resource>) (key, value) -> value.memoryUsage())
// evict the cache once the given duration have elapsed
.expireAfterWrite(2, TimeUnit.MINUTES)
// mark the cache refreshable once the given duration have elapsed
// The old value (if any) is still returned while the key is being refreshed,
// in contrast to eviction, which forces retrievals to wait until the value is loaded anew.
.refreshAfterWrite(1, TimeUnit.MINUTES)
// invoke the operation once cache is removed
.removalListener(notification -> {
Resource resource = notification.getValue();
resource.release();
})
.build(new CacheLoader<String, Resource>() {
// build the cache for the given key
@Override
public Resource load(String key) {
|
// Path: src/main/java/guava/cache/resource/Resource.java
// public interface Resource {
//
// // compute a resource from a given key
// // the computation could be time consuming
// Resource compute(String key);
//
// // release the related resource it hold on
// void release();
//
// // check whether this resource is valid
// boolean isValid();
//
// // memory usage this resource occupied
// int memoryUsage();
// }
//
// Path: src/main/java/guava/cache/resource/ResourceBuilder.java
// public class ResourceBuilder {
// // build a resource by the given key
// public static Resource build(String key) {
// return new ResourceImpl().compute(key);
// }
//
// }
// Path: src/main/java/guava/cache/Cache.java
import com.google.common.cache.*;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
import guava.cache.resource.Resource;
import guava.cache.resource.ResourceBuilder;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
package guava.cache;
public class Cache {
private static final ExecutorService executor = Executors.newFixedThreadPool(4);
public static void main(String[] args) {
LoadingCache<String, Resource> resources = CacheBuilder.newBuilder()
// max memory size
.maximumWeight(1000)
// memory usage each item occupy
.weigher((Weigher<String, Resource>) (key, value) -> value.memoryUsage())
// evict the cache once the given duration have elapsed
.expireAfterWrite(2, TimeUnit.MINUTES)
// mark the cache refreshable once the given duration have elapsed
// The old value (if any) is still returned while the key is being refreshed,
// in contrast to eviction, which forces retrievals to wait until the value is loaded anew.
.refreshAfterWrite(1, TimeUnit.MINUTES)
// invoke the operation once cache is removed
.removalListener(notification -> {
Resource resource = notification.getValue();
resource.release();
})
.build(new CacheLoader<String, Resource>() {
// build the cache for the given key
@Override
public Resource load(String key) {
|
return ResourceBuilder.build(key);
|
kennylbj/concurrent-java
|
src/main/java/producerconsumer/condition/ConditionProducer.java
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Producer.java
// public interface Producer<E> {
// //produce a element of type E
// E produce();
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
|
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Producer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
|
package producerconsumer.condition;
/**
* Created by kennylbj on 16/9/10.
* Producer implemented by Condition.
* Using monitors makes race conditions much less likely than when using semaphores.
*/
public class ConditionProducer implements Producer<Item>, Runnable {
@GuardedBy("lock")
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Producer.java
// public interface Producer<E> {
// //produce a element of type E
// E produce();
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
// Path: src/main/java/producerconsumer/condition/ConditionProducer.java
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Producer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
package producerconsumer.condition;
/**
* Created by kennylbj on 16/9/10.
* Producer implemented by Condition.
* Using monitors makes race conditions much less likely than when using semaphores.
*/
public class ConditionProducer implements Producer<Item>, Runnable {
@GuardedBy("lock")
|
private final Buffer<Item> buffer;
|
kennylbj/concurrent-java
|
src/main/java/producerconsumer/semaphore/SemaphoreProducer.java
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Producer.java
// public interface Producer<E> {
// //produce a element of type E
// E produce();
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
|
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Producer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.Semaphore;
|
package producerconsumer.semaphore;
/**
* Created by kennylbj on 16/9/10.
* Producer implemented by Semaphore.
*/
public class SemaphoreProducer implements Producer<Item>, Runnable {
@GuardedBy("buffer")
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Producer.java
// public interface Producer<E> {
// //produce a element of type E
// E produce();
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
// Path: src/main/java/producerconsumer/semaphore/SemaphoreProducer.java
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Producer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.Semaphore;
package producerconsumer.semaphore;
/**
* Created by kennylbj on 16/9/10.
* Producer implemented by Semaphore.
*/
public class SemaphoreProducer implements Producer<Item>, Runnable {
@GuardedBy("buffer")
|
private final Buffer<Item> buffer;
|
kennylbj/concurrent-java
|
src/main/java/producerconsumer/condition/ConditionConsumer.java
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Consumer.java
// public interface Consumer<E> {
// //consume a element of type E
// void consume(E e);
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
|
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Consumer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
|
package producerconsumer.condition;
/**
* Created by kennylbj on 16/9/10.
* Consumer implemented by Condition
*/
public class ConditionConsumer implements Consumer<Item>, Runnable {
@GuardedBy("lock")
|
// Path: src/main/java/producerconsumer/Buffer.java
// public abstract class Buffer<E> {
//
// public abstract void putItem(E e);
//
// public abstract E popItem();
//
// public abstract int getSize();
//
// public abstract int getCapacity();
// }
//
// Path: src/main/java/producerconsumer/Consumer.java
// public interface Consumer<E> {
// //consume a element of type E
// void consume(E e);
// }
//
// Path: src/main/java/producerconsumer/Item.java
// @ThreadSafe
// public final class Item {
// private final String itemId;
// private final String itemName;
// private static final Random random = new Random(System.nanoTime());
// private static final String ITEM_NAME[] = {
// "apple",
// "banana",
// "tomato",
// "watermelon"
// };
//
// private Item(String itemId, String itemName) {
// this.itemId = itemId;
// this.itemName = itemName;
// }
//
// public static Item generate() {
// String uuid = UUID.randomUUID().toString();
// String name = ITEM_NAME[random.nextInt(ITEM_NAME.length)];
// return new Item(uuid, name);
// }
//
// @Override
// public String toString() {
// return MoreObjects.toStringHelper(this)
// .add("itemId", itemId)
// .add("itemName", itemName)
// .toString();
// }
//
// }
// Path: src/main/java/producerconsumer/condition/ConditionConsumer.java
import net.jcip.annotations.GuardedBy;
import producerconsumer.Buffer;
import producerconsumer.Consumer;
import producerconsumer.Item;
import java.util.Random;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
package producerconsumer.condition;
/**
* Created by kennylbj on 16/9/10.
* Consumer implemented by Condition
*/
public class ConditionConsumer implements Consumer<Item>, Runnable {
@GuardedBy("lock")
|
private final Buffer<Item> buffer;
|
bigchange/AI
|
src/main/java/com/bigchange/concurrent/blockingqueue/main/Test.java
|
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/consumer/Consumer.java
// public class Consumer implements Runnable {
// BlockingQueue<String> queue;
// public Consumer(BlockingQueue<String> queue){
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
// System.out.println(Thread.currentThread().getName());
// String temp = queue.take(); //如果队列为空,会阻塞当前线程
// System.out.println(temp);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/producer/Producer.java
// public class Producer implements Runnable {
// BlockingQueue<String> queue;
// public Producer(BlockingQueue<String> queue) {
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
//
// System.out.println("I have made a product:"
// + Thread.currentThread().getName());
// String temp = "A Product, 生产线程:"
// + Thread.currentThread().getName();
// queue.put(temp);//如果队列是满的话,会阻塞当前线程
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
|
import com.bigchange.concurrent.blockingqueue.consumer.Consumer;
import com.bigchange.concurrent.blockingqueue.producer.Producer;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
|
package com.bigchange.concurrent.blockingqueue.main;
public class Test {
public static void main(String[] args) throws Exception {
BlockingQueue<String> queue = new LinkedBlockingQueue<String>(2);
// BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
// 不设置的话,LinkedBlockingQueue默认大小为Integer.MAX_VALUE
// BlockingQueue<String> queue = new ArrayBlockingQueue<String>(2);
|
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/consumer/Consumer.java
// public class Consumer implements Runnable {
// BlockingQueue<String> queue;
// public Consumer(BlockingQueue<String> queue){
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
// System.out.println(Thread.currentThread().getName());
// String temp = queue.take(); //如果队列为空,会阻塞当前线程
// System.out.println(temp);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/producer/Producer.java
// public class Producer implements Runnable {
// BlockingQueue<String> queue;
// public Producer(BlockingQueue<String> queue) {
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
//
// System.out.println("I have made a product:"
// + Thread.currentThread().getName());
// String temp = "A Product, 生产线程:"
// + Thread.currentThread().getName();
// queue.put(temp);//如果队列是满的话,会阻塞当前线程
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/main/Test.java
import com.bigchange.concurrent.blockingqueue.consumer.Consumer;
import com.bigchange.concurrent.blockingqueue.producer.Producer;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
package com.bigchange.concurrent.blockingqueue.main;
public class Test {
public static void main(String[] args) throws Exception {
BlockingQueue<String> queue = new LinkedBlockingQueue<String>(2);
// BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
// 不设置的话,LinkedBlockingQueue默认大小为Integer.MAX_VALUE
// BlockingQueue<String> queue = new ArrayBlockingQueue<String>(2);
|
Consumer consumer = new Consumer(queue);
|
bigchange/AI
|
src/main/java/com/bigchange/concurrent/blockingqueue/main/Test.java
|
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/consumer/Consumer.java
// public class Consumer implements Runnable {
// BlockingQueue<String> queue;
// public Consumer(BlockingQueue<String> queue){
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
// System.out.println(Thread.currentThread().getName());
// String temp = queue.take(); //如果队列为空,会阻塞当前线程
// System.out.println(temp);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/producer/Producer.java
// public class Producer implements Runnable {
// BlockingQueue<String> queue;
// public Producer(BlockingQueue<String> queue) {
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
//
// System.out.println("I have made a product:"
// + Thread.currentThread().getName());
// String temp = "A Product, 生产线程:"
// + Thread.currentThread().getName();
// queue.put(temp);//如果队列是满的话,会阻塞当前线程
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
|
import com.bigchange.concurrent.blockingqueue.consumer.Consumer;
import com.bigchange.concurrent.blockingqueue.producer.Producer;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
|
package com.bigchange.concurrent.blockingqueue.main;
public class Test {
public static void main(String[] args) throws Exception {
BlockingQueue<String> queue = new LinkedBlockingQueue<String>(2);
// BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
// 不设置的话,LinkedBlockingQueue默认大小为Integer.MAX_VALUE
// BlockingQueue<String> queue = new ArrayBlockingQueue<String>(2);
Consumer consumer = new Consumer(queue);
|
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/consumer/Consumer.java
// public class Consumer implements Runnable {
// BlockingQueue<String> queue;
// public Consumer(BlockingQueue<String> queue){
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
// System.out.println(Thread.currentThread().getName());
// String temp = queue.take(); //如果队列为空,会阻塞当前线程
// System.out.println(temp);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/producer/Producer.java
// public class Producer implements Runnable {
// BlockingQueue<String> queue;
// public Producer(BlockingQueue<String> queue) {
// this.queue = queue;
// }
// @Override
// public void run() {
// try {
//
// System.out.println("I have made a product:"
// + Thread.currentThread().getName());
// String temp = "A Product, 生产线程:"
// + Thread.currentThread().getName();
// queue.put(temp);//如果队列是满的话,会阻塞当前线程
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
// }
// Path: src/main/java/com/bigchange/concurrent/blockingqueue/main/Test.java
import com.bigchange.concurrent.blockingqueue.consumer.Consumer;
import com.bigchange.concurrent.blockingqueue.producer.Producer;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
package com.bigchange.concurrent.blockingqueue.main;
public class Test {
public static void main(String[] args) throws Exception {
BlockingQueue<String> queue = new LinkedBlockingQueue<String>(2);
// BlockingQueue<String> queue = new LinkedBlockingQueue<String>();
// 不设置的话,LinkedBlockingQueue默认大小为Integer.MAX_VALUE
// BlockingQueue<String> queue = new ArrayBlockingQueue<String>(2);
Consumer consumer = new Consumer(queue);
|
Producer producer = new Producer(queue);
|
ThunderGemios10/Survival-Games
|
src/main/java/com/thundergemios10/survivalgames/hooks/EconHook.java
|
// Path: src/main/java/com/thundergemios10/survivalgames/util/EconomyManager.java
// public class EconomyManager {
//
// private static EconomyManager instance = new EconomyManager();
// private Economy economy;
// private boolean enabled = false;
// private EconomyManager(){
//
// }
//
// public static EconomyManager getInstance(){
// return instance;
// }
//
// public void setup(){
// enabled = setupEconomy();
//
//
// }
//
//
// private boolean setupEconomy()
// {
// RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
// if (economyProvider != null) {
// economy = economyProvider.getProvider();
// }
//
// return (economy != null);
// }
//
// public Economy getEcon(){
// return economy;
// }
//
// public boolean econPresent(){
// return enabled;
// }
//
// }
|
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.thundergemios10.survivalgames.util.EconomyManager;
|
package com.thundergemios10.survivalgames.hooks;
/**
*
*
* something wrote by pogo.
*
*/
public class EconHook implements HookBase {
public void executehook(String player, String[] s2) {
|
// Path: src/main/java/com/thundergemios10/survivalgames/util/EconomyManager.java
// public class EconomyManager {
//
// private static EconomyManager instance = new EconomyManager();
// private Economy economy;
// private boolean enabled = false;
// private EconomyManager(){
//
// }
//
// public static EconomyManager getInstance(){
// return instance;
// }
//
// public void setup(){
// enabled = setupEconomy();
//
//
// }
//
//
// private boolean setupEconomy()
// {
// RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
// if (economyProvider != null) {
// economy = economyProvider.getProvider();
// }
//
// return (economy != null);
// }
//
// public Economy getEcon(){
// return economy;
// }
//
// public boolean econPresent(){
// return enabled;
// }
//
// }
// Path: src/main/java/com/thundergemios10/survivalgames/hooks/EconHook.java
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.thundergemios10.survivalgames.util.EconomyManager;
package com.thundergemios10.survivalgames.hooks;
/**
*
*
* something wrote by pogo.
*
*/
public class EconHook implements HookBase {
public void executehook(String player, String[] s2) {
|
if(EconomyManager.getInstance().econPresent()){
|
ThunderGemios10/Survival-Games
|
src/main/java/com/thundergemios10/survivalgames/MessageManager.java
|
// Path: src/main/java/com/thundergemios10/survivalgames/util/MessageUtil.java
// public class MessageUtil {
//
// private static HashMap<String, String>varcache = new HashMap<String, String>();
//
//
// public static String replaceColors(String s){
// if(s == null){
// return null;
// }
// return s.replaceAll("(&([a-fk-or0-9]))", "\u00A7$2");
// }
//
// public static String replaceVars(String msg, HashMap<String, String>vars){
// boolean error = false;
// for(String s:vars.keySet()){
// try{
// msg.replace("{$"+s+"}", vars.get(s));
// }catch(Exception e){
// SurvivalGames.$(Level.WARNING, "Failed to replace string vars. Error on "+s);
// error = true;
// }
// }
// if(error){
// SurvivalGames.$(Level.SEVERE, "Error replacing vars in message: "+msg);
// SurvivalGames.$(Level.SEVERE, "Vars: "+vars.toString());
// SurvivalGames.$(Level.SEVERE, "Vars Cache: "+varcache.toString());
// }
// return msg;
// }
//
// public static String replaceVars(String msg, String[] vars){
// for(String str: vars){
// String[] s = str.split("-");
// varcache.put(s[0], s[1]);
// }
// boolean error = false;
// for(String str: varcache.keySet()){
// try{
// msg = msg.replace("{$"+str+"}", varcache.get(str));
// }catch(Exception e){
// SurvivalGames.$(Level.WARNING,"Failed to replace string vars. Error on "+str);
// error = true;
// }
// }
// if(error){
// SurvivalGames.$(Level.SEVERE, "Error replacing vars in message: "+msg);
// SurvivalGames.$(Level.SEVERE, "Vars: "+Arrays.toString(vars));
// SurvivalGames.$(Level.SEVERE, "Vars Cache: "+varcache.toString());
// }
//
// return msg;
// }
// }
|
import java.util.HashMap;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import com.thundergemios10.survivalgames.util.MessageUtil;
|
package com.thundergemios10.survivalgames;
public class MessageManager {
public static MessageManager instance = new MessageManager();
public String pre = ChatColor.BLUE + "" + ChatColor.BOLD + "[" + ChatColor.GOLD + "" + ChatColor.BOLD + "SG" + ChatColor.BLUE + "" + ChatColor.BOLD + "] " + ChatColor.RESET;
private HashMap<PrefixType, String>prefix = new HashMap<PrefixType, String>();
public enum PrefixType {
MAIN, INFO, WARNING, ERROR;
}
public static MessageManager getInstance() {
return instance;
}
public void setup() {
FileConfiguration f = SettingsManager.getInstance().getMessageConfig();
|
// Path: src/main/java/com/thundergemios10/survivalgames/util/MessageUtil.java
// public class MessageUtil {
//
// private static HashMap<String, String>varcache = new HashMap<String, String>();
//
//
// public static String replaceColors(String s){
// if(s == null){
// return null;
// }
// return s.replaceAll("(&([a-fk-or0-9]))", "\u00A7$2");
// }
//
// public static String replaceVars(String msg, HashMap<String, String>vars){
// boolean error = false;
// for(String s:vars.keySet()){
// try{
// msg.replace("{$"+s+"}", vars.get(s));
// }catch(Exception e){
// SurvivalGames.$(Level.WARNING, "Failed to replace string vars. Error on "+s);
// error = true;
// }
// }
// if(error){
// SurvivalGames.$(Level.SEVERE, "Error replacing vars in message: "+msg);
// SurvivalGames.$(Level.SEVERE, "Vars: "+vars.toString());
// SurvivalGames.$(Level.SEVERE, "Vars Cache: "+varcache.toString());
// }
// return msg;
// }
//
// public static String replaceVars(String msg, String[] vars){
// for(String str: vars){
// String[] s = str.split("-");
// varcache.put(s[0], s[1]);
// }
// boolean error = false;
// for(String str: varcache.keySet()){
// try{
// msg = msg.replace("{$"+str+"}", varcache.get(str));
// }catch(Exception e){
// SurvivalGames.$(Level.WARNING,"Failed to replace string vars. Error on "+str);
// error = true;
// }
// }
// if(error){
// SurvivalGames.$(Level.SEVERE, "Error replacing vars in message: "+msg);
// SurvivalGames.$(Level.SEVERE, "Vars: "+Arrays.toString(vars));
// SurvivalGames.$(Level.SEVERE, "Vars Cache: "+varcache.toString());
// }
//
// return msg;
// }
// }
// Path: src/main/java/com/thundergemios10/survivalgames/MessageManager.java
import java.util.HashMap;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import com.thundergemios10.survivalgames.util.MessageUtil;
package com.thundergemios10.survivalgames;
public class MessageManager {
public static MessageManager instance = new MessageManager();
public String pre = ChatColor.BLUE + "" + ChatColor.BOLD + "[" + ChatColor.GOLD + "" + ChatColor.BOLD + "SG" + ChatColor.BLUE + "" + ChatColor.BOLD + "] " + ChatColor.RESET;
private HashMap<PrefixType, String>prefix = new HashMap<PrefixType, String>();
public enum PrefixType {
MAIN, INFO, WARNING, ERROR;
}
public static MessageManager getInstance() {
return instance;
}
public void setup() {
FileConfiguration f = SettingsManager.getInstance().getMessageConfig();
|
prefix.put(PrefixType.MAIN, MessageUtil.replaceColors(f.getString("prefix.main")));
|
ThunderGemios10/Survival-Games
|
src/main/java/com/thundergemios10/survivalgames/CommandHandler.java
|
// Path: src/main/java/com/thundergemios10/survivalgames/MessageManager.java
// public enum PrefixType {
//
// MAIN, INFO, WARNING, ERROR;
//
// }
|
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import com.thundergemios10.survivalgames.MessageManager.PrefixType;
import com.thundergemios10.survivalgames.commands.*;
|
helpinfo.put("reload", 3);
helpinfo.put("refill", 3);
helpinfo.put("resetarena", 3);
//helpinfo.put("setstatswall", 1);
//helpinfo.put("sponsor", 1);
}
private void loadNonPlayerOnlyCmdList() {
nonPlayerOnlyCmds.put("forcestart", new ForceStart());
nonPlayerOnlyCmds.put("enable", new Enable());
nonPlayerOnlyCmds.put("disable", new Disable());
nonPlayerOnlyCmds.put("delarena", new DelArena());
nonPlayerOnlyCmds.put("reload", new Reload());
nonPlayerOnlyCmds.put("resetarena", new ResetArena());
nonPlayerOnlyCmds.put("listarenas", new ListArenas());
nonPlayerOnlyCmds.put("getcount", new ListArenas());//Same as listarenas
nonPlayerOnlyCmds.put("list", new ListPlayers());
nonPlayerOnlyCmds.put("flag", new Flag());
}
private void loadTabCompletionList(){
for (String key : commands.keySet()) {
tabCompletionList.add(key);
}
}
public boolean onCommand(CommandSender sender, Command cmd1, String commandLabel, String[] args) {
PluginDescriptionFile pdfFile = plugin.getDescription();
if (SurvivalGames.config_todate == false) {
|
// Path: src/main/java/com/thundergemios10/survivalgames/MessageManager.java
// public enum PrefixType {
//
// MAIN, INFO, WARNING, ERROR;
//
// }
// Path: src/main/java/com/thundergemios10/survivalgames/CommandHandler.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import com.thundergemios10.survivalgames.MessageManager.PrefixType;
import com.thundergemios10.survivalgames.commands.*;
helpinfo.put("reload", 3);
helpinfo.put("refill", 3);
helpinfo.put("resetarena", 3);
//helpinfo.put("setstatswall", 1);
//helpinfo.put("sponsor", 1);
}
private void loadNonPlayerOnlyCmdList() {
nonPlayerOnlyCmds.put("forcestart", new ForceStart());
nonPlayerOnlyCmds.put("enable", new Enable());
nonPlayerOnlyCmds.put("disable", new Disable());
nonPlayerOnlyCmds.put("delarena", new DelArena());
nonPlayerOnlyCmds.put("reload", new Reload());
nonPlayerOnlyCmds.put("resetarena", new ResetArena());
nonPlayerOnlyCmds.put("listarenas", new ListArenas());
nonPlayerOnlyCmds.put("getcount", new ListArenas());//Same as listarenas
nonPlayerOnlyCmds.put("list", new ListPlayers());
nonPlayerOnlyCmds.put("flag", new Flag());
}
private void loadTabCompletionList(){
for (String key : commands.keySet()) {
tabCompletionList.add(key);
}
}
public boolean onCommand(CommandSender sender, Command cmd1, String commandLabel, String[] args) {
PluginDescriptionFile pdfFile = plugin.getDescription();
if (SurvivalGames.config_todate == false) {
|
msgmgr.sendMessage(PrefixType.WARNING, "The config file is out of date. Please tell an administrator to reset the config.", sender);
|
ganguo/yingping_rn
|
Yingping/android/app/src/main/java/io/ganguo/movie/MainActivity.java
|
// Path: Yingping/android/app/src/main/java/io/ganguo/movie/reactPackage/ShareReactPackage.java
// public class ShareReactPackage implements ReactPackage {
// @Override
// public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
// List<NativeModule> modules = new ArrayList<>();
// modules.add(new ShareManager(reactContext));
// return modules;
// }
//
// @Override
// public List<Class<? extends JavaScriptModule>> createJSModules() {
// return Collections.emptyList();
// }
//
// @Override
// public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
// return Collections.emptyList();
// }
// }
|
import com.facebook.react.ReactActivity;
import com.BV.LinearGradient.LinearGradientPackage;
import io.realm.react.RealmReactPackage;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import io.ganguo.movie.reactPackage.ShareReactPackage;
import java.util.Arrays;
import java.util.List;
|
package io.ganguo.movie;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "Yingping";
}
/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new LinearGradientPackage(),
new RealmReactPackage(),
|
// Path: Yingping/android/app/src/main/java/io/ganguo/movie/reactPackage/ShareReactPackage.java
// public class ShareReactPackage implements ReactPackage {
// @Override
// public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
// List<NativeModule> modules = new ArrayList<>();
// modules.add(new ShareManager(reactContext));
// return modules;
// }
//
// @Override
// public List<Class<? extends JavaScriptModule>> createJSModules() {
// return Collections.emptyList();
// }
//
// @Override
// public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
// return Collections.emptyList();
// }
// }
// Path: Yingping/android/app/src/main/java/io/ganguo/movie/MainActivity.java
import com.facebook.react.ReactActivity;
import com.BV.LinearGradient.LinearGradientPackage;
import io.realm.react.RealmReactPackage;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import io.ganguo.movie.reactPackage.ShareReactPackage;
import java.util.Arrays;
import java.util.List;
package io.ganguo.movie;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "Yingping";
}
/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new LinearGradientPackage(),
new RealmReactPackage(),
|
new ShareReactPackage()
|
ganguo/yingping_rn
|
Yingping/android/app/src/main/java/io/ganguo/movie/reactPackage/ShareReactPackage.java
|
// Path: Yingping/android/app/src/main/java/io/ganguo/movie/model/ShareManager.java
// public class ShareManager extends ReactContextBaseJavaModule implements IWeiboHandler.Response {
// private static final String shareQQPlatform = "QQ";
// private static final String shareWechatPlatform = "Wechat";
// private static final String shareWeiboPlatform = "Weibo";
// private static final String shareMomentPlatform = "Moment";
//
// public ShareManager(ReactApplicationContext reactContext) {
// super(reactContext);
// }
//
// @Override
// public String getName() {
// return "ShareManager";
// }
//
// @Override
// public Map<String, Object> getConstants() {
// final Map<String, Object> constants = new HashMap<>();
// constants.put(shareQQPlatform, "QQ");
// constants.put(shareWechatPlatform, "Wechat");
// constants.put(shareWeiboPlatform, "Weibo");
// constants.put(shareMomentPlatform, "Moment");
// return constants;
// }
//
// @ReactMethod
// public void show(String message, int duration) {
// Toast.makeText(getReactApplicationContext(), message, duration).show();
// }
//
// @ReactMethod
// public void shareContent(ReadableMap content, String type) {
// switch (type) {
// case shareQQPlatform:
// shareToQQ(content);
// break;
// case shareWeiboPlatform:
// shareToSina(content);
// break;
// case shareMomentPlatform:
// shareToMoments(content);
// break;
// case shareWechatPlatform:
// shareToWechat(content);
// break;
// }
// }
//
// @Override
// public void onResponse(BaseResponse baseResponse) {
// }
//
// public void shareToWechat(ReadableMap content) {
// com.share.api.ShareManager.shareToWechatFriends(getCurrentActivity(), callback)
// .isWebPage()
// .setWebpageUrl(content.getString("url"))
// .setTitle(content.getString("title"))
// .setDescription(content.getString("content"))
// .setImageResource(R.drawable.ic_launcher)
// .share();
// }
//
// public void shareToSina(ReadableMap content) {
// com.share.api.ShareManager
// .shareToSina(getCurrentActivity(), weiboAuthListener)
// .isWebPage()
// .setTitle(content.getString("title"))
// .setActionUrl(content.getString("url"))
// .setDescription(content.getString("content"))
// .setImageResource(R.drawable.ic_launcher)
// .setContent(content.getString("content"))
// .share();
// }
//
// public void shareToMoments(ReadableMap content) {
// com.share.api.ShareManager.shareToWechatMoments(getCurrentActivity(), callback)
// .isWebPage()
// .setWebpageUrl(content.getString("url"))
// .setTitle(content.getString("title"))
// .setDescription(content.getString("content"))
// .setImageResource(R.drawable.ic_launcher)
// .share();
// }
//
// public void shareToQQ(ReadableMap content) {
// com.share.api.ShareManager.shareToQQ(getCurrentActivity(), iUiListener)
// .isDefault()
// .setTargetUrl(content.getString("url"))
// .setTitle(content.getString("title"))
// .setSummary(content.getString("content"))
// .share();
// }
//
// ICallback callback = new SimpleCallback() {
// @Override
// public void onSuccess() {
// Toast.makeText(getReactApplicationContext(), "成功分享", Toast.LENGTH_LONG).show();
// // ToastHelper.showMessage(getCurrentActivity(), "成功分享");
// }
//
// @Override
// public void onFailed() {
// // ToastHelper.showMessage(getCurrentActivity(), "成功失败");
// }
//
// @Override
// public void onCancel() {
// // ToastHelper.showMessage(getCurrentActivity(), "成功取消");
// }
//
// @Override
// public void onFinally() {
// // ToastHelper.showMessage(getCurrentActivity(), "成功结束");
// }
// };
//
// //新浪all in one 的授权回调listener
// WeiboAuthListener weiboAuthListener = new WeiboAuthListener() {
//
// @Override
// public void onWeiboException(WeiboException arg0) {
// ToastHelper.showMessage(getCurrentActivity(), "WeiboException " + arg0.toString());
// }
//
// @Override
// public void onComplete(Bundle bundle) {
// // TODO Auto-generated method stub
// Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
// AccessTokenKeeper.writeAccessToken(getCurrentActivity(), newToken);
// }
//
// @Override
// public void onCancel() {
// }
// };
//
// //QQ跟QQ空间设置回调接口
// IUiListener iUiListener = new IUiListener() {
// @Override
// public void onCancel() {
// if (callback != null) {
// callback.onCancel();
// }
// }
//
// @Override
// public void onComplete(Object response) {
// if (callback != null) {
// callback.onSuccess();
// }
// }
//
// @Override
// public void onError(UiError e) {
// if (callback != null) {
// callback.onFailed();
// }
// }
// };
// }
|
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import io.ganguo.movie.model.ShareManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
|
package io.ganguo.movie.reactPackage;
/**
* Created by aaron on 6/14/16.
*/
public class ShareReactPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
|
// Path: Yingping/android/app/src/main/java/io/ganguo/movie/model/ShareManager.java
// public class ShareManager extends ReactContextBaseJavaModule implements IWeiboHandler.Response {
// private static final String shareQQPlatform = "QQ";
// private static final String shareWechatPlatform = "Wechat";
// private static final String shareWeiboPlatform = "Weibo";
// private static final String shareMomentPlatform = "Moment";
//
// public ShareManager(ReactApplicationContext reactContext) {
// super(reactContext);
// }
//
// @Override
// public String getName() {
// return "ShareManager";
// }
//
// @Override
// public Map<String, Object> getConstants() {
// final Map<String, Object> constants = new HashMap<>();
// constants.put(shareQQPlatform, "QQ");
// constants.put(shareWechatPlatform, "Wechat");
// constants.put(shareWeiboPlatform, "Weibo");
// constants.put(shareMomentPlatform, "Moment");
// return constants;
// }
//
// @ReactMethod
// public void show(String message, int duration) {
// Toast.makeText(getReactApplicationContext(), message, duration).show();
// }
//
// @ReactMethod
// public void shareContent(ReadableMap content, String type) {
// switch (type) {
// case shareQQPlatform:
// shareToQQ(content);
// break;
// case shareWeiboPlatform:
// shareToSina(content);
// break;
// case shareMomentPlatform:
// shareToMoments(content);
// break;
// case shareWechatPlatform:
// shareToWechat(content);
// break;
// }
// }
//
// @Override
// public void onResponse(BaseResponse baseResponse) {
// }
//
// public void shareToWechat(ReadableMap content) {
// com.share.api.ShareManager.shareToWechatFriends(getCurrentActivity(), callback)
// .isWebPage()
// .setWebpageUrl(content.getString("url"))
// .setTitle(content.getString("title"))
// .setDescription(content.getString("content"))
// .setImageResource(R.drawable.ic_launcher)
// .share();
// }
//
// public void shareToSina(ReadableMap content) {
// com.share.api.ShareManager
// .shareToSina(getCurrentActivity(), weiboAuthListener)
// .isWebPage()
// .setTitle(content.getString("title"))
// .setActionUrl(content.getString("url"))
// .setDescription(content.getString("content"))
// .setImageResource(R.drawable.ic_launcher)
// .setContent(content.getString("content"))
// .share();
// }
//
// public void shareToMoments(ReadableMap content) {
// com.share.api.ShareManager.shareToWechatMoments(getCurrentActivity(), callback)
// .isWebPage()
// .setWebpageUrl(content.getString("url"))
// .setTitle(content.getString("title"))
// .setDescription(content.getString("content"))
// .setImageResource(R.drawable.ic_launcher)
// .share();
// }
//
// public void shareToQQ(ReadableMap content) {
// com.share.api.ShareManager.shareToQQ(getCurrentActivity(), iUiListener)
// .isDefault()
// .setTargetUrl(content.getString("url"))
// .setTitle(content.getString("title"))
// .setSummary(content.getString("content"))
// .share();
// }
//
// ICallback callback = new SimpleCallback() {
// @Override
// public void onSuccess() {
// Toast.makeText(getReactApplicationContext(), "成功分享", Toast.LENGTH_LONG).show();
// // ToastHelper.showMessage(getCurrentActivity(), "成功分享");
// }
//
// @Override
// public void onFailed() {
// // ToastHelper.showMessage(getCurrentActivity(), "成功失败");
// }
//
// @Override
// public void onCancel() {
// // ToastHelper.showMessage(getCurrentActivity(), "成功取消");
// }
//
// @Override
// public void onFinally() {
// // ToastHelper.showMessage(getCurrentActivity(), "成功结束");
// }
// };
//
// //新浪all in one 的授权回调listener
// WeiboAuthListener weiboAuthListener = new WeiboAuthListener() {
//
// @Override
// public void onWeiboException(WeiboException arg0) {
// ToastHelper.showMessage(getCurrentActivity(), "WeiboException " + arg0.toString());
// }
//
// @Override
// public void onComplete(Bundle bundle) {
// // TODO Auto-generated method stub
// Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
// AccessTokenKeeper.writeAccessToken(getCurrentActivity(), newToken);
// }
//
// @Override
// public void onCancel() {
// }
// };
//
// //QQ跟QQ空间设置回调接口
// IUiListener iUiListener = new IUiListener() {
// @Override
// public void onCancel() {
// if (callback != null) {
// callback.onCancel();
// }
// }
//
// @Override
// public void onComplete(Object response) {
// if (callback != null) {
// callback.onSuccess();
// }
// }
//
// @Override
// public void onError(UiError e) {
// if (callback != null) {
// callback.onFailed();
// }
// }
// };
// }
// Path: Yingping/android/app/src/main/java/io/ganguo/movie/reactPackage/ShareReactPackage.java
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import io.ganguo.movie.model.ShareManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
package io.ganguo.movie.reactPackage;
/**
* Created by aaron on 6/14/16.
*/
public class ShareReactPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
|
modules.add(new ShareManager(reactContext));
|
ganguo/yingping_rn
|
Yingping/android/OfficialOpenSDK/src/main/java/com/share/api/utils/Strings.java
|
// Path: Yingping/android/OfficialOpenSDK/src/main/java/com/share/api/base/Globals.java
// public class Globals {
//
// /**
// * 设备唯一码
// */
// public static final String KEY_DEVICE_ID = "key_device_id";
//
// public static final String ERROR_MSG_UTILS_CONSTRUCTOR = "this is static util.";
//
//
// }
|
import android.content.Context;
import android.text.TextUtils;
import com.share.api.base.Globals;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
|
package com.share.api.utils;
/**
* 字符串工具
* <p/>
* Created by Tony on 9/30/15.
*/
public class Strings {
private Strings() {
|
// Path: Yingping/android/OfficialOpenSDK/src/main/java/com/share/api/base/Globals.java
// public class Globals {
//
// /**
// * 设备唯一码
// */
// public static final String KEY_DEVICE_ID = "key_device_id";
//
// public static final String ERROR_MSG_UTILS_CONSTRUCTOR = "this is static util.";
//
//
// }
// Path: Yingping/android/OfficialOpenSDK/src/main/java/com/share/api/utils/Strings.java
import android.content.Context;
import android.text.TextUtils;
import com.share.api.base.Globals;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
package com.share.api.utils;
/**
* 字符串工具
* <p/>
* Created by Tony on 9/30/15.
*/
public class Strings {
private Strings() {
|
throw new Error(Globals.ERROR_MSG_UTILS_CONSTRUCTOR);
|
blazegraph/tinkerpop3
|
src/main/java/com/blazegraph/gremlin/structure/BlazeVertex.java
|
// Path: src/main/java/com/blazegraph/gremlin/util/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// /**
// * You MUST close this iterator or auto-close with a try-with-resources.
// */
// @Override
// void close();
//
// /**
// * Perform some action on each remaining element and then close the itertor.
// */
// @Override
// default void forEachRemaining(Consumer<? super E> action) {
// try {
// Iterator.super.forEachRemaining(action);
// } finally {
// close();
// }
// }
//
// /**
// * You MUST close this stream or auto-close in a try-with-resources.
// */
// default Stream<E> stream() {
// return Streams.of(this).onClose(() -> close());
// }
//
// /**
// * Collect the elements into a list. This will close the iterator.
// */
// default List<E> collect() {
// try (Stream<E> s = stream()) {
// return s.collect(toList());
// }
// }
//
// /**
// * Count the elements. This will close the iterator.
// */
// default long count() {
// try (Stream<E> s = stream()) {
// return s.count();
// }
// }
//
// /**
// * Count the distinct elements. This will close the iterator.
// */
// default long countDistinct() {
// try (Stream<E> s = stream()) {
// return s.distinct().count();
// }
// }
//
// /**
// * Construct an instance from a stream using stream.close() as the close
// * behavior for the iterator.
// */
// public static <T> CloseableIterator<T> of(final Stream<T> stream) {
// return of(stream.iterator(), () -> stream.close());
// }
//
// /**
// * Construct an instance from the supplied iterator and the supplied
// * onClose behavior.
// */
// public static <T>
// CloseableIterator<T> of(final Iterator<T> it, final Runnable onClose) {
// return new CloseableIterator<T>() {
//
// @Override
// public boolean hasNext() {
// return it.hasNext();
// }
//
// @Override
// public T next() {
// return it.next();
// }
//
// @Override
// public void remove() {
// it.remove();
// }
//
// @Override
// public void close() {
// onClose.run();
// }
//
// @Override
// public void forEachRemaining(Consumer<? super T> action) {
// it.forEachRemaining(action);
// }
//
// };
// }
//
// /**
// * Empty instance.
// */
// public static <T> CloseableIterator<T> emptyIterator() {
// final Iterator<T> it = Collections.<T>emptyIterator();
// return of(it, () -> {});
// }
//
// }
|
import org.openrdf.model.Literal;
import com.bigdata.rdf.model.BigdataURI;
import com.blazegraph.gremlin.util.CloseableIterator;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
|
/**
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Contact:
SYSTAP, LLC DBA Blazegraph
2501 Calvert ST NW #106
Washington, DC 20008
[email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.blazegraph.gremlin.structure;
/**
* Concrete vertex implementation for BlazeGraph.
* <p>
* Vertex existence is represented as one triples as follows:
* </p>
* <pre>
* :vertexId rdf:type :label .
* </pre>
* <p>
* Vertex properties are represented as follows:
* </p>
* <pre>
* :vertexId :key "val" .
* </pre>
*
* @author mikepersonick
*/
public class BlazeVertex extends AbstractBlazeElement implements Vertex, BlazeElement {
/**
* Construct an instance.
*/
BlazeVertex(final BlazeGraph graph, final BigdataURI uri,
final BigdataURI label) {
super(graph, uri, label);
}
/**
* Strengthen return type. Vertex RDF id is its URI.
*/
@Override
public BigdataURI rdfId() {
return uri;
}
/**
* Pass through to {@link StringFactory#vertexString(Vertex)}
*/
@Override
public String toString() {
return StringFactory.vertexString(this);
}
/**
* Strengthen return type to {@link BlazeVertexProperty}.
*
* @see Vertex#property(String)
* @see BlazeVertex#properties(String...)
*/
@Override
public <V> BlazeVertexProperty<V> property(final String key) {
|
// Path: src/main/java/com/blazegraph/gremlin/util/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// /**
// * You MUST close this iterator or auto-close with a try-with-resources.
// */
// @Override
// void close();
//
// /**
// * Perform some action on each remaining element and then close the itertor.
// */
// @Override
// default void forEachRemaining(Consumer<? super E> action) {
// try {
// Iterator.super.forEachRemaining(action);
// } finally {
// close();
// }
// }
//
// /**
// * You MUST close this stream or auto-close in a try-with-resources.
// */
// default Stream<E> stream() {
// return Streams.of(this).onClose(() -> close());
// }
//
// /**
// * Collect the elements into a list. This will close the iterator.
// */
// default List<E> collect() {
// try (Stream<E> s = stream()) {
// return s.collect(toList());
// }
// }
//
// /**
// * Count the elements. This will close the iterator.
// */
// default long count() {
// try (Stream<E> s = stream()) {
// return s.count();
// }
// }
//
// /**
// * Count the distinct elements. This will close the iterator.
// */
// default long countDistinct() {
// try (Stream<E> s = stream()) {
// return s.distinct().count();
// }
// }
//
// /**
// * Construct an instance from a stream using stream.close() as the close
// * behavior for the iterator.
// */
// public static <T> CloseableIterator<T> of(final Stream<T> stream) {
// return of(stream.iterator(), () -> stream.close());
// }
//
// /**
// * Construct an instance from the supplied iterator and the supplied
// * onClose behavior.
// */
// public static <T>
// CloseableIterator<T> of(final Iterator<T> it, final Runnable onClose) {
// return new CloseableIterator<T>() {
//
// @Override
// public boolean hasNext() {
// return it.hasNext();
// }
//
// @Override
// public T next() {
// return it.next();
// }
//
// @Override
// public void remove() {
// it.remove();
// }
//
// @Override
// public void close() {
// onClose.run();
// }
//
// @Override
// public void forEachRemaining(Consumer<? super T> action) {
// it.forEachRemaining(action);
// }
//
// };
// }
//
// /**
// * Empty instance.
// */
// public static <T> CloseableIterator<T> emptyIterator() {
// final Iterator<T> it = Collections.<T>emptyIterator();
// return of(it, () -> {});
// }
//
// }
// Path: src/main/java/com/blazegraph/gremlin/structure/BlazeVertex.java
import org.openrdf.model.Literal;
import com.bigdata.rdf.model.BigdataURI;
import com.blazegraph.gremlin.util.CloseableIterator;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
/**
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Contact:
SYSTAP, LLC DBA Blazegraph
2501 Calvert ST NW #106
Washington, DC 20008
[email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.blazegraph.gremlin.structure;
/**
* Concrete vertex implementation for BlazeGraph.
* <p>
* Vertex existence is represented as one triples as follows:
* </p>
* <pre>
* :vertexId rdf:type :label .
* </pre>
* <p>
* Vertex properties are represented as follows:
* </p>
* <pre>
* :vertexId :key "val" .
* </pre>
*
* @author mikepersonick
*/
public class BlazeVertex extends AbstractBlazeElement implements Vertex, BlazeElement {
/**
* Construct an instance.
*/
BlazeVertex(final BlazeGraph graph, final BigdataURI uri,
final BigdataURI label) {
super(graph, uri, label);
}
/**
* Strengthen return type. Vertex RDF id is its URI.
*/
@Override
public BigdataURI rdfId() {
return uri;
}
/**
* Pass through to {@link StringFactory#vertexString(Vertex)}
*/
@Override
public String toString() {
return StringFactory.vertexString(this);
}
/**
* Strengthen return type to {@link BlazeVertexProperty}.
*
* @see Vertex#property(String)
* @see BlazeVertex#properties(String...)
*/
@Override
public <V> BlazeVertexProperty<V> property(final String key) {
|
try (CloseableIterator<VertexProperty<V>> it = this.properties(key)) {
|
blazegraph/tinkerpop3
|
src/main/java/com/blazegraph/gremlin/structure/BlazeValueFactory.java
|
// Path: src/main/java/com/blazegraph/gremlin/internal/ListIndexExtension.java
// @SuppressWarnings("rawtypes")
// public class ListIndexExtension<V extends BigdataValue> implements IExtension<V> {
//
// private final BigdataURI datatype;
//
// public static final URI DATATYPE =
// new URIImpl("http://www.blazegraph.com/rdf/datatype#listIndex");
//
//
// public ListIndexExtension(final IDatatypeURIResolver resolver) {
// datatype = resolver.resolve(DATATYPE);
// }
//
// public Set<BigdataURI> getDatatypes() {
// return Collections.singleton(datatype);
// }
//
// /**
// * Convert the supplied value into an internal representation as
// * PackedLongIV.
// */
// @SuppressWarnings("unchecked")
// public LiteralExtensionIV createIV(final Value value) {
//
// if (value instanceof Literal == false)
// throw new IllegalArgumentException();
//
// final Literal lit = (Literal) value;
//
// final AbstractLiteralIV delegate =
// new PackedLongIV(Long.parseLong(lit.getLabel()));
// return new LiteralExtensionIV(delegate, datatype.getIV());
//
// }
//
// @SuppressWarnings("unchecked")
// public V asValue(final LiteralExtensionIV iv, final BigdataValueFactory vf) {
//
// AbstractLiteralIV delegate = iv.getDelegate();
// if (delegate == null || !(delegate instanceof PackedLongIV)) {
// throw new IllegalArgumentException();
// }
//
// final PackedLongIV pIv = (PackedLongIV) delegate;
// return (V) vf.createLiteral(
// String.valueOf(pIv.getInlineValue()), DATATYPE);
//
// }
//
// }
|
import com.bigdata.rdf.sail.RDRHistory;
import com.blazegraph.gremlin.internal.ListIndexExtension;
import org.openrdf.model.Literal;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.model.impl.ValueFactoryImpl;
import org.openrdf.model.vocabulary.RDF;
import com.bigdata.rdf.internal.XSD;
|
/**
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Contact:
SYSTAP, LLC DBA Blazegraph
2501 Calvert ST NW #106
Washington, DC 20008
[email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.blazegraph.gremlin.structure;
/**
* Factory for converting Tinkerpop data (element ids, property names/values)
* to RDF values (URIs, Literals) and back again. This interface comes with
* reasonable default behavior for all methods. It can be overridden to give
* an application a custom look and feel for the RDF values used to represent
* the property graph.
*
* @author mikepersonick
*/
public interface BlazeValueFactory {
/**
* Default instance.
*/
public static final BlazeValueFactory INSTANCE = new BlazeValueFactory() {};
/**
* Some default constants.
*
* @author mikepersonick
*/
public interface Defaults {
/**
* Namespace for RDF URIs.
*/
String NAMESPACE = "blaze:";
/**
* URI used for typing elements.
*/
URI TYPE = RDF.TYPE;
/**
* URI used for list item values.
*/
URI VALUE = RDF.VALUE;
/**
* Datatype URI for list index for Cardinality.list vertex properties.
*/
|
// Path: src/main/java/com/blazegraph/gremlin/internal/ListIndexExtension.java
// @SuppressWarnings("rawtypes")
// public class ListIndexExtension<V extends BigdataValue> implements IExtension<V> {
//
// private final BigdataURI datatype;
//
// public static final URI DATATYPE =
// new URIImpl("http://www.blazegraph.com/rdf/datatype#listIndex");
//
//
// public ListIndexExtension(final IDatatypeURIResolver resolver) {
// datatype = resolver.resolve(DATATYPE);
// }
//
// public Set<BigdataURI> getDatatypes() {
// return Collections.singleton(datatype);
// }
//
// /**
// * Convert the supplied value into an internal representation as
// * PackedLongIV.
// */
// @SuppressWarnings("unchecked")
// public LiteralExtensionIV createIV(final Value value) {
//
// if (value instanceof Literal == false)
// throw new IllegalArgumentException();
//
// final Literal lit = (Literal) value;
//
// final AbstractLiteralIV delegate =
// new PackedLongIV(Long.parseLong(lit.getLabel()));
// return new LiteralExtensionIV(delegate, datatype.getIV());
//
// }
//
// @SuppressWarnings("unchecked")
// public V asValue(final LiteralExtensionIV iv, final BigdataValueFactory vf) {
//
// AbstractLiteralIV delegate = iv.getDelegate();
// if (delegate == null || !(delegate instanceof PackedLongIV)) {
// throw new IllegalArgumentException();
// }
//
// final PackedLongIV pIv = (PackedLongIV) delegate;
// return (V) vf.createLiteral(
// String.valueOf(pIv.getInlineValue()), DATATYPE);
//
// }
//
// }
// Path: src/main/java/com/blazegraph/gremlin/structure/BlazeValueFactory.java
import com.bigdata.rdf.sail.RDRHistory;
import com.blazegraph.gremlin.internal.ListIndexExtension;
import org.openrdf.model.Literal;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.model.impl.ValueFactoryImpl;
import org.openrdf.model.vocabulary.RDF;
import com.bigdata.rdf.internal.XSD;
/**
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Contact:
SYSTAP, LLC DBA Blazegraph
2501 Calvert ST NW #106
Washington, DC 20008
[email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.blazegraph.gremlin.structure;
/**
* Factory for converting Tinkerpop data (element ids, property names/values)
* to RDF values (URIs, Literals) and back again. This interface comes with
* reasonable default behavior for all methods. It can be overridden to give
* an application a custom look and feel for the RDF values used to represent
* the property graph.
*
* @author mikepersonick
*/
public interface BlazeValueFactory {
/**
* Default instance.
*/
public static final BlazeValueFactory INSTANCE = new BlazeValueFactory() {};
/**
* Some default constants.
*
* @author mikepersonick
*/
public interface Defaults {
/**
* Namespace for RDF URIs.
*/
String NAMESPACE = "blaze:";
/**
* URI used for typing elements.
*/
URI TYPE = RDF.TYPE;
/**
* URI used for list item values.
*/
URI VALUE = RDF.VALUE;
/**
* Datatype URI for list index for Cardinality.list vertex properties.
*/
|
URI LI_DATATYPE = ListIndexExtension.DATATYPE;
|
blazegraph/tinkerpop3
|
src/main/java/com/blazegraph/gremlin/structure/BlazeEdge.java
|
// Path: src/main/java/com/blazegraph/gremlin/structure/BlazeGraphFeatures.java
// public static class Graph implements GraphFeatures {
//
// public static final boolean SUPPORTS_PERSISTENCE = true;
// public static final boolean SUPPORTS_TRANSACTIONS = true;
// public static final boolean SUPPORTS_THREADED_TRANSACTIONS = false;
// public static final boolean SUPPORTS_CONCURRENT_ACCESS = true;
// public static final boolean SUPPORTS_COMPUTER = false;
//
// private VariableFeatures variableFeatures = new Variable();
//
// @Override
// public VariableFeatures variables() {
// return variableFeatures;
// }
//
// @Override
// public boolean supportsPersistence() {
// return SUPPORTS_PERSISTENCE;
// }
//
// @Override
// public boolean supportsTransactions() {
// return SUPPORTS_TRANSACTIONS;
// }
//
// @Override
// public boolean supportsThreadedTransactions() {
// return SUPPORTS_THREADED_TRANSACTIONS;
// }
//
// /**
// * One writer, many readers
// */
// @Override
// public boolean supportsConcurrentAccess() {
// return SUPPORTS_CONCURRENT_ACCESS;
// }
//
// @Override
// public boolean supportsComputer() {
// return SUPPORTS_COMPUTER;
// }
//
// }
//
// Path: src/main/java/com/blazegraph/gremlin/util/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// /**
// * You MUST close this iterator or auto-close with a try-with-resources.
// */
// @Override
// void close();
//
// /**
// * Perform some action on each remaining element and then close the itertor.
// */
// @Override
// default void forEachRemaining(Consumer<? super E> action) {
// try {
// Iterator.super.forEachRemaining(action);
// } finally {
// close();
// }
// }
//
// /**
// * You MUST close this stream or auto-close in a try-with-resources.
// */
// default Stream<E> stream() {
// return Streams.of(this).onClose(() -> close());
// }
//
// /**
// * Collect the elements into a list. This will close the iterator.
// */
// default List<E> collect() {
// try (Stream<E> s = stream()) {
// return s.collect(toList());
// }
// }
//
// /**
// * Count the elements. This will close the iterator.
// */
// default long count() {
// try (Stream<E> s = stream()) {
// return s.count();
// }
// }
//
// /**
// * Count the distinct elements. This will close the iterator.
// */
// default long countDistinct() {
// try (Stream<E> s = stream()) {
// return s.distinct().count();
// }
// }
//
// /**
// * Construct an instance from a stream using stream.close() as the close
// * behavior for the iterator.
// */
// public static <T> CloseableIterator<T> of(final Stream<T> stream) {
// return of(stream.iterator(), () -> stream.close());
// }
//
// /**
// * Construct an instance from the supplied iterator and the supplied
// * onClose behavior.
// */
// public static <T>
// CloseableIterator<T> of(final Iterator<T> it, final Runnable onClose) {
// return new CloseableIterator<T>() {
//
// @Override
// public boolean hasNext() {
// return it.hasNext();
// }
//
// @Override
// public T next() {
// return it.next();
// }
//
// @Override
// public void remove() {
// it.remove();
// }
//
// @Override
// public void close() {
// onClose.run();
// }
//
// @Override
// public void forEachRemaining(Consumer<? super T> action) {
// it.forEachRemaining(action);
// }
//
// };
// }
//
// /**
// * Empty instance.
// */
// public static <T> CloseableIterator<T> emptyIterator() {
// final Iterator<T> it = Collections.<T>emptyIterator();
// return of(it, () -> {});
// }
//
// }
|
import com.bigdata.rdf.model.BigdataBNode;
import com.bigdata.rdf.model.BigdataStatement;
import com.bigdata.rdf.model.BigdataURI;
import com.bigdata.rdf.model.BigdataValueFactory;
import com.blazegraph.gremlin.structure.BlazeGraphFeatures.Graph;
import com.blazegraph.gremlin.util.CloseableIterator;
import java.util.Iterator;
import java.util.stream.Stream;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
|
/**
* Return the sid (reified statement) for this edge.
*/
@Override
public BigdataBNode rdfId() {
return sid;
}
/**
* @see Edge#remove()
* @see BlazeGraph#remove(BlazeReifiedElement)
*/
@Override
public void remove() {
graph.remove(this);
}
/**
* Strengthen return type to {@link BlazeProperty}.
*/
@Override
public <V> BlazeProperty<V> property(String key, V val) {
return BlazeReifiedElement.super.property(key, val);
}
/**
* Strength return type to {@link CloseableIterator}. You MUST close this
* iterator when finished.
*/
@Override
|
// Path: src/main/java/com/blazegraph/gremlin/structure/BlazeGraphFeatures.java
// public static class Graph implements GraphFeatures {
//
// public static final boolean SUPPORTS_PERSISTENCE = true;
// public static final boolean SUPPORTS_TRANSACTIONS = true;
// public static final boolean SUPPORTS_THREADED_TRANSACTIONS = false;
// public static final boolean SUPPORTS_CONCURRENT_ACCESS = true;
// public static final boolean SUPPORTS_COMPUTER = false;
//
// private VariableFeatures variableFeatures = new Variable();
//
// @Override
// public VariableFeatures variables() {
// return variableFeatures;
// }
//
// @Override
// public boolean supportsPersistence() {
// return SUPPORTS_PERSISTENCE;
// }
//
// @Override
// public boolean supportsTransactions() {
// return SUPPORTS_TRANSACTIONS;
// }
//
// @Override
// public boolean supportsThreadedTransactions() {
// return SUPPORTS_THREADED_TRANSACTIONS;
// }
//
// /**
// * One writer, many readers
// */
// @Override
// public boolean supportsConcurrentAccess() {
// return SUPPORTS_CONCURRENT_ACCESS;
// }
//
// @Override
// public boolean supportsComputer() {
// return SUPPORTS_COMPUTER;
// }
//
// }
//
// Path: src/main/java/com/blazegraph/gremlin/util/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// /**
// * You MUST close this iterator or auto-close with a try-with-resources.
// */
// @Override
// void close();
//
// /**
// * Perform some action on each remaining element and then close the itertor.
// */
// @Override
// default void forEachRemaining(Consumer<? super E> action) {
// try {
// Iterator.super.forEachRemaining(action);
// } finally {
// close();
// }
// }
//
// /**
// * You MUST close this stream or auto-close in a try-with-resources.
// */
// default Stream<E> stream() {
// return Streams.of(this).onClose(() -> close());
// }
//
// /**
// * Collect the elements into a list. This will close the iterator.
// */
// default List<E> collect() {
// try (Stream<E> s = stream()) {
// return s.collect(toList());
// }
// }
//
// /**
// * Count the elements. This will close the iterator.
// */
// default long count() {
// try (Stream<E> s = stream()) {
// return s.count();
// }
// }
//
// /**
// * Count the distinct elements. This will close the iterator.
// */
// default long countDistinct() {
// try (Stream<E> s = stream()) {
// return s.distinct().count();
// }
// }
//
// /**
// * Construct an instance from a stream using stream.close() as the close
// * behavior for the iterator.
// */
// public static <T> CloseableIterator<T> of(final Stream<T> stream) {
// return of(stream.iterator(), () -> stream.close());
// }
//
// /**
// * Construct an instance from the supplied iterator and the supplied
// * onClose behavior.
// */
// public static <T>
// CloseableIterator<T> of(final Iterator<T> it, final Runnable onClose) {
// return new CloseableIterator<T>() {
//
// @Override
// public boolean hasNext() {
// return it.hasNext();
// }
//
// @Override
// public T next() {
// return it.next();
// }
//
// @Override
// public void remove() {
// it.remove();
// }
//
// @Override
// public void close() {
// onClose.run();
// }
//
// @Override
// public void forEachRemaining(Consumer<? super T> action) {
// it.forEachRemaining(action);
// }
//
// };
// }
//
// /**
// * Empty instance.
// */
// public static <T> CloseableIterator<T> emptyIterator() {
// final Iterator<T> it = Collections.<T>emptyIterator();
// return of(it, () -> {});
// }
//
// }
// Path: src/main/java/com/blazegraph/gremlin/structure/BlazeEdge.java
import com.bigdata.rdf.model.BigdataBNode;
import com.bigdata.rdf.model.BigdataStatement;
import com.bigdata.rdf.model.BigdataURI;
import com.bigdata.rdf.model.BigdataValueFactory;
import com.blazegraph.gremlin.structure.BlazeGraphFeatures.Graph;
import com.blazegraph.gremlin.util.CloseableIterator;
import java.util.Iterator;
import java.util.stream.Stream;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
/**
* Return the sid (reified statement) for this edge.
*/
@Override
public BigdataBNode rdfId() {
return sid;
}
/**
* @see Edge#remove()
* @see BlazeGraph#remove(BlazeReifiedElement)
*/
@Override
public void remove() {
graph.remove(this);
}
/**
* Strengthen return type to {@link BlazeProperty}.
*/
@Override
public <V> BlazeProperty<V> property(String key, V val) {
return BlazeReifiedElement.super.property(key, val);
}
/**
* Strength return type to {@link CloseableIterator}. You MUST close this
* iterator when finished.
*/
@Override
|
public <V> CloseableIterator<Property<V>> properties(final String... keys) {
|
blazegraph/tinkerpop3
|
src/test/java/com/blazegraph/gremlin/structure/TestBulkLoad.java
|
// Path: src/main/java/com/blazegraph/gremlin/listener/BlazeGraphEdit.java
// public class BlazeGraphEdit {
//
// /**
// * Edit action - add or remove.
// *
// * @author mikepersonick
// */
// public static enum Action {
//
// /**
// * Graph atom added.
// */
// Add,
//
// /**
// * Graph atom removed.
// */
// Remove;
//
// }
//
// /**
// * Edit action.
// */
// private final Action action;
//
// /**
// * Atomic unit of graph information edited.
// */
// private final BlazeGraphAtom atom;
//
// /**
// * The commit time of the edit action.
// */
// private final long timestamp;
//
// /**
// * Construct an edit with an unknown commit time (listener API).
// */
// public BlazeGraphEdit(final Action action, final BlazeGraphAtom atom) {
// this(action, atom, 0l);
// }
//
// /**
// * Construct an edit with an known commit time (history API).
// */
// public BlazeGraphEdit(final Action action, final BlazeGraphAtom atom,
// final long timestamp) {
// this.action = action;
// this.atom = atom;
// this.timestamp = timestamp;
// }
//
// /**
// * Return the edit action.
// */
// public Action getAction() {
// return action;
// }
//
// /**
// * Return the atomic unit of graph information edited.
// */
// public BlazeGraphAtom getAtom() {
// return atom;
// }
//
// /**
// * Return the commit time of the edit action or 0l if this is an
// * uncommitted edit.
// */
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return "BlazeGraphEdit [action=" + action + ", atom=" + atom
// + (timestamp > 0 ? ", timestamp=" + timestamp : "") + "]";
// }
//
// }
//
// Path: src/main/java/com/blazegraph/gremlin/listener/BlazeGraphEdit.java
// public static enum Action {
//
// /**
// * Graph atom added.
// */
// Add,
//
// /**
// * Graph atom removed.
// */
// Remove;
//
// }
|
import java.util.LinkedList;
import java.util.List;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality;
import com.blazegraph.gremlin.listener.BlazeGraphEdit;
import com.blazegraph.gremlin.listener.BlazeGraphEdit.Action;
|
/**
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Contact:
SYSTAP, LLC DBA Blazegraph
2501 Calvert ST NW #106
Washington, DC 20008
[email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.blazegraph.gremlin.structure;
/**
* Bulk load API tests.
*
* @author mikepersonick
*/
public class TestBulkLoad extends TestBlazeGraph {
public void testBulkLoad1() {
|
// Path: src/main/java/com/blazegraph/gremlin/listener/BlazeGraphEdit.java
// public class BlazeGraphEdit {
//
// /**
// * Edit action - add or remove.
// *
// * @author mikepersonick
// */
// public static enum Action {
//
// /**
// * Graph atom added.
// */
// Add,
//
// /**
// * Graph atom removed.
// */
// Remove;
//
// }
//
// /**
// * Edit action.
// */
// private final Action action;
//
// /**
// * Atomic unit of graph information edited.
// */
// private final BlazeGraphAtom atom;
//
// /**
// * The commit time of the edit action.
// */
// private final long timestamp;
//
// /**
// * Construct an edit with an unknown commit time (listener API).
// */
// public BlazeGraphEdit(final Action action, final BlazeGraphAtom atom) {
// this(action, atom, 0l);
// }
//
// /**
// * Construct an edit with an known commit time (history API).
// */
// public BlazeGraphEdit(final Action action, final BlazeGraphAtom atom,
// final long timestamp) {
// this.action = action;
// this.atom = atom;
// this.timestamp = timestamp;
// }
//
// /**
// * Return the edit action.
// */
// public Action getAction() {
// return action;
// }
//
// /**
// * Return the atomic unit of graph information edited.
// */
// public BlazeGraphAtom getAtom() {
// return atom;
// }
//
// /**
// * Return the commit time of the edit action or 0l if this is an
// * uncommitted edit.
// */
// public long getTimestamp() {
// return timestamp;
// }
//
// @Override
// public String toString() {
// return "BlazeGraphEdit [action=" + action + ", atom=" + atom
// + (timestamp > 0 ? ", timestamp=" + timestamp : "") + "]";
// }
//
// }
//
// Path: src/main/java/com/blazegraph/gremlin/listener/BlazeGraphEdit.java
// public static enum Action {
//
// /**
// * Graph atom added.
// */
// Add,
//
// /**
// * Graph atom removed.
// */
// Remove;
//
// }
// Path: src/test/java/com/blazegraph/gremlin/structure/TestBulkLoad.java
import java.util.LinkedList;
import java.util.List;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality;
import com.blazegraph.gremlin.listener.BlazeGraphEdit;
import com.blazegraph.gremlin.listener.BlazeGraphEdit.Action;
/**
Copyright (C) SYSTAP, LLC DBA Blazegraph 2006-2016. All rights reserved.
Contact:
SYSTAP, LLC DBA Blazegraph
2501 Calvert ST NW #106
Washington, DC 20008
[email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.blazegraph.gremlin.structure;
/**
* Bulk load API tests.
*
* @author mikepersonick
*/
public class TestBulkLoad extends TestBlazeGraph {
public void testBulkLoad1() {
|
final List<BlazeGraphEdit> edits = new LinkedList<>();
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.