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
mayanhui/ella
src/main/java/com/adintellig/ella/hbase/handler/JMXHMasterHandler.java
// Path: src/main/java/com/adintellig/ella/model/jmxbeans/LiveRegionServerBeans.java // public class LiveRegionServerBeans { // private LiveRegionServerBean[] beans; // // public LiveRegionServerBean[] getBeans() { // return beans; // } // // public void setBeans(LiveRegionServerBean[] beans) { // this.beans = beans; // } // // } // // Path: src/main/java/com/adintellig/ella/util/ConfigFactory.java // public class ConfigFactory { // public static final String ELLA_CONFIG_PATH = "/ella.properties"; // // private static ConfigFactory instance = new ConfigFactory(); // private HashMap<String, ConfigProperties> configMap = new HashMap<String, ConfigProperties>(); // // public static ConfigFactory getInstance() { // return instance; // } // // private ConfigFactory() { // // } // // /** // * This is the factory method for producing config properties object // * each path has a single instance of config properties // * @param filePath the class path to the config file // * @return // */ // synchronized public ConfigProperties getConfigProperties(String filePath) { // ConfigProperties config = configMap.get(filePath); // if (config == null) { // config = new ConfigProperties(filePath); // configMap.put(filePath, config); // } // // return config; // } // } // // Path: src/main/java/com/adintellig/ella/util/ConfigProperties.java // public class ConfigProperties extends Properties { // // private static final long serialVersionUID = -1851097272122935390L; // // public static final String CONFIG_NAME_MAPRED_QUEUE_NAME = "mapred.job.queue.name"; // public static final String CONFIG_NAME_HBASE_MASTER = "hbase.master"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; // public static final String CONFIG_NAME_HBASE_REGIONSERVER_NUM = "hbase.regionserver.num"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_PROPRERTY_CLIENTPORT = "hbase.zookeeper.property.clientPort"; // // /** // * @Constructor // * @param filePath // * is the class path to the config file // */ // protected ConfigProperties(final String filePath) { // final InputStream inStream = ConfigProperties.class // .getResourceAsStream(filePath); // try { // load(inStream); // } catch (final IOException e) { // e.printStackTrace(); // throw new NullPointerException("Failed to load config file: " // + filePath + ", error: " + e.getMessage()); // } finally { // if (inStream != null) { // try { // inStream.close(); // } catch (final IOException e) { // // do nothing // } // } // // } // } // // public int getInt(final String propertyName, final int defaultValue) { // int propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Integer.parseInt(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public float getFloat(final String propertyName, final float defaultValue) { // float propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Float.parseFloat(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public double getDouble(final String propertyName, final double defaultValue) { // double propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Double.parseDouble(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // }
import java.io.IOException; import java.sql.SQLException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.jmxbeans.LiveRegionServerBeans; import com.adintellig.ella.util.ConfigFactory; import com.adintellig.ella.util.ConfigProperties; import com.alibaba.fastjson.JSON;
package com.adintellig.ella.hbase.handler; public class JMXHMasterHandler extends ServerHandler{ private static Logger logger = LoggerFactory .getLogger(JMXHMasterHandler.class);
// Path: src/main/java/com/adintellig/ella/model/jmxbeans/LiveRegionServerBeans.java // public class LiveRegionServerBeans { // private LiveRegionServerBean[] beans; // // public LiveRegionServerBean[] getBeans() { // return beans; // } // // public void setBeans(LiveRegionServerBean[] beans) { // this.beans = beans; // } // // } // // Path: src/main/java/com/adintellig/ella/util/ConfigFactory.java // public class ConfigFactory { // public static final String ELLA_CONFIG_PATH = "/ella.properties"; // // private static ConfigFactory instance = new ConfigFactory(); // private HashMap<String, ConfigProperties> configMap = new HashMap<String, ConfigProperties>(); // // public static ConfigFactory getInstance() { // return instance; // } // // private ConfigFactory() { // // } // // /** // * This is the factory method for producing config properties object // * each path has a single instance of config properties // * @param filePath the class path to the config file // * @return // */ // synchronized public ConfigProperties getConfigProperties(String filePath) { // ConfigProperties config = configMap.get(filePath); // if (config == null) { // config = new ConfigProperties(filePath); // configMap.put(filePath, config); // } // // return config; // } // } // // Path: src/main/java/com/adintellig/ella/util/ConfigProperties.java // public class ConfigProperties extends Properties { // // private static final long serialVersionUID = -1851097272122935390L; // // public static final String CONFIG_NAME_MAPRED_QUEUE_NAME = "mapred.job.queue.name"; // public static final String CONFIG_NAME_HBASE_MASTER = "hbase.master"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; // public static final String CONFIG_NAME_HBASE_REGIONSERVER_NUM = "hbase.regionserver.num"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_PROPRERTY_CLIENTPORT = "hbase.zookeeper.property.clientPort"; // // /** // * @Constructor // * @param filePath // * is the class path to the config file // */ // protected ConfigProperties(final String filePath) { // final InputStream inStream = ConfigProperties.class // .getResourceAsStream(filePath); // try { // load(inStream); // } catch (final IOException e) { // e.printStackTrace(); // throw new NullPointerException("Failed to load config file: " // + filePath + ", error: " + e.getMessage()); // } finally { // if (inStream != null) { // try { // inStream.close(); // } catch (final IOException e) { // // do nothing // } // } // // } // } // // public int getInt(final String propertyName, final int defaultValue) { // int propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Integer.parseInt(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public float getFloat(final String propertyName, final float defaultValue) { // float propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Float.parseFloat(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public double getDouble(final String propertyName, final double defaultValue) { // double propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Double.parseDouble(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // } // Path: src/main/java/com/adintellig/ella/hbase/handler/JMXHMasterHandler.java import java.io.IOException; import java.sql.SQLException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.jmxbeans.LiveRegionServerBeans; import com.adintellig.ella.util.ConfigFactory; import com.adintellig.ella.util.ConfigProperties; import com.alibaba.fastjson.JSON; package com.adintellig.ella.hbase.handler; public class JMXHMasterHandler extends ServerHandler{ private static Logger logger = LoggerFactory .getLogger(JMXHMasterHandler.class);
static ConfigProperties config = ConfigFactory.getInstance()
mayanhui/ella
src/main/java/com/adintellig/ella/hbase/handler/JMXHMasterHandler.java
// Path: src/main/java/com/adintellig/ella/model/jmxbeans/LiveRegionServerBeans.java // public class LiveRegionServerBeans { // private LiveRegionServerBean[] beans; // // public LiveRegionServerBean[] getBeans() { // return beans; // } // // public void setBeans(LiveRegionServerBean[] beans) { // this.beans = beans; // } // // } // // Path: src/main/java/com/adintellig/ella/util/ConfigFactory.java // public class ConfigFactory { // public static final String ELLA_CONFIG_PATH = "/ella.properties"; // // private static ConfigFactory instance = new ConfigFactory(); // private HashMap<String, ConfigProperties> configMap = new HashMap<String, ConfigProperties>(); // // public static ConfigFactory getInstance() { // return instance; // } // // private ConfigFactory() { // // } // // /** // * This is the factory method for producing config properties object // * each path has a single instance of config properties // * @param filePath the class path to the config file // * @return // */ // synchronized public ConfigProperties getConfigProperties(String filePath) { // ConfigProperties config = configMap.get(filePath); // if (config == null) { // config = new ConfigProperties(filePath); // configMap.put(filePath, config); // } // // return config; // } // } // // Path: src/main/java/com/adintellig/ella/util/ConfigProperties.java // public class ConfigProperties extends Properties { // // private static final long serialVersionUID = -1851097272122935390L; // // public static final String CONFIG_NAME_MAPRED_QUEUE_NAME = "mapred.job.queue.name"; // public static final String CONFIG_NAME_HBASE_MASTER = "hbase.master"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; // public static final String CONFIG_NAME_HBASE_REGIONSERVER_NUM = "hbase.regionserver.num"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_PROPRERTY_CLIENTPORT = "hbase.zookeeper.property.clientPort"; // // /** // * @Constructor // * @param filePath // * is the class path to the config file // */ // protected ConfigProperties(final String filePath) { // final InputStream inStream = ConfigProperties.class // .getResourceAsStream(filePath); // try { // load(inStream); // } catch (final IOException e) { // e.printStackTrace(); // throw new NullPointerException("Failed to load config file: " // + filePath + ", error: " + e.getMessage()); // } finally { // if (inStream != null) { // try { // inStream.close(); // } catch (final IOException e) { // // do nothing // } // } // // } // } // // public int getInt(final String propertyName, final int defaultValue) { // int propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Integer.parseInt(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public float getFloat(final String propertyName, final float defaultValue) { // float propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Float.parseFloat(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public double getDouble(final String propertyName, final double defaultValue) { // double propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Double.parseDouble(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // }
import java.io.IOException; import java.sql.SQLException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.jmxbeans.LiveRegionServerBeans; import com.adintellig.ella.util.ConfigFactory; import com.adintellig.ella.util.ConfigProperties; import com.alibaba.fastjson.JSON;
package com.adintellig.ella.hbase.handler; public class JMXHMasterHandler extends ServerHandler{ private static Logger logger = LoggerFactory .getLogger(JMXHMasterHandler.class);
// Path: src/main/java/com/adintellig/ella/model/jmxbeans/LiveRegionServerBeans.java // public class LiveRegionServerBeans { // private LiveRegionServerBean[] beans; // // public LiveRegionServerBean[] getBeans() { // return beans; // } // // public void setBeans(LiveRegionServerBean[] beans) { // this.beans = beans; // } // // } // // Path: src/main/java/com/adintellig/ella/util/ConfigFactory.java // public class ConfigFactory { // public static final String ELLA_CONFIG_PATH = "/ella.properties"; // // private static ConfigFactory instance = new ConfigFactory(); // private HashMap<String, ConfigProperties> configMap = new HashMap<String, ConfigProperties>(); // // public static ConfigFactory getInstance() { // return instance; // } // // private ConfigFactory() { // // } // // /** // * This is the factory method for producing config properties object // * each path has a single instance of config properties // * @param filePath the class path to the config file // * @return // */ // synchronized public ConfigProperties getConfigProperties(String filePath) { // ConfigProperties config = configMap.get(filePath); // if (config == null) { // config = new ConfigProperties(filePath); // configMap.put(filePath, config); // } // // return config; // } // } // // Path: src/main/java/com/adintellig/ella/util/ConfigProperties.java // public class ConfigProperties extends Properties { // // private static final long serialVersionUID = -1851097272122935390L; // // public static final String CONFIG_NAME_MAPRED_QUEUE_NAME = "mapred.job.queue.name"; // public static final String CONFIG_NAME_HBASE_MASTER = "hbase.master"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; // public static final String CONFIG_NAME_HBASE_REGIONSERVER_NUM = "hbase.regionserver.num"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_PROPRERTY_CLIENTPORT = "hbase.zookeeper.property.clientPort"; // // /** // * @Constructor // * @param filePath // * is the class path to the config file // */ // protected ConfigProperties(final String filePath) { // final InputStream inStream = ConfigProperties.class // .getResourceAsStream(filePath); // try { // load(inStream); // } catch (final IOException e) { // e.printStackTrace(); // throw new NullPointerException("Failed to load config file: " // + filePath + ", error: " + e.getMessage()); // } finally { // if (inStream != null) { // try { // inStream.close(); // } catch (final IOException e) { // // do nothing // } // } // // } // } // // public int getInt(final String propertyName, final int defaultValue) { // int propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Integer.parseInt(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public float getFloat(final String propertyName, final float defaultValue) { // float propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Float.parseFloat(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public double getDouble(final String propertyName, final double defaultValue) { // double propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Double.parseDouble(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // } // Path: src/main/java/com/adintellig/ella/hbase/handler/JMXHMasterHandler.java import java.io.IOException; import java.sql.SQLException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.jmxbeans.LiveRegionServerBeans; import com.adintellig.ella.util.ConfigFactory; import com.adintellig.ella.util.ConfigProperties; import com.alibaba.fastjson.JSON; package com.adintellig.ella.hbase.handler; public class JMXHMasterHandler extends ServerHandler{ private static Logger logger = LoggerFactory .getLogger(JMXHMasterHandler.class);
static ConfigProperties config = ConfigFactory.getInstance()
mayanhui/ella
src/main/java/com/adintellig/ella/hbase/handler/JMXHMasterHandler.java
// Path: src/main/java/com/adintellig/ella/model/jmxbeans/LiveRegionServerBeans.java // public class LiveRegionServerBeans { // private LiveRegionServerBean[] beans; // // public LiveRegionServerBean[] getBeans() { // return beans; // } // // public void setBeans(LiveRegionServerBean[] beans) { // this.beans = beans; // } // // } // // Path: src/main/java/com/adintellig/ella/util/ConfigFactory.java // public class ConfigFactory { // public static final String ELLA_CONFIG_PATH = "/ella.properties"; // // private static ConfigFactory instance = new ConfigFactory(); // private HashMap<String, ConfigProperties> configMap = new HashMap<String, ConfigProperties>(); // // public static ConfigFactory getInstance() { // return instance; // } // // private ConfigFactory() { // // } // // /** // * This is the factory method for producing config properties object // * each path has a single instance of config properties // * @param filePath the class path to the config file // * @return // */ // synchronized public ConfigProperties getConfigProperties(String filePath) { // ConfigProperties config = configMap.get(filePath); // if (config == null) { // config = new ConfigProperties(filePath); // configMap.put(filePath, config); // } // // return config; // } // } // // Path: src/main/java/com/adintellig/ella/util/ConfigProperties.java // public class ConfigProperties extends Properties { // // private static final long serialVersionUID = -1851097272122935390L; // // public static final String CONFIG_NAME_MAPRED_QUEUE_NAME = "mapred.job.queue.name"; // public static final String CONFIG_NAME_HBASE_MASTER = "hbase.master"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; // public static final String CONFIG_NAME_HBASE_REGIONSERVER_NUM = "hbase.regionserver.num"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_PROPRERTY_CLIENTPORT = "hbase.zookeeper.property.clientPort"; // // /** // * @Constructor // * @param filePath // * is the class path to the config file // */ // protected ConfigProperties(final String filePath) { // final InputStream inStream = ConfigProperties.class // .getResourceAsStream(filePath); // try { // load(inStream); // } catch (final IOException e) { // e.printStackTrace(); // throw new NullPointerException("Failed to load config file: " // + filePath + ", error: " + e.getMessage()); // } finally { // if (inStream != null) { // try { // inStream.close(); // } catch (final IOException e) { // // do nothing // } // } // // } // } // // public int getInt(final String propertyName, final int defaultValue) { // int propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Integer.parseInt(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public float getFloat(final String propertyName, final float defaultValue) { // float propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Float.parseFloat(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public double getDouble(final String propertyName, final double defaultValue) { // double propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Double.parseDouble(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // }
import java.io.IOException; import java.sql.SQLException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.jmxbeans.LiveRegionServerBeans; import com.adintellig.ella.util.ConfigFactory; import com.adintellig.ella.util.ConfigProperties; import com.alibaba.fastjson.JSON;
package com.adintellig.ella.hbase.handler; public class JMXHMasterHandler extends ServerHandler{ private static Logger logger = LoggerFactory .getLogger(JMXHMasterHandler.class); static ConfigProperties config = ConfigFactory.getInstance() .getConfigProperties(ConfigFactory.ELLA_CONFIG_PATH); public static String url; private static JMXHMasterHandler service; private JMXHMasterHandler() { url = config.getProperty("ella.hbase.master.baseurl") + config.getProperty("ella.hbase.master.jmx.req.suburl"); } public static synchronized JMXHMasterHandler getInstance() { if (service == null) service = new JMXHMasterHandler(); return service; } /** * 将JSON对象转换为Java Bean。 * @param jsonString * @return */
// Path: src/main/java/com/adintellig/ella/model/jmxbeans/LiveRegionServerBeans.java // public class LiveRegionServerBeans { // private LiveRegionServerBean[] beans; // // public LiveRegionServerBean[] getBeans() { // return beans; // } // // public void setBeans(LiveRegionServerBean[] beans) { // this.beans = beans; // } // // } // // Path: src/main/java/com/adintellig/ella/util/ConfigFactory.java // public class ConfigFactory { // public static final String ELLA_CONFIG_PATH = "/ella.properties"; // // private static ConfigFactory instance = new ConfigFactory(); // private HashMap<String, ConfigProperties> configMap = new HashMap<String, ConfigProperties>(); // // public static ConfigFactory getInstance() { // return instance; // } // // private ConfigFactory() { // // } // // /** // * This is the factory method for producing config properties object // * each path has a single instance of config properties // * @param filePath the class path to the config file // * @return // */ // synchronized public ConfigProperties getConfigProperties(String filePath) { // ConfigProperties config = configMap.get(filePath); // if (config == null) { // config = new ConfigProperties(filePath); // configMap.put(filePath, config); // } // // return config; // } // } // // Path: src/main/java/com/adintellig/ella/util/ConfigProperties.java // public class ConfigProperties extends Properties { // // private static final long serialVersionUID = -1851097272122935390L; // // public static final String CONFIG_NAME_MAPRED_QUEUE_NAME = "mapred.job.queue.name"; // public static final String CONFIG_NAME_HBASE_MASTER = "hbase.master"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; // public static final String CONFIG_NAME_HBASE_REGIONSERVER_NUM = "hbase.regionserver.num"; // public static final String CONFIG_NAME_HBASE_ZOOKEEPER_PROPRERTY_CLIENTPORT = "hbase.zookeeper.property.clientPort"; // // /** // * @Constructor // * @param filePath // * is the class path to the config file // */ // protected ConfigProperties(final String filePath) { // final InputStream inStream = ConfigProperties.class // .getResourceAsStream(filePath); // try { // load(inStream); // } catch (final IOException e) { // e.printStackTrace(); // throw new NullPointerException("Failed to load config file: " // + filePath + ", error: " + e.getMessage()); // } finally { // if (inStream != null) { // try { // inStream.close(); // } catch (final IOException e) { // // do nothing // } // } // // } // } // // public int getInt(final String propertyName, final int defaultValue) { // int propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Integer.parseInt(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public float getFloat(final String propertyName, final float defaultValue) { // float propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Float.parseFloat(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // // public double getDouble(final String propertyName, final double defaultValue) { // double propertyValue = defaultValue; // // final String valueStr = getProperty(propertyName); // try { // propertyValue = Double.parseDouble(valueStr); // } catch (final Exception e) { // // do nothing, just return the default value; // } // // return propertyValue; // } // } // Path: src/main/java/com/adintellig/ella/hbase/handler/JMXHMasterHandler.java import java.io.IOException; import java.sql.SQLException; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.jmxbeans.LiveRegionServerBeans; import com.adintellig.ella.util.ConfigFactory; import com.adintellig.ella.util.ConfigProperties; import com.alibaba.fastjson.JSON; package com.adintellig.ella.hbase.handler; public class JMXHMasterHandler extends ServerHandler{ private static Logger logger = LoggerFactory .getLogger(JMXHMasterHandler.class); static ConfigProperties config = ConfigFactory.getInstance() .getConfigProperties(ConfigFactory.ELLA_CONFIG_PATH); public static String url; private static JMXHMasterHandler service; private JMXHMasterHandler() { url = config.getProperty("ella.hbase.master.baseurl") + config.getProperty("ella.hbase.master.jmx.req.suburl"); } public static synchronized JMXHMasterHandler getInstance() { if (service == null) service = new JMXHMasterHandler(); return service; } /** * 将JSON对象转换为Java Bean。 * @param jsonString * @return */
public LiveRegionServerBeans parseBean(String jsonString) {
mayanhui/ella
src/main/java/com/adintellig/ella/action/LoginServlet.java
// Path: src/main/java/com/adintellig/ella/dao/UserDaoImpl.java // public class UserDaoImpl { // private static Logger logger = LoggerFactory.getLogger(UserDaoImpl.class); // // public User findByNameAndPassword(String username, String password) // throws SQLException { // String sql = "select * from hbase.user where username=? and password=?"; // // Connection conn = JdbcUtil.getConnection(); // PreparedStatement ps = conn.prepareStatement(sql); // ps.setString(1, username); // ps.setString(2, password); // ResultSet rs = ps.executeQuery(); // logger.info("[QUERY]: " + sql); // // User u = null; // if (rs.next()) { // u = new User(); // u.setUsername(rs.getString("username")); // u.setPassword(rs.getString("password")); // } // JdbcUtil.close(conn,ps,rs); // return u; // } // } // // Path: src/main/java/com/adintellig/ella/model/user/User.java // public class User { // // private String username; // private String password; // private Timestamp update_time; // // 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 Timestamp getUpdate_time() { // return update_time; // } // // public void setUpdate_time(Timestamp update_time) { // this.update_time = update_time; // } // // }
import java.io.IOException; import java.sql.SQLException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.dao.UserDaoImpl; import com.adintellig.ella.model.user.User;
package com.adintellig.ella.action; public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; private static Logger logger = LoggerFactory.getLogger(LoginServlet.class);
// Path: src/main/java/com/adintellig/ella/dao/UserDaoImpl.java // public class UserDaoImpl { // private static Logger logger = LoggerFactory.getLogger(UserDaoImpl.class); // // public User findByNameAndPassword(String username, String password) // throws SQLException { // String sql = "select * from hbase.user where username=? and password=?"; // // Connection conn = JdbcUtil.getConnection(); // PreparedStatement ps = conn.prepareStatement(sql); // ps.setString(1, username); // ps.setString(2, password); // ResultSet rs = ps.executeQuery(); // logger.info("[QUERY]: " + sql); // // User u = null; // if (rs.next()) { // u = new User(); // u.setUsername(rs.getString("username")); // u.setPassword(rs.getString("password")); // } // JdbcUtil.close(conn,ps,rs); // return u; // } // } // // Path: src/main/java/com/adintellig/ella/model/user/User.java // public class User { // // private String username; // private String password; // private Timestamp update_time; // // 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 Timestamp getUpdate_time() { // return update_time; // } // // public void setUpdate_time(Timestamp update_time) { // this.update_time = update_time; // } // // } // Path: src/main/java/com/adintellig/ella/action/LoginServlet.java import java.io.IOException; import java.sql.SQLException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.dao.UserDaoImpl; import com.adintellig.ella.model.user.User; package com.adintellig.ella.action; public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; private static Logger logger = LoggerFactory.getLogger(LoginServlet.class);
UserDaoImpl dao = new UserDaoImpl();
mayanhui/ella
src/main/java/com/adintellig/ella/action/LoginServlet.java
// Path: src/main/java/com/adintellig/ella/dao/UserDaoImpl.java // public class UserDaoImpl { // private static Logger logger = LoggerFactory.getLogger(UserDaoImpl.class); // // public User findByNameAndPassword(String username, String password) // throws SQLException { // String sql = "select * from hbase.user where username=? and password=?"; // // Connection conn = JdbcUtil.getConnection(); // PreparedStatement ps = conn.prepareStatement(sql); // ps.setString(1, username); // ps.setString(2, password); // ResultSet rs = ps.executeQuery(); // logger.info("[QUERY]: " + sql); // // User u = null; // if (rs.next()) { // u = new User(); // u.setUsername(rs.getString("username")); // u.setPassword(rs.getString("password")); // } // JdbcUtil.close(conn,ps,rs); // return u; // } // } // // Path: src/main/java/com/adintellig/ella/model/user/User.java // public class User { // // private String username; // private String password; // private Timestamp update_time; // // 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 Timestamp getUpdate_time() { // return update_time; // } // // public void setUpdate_time(Timestamp update_time) { // this.update_time = update_time; // } // // }
import java.io.IOException; import java.sql.SQLException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.dao.UserDaoImpl; import com.adintellig.ella.model.user.User;
package com.adintellig.ella.action; public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; private static Logger logger = LoggerFactory.getLogger(LoginServlet.class); UserDaoImpl dao = new UserDaoImpl(); @Override public void init() throws ServletException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info("{POST}"); RequestDispatcher dispatcher = null; String username = request.getParameter("username").trim(); String password = request.getParameter("password").trim(); HttpSession session = request.getSession(true); String sessionUsername = (String) session.getAttribute("username"); logger.info("username=" + username + " password=" + password + " sessionuname=" + sessionUsername); if (null != sessionUsername && sessionUsername.length() > 0) sessionUsername = sessionUsername.trim(); if (username.equals(sessionUsername)) { dispatcher = request.getRequestDispatcher("/index.jsp"); dispatcher.forward(request, response); } else { try {
// Path: src/main/java/com/adintellig/ella/dao/UserDaoImpl.java // public class UserDaoImpl { // private static Logger logger = LoggerFactory.getLogger(UserDaoImpl.class); // // public User findByNameAndPassword(String username, String password) // throws SQLException { // String sql = "select * from hbase.user where username=? and password=?"; // // Connection conn = JdbcUtil.getConnection(); // PreparedStatement ps = conn.prepareStatement(sql); // ps.setString(1, username); // ps.setString(2, password); // ResultSet rs = ps.executeQuery(); // logger.info("[QUERY]: " + sql); // // User u = null; // if (rs.next()) { // u = new User(); // u.setUsername(rs.getString("username")); // u.setPassword(rs.getString("password")); // } // JdbcUtil.close(conn,ps,rs); // return u; // } // } // // Path: src/main/java/com/adintellig/ella/model/user/User.java // public class User { // // private String username; // private String password; // private Timestamp update_time; // // 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 Timestamp getUpdate_time() { // return update_time; // } // // public void setUpdate_time(Timestamp update_time) { // this.update_time = update_time; // } // // } // Path: src/main/java/com/adintellig/ella/action/LoginServlet.java import java.io.IOException; import java.sql.SQLException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.dao.UserDaoImpl; import com.adintellig.ella.model.user.User; package com.adintellig.ella.action; public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; private static Logger logger = LoggerFactory.getLogger(LoginServlet.class); UserDaoImpl dao = new UserDaoImpl(); @Override public void init() throws ServletException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info("{POST}"); RequestDispatcher dispatcher = null; String username = request.getParameter("username").trim(); String password = request.getParameter("password").trim(); HttpSession session = request.getSession(true); String sessionUsername = (String) session.getAttribute("username"); logger.info("username=" + username + " password=" + password + " sessionuname=" + sessionUsername); if (null != sessionUsername && sessionUsername.length() > 0) sessionUsername = sessionUsername.trim(); if (username.equals(sessionUsername)) { dispatcher = request.getRequestDispatcher("/index.jsp"); dispatcher.forward(request, response); } else { try {
User u = dao.findByNameAndPassword(username, password);
mayanhui/ella
src/main/java/com/adintellig/ella/dao/ServerDaoImpl.java
// Path: src/main/java/com/adintellig/ella/model/Server.java // public class Server { // private String host; // private Timestamp updateTime; // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public Timestamp getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Timestamp updateTime) { // this.updateTime = updateTime; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((host == null) ? 0 : host.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Server other = (Server) obj; // if (host == null) { // if (other.host != null) // return false; // } else if (!host.equals(other.host)) // return false; // return true; // } // // } // // Path: src/main/java/com/adintellig/ella/util/JdbcUtil.java // public class JdbcUtil { // // private static String db_driver; // private static String db_url; // private static String db_userName; // private static String db_passWord; // // static { // ConfigProperties config = ConfigFactory.getInstance() // .getConfigProperties(ConfigFactory.ELLA_CONFIG_PATH); // db_driver = config.getProperty("mysql.db.driver"); // db_url = config.getProperty("mysql.db.url"); // db_userName = config.getProperty("mysql.db.user"); // db_passWord = config.getProperty("mysql.db.pwd"); // } // // public static Connection getConnection() { // Connection con = null; // try { // Class.forName(db_driver); // } catch (ClassNotFoundException e) { // System.out.println("3-ClassNotFoundException"); // e.printStackTrace(); // return null; // } // try { // con = DriverManager.getConnection(db_url, db_userName, db_passWord); // } catch (SQLException e) { // System.out.println("4-SQLException"); // e.printStackTrace(); // return null; // } // return con; // } // // public static void close(Connection con, Statement stmt, ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("5--SQLException"); // e.printStackTrace(); // } // } // if (stmt != null) { // try { // stmt.close(); // } catch (SQLException e) { // System.out.println("6-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("7-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con, PreparedStatement pstmt, // ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("8-SQLException"); // e.printStackTrace(); // } // } // if (pstmt != null) { // try { // pstmt.close(); // } catch (SQLException e) { // System.out.println("9-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("10-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con) { // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("11-closeSQLException"); // e.printStackTrace(); // } // } // } // // }
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.Server; import com.adintellig.ella.util.JdbcUtil;
package com.adintellig.ella.dao; public class ServerDaoImpl { private static Logger logger = LoggerFactory.getLogger(ServerDaoImpl.class); static final String insertSQL = "INSERT INTO hbase.servers(host, update_time) " + "VALUES(?, ?)";
// Path: src/main/java/com/adintellig/ella/model/Server.java // public class Server { // private String host; // private Timestamp updateTime; // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public Timestamp getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Timestamp updateTime) { // this.updateTime = updateTime; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((host == null) ? 0 : host.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Server other = (Server) obj; // if (host == null) { // if (other.host != null) // return false; // } else if (!host.equals(other.host)) // return false; // return true; // } // // } // // Path: src/main/java/com/adintellig/ella/util/JdbcUtil.java // public class JdbcUtil { // // private static String db_driver; // private static String db_url; // private static String db_userName; // private static String db_passWord; // // static { // ConfigProperties config = ConfigFactory.getInstance() // .getConfigProperties(ConfigFactory.ELLA_CONFIG_PATH); // db_driver = config.getProperty("mysql.db.driver"); // db_url = config.getProperty("mysql.db.url"); // db_userName = config.getProperty("mysql.db.user"); // db_passWord = config.getProperty("mysql.db.pwd"); // } // // public static Connection getConnection() { // Connection con = null; // try { // Class.forName(db_driver); // } catch (ClassNotFoundException e) { // System.out.println("3-ClassNotFoundException"); // e.printStackTrace(); // return null; // } // try { // con = DriverManager.getConnection(db_url, db_userName, db_passWord); // } catch (SQLException e) { // System.out.println("4-SQLException"); // e.printStackTrace(); // return null; // } // return con; // } // // public static void close(Connection con, Statement stmt, ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("5--SQLException"); // e.printStackTrace(); // } // } // if (stmt != null) { // try { // stmt.close(); // } catch (SQLException e) { // System.out.println("6-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("7-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con, PreparedStatement pstmt, // ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("8-SQLException"); // e.printStackTrace(); // } // } // if (pstmt != null) { // try { // pstmt.close(); // } catch (SQLException e) { // System.out.println("9-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("10-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con) { // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("11-closeSQLException"); // e.printStackTrace(); // } // } // } // // } // Path: src/main/java/com/adintellig/ella/dao/ServerDaoImpl.java import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.Server; import com.adintellig.ella.util.JdbcUtil; package com.adintellig.ella.dao; public class ServerDaoImpl { private static Logger logger = LoggerFactory.getLogger(ServerDaoImpl.class); static final String insertSQL = "INSERT INTO hbase.servers(host, update_time) " + "VALUES(?, ?)";
public void batchUpdate(List<Server> beans) throws Exception {
mayanhui/ella
src/main/java/com/adintellig/ella/dao/ServerDaoImpl.java
// Path: src/main/java/com/adintellig/ella/model/Server.java // public class Server { // private String host; // private Timestamp updateTime; // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public Timestamp getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Timestamp updateTime) { // this.updateTime = updateTime; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((host == null) ? 0 : host.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Server other = (Server) obj; // if (host == null) { // if (other.host != null) // return false; // } else if (!host.equals(other.host)) // return false; // return true; // } // // } // // Path: src/main/java/com/adintellig/ella/util/JdbcUtil.java // public class JdbcUtil { // // private static String db_driver; // private static String db_url; // private static String db_userName; // private static String db_passWord; // // static { // ConfigProperties config = ConfigFactory.getInstance() // .getConfigProperties(ConfigFactory.ELLA_CONFIG_PATH); // db_driver = config.getProperty("mysql.db.driver"); // db_url = config.getProperty("mysql.db.url"); // db_userName = config.getProperty("mysql.db.user"); // db_passWord = config.getProperty("mysql.db.pwd"); // } // // public static Connection getConnection() { // Connection con = null; // try { // Class.forName(db_driver); // } catch (ClassNotFoundException e) { // System.out.println("3-ClassNotFoundException"); // e.printStackTrace(); // return null; // } // try { // con = DriverManager.getConnection(db_url, db_userName, db_passWord); // } catch (SQLException e) { // System.out.println("4-SQLException"); // e.printStackTrace(); // return null; // } // return con; // } // // public static void close(Connection con, Statement stmt, ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("5--SQLException"); // e.printStackTrace(); // } // } // if (stmt != null) { // try { // stmt.close(); // } catch (SQLException e) { // System.out.println("6-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("7-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con, PreparedStatement pstmt, // ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("8-SQLException"); // e.printStackTrace(); // } // } // if (pstmt != null) { // try { // pstmt.close(); // } catch (SQLException e) { // System.out.println("9-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("10-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con) { // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("11-closeSQLException"); // e.printStackTrace(); // } // } // } // // }
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.Server; import com.adintellig.ella.util.JdbcUtil;
package com.adintellig.ella.dao; public class ServerDaoImpl { private static Logger logger = LoggerFactory.getLogger(ServerDaoImpl.class); static final String insertSQL = "INSERT INTO hbase.servers(host, update_time) " + "VALUES(?, ?)"; public void batchUpdate(List<Server> beans) throws Exception {
// Path: src/main/java/com/adintellig/ella/model/Server.java // public class Server { // private String host; // private Timestamp updateTime; // // public String getHost() { // return host; // } // // public void setHost(String host) { // this.host = host; // } // // public Timestamp getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Timestamp updateTime) { // this.updateTime = updateTime; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((host == null) ? 0 : host.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (getClass() != obj.getClass()) // return false; // Server other = (Server) obj; // if (host == null) { // if (other.host != null) // return false; // } else if (!host.equals(other.host)) // return false; // return true; // } // // } // // Path: src/main/java/com/adintellig/ella/util/JdbcUtil.java // public class JdbcUtil { // // private static String db_driver; // private static String db_url; // private static String db_userName; // private static String db_passWord; // // static { // ConfigProperties config = ConfigFactory.getInstance() // .getConfigProperties(ConfigFactory.ELLA_CONFIG_PATH); // db_driver = config.getProperty("mysql.db.driver"); // db_url = config.getProperty("mysql.db.url"); // db_userName = config.getProperty("mysql.db.user"); // db_passWord = config.getProperty("mysql.db.pwd"); // } // // public static Connection getConnection() { // Connection con = null; // try { // Class.forName(db_driver); // } catch (ClassNotFoundException e) { // System.out.println("3-ClassNotFoundException"); // e.printStackTrace(); // return null; // } // try { // con = DriverManager.getConnection(db_url, db_userName, db_passWord); // } catch (SQLException e) { // System.out.println("4-SQLException"); // e.printStackTrace(); // return null; // } // return con; // } // // public static void close(Connection con, Statement stmt, ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("5--SQLException"); // e.printStackTrace(); // } // } // if (stmt != null) { // try { // stmt.close(); // } catch (SQLException e) { // System.out.println("6-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("7-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con, PreparedStatement pstmt, // ResultSet rs) { // if (rs != null) { // try { // rs.close(); // } catch (SQLException e) { // System.out.println("8-SQLException"); // e.printStackTrace(); // } // } // if (pstmt != null) { // try { // pstmt.close(); // } catch (SQLException e) { // System.out.println("9-SQLException"); // e.printStackTrace(); // } // } // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("10-closeSQLException"); // e.printStackTrace(); // } // } // } // // public static void close(Connection con) { // if (con != null) { // try { // con.close(); // } catch (SQLException e) { // System.out.println("11-closeSQLException"); // e.printStackTrace(); // } // } // } // // } // Path: src/main/java/com/adintellig/ella/dao/ServerDaoImpl.java import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.adintellig.ella.model.Server; import com.adintellig.ella.util.JdbcUtil; package com.adintellig.ella.dao; public class ServerDaoImpl { private static Logger logger = LoggerFactory.getLogger(ServerDaoImpl.class); static final String insertSQL = "INSERT INTO hbase.servers(host, update_time) " + "VALUES(?, ?)"; public void batchUpdate(List<Server> beans) throws Exception {
Connection con = JdbcUtil.getConnection();
mayanhui/ella
src/main/java/com/adintellig/ella/service/quartz/CronQuartzJob.java
// Path: src/main/java/com/adintellig/ella/hbase/handler/JMXHandler.java // public class JMXHandler extends Thread { // private static Logger logger = LoggerFactory.getLogger(JMXHandler.class); // // private static JMXHandler service; // // private RequestCountDaoImpl reqDao = null; // private TableDaoImpl tblDao = null; // private RegionDaoImpl regDao = null; // private ServerDaoImpl serDao = null; // // private JMXHandler() { // this.reqDao = new RequestCountDaoImpl(); // this.tblDao = new TableDaoImpl(); // this.regDao = new RegionDaoImpl(); // this.serDao = new ServerDaoImpl(); // } // // public static synchronized JMXHandler getInstance() { // if (service == null) // service = new JMXHandler(); // return service; // } // // /** // * 解析live regionserver hostname // * 输入格式:slave,16020,1496208060829;master,16020,1496208216136 // * // * @param rsList // * @return // */ // public List<Object> parseLiveRSHostname(String rsList) { // List<Object> hosts = new ArrayList<Object>(); // if (null != rsList && rsList.length() > 0) { // String[] arr = rsList.split(";"); // for (String hostString : arr) { // String[] partStringArr = hostString.split(","); // if (partStringArr.length == 3) { // hosts.add(partStringArr[0]); // } // } // } // return hosts; // } // // @Override // public void run() { // // List<Region> rgs = new ArrayList<Region>(); // List<Server> ses = new ArrayList<Server>(); // List<Table> tbs = new ArrayList<Table>(); // // // 获取Master的JMX信息 // JMXHMasterHandler handler = JMXHMasterHandler.getInstance(); // LiveRegionServerBeans beans = (LiveRegionServerBeans) handler.handle(); // for (Object obj : parseLiveRSHostname(beans.getBeans()[0].getLiveRegionServers())) { // logger.info("测试hostname:" + obj); // /* 获取RS的JMX信息 */ // RegionBeans rbs = (RegionBeans) new JMXRegionServerHandler((String) obj).handle(); // // /* 将获取RS信息转换为基础数据模型(mysql表模型),并写入数据库 */ // try { // // region count // List<RequestCount> list = RequestPopulator.populateRegionRequestCount(rbs); // reqDao.batchAdd(list); // logger.info("[INSERT] Load Region Count info into 'region_requests'. Size=" + list.size()); // // // add region check // List<Region> regions = RequestPopulator.populateRegions(list); // rgs.addAll(regions); // // // server count // list = RequestPopulator.populateRegionServerRequestCount(rbs); // reqDao.batchAdd(list); // logger.info("[INSERT] Load Server Count info into 'server_requests'. Size=" + list.size()); // // // add server check // List<Server> servers = RequestPopulator.populateServers(list); // ses.addAll(servers); // // // table count // list = RequestPopulator.populateTableRequestCount(rbs); // reqDao.batchAdd(list); // logger.info("[INSERT] Load Table Count info into 'table_requests'. Size=" + list.size()); // // // add table check // List<Table> tables = RequestPopulator.populateTables(list); // tbs.addAll(tables); // // } catch (SQLException e) { // e.printStackTrace(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // /* region/table/server check */ // try { // if (regDao.needUpdate(rgs)) { // regDao.truncate(); // regDao.batchUpdate(rgs); // } // // if (serDao.needUpdate(ses)) { // serDao.truncate(); // serDao.batchUpdate(ses); // } // // if (tblDao.needUpdate(tbs)) { // tblDao.truncate(); // tblDao.batchUpdate(tbs); // } // } catch (Exception e) { // e.printStackTrace(); // } // // } // // public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException, SQLException { // JMXHandler service = JMXHandler.getInstance(); // Thread t = new Thread(service); // t.start(); // } // }
import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import com.adintellig.ella.hbase.handler.JMXHandler;
package com.adintellig.ella.service.quartz; public class CronQuartzJob implements Job { public CronQuartzJob() { } @Override public void execute(JobExecutionContext context) throws JobExecutionException {
// Path: src/main/java/com/adintellig/ella/hbase/handler/JMXHandler.java // public class JMXHandler extends Thread { // private static Logger logger = LoggerFactory.getLogger(JMXHandler.class); // // private static JMXHandler service; // // private RequestCountDaoImpl reqDao = null; // private TableDaoImpl tblDao = null; // private RegionDaoImpl regDao = null; // private ServerDaoImpl serDao = null; // // private JMXHandler() { // this.reqDao = new RequestCountDaoImpl(); // this.tblDao = new TableDaoImpl(); // this.regDao = new RegionDaoImpl(); // this.serDao = new ServerDaoImpl(); // } // // public static synchronized JMXHandler getInstance() { // if (service == null) // service = new JMXHandler(); // return service; // } // // /** // * 解析live regionserver hostname // * 输入格式:slave,16020,1496208060829;master,16020,1496208216136 // * // * @param rsList // * @return // */ // public List<Object> parseLiveRSHostname(String rsList) { // List<Object> hosts = new ArrayList<Object>(); // if (null != rsList && rsList.length() > 0) { // String[] arr = rsList.split(";"); // for (String hostString : arr) { // String[] partStringArr = hostString.split(","); // if (partStringArr.length == 3) { // hosts.add(partStringArr[0]); // } // } // } // return hosts; // } // // @Override // public void run() { // // List<Region> rgs = new ArrayList<Region>(); // List<Server> ses = new ArrayList<Server>(); // List<Table> tbs = new ArrayList<Table>(); // // // 获取Master的JMX信息 // JMXHMasterHandler handler = JMXHMasterHandler.getInstance(); // LiveRegionServerBeans beans = (LiveRegionServerBeans) handler.handle(); // for (Object obj : parseLiveRSHostname(beans.getBeans()[0].getLiveRegionServers())) { // logger.info("测试hostname:" + obj); // /* 获取RS的JMX信息 */ // RegionBeans rbs = (RegionBeans) new JMXRegionServerHandler((String) obj).handle(); // // /* 将获取RS信息转换为基础数据模型(mysql表模型),并写入数据库 */ // try { // // region count // List<RequestCount> list = RequestPopulator.populateRegionRequestCount(rbs); // reqDao.batchAdd(list); // logger.info("[INSERT] Load Region Count info into 'region_requests'. Size=" + list.size()); // // // add region check // List<Region> regions = RequestPopulator.populateRegions(list); // rgs.addAll(regions); // // // server count // list = RequestPopulator.populateRegionServerRequestCount(rbs); // reqDao.batchAdd(list); // logger.info("[INSERT] Load Server Count info into 'server_requests'. Size=" + list.size()); // // // add server check // List<Server> servers = RequestPopulator.populateServers(list); // ses.addAll(servers); // // // table count // list = RequestPopulator.populateTableRequestCount(rbs); // reqDao.batchAdd(list); // logger.info("[INSERT] Load Table Count info into 'table_requests'. Size=" + list.size()); // // // add table check // List<Table> tables = RequestPopulator.populateTables(list); // tbs.addAll(tables); // // } catch (SQLException e) { // e.printStackTrace(); // } catch (Exception e) { // e.printStackTrace(); // } // } // // /* region/table/server check */ // try { // if (regDao.needUpdate(rgs)) { // regDao.truncate(); // regDao.batchUpdate(rgs); // } // // if (serDao.needUpdate(ses)) { // serDao.truncate(); // serDao.batchUpdate(ses); // } // // if (tblDao.needUpdate(tbs)) { // tblDao.truncate(); // tblDao.batchUpdate(tbs); // } // } catch (Exception e) { // e.printStackTrace(); // } // // } // // public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException, SQLException { // JMXHandler service = JMXHandler.getInstance(); // Thread t = new Thread(service); // t.start(); // } // } // Path: src/main/java/com/adintellig/ella/service/quartz/CronQuartzJob.java import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import com.adintellig.ella.hbase.handler.JMXHandler; package com.adintellig.ella.service.quartz; public class CronQuartzJob implements Job { public CronQuartzJob() { } @Override public void execute(JobExecutionContext context) throws JobExecutionException {
JMXHandler service = JMXHandler.getInstance();
mayanhui/ella
src/main/java/com/adintellig/ella/util/RequestCountUtil.java
// Path: src/main/java/com/adintellig/ella/model/RequestCount.java // public class RequestCount { // private long writeCount = 0l; // private long readCount = 0l; // private long totalCount = 0l; // private Timestamp updateTime = null; // private Timestamp insertTime = null; // private int writeTps = 0; // private int readTps = 0; // private int totalTps = 0; // // public RequestCount() { // } // // public RequestCount(long writeCount, long readCount, long totalCount, // Timestamp updateTime, Timestamp insertTime, int writeTps, // int readTps, int totalTps) { // super(); // this.writeCount = writeCount; // this.readCount = readCount; // this.totalCount = totalCount; // this.updateTime = updateTime; // this.insertTime = insertTime; // this.writeTps = writeTps; // this.readTps = readTps; // this.totalTps = totalTps; // } // // public long getWriteCount() { // return writeCount; // } // // public void setWriteCount(long writeCount) { // this.writeCount = writeCount; // } // // public long getReadCount() { // return readCount; // } // // public void setReadCount(long readCount) { // this.readCount = readCount; // } // // public long getTotalCount() { // return totalCount; // } // // public void setTotalCount(long totalCount) { // this.totalCount = totalCount; // } // // public Timestamp getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Timestamp updateTime) { // this.updateTime = updateTime; // } // // public Timestamp getInsertTime() { // return insertTime; // } // // public void setInsertTime(Timestamp insertTime) { // this.insertTime = insertTime; // } // // public int getWriteTps() { // return writeTps; // } // // public void setWriteTps(int writeTps) { // this.writeTps = writeTps; // } // // public int getReadTps() { // return readTps; // } // // public void setReadTps(int readTps) { // this.readTps = readTps; // } // // public int getTotalTps() { // return totalTps; // } // // public void setTotalTps(int totalTps) { // this.totalTps = totalTps; // } // // }
import java.util.List; import com.adintellig.ella.model.RequestCount;
package com.adintellig.ella.util; public class RequestCountUtil { public static final String WRITE = "WRITE"; public static final String READ = "READ"; public static final String TOTAL = "TOTAL";
// Path: src/main/java/com/adintellig/ella/model/RequestCount.java // public class RequestCount { // private long writeCount = 0l; // private long readCount = 0l; // private long totalCount = 0l; // private Timestamp updateTime = null; // private Timestamp insertTime = null; // private int writeTps = 0; // private int readTps = 0; // private int totalTps = 0; // // public RequestCount() { // } // // public RequestCount(long writeCount, long readCount, long totalCount, // Timestamp updateTime, Timestamp insertTime, int writeTps, // int readTps, int totalTps) { // super(); // this.writeCount = writeCount; // this.readCount = readCount; // this.totalCount = totalCount; // this.updateTime = updateTime; // this.insertTime = insertTime; // this.writeTps = writeTps; // this.readTps = readTps; // this.totalTps = totalTps; // } // // public long getWriteCount() { // return writeCount; // } // // public void setWriteCount(long writeCount) { // this.writeCount = writeCount; // } // // public long getReadCount() { // return readCount; // } // // public void setReadCount(long readCount) { // this.readCount = readCount; // } // // public long getTotalCount() { // return totalCount; // } // // public void setTotalCount(long totalCount) { // this.totalCount = totalCount; // } // // public Timestamp getUpdateTime() { // return updateTime; // } // // public void setUpdateTime(Timestamp updateTime) { // this.updateTime = updateTime; // } // // public Timestamp getInsertTime() { // return insertTime; // } // // public void setInsertTime(Timestamp insertTime) { // this.insertTime = insertTime; // } // // public int getWriteTps() { // return writeTps; // } // // public void setWriteTps(int writeTps) { // this.writeTps = writeTps; // } // // public int getReadTps() { // return readTps; // } // // public void setReadTps(int readTps) { // this.readTps = readTps; // } // // public int getTotalTps() { // return totalTps; // } // // public void setTotalTps(int totalTps) { // this.totalTps = totalTps; // } // // } // Path: src/main/java/com/adintellig/ella/util/RequestCountUtil.java import java.util.List; import com.adintellig.ella.model.RequestCount; package com.adintellig.ella.util; public class RequestCountUtil { public static final String WRITE = "WRITE"; public static final String READ = "READ"; public static final String TOTAL = "TOTAL";
public static int sumTps(List<RequestCount> tables, String type) {
spearal/spearal-java
src/main/java/org/spearal/impl/coder/BeanCoder.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class BeanCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return this; } @Override
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/coder/BeanCoder.java import java.io.IOException; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class BeanCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return this; } @Override
public void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException {
spearal/spearal-java
src/main/java/org/spearal/Spearal.java
// Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // }
import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF * @author William DRAI */ public class Spearal { public final static String APPLICATION_SPEARAL = "application/spearal"; public final static String PROPERTY_FILTER_HEADER = "Spearal-PropertyFilter"; public static void undefine(Object object, String propertyName) {
// Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // Path: src/main/java/org/spearal/Spearal.java import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF * @author William DRAI */ public class Spearal { public final static String APPLICATION_SPEARAL = "application/spearal"; public final static String PROPERTY_FILTER_HEADER = "Spearal-PropertyFilter"; public static void undefine(Object object, String propertyName) {
if (!(object instanceof PartialObjectProxy))
spearal/spearal-java
src/main/java/org/spearal/impl/property/StringProperty.java
// Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.property; /** * @author Franck WOLFF */ public class StringProperty extends AnyProperty { public StringProperty(String name, Field field, Method getter, Method setter) { super(name, field, getter, setter); } @Override
// Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/property/StringProperty.java import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.property; /** * @author Franck WOLFF */ public class StringProperty extends AnyProperty { public StringProperty(String name, Field field, Method getter, Method setter) { super(name, field, getter, setter); } @Override
public void write(ExtendedSpearalEncoder encoder, Object holder)
spearal/spearal-java
src/main/java/org/spearal/impl/coder/CollectionCoder.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import java.util.Collection; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class CollectionCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (Collection.class.isAssignableFrom(valueClass) ? this : null); } @Override
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/coder/CollectionCoder.java import java.io.IOException; import java.util.Collection; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class CollectionCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (Collection.class.isAssignableFrom(valueClass) ? this : null); } @Override
public void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException {
spearal/spearal-java
src/main/java/org/spearal/impl/security/SecurizerImpl.java
// Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // } // // Path: src/main/java/org/spearal/impl/util/TypeUtil.java // public abstract class TypeUtil { // // public static Class<?> classOfType(Type type) { // if (type instanceof Class<?>) // return (Class<?>)type; // if (type instanceof ParameterizedType) // return (Class<?>)((ParameterizedType)type).getRawType(); // if (type instanceof WildcardType) { // // Forget lower bounds and only deal with first upper bound... // Type[] ubs = ((WildcardType)type).getUpperBounds(); // if (ubs.length > 0) // return classOfType(ubs[0]); // } // if (type instanceof GenericArrayType) { // Class<?> ct = classOfType(((GenericArrayType)type).getGenericComponentType()); // return (ct != null ? Array.newInstance(ct, 0).getClass() : Object[].class); // } // if (type instanceof TypeVariable<?>) { // // Only deal with first (upper) bound... // Type[] ubs = ((TypeVariable<?>)type).getBounds(); // if (ubs.length > 0) // return classOfType(ubs[0]); // } // // Should never append... // return Object.class; // } // // public static Type unwrapTypeVariable(Type type) { // if (type instanceof TypeVariable) // return getBoundType((TypeVariable<?>)type); // return type; // } // // public static Type getBoundType(TypeVariable<?> typeVariable) { // Type[] ubs = typeVariable.getBounds(); // if (ubs.length > 0) // return ubs[0]; // // // should never happen... // if (typeVariable.getGenericDeclaration() instanceof Type) // return (Type)typeVariable.getGenericDeclaration(); // return typeVariable; // } // // public static Type getElementType(Type collectionType) { // Class<?> collectionClass = classOfType(collectionType); // // if (collectionClass.isArray()) // return collectionClass.getComponentType(); // // if (Collection.class.isAssignableFrom(collectionClass) && collectionType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)collectionType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 1) // return componentTypes[0]; // } // // return Object.class; // } // // public static Type getKeyType(Type mapType) { // if (mapType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)mapType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 2) // return componentTypes[0]; // } // return Object.class; // } // // public static Type getValueType(Type mapType) { // if (mapType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)mapType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 2) // return componentTypes[1]; // } // return Object.class; // } // // public static Type[] getKeyValueType(Type mapType) { // if (mapType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)mapType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 2) // return componentTypes; // } // return new Type[] {Object.class, Object.class}; // } // }
import java.io.Serializable; import java.lang.reflect.Type; import org.spearal.configuration.Securizer; import org.spearal.impl.util.TypeUtil;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.security; /** * @author Franck WOLFF */ public class SecurizerImpl implements Securizer { @Override public void checkDecodable(Type type) throws SecurityException {
// Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // } // // Path: src/main/java/org/spearal/impl/util/TypeUtil.java // public abstract class TypeUtil { // // public static Class<?> classOfType(Type type) { // if (type instanceof Class<?>) // return (Class<?>)type; // if (type instanceof ParameterizedType) // return (Class<?>)((ParameterizedType)type).getRawType(); // if (type instanceof WildcardType) { // // Forget lower bounds and only deal with first upper bound... // Type[] ubs = ((WildcardType)type).getUpperBounds(); // if (ubs.length > 0) // return classOfType(ubs[0]); // } // if (type instanceof GenericArrayType) { // Class<?> ct = classOfType(((GenericArrayType)type).getGenericComponentType()); // return (ct != null ? Array.newInstance(ct, 0).getClass() : Object[].class); // } // if (type instanceof TypeVariable<?>) { // // Only deal with first (upper) bound... // Type[] ubs = ((TypeVariable<?>)type).getBounds(); // if (ubs.length > 0) // return classOfType(ubs[0]); // } // // Should never append... // return Object.class; // } // // public static Type unwrapTypeVariable(Type type) { // if (type instanceof TypeVariable) // return getBoundType((TypeVariable<?>)type); // return type; // } // // public static Type getBoundType(TypeVariable<?> typeVariable) { // Type[] ubs = typeVariable.getBounds(); // if (ubs.length > 0) // return ubs[0]; // // // should never happen... // if (typeVariable.getGenericDeclaration() instanceof Type) // return (Type)typeVariable.getGenericDeclaration(); // return typeVariable; // } // // public static Type getElementType(Type collectionType) { // Class<?> collectionClass = classOfType(collectionType); // // if (collectionClass.isArray()) // return collectionClass.getComponentType(); // // if (Collection.class.isAssignableFrom(collectionClass) && collectionType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)collectionType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 1) // return componentTypes[0]; // } // // return Object.class; // } // // public static Type getKeyType(Type mapType) { // if (mapType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)mapType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 2) // return componentTypes[0]; // } // return Object.class; // } // // public static Type getValueType(Type mapType) { // if (mapType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)mapType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 2) // return componentTypes[1]; // } // return Object.class; // } // // public static Type[] getKeyValueType(Type mapType) { // if (mapType instanceof ParameterizedType) { // Type[] componentTypes = ((ParameterizedType)mapType).getActualTypeArguments(); // if (componentTypes != null && componentTypes.length == 2) // return componentTypes; // } // return new Type[] {Object.class, Object.class}; // } // } // Path: src/main/java/org/spearal/impl/security/SecurizerImpl.java import java.io.Serializable; import java.lang.reflect.Type; import org.spearal.configuration.Securizer; import org.spearal.impl.util.TypeUtil; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.security; /** * @author Franck WOLFF */ public class SecurizerImpl implements Securizer { @Override public void checkDecodable(Type type) throws SecurityException {
if (!Serializable.class.isAssignableFrom(TypeUtil.classOfType(type)))
spearal/spearal-java
src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // }
import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.instantiator; /** * @author Franck WOLFF */ public class ProxyInstantiator implements TypeInstantiatorProvider, TypeInstantiator,
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // Path: src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.instantiator; /** * @author Franck WOLFF */ public class ProxyInstantiator implements TypeInstantiatorProvider, TypeInstantiator,
PropertyInstantiatorProvider, PropertyInstantiator {
spearal/spearal-java
src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // }
import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.instantiator; /** * @author Franck WOLFF */ public class ProxyInstantiator implements TypeInstantiatorProvider, TypeInstantiator,
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // Path: src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.instantiator; /** * @author Franck WOLFF */ public class ProxyInstantiator implements TypeInstantiatorProvider, TypeInstantiator,
PropertyInstantiatorProvider, PropertyInstantiator {
spearal/spearal-java
src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // }
import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.instantiator; /** * @author Franck WOLFF */ public class ProxyInstantiator implements TypeInstantiatorProvider, TypeInstantiator, PropertyInstantiatorProvider, PropertyInstantiator { @Override public TypeInstantiator getInstantiator(Type type) { return (canInstantiate(type) ? this : null); } @Override
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // Path: src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.instantiator; /** * @author Franck WOLFF */ public class ProxyInstantiator implements TypeInstantiatorProvider, TypeInstantiator, PropertyInstantiatorProvider, PropertyInstantiator { @Override public TypeInstantiator getInstantiator(Type type) { return (canInstantiate(type) ? this : null); } @Override
public Object instantiate(SpearalContext context, Type type, Object param) {
spearal/spearal-java
src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // }
import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider;
private final Property[] properties; private Map<String, Property> definedProperties = new HashMap<String, Property>(); public PropertiesInvocationHandler(SpearalContext context, Property[] properties) { this(context, properties, null); } public PropertiesInvocationHandler(SpearalContext context, Property[] properties, Property[] definedProperties) { this.context = context; this.methods = new HashMap<Method, String>(); this.values = new HashMap<String, Object>(); this.properties = properties; for (Property property : properties) { methods.put(property.getGetter(), property.getName()); if (property.getSetter() != null) methods.put(property.getSetter(), property.getName()); } if (definedProperties != null) { for (Property property : definedProperties) { this.definedProperties.put(property.getName(), property); this.values.put(property.getName(), null); } } } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // Path: src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider; private final Property[] properties; private Map<String, Property> definedProperties = new HashMap<String, Property>(); public PropertiesInvocationHandler(SpearalContext context, Property[] properties) { this(context, properties, null); } public PropertiesInvocationHandler(SpearalContext context, Property[] properties, Property[] definedProperties) { this.context = context; this.methods = new HashMap<Method, String>(); this.values = new HashMap<String, Object>(); this.properties = properties; for (Property property : properties) { methods.put(property.getGetter(), property.getName()); if (property.getSetter() != null) methods.put(property.getSetter(), property.getName()); } if (definedProperties != null) { for (Property property : definedProperties) { this.definedProperties.put(property.getName(), property); this.values.put(property.getName(), null); } } } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getDeclaringClass() == PartialObjectProxy.class) {
spearal/spearal-java
src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // }
import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider;
if (values.containsKey(args[0])) return true; if (definedProperties.containsKey(args[0])) return true; return false; } else if ("$undefine".equals(method.getName()) && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == String.class) { values.remove(args[0]); return definedProperties.remove(args[0]); } else if ("$getDefinedProperties".equals(method.getName()) && method.getParameterTypes().length == 0) return definedProperties.values().toArray(new Property[definedProperties.size()]); } String propertyName = methods.get(method); if (propertyName != null) { if (method.getName().startsWith("set")) { values.put(propertyName, args[0]); Property property = null; for (Property p : properties) { if (p.getName().equals(propertyName)) { property = p; break; } } definedProperties.put(propertyName, property); } else { if (!values.containsKey(propertyName))
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public static class UndefinedPropertyException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public UndefinedPropertyException(String propertyName) { // super("Property '" + propertyName + "' is undefined"); // } // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiatorProvider extends Repeatable { // // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // PropertyInstantiator getInstantiator(Property property); // } // // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java // public interface PropertyInstantiator { // // Object instantiate(SpearalContext context, Property property, Object param); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiatorProvider extends Repeatable { // // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // // TypeInstantiator getInstantiator(Type type); // } // // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java // public interface TypeInstantiator { // // Object instantiate(SpearalContext context, Type type, Object param); // } // Path: src/main/java/org/spearal/impl/instantiator/ProxyInstantiator.java import org.spearal.configuration.PropertyInstantiatorProvider.PropertyInstantiator; import org.spearal.configuration.TypeInstantiatorProvider; import org.spearal.configuration.TypeInstantiatorProvider.TypeInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PartialObjectFactory.UndefinedPropertyException; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.PropertyInstantiatorProvider; if (values.containsKey(args[0])) return true; if (definedProperties.containsKey(args[0])) return true; return false; } else if ("$undefine".equals(method.getName()) && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == String.class) { values.remove(args[0]); return definedProperties.remove(args[0]); } else if ("$getDefinedProperties".equals(method.getName()) && method.getParameterTypes().length == 0) return definedProperties.values().toArray(new Property[definedProperties.size()]); } String propertyName = methods.get(method); if (propertyName != null) { if (method.getName().startsWith("set")) { values.put(propertyName, args[0]); Property property = null; for (Property p : properties) { if (p.getName().equals(propertyName)) { property = p; break; } } definedProperties.put(propertyName, property); } else { if (!values.containsKey(propertyName))
throw new UndefinedPropertyException(method.toString());
spearal/spearal-java
src/test/java/org/spearal/test/TestCollection.java
// Path: src/test/java/org/spearal/test/model/SimpleBean.java // public class SimpleBean implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean booleanValue; // private int intValue; // private double doubleValue; // private String stringValue; // // // public SimpleBean() { // } // // public SimpleBean(boolean booleanValue, int intValue, double doubleValue, String stringValue) { // this.booleanValue = booleanValue; // this.intValue = intValue; // this.doubleValue = doubleValue; // this.stringValue = stringValue; // } // // public boolean isBooleanValue() { // return booleanValue; // } // // public void setBooleanValue(boolean booleanValue) { // this.booleanValue = booleanValue; // } // // public int getIntValue() { // return intValue; // } // // public void setIntValue(int intValue) { // this.intValue = intValue; // } // // public double getDoubleValue() { // return doubleValue; // } // // public void setDoubleValue(double doubleValue) { // this.doubleValue = doubleValue; // } // // public String getStringValue() { // return stringValue; // } // // public void setStringValue(String stringValue) { // this.stringValue = stringValue; // } // // @Override // public int hashCode() { // return ( // (booleanValue ? 1 : 0) + // intValue + // (int)doubleValue + // (stringValue == null ? 0 : stringValue.hashCode()) // ); // } // // @Override // public boolean equals(Object obj) { // if (obj == this) // return true; // if (!(obj instanceof SimpleBean)) // return false; // SimpleBean that = (SimpleBean)obj; // return ( // booleanValue == that.booleanValue && // intValue == that.intValue && // Double.compare(doubleValue, that.doubleValue) == 0 && // (stringValue == that.stringValue || (stringValue != null && stringValue.equals(that.stringValue))) // ); // } // }
import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Random; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.SimpleBean;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestCollection extends AbstractSpearalTestUnit { @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException { encodeDecode(new ArrayList<Object>(), -1); encodeDecode(Arrays.asList("abc", "def", "abc"), -1); encodeDecode(Arrays.asList(
// Path: src/test/java/org/spearal/test/model/SimpleBean.java // public class SimpleBean implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean booleanValue; // private int intValue; // private double doubleValue; // private String stringValue; // // // public SimpleBean() { // } // // public SimpleBean(boolean booleanValue, int intValue, double doubleValue, String stringValue) { // this.booleanValue = booleanValue; // this.intValue = intValue; // this.doubleValue = doubleValue; // this.stringValue = stringValue; // } // // public boolean isBooleanValue() { // return booleanValue; // } // // public void setBooleanValue(boolean booleanValue) { // this.booleanValue = booleanValue; // } // // public int getIntValue() { // return intValue; // } // // public void setIntValue(int intValue) { // this.intValue = intValue; // } // // public double getDoubleValue() { // return doubleValue; // } // // public void setDoubleValue(double doubleValue) { // this.doubleValue = doubleValue; // } // // public String getStringValue() { // return stringValue; // } // // public void setStringValue(String stringValue) { // this.stringValue = stringValue; // } // // @Override // public int hashCode() { // return ( // (booleanValue ? 1 : 0) + // intValue + // (int)doubleValue + // (stringValue == null ? 0 : stringValue.hashCode()) // ); // } // // @Override // public boolean equals(Object obj) { // if (obj == this) // return true; // if (!(obj instanceof SimpleBean)) // return false; // SimpleBean that = (SimpleBean)obj; // return ( // booleanValue == that.booleanValue && // intValue == that.intValue && // Double.compare(doubleValue, that.doubleValue) == 0 && // (stringValue == that.stringValue || (stringValue != null && stringValue.equals(that.stringValue))) // ); // } // } // Path: src/test/java/org/spearal/test/TestCollection.java import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Random; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.SimpleBean; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestCollection extends AbstractSpearalTestUnit { @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException { encodeDecode(new ArrayList<Object>(), -1); encodeDecode(Arrays.asList("abc", "def", "abc"), -1); encodeDecode(Arrays.asList(
new SimpleBean(true, 3, -0.1, "abc"),
spearal/spearal-java
src/main/java/org/spearal/impl/coder/ArrayCoder.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class ArrayCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (valueClass.isArray() ? this : null); } @Override
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/coder/ArrayCoder.java import java.io.IOException; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class ArrayCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (valueClass.isArray() ? this : null); } @Override
public void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException {
spearal/spearal-java
src/main/java/org/spearal/impl/SpearalPropertyFilterImpl.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl; /** * @author Franck WOLFF */ public class SpearalPropertyFilterImpl implements SpearalPropertyFilter { private final SpearalContext context;
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/impl/SpearalPropertyFilterImpl.java import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl; /** * @author Franck WOLFF */ public class SpearalPropertyFilterImpl implements SpearalPropertyFilter { private final SpearalContext context;
private final Map<Class<?>, Property[]> propertiesMap;
spearal/spearal-java
src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // }
import java.lang.reflect.Type; import org.spearal.SpearalContext;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface TypeInstantiatorProvider extends Repeatable { public interface TypeInstantiator {
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // Path: src/main/java/org/spearal/configuration/TypeInstantiatorProvider.java import java.lang.reflect.Type; import org.spearal.SpearalContext; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface TypeInstantiatorProvider extends Repeatable { public interface TypeInstantiator {
Object instantiate(SpearalContext context, Type type, Object param);
spearal/spearal-java
src/main/java/org/spearal/impl/cache/AnyMap.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // }
import org.spearal.SpearalContext;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public interface AnyMap<K, P, V> extends Cloneable { V get(K key);
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // Path: src/main/java/org/spearal/impl/cache/AnyMap.java import org.spearal.SpearalContext; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public interface AnyMap<K, P, V> extends Cloneable { V get(K key);
V putIfAbsent(SpearalContext context, K key);
spearal/spearal-java
src/main/java/org/spearal/SpearalDecoder.java
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import java.io.IOException; import java.lang.reflect.Type; import java.util.Collection; import java.util.List; import java.util.Map; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalDecoder { public interface Path { Collection<PathSegment> segments(); } public interface PathSegment { PathSegment copy(); } public interface CollectionPathSegment extends PathSegment { public Collection<?> getCollection(); public int getIndex(); } public interface ArrayPathSegment extends PathSegment { public Object getArray(); public int getIndex(); } public interface MapPathSegment extends PathSegment { public Map<?, ?> getMap(); public Object getKey(); } public interface BeanPathSegment extends PathSegment { public Object getBean();
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/SpearalDecoder.java import java.io.IOException; import java.lang.reflect.Type; import java.util.Collection; import java.util.List; import java.util.Map; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalDecoder { public interface Path { Collection<PathSegment> segments(); } public interface PathSegment { PathSegment copy(); } public interface CollectionPathSegment extends PathSegment { public Collection<?> getCollection(); public int getIndex(); } public interface ArrayPathSegment extends PathSegment { public Object getArray(); public int getIndex(); } public interface MapPathSegment extends PathSegment { public Map<?, ?> getMap(); public Object getKey(); } public interface BeanPathSegment extends PathSegment { public Object getBean();
public Property getProperty();
spearal/spearal-java
src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java
// Path: src/main/java/org/spearal/SpearalDecoder.java // public interface SpearalDecoder { // // public interface Path { // // Collection<PathSegment> segments(); // } // // public interface PathSegment { // // PathSegment copy(); // } // // public interface CollectionPathSegment extends PathSegment { // // public Collection<?> getCollection(); // public int getIndex(); // } // // public interface ArrayPathSegment extends PathSegment { // // public Object getArray(); // public int getIndex(); // } // // public interface MapPathSegment extends PathSegment { // // public Map<?, ?> getMap(); // public Object getKey(); // } // // public interface BeanPathSegment extends PathSegment { // // public Object getBean(); // public Property getProperty(); // } // // SpearalContext getContext(); // // Path getPath(); // boolean containsPartialObjects(); // Map<Object, List<PathSegment>> getPartialObjectsMap(); // // Object readAny() throws IOException; // <T> T readAny(Type targetType) throws IOException; // // void skipAny() throws IOException; // // void printAny(SpearalPrinter printer) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Map; import org.spearal.SpearalDecoder; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl; /** * @author Franck WOLFF */ public interface ExtendedSpearalDecoder extends SpearalDecoder { Object readAny(int parameterizedType) throws IOException; Object readAny(int parameterizedType, Type targetType) throws IOException; void skipAny(int parameterizedType) throws IOException; SpearalDateTime readDateTime(int parameterizedType) throws IOException; long readIntegral(int parameterizedType) throws IOException; BigInteger readBigIntegral(int parameterizedType) throws IOException; double readFloating(int parameterizedType) throws IOException; BigDecimal readBigFloating(int parameterizedType) throws IOException; String readString(int parameterizedType) throws IOException; byte[] readByteArray(int parameterizedType) throws IOException; Object readCollection(int parameterizedType, Type targetType) throws IOException;
// Path: src/main/java/org/spearal/SpearalDecoder.java // public interface SpearalDecoder { // // public interface Path { // // Collection<PathSegment> segments(); // } // // public interface PathSegment { // // PathSegment copy(); // } // // public interface CollectionPathSegment extends PathSegment { // // public Collection<?> getCollection(); // public int getIndex(); // } // // public interface ArrayPathSegment extends PathSegment { // // public Object getArray(); // public int getIndex(); // } // // public interface MapPathSegment extends PathSegment { // // public Map<?, ?> getMap(); // public Object getKey(); // } // // public interface BeanPathSegment extends PathSegment { // // public Object getBean(); // public Property getProperty(); // } // // SpearalContext getContext(); // // Path getPath(); // boolean containsPartialObjects(); // Map<Object, List<PathSegment>> getPartialObjectsMap(); // // Object readAny() throws IOException; // <T> T readAny(Type targetType) throws IOException; // // void skipAny() throws IOException; // // void printAny(SpearalPrinter printer) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Map; import org.spearal.SpearalDecoder; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl; /** * @author Franck WOLFF */ public interface ExtendedSpearalDecoder extends SpearalDecoder { Object readAny(int parameterizedType) throws IOException; Object readAny(int parameterizedType, Type targetType) throws IOException; void skipAny(int parameterizedType) throws IOException; SpearalDateTime readDateTime(int parameterizedType) throws IOException; long readIntegral(int parameterizedType) throws IOException; BigInteger readBigIntegral(int parameterizedType) throws IOException; double readFloating(int parameterizedType) throws IOException; BigDecimal readBigFloating(int parameterizedType) throws IOException; String readString(int parameterizedType) throws IOException; byte[] readByteArray(int parameterizedType) throws IOException; Object readCollection(int parameterizedType, Type targetType) throws IOException;
void readCollection(int parameterizedType, Object holder, Property property)
spearal/spearal-java
src/test/java/org/spearal/test/TestSpearalType.java
// Path: src/main/java/org/spearal/impl/SpearalType.java // public enum SpearalType { // // // No parameters (0x00...0x0f). // // NULL(0x00), // // TRUE(0x01), // FALSE(0x02), // // // 4 bits of parameters (0x10...0xf0). // // INTEGRAL(0x10), // BIG_INTEGRAL(0x20), // // FLOATING(0x30), // BIG_FLOATING(0x40), // // STRING(0x50), // // BYTE_ARRAY(0x60), // // DATE_TIME(0x70), // // COLLECTION(0x80), // MAP(0x90), // // ENUM(0xa0), // CLASS(0xb0), // BEAN(0xc0); // // private static final SpearalType[] SIO_TYPES; // static { // SpearalType[] types = SpearalType.values(); // SIO_TYPES = new SpearalType[0xf0 + 1]; // // for (SpearalType type : types) { // int id = type.id; // if (id < 0 || id > 0xf0 || (id != 0 && (id & 0xf0) != 0 && (id & 0x0f) != 0)) // throw new ExceptionInInitializerError("Illegal type id: " + id); // if (SIO_TYPES[id] != null) // throw new ExceptionInInitializerError("Duplicated ids: " + SIO_TYPES[id] + " / " + type); // SIO_TYPES[id] = type; // } // } // // private final int id; // // SpearalType(int id) { // this.id = id; // } // // public int id() { // return id; // } // // public static SpearalType valueOf(int parameterizedType) { // // if (parameterizedType >= 0x10) { // if (parameterizedType <= 0xff) { // SpearalType type = SIO_TYPES[parameterizedType & 0xf0]; // if (type != null) // return type; // } // } // else if (parameterizedType >= 0) { // SpearalType type = SIO_TYPES[parameterizedType]; // if (type != null) // return type; // } // // throw new IllegalArgumentException("Illegal parameterized type: " + parameterizedType); // } // }
import org.junit.Assert; import org.junit.Test; import org.spearal.impl.SpearalType;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestSpearalType { @Test public void test() { int parameterizedType = Integer.MIN_VALUE; try {
// Path: src/main/java/org/spearal/impl/SpearalType.java // public enum SpearalType { // // // No parameters (0x00...0x0f). // // NULL(0x00), // // TRUE(0x01), // FALSE(0x02), // // // 4 bits of parameters (0x10...0xf0). // // INTEGRAL(0x10), // BIG_INTEGRAL(0x20), // // FLOATING(0x30), // BIG_FLOATING(0x40), // // STRING(0x50), // // BYTE_ARRAY(0x60), // // DATE_TIME(0x70), // // COLLECTION(0x80), // MAP(0x90), // // ENUM(0xa0), // CLASS(0xb0), // BEAN(0xc0); // // private static final SpearalType[] SIO_TYPES; // static { // SpearalType[] types = SpearalType.values(); // SIO_TYPES = new SpearalType[0xf0 + 1]; // // for (SpearalType type : types) { // int id = type.id; // if (id < 0 || id > 0xf0 || (id != 0 && (id & 0xf0) != 0 && (id & 0x0f) != 0)) // throw new ExceptionInInitializerError("Illegal type id: " + id); // if (SIO_TYPES[id] != null) // throw new ExceptionInInitializerError("Duplicated ids: " + SIO_TYPES[id] + " / " + type); // SIO_TYPES[id] = type; // } // } // // private final int id; // // SpearalType(int id) { // this.id = id; // } // // public int id() { // return id; // } // // public static SpearalType valueOf(int parameterizedType) { // // if (parameterizedType >= 0x10) { // if (parameterizedType <= 0xff) { // SpearalType type = SIO_TYPES[parameterizedType & 0xf0]; // if (type != null) // return type; // } // } // else if (parameterizedType >= 0) { // SpearalType type = SIO_TYPES[parameterizedType]; // if (type != null) // return type; // } // // throw new IllegalArgumentException("Illegal parameterized type: " + parameterizedType); // } // } // Path: src/test/java/org/spearal/test/TestSpearalType.java import org.junit.Assert; import org.junit.Test; import org.spearal.impl.SpearalType; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestSpearalType { @Test public void test() { int parameterizedType = Integer.MIN_VALUE; try {
SpearalType.valueOf(parameterizedType);
spearal/spearal-java
src/main/java/org/spearal/impl/coder/EnumCoder.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class EnumCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (Enum.class.isAssignableFrom(valueClass) ? this : null); } @Override
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/coder/EnumCoder.java import java.io.IOException; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class EnumCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (Enum.class.isAssignableFrom(valueClass) ? this : null); } @Override
public void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException {
spearal/spearal-java
src/main/java/org/spearal/SpearalContext.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append);
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // } // Path: src/main/java/org/spearal/SpearalContext.java import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append);
Securizer getSecurizer();
spearal/spearal-java
src/main/java/org/spearal/SpearalContext.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append); Securizer getSecurizer(); String alias(Class<?> cls); String unalias(String aliasedClassName); Class<?> loadClass(String classNames, Type target) throws SecurityException; Object newInstance(Class<?> cls);
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // } // Path: src/main/java/org/spearal/SpearalContext.java import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append); Securizer getSecurizer(); String alias(Class<?> cls); String unalias(String aliasedClassName); Class<?> loadClass(String classNames, Type target) throws SecurityException; Object newInstance(Class<?> cls);
Property[] getProperties(Class<?> cls);
spearal/spearal-java
src/main/java/org/spearal/SpearalContext.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append); Securizer getSecurizer(); String alias(Class<?> cls); String unalias(String aliasedClassName); Class<?> loadClass(String classNames, Type target) throws SecurityException; Object newInstance(Class<?> cls); Property[] getProperties(Class<?> cls); Object instantiate(Type type, Object param) throws InstantiationException, IllegalAccessException; Object instantiate(Property property, Object param) throws InstantiationException, IllegalAccessException; Object instantiatePartial(Class<?> cls, Property[] partialProperties) throws InstantiationException, IllegalAccessException;
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // } // Path: src/main/java/org/spearal/SpearalContext.java import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append); Securizer getSecurizer(); String alias(Class<?> cls); String unalias(String aliasedClassName); Class<?> loadClass(String classNames, Type target) throws SecurityException; Object newInstance(Class<?> cls); Property[] getProperties(Class<?> cls); Object instantiate(Type type, Object param) throws InstantiationException, IllegalAccessException; Object instantiate(Property property, Object param) throws InstantiationException, IllegalAccessException; Object instantiatePartial(Class<?> cls, Property[] partialProperties) throws InstantiationException, IllegalAccessException;
Coder getCoder(Class<?> valueClass);
spearal/spearal-java
src/main/java/org/spearal/SpearalContext.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append); Securizer getSecurizer(); String alias(Class<?> cls); String unalias(String aliasedClassName); Class<?> loadClass(String classNames, Type target) throws SecurityException; Object newInstance(Class<?> cls); Property[] getProperties(Class<?> cls); Object instantiate(Type type, Object param) throws InstantiationException, IllegalAccessException; Object instantiate(Property property, Object param) throws InstantiationException, IllegalAccessException; Object instantiatePartial(Class<?> cls, Property[] partialProperties) throws InstantiationException, IllegalAccessException; Coder getCoder(Class<?> valueClass); String[] getUnfilterableProperties(Class<?> valueClass); Object convert(Object value, Type targetType); Property createProperty(String name, Field field, Method getter, Method setter);
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/configuration/Configurable.java // public interface Configurable { // // } // // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java // public interface FilteredBeanDescriptor { // // String getDescription(); // Property[] getProperties(); // // boolean isCacheable(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/configuration/Securizer.java // public interface Securizer extends Configurable { // // void checkDecodable(Type type) throws SecurityException; // void checkEncodable(Class<?> cls) throws SecurityException; // } // Path: src/main/java/org/spearal/SpearalContext.java import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.configuration.Configurable; import org.spearal.configuration.FilteredBeanDescriptorFactory.FilteredBeanDescriptor; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.configuration.Securizer; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalContext { void configure(Configurable configurable); void configure(Configurable configurable, boolean append); Securizer getSecurizer(); String alias(Class<?> cls); String unalias(String aliasedClassName); Class<?> loadClass(String classNames, Type target) throws SecurityException; Object newInstance(Class<?> cls); Property[] getProperties(Class<?> cls); Object instantiate(Type type, Object param) throws InstantiationException, IllegalAccessException; Object instantiate(Property property, Object param) throws InstantiationException, IllegalAccessException; Object instantiatePartial(Class<?> cls, Property[] partialProperties) throws InstantiationException, IllegalAccessException; Coder getCoder(Class<?> valueClass); String[] getUnfilterableProperties(Class<?> valueClass); Object convert(Object value, Type targetType); Property createProperty(String name, Field field, Method getter, Method setter);
FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value);
spearal/spearal-java
src/main/java/org/spearal/impl/cache/DualIdentityMap.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // }
import org.spearal.SpearalContext;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class DualIdentityMap<K1, K2, V> extends AbstractMap { protected ValueProvider<K1, K2, V> provider; protected Entry<K1, K2, V>[] entries; public DualIdentityMap(ValueProvider<K1, K2, V> provider) { super(); this.provider = provider; } public DualIdentityMap(ValueProvider<K1, K2, V> provider, int capacity) { super(capacity); this.provider = provider; } @SuppressWarnings("unchecked") @Override protected void init(int capacity) { super.init(capacity); this.entries = new Entry[capacity]; } public V get(K1 key1, K2 key2) { int hash = hash(key1, key2); Entry<K1, K2, V>[] entries = this.entries; for (Entry<K1, K2, V> entry = entries[hash & (entries.length - 1)]; entry != null; entry = entry.next) { if (key1 == entry.key1 && key2 == entry.key2) return entry.value; } return null; }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // Path: src/main/java/org/spearal/impl/cache/DualIdentityMap.java import org.spearal.SpearalContext; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class DualIdentityMap<K1, K2, V> extends AbstractMap { protected ValueProvider<K1, K2, V> provider; protected Entry<K1, K2, V>[] entries; public DualIdentityMap(ValueProvider<K1, K2, V> provider) { super(); this.provider = provider; } public DualIdentityMap(ValueProvider<K1, K2, V> provider, int capacity) { super(capacity); this.provider = provider; } @SuppressWarnings("unchecked") @Override protected void init(int capacity) { super.init(capacity); this.entries = new Entry[capacity]; } public V get(K1 key1, K2 key2) { int hash = hash(key1, key2); Entry<K1, K2, V>[] entries = this.entries; for (Entry<K1, K2, V> entry = entries[hash & (entries.length - 1)]; entry != null; entry = entry.next) { if (key1 == entry.key1 && key2 == entry.key2) return entry.value; } return null; }
public V putIfAbsent(SpearalContext context, K1 key1, K2 key2) {
spearal/spearal-java
src/test/java/org/spearal/test/TestEnum.java
// Path: src/test/java/org/spearal/test/model/SimpleEnum.java // public enum SimpleEnum { // A, // BC, // DEF, // GHIJ, // KLMNOPQRSTUVWXYZ // }
import java.io.IOException; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.SimpleEnum;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestEnum extends AbstractSpearalTestUnit { @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException {
// Path: src/test/java/org/spearal/test/model/SimpleEnum.java // public enum SimpleEnum { // A, // BC, // DEF, // GHIJ, // KLMNOPQRSTUVWXYZ // } // Path: src/test/java/org/spearal/test/TestEnum.java import java.io.IOException; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.SimpleEnum; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestEnum extends AbstractSpearalTestUnit { @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException {
int length = SimpleEnum.class.getName().length();
spearal/spearal-java
src/main/java/org/spearal/SpearalPropertyFilter.java
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalPropertyFilter { void add(Class<?> cls, String... propertyNames);
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/SpearalPropertyFilter.java import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal; /** * @author Franck WOLFF */ public interface SpearalPropertyFilter { void add(Class<?> cls, String... propertyNames);
Property[] get(Class<?> cls);
spearal/spearal-java
src/main/java/org/spearal/configuration/ConverterProvider.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // }
import java.lang.reflect.Type; import org.spearal.SpearalContext;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface ConverterProvider extends Repeatable { public interface Converter<T> {
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // Path: src/main/java/org/spearal/configuration/ConverterProvider.java import java.lang.reflect.Type; import org.spearal.SpearalContext; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface ConverterProvider extends Repeatable { public interface Converter<T> {
T convert(SpearalContext context, Object value, Type targetType);
spearal/spearal-java
src/main/java/org/spearal/impl/cache/CopyOnWriteDualIdentityMap.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // }
import org.spearal.SpearalContext;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class CopyOnWriteDualIdentityMap<K1, K2, V> { protected volatile DualIdentityMap<K1, K2, V> map; public CopyOnWriteDualIdentityMap(DualIdentityMap.ValueProvider<K1, K2, V> provider) { this.map = new DualIdentityMap<K1, K2, V>(provider, 1); } public V get(K1 key1, K2 key2) { return get().get(key1, key2); }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // Path: src/main/java/org/spearal/impl/cache/CopyOnWriteDualIdentityMap.java import org.spearal.SpearalContext; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class CopyOnWriteDualIdentityMap<K1, K2, V> { protected volatile DualIdentityMap<K1, K2, V> map; public CopyOnWriteDualIdentityMap(DualIdentityMap.ValueProvider<K1, K2, V> provider) { this.map = new DualIdentityMap<K1, K2, V>(provider, 1); } public V get(K1 key1, K2 key2) { return get().get(key1, key2); }
public synchronized V putIfAbsent(SpearalContext context, K1 key1, K2 key2) {
spearal/spearal-java
src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface FilteredBeanDescriptorFactory extends Repeatable { public interface FilteredBeanDescriptor { String getDescription();
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface FilteredBeanDescriptorFactory extends Repeatable { public interface FilteredBeanDescriptor { String getDescription();
Property[] getProperties();
spearal/spearal-java
src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface FilteredBeanDescriptorFactory extends Repeatable { public interface FilteredBeanDescriptor { String getDescription(); Property[] getProperties(); boolean isCacheable(); }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface FilteredBeanDescriptorFactory extends Repeatable { public interface FilteredBeanDescriptor { String getDescription(); Property[] getProperties(); boolean isCacheable(); }
FilteredBeanDescriptor createDescription(SpearalContext context, SpearalPropertyFilter filter, Object value);
spearal/spearal-java
src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface FilteredBeanDescriptorFactory extends Repeatable { public interface FilteredBeanDescriptor { String getDescription(); Property[] getProperties(); boolean isCacheable(); }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/SpearalPropertyFilter.java // public interface SpearalPropertyFilter { // // void add(Class<?> cls, String... propertyNames); // // Property[] get(Class<?> cls); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/configuration/FilteredBeanDescriptorFactory.java import org.spearal.SpearalContext; import org.spearal.SpearalPropertyFilter; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface FilteredBeanDescriptorFactory extends Repeatable { public interface FilteredBeanDescriptor { String getDescription(); Property[] getProperties(); boolean isCacheable(); }
FilteredBeanDescriptor createDescription(SpearalContext context, SpearalPropertyFilter filter, Object value);
spearal/spearal-java
src/main/java/org/spearal/impl/cache/EqualityMap.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // }
import org.spearal.SpearalContext;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public class EqualityMap<K, P, V> extends AbstractAnyMap<K, P, V> { public EqualityMap(ValueProvider<K, P, V> provider) { super(provider); } public EqualityMap(ValueProvider<K, P, V> provider, int capacity) { super(provider, capacity); } @Override public V get(K key) { int hash = key.hashCode(); Entry<K, V>[] entries = this.entries; for (Entry<K, V> entry = entries[hash & (entries.length - 1)]; entry != null; entry = entry.next) { if (hash == entry.hash && key.equals(entry.key)) return entry.value; } return null; } @Override
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // Path: src/main/java/org/spearal/impl/cache/EqualityMap.java import org.spearal.SpearalContext; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public class EqualityMap<K, P, V> extends AbstractAnyMap<K, P, V> { public EqualityMap(ValueProvider<K, P, V> provider) { super(provider); } public EqualityMap(ValueProvider<K, P, V> provider, int capacity) { super(provider, capacity); } @Override public V get(K key) { int hash = key.hashCode(); Entry<K, V>[] entries = this.entries; for (Entry<K, V> entry = entries[hash & (entries.length - 1)]; entry != null; entry = entry.next) { if (hash == entry.hash && key.equals(entry.key)) return entry.value; } return null; } @Override
public V putIfAbsent(SpearalContext context, K key) {
spearal/spearal-java
src/test/java/org/spearal/test/TestMap.java
// Path: src/test/java/org/spearal/test/model/SimpleBean.java // public class SimpleBean implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean booleanValue; // private int intValue; // private double doubleValue; // private String stringValue; // // // public SimpleBean() { // } // // public SimpleBean(boolean booleanValue, int intValue, double doubleValue, String stringValue) { // this.booleanValue = booleanValue; // this.intValue = intValue; // this.doubleValue = doubleValue; // this.stringValue = stringValue; // } // // public boolean isBooleanValue() { // return booleanValue; // } // // public void setBooleanValue(boolean booleanValue) { // this.booleanValue = booleanValue; // } // // public int getIntValue() { // return intValue; // } // // public void setIntValue(int intValue) { // this.intValue = intValue; // } // // public double getDoubleValue() { // return doubleValue; // } // // public void setDoubleValue(double doubleValue) { // this.doubleValue = doubleValue; // } // // public String getStringValue() { // return stringValue; // } // // public void setStringValue(String stringValue) { // this.stringValue = stringValue; // } // // @Override // public int hashCode() { // return ( // (booleanValue ? 1 : 0) + // intValue + // (int)doubleValue + // (stringValue == null ? 0 : stringValue.hashCode()) // ); // } // // @Override // public boolean equals(Object obj) { // if (obj == this) // return true; // if (!(obj instanceof SimpleBean)) // return false; // SimpleBean that = (SimpleBean)obj; // return ( // booleanValue == that.booleanValue && // intValue == that.intValue && // Double.compare(doubleValue, that.doubleValue) == 0 && // (stringValue == that.stringValue || (stringValue != null && stringValue.equals(that.stringValue))) // ); // } // }
import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Random; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.SimpleBean;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestMap extends AbstractSpearalTestUnit { @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException { encodeDecode(new HashMap<String, Object>(), -1);
// Path: src/test/java/org/spearal/test/model/SimpleBean.java // public class SimpleBean implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean booleanValue; // private int intValue; // private double doubleValue; // private String stringValue; // // // public SimpleBean() { // } // // public SimpleBean(boolean booleanValue, int intValue, double doubleValue, String stringValue) { // this.booleanValue = booleanValue; // this.intValue = intValue; // this.doubleValue = doubleValue; // this.stringValue = stringValue; // } // // public boolean isBooleanValue() { // return booleanValue; // } // // public void setBooleanValue(boolean booleanValue) { // this.booleanValue = booleanValue; // } // // public int getIntValue() { // return intValue; // } // // public void setIntValue(int intValue) { // this.intValue = intValue; // } // // public double getDoubleValue() { // return doubleValue; // } // // public void setDoubleValue(double doubleValue) { // this.doubleValue = doubleValue; // } // // public String getStringValue() { // return stringValue; // } // // public void setStringValue(String stringValue) { // this.stringValue = stringValue; // } // // @Override // public int hashCode() { // return ( // (booleanValue ? 1 : 0) + // intValue + // (int)doubleValue + // (stringValue == null ? 0 : stringValue.hashCode()) // ); // } // // @Override // public boolean equals(Object obj) { // if (obj == this) // return true; // if (!(obj instanceof SimpleBean)) // return false; // SimpleBean that = (SimpleBean)obj; // return ( // booleanValue == that.booleanValue && // intValue == that.intValue && // Double.compare(doubleValue, that.doubleValue) == 0 && // (stringValue == that.stringValue || (stringValue != null && stringValue.equals(that.stringValue))) // ); // } // } // Path: src/test/java/org/spearal/test/TestMap.java import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Random; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.SimpleBean; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestMap extends AbstractSpearalTestUnit { @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException { encodeDecode(new HashMap<String, Object>(), -1);
Map<String, SimpleBean> map = new HashMap<String, SimpleBean>();
spearal/spearal-java
src/main/java/org/spearal/impl/property/AnyProperty.java
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder;
public Field getField() { return field; } @Override public boolean hasGetter() { return getter != null; } @Override public Method getGetter() { return getter; } @Override public boolean hasSetter() { return setter != null; } @Override public Method getSetter() { return setter; } @Override public Class<?> getDeclaringClass() { return (field != null ? field.getDeclaringClass() : getter.getDeclaringClass()); } @Override
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/property/AnyProperty.java import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder; public Field getField() { return field; } @Override public boolean hasGetter() { return getter != null; } @Override public Method getGetter() { return getter; } @Override public boolean hasSetter() { return setter != null; } @Override public Method getSetter() { return setter; } @Override public Class<?> getDeclaringClass() { return (field != null ? field.getDeclaringClass() : getter.getDeclaringClass()); } @Override
public Object init(ExtendedSpearalDecoder decoder, Object holder)
spearal/spearal-java
src/main/java/org/spearal/impl/property/AnyProperty.java
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder;
if (field != null) field.set(holder, value); else if (setter != null) setter.invoke(holder, value); } @Override public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) { return getAnnotation(annotationClass) != null; } @Override public <A extends Annotation> A getAnnotation(Class<A> annotationClass) { A annotation = (field != null ? field.getAnnotation(annotationClass) : null); if (annotation == null) { if (getter != null) annotation = getter.getAnnotation(annotationClass); if (annotation == null && setter != null) annotation = setter.getAnnotation(annotationClass); } return annotation; } @Override public boolean isReadOnly() { return (field == null && setter == null); } @Override
// Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/property/AnyProperty.java import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.configuration.PropertyFactory.Property; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder; if (field != null) field.set(holder, value); else if (setter != null) setter.invoke(holder, value); } @Override public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) { return getAnnotation(annotationClass) != null; } @Override public <A extends Annotation> A getAnnotation(Class<A> annotationClass) { A annotation = (field != null ? field.getAnnotation(annotationClass) : null); if (annotation == null) { if (getter != null) annotation = getter.getAnnotation(annotationClass); if (annotation == null && setter != null) annotation = setter.getAnnotation(annotationClass); } return annotation; } @Override public boolean isReadOnly() { return (field == null && setter == null); } @Override
public void write(ExtendedSpearalEncoder encoder, Object holder)
spearal/spearal-java
src/main/java/org/spearal/impl/cache/IdentityMap.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // }
import org.spearal.SpearalContext;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public class IdentityMap<K, P, V> extends AbstractAnyMap<K, P, V> { public IdentityMap(ValueProvider<K, P, V> provider) { super(provider); } public IdentityMap(ValueProvider<K, P, V> provider, int capacity) { super(provider, capacity); } @Override public V get(K key) { Entry<K, V>[] entries = this.entries; for (Entry<K, V> entry = entries[System.identityHashCode(key) & (entries.length - 1)]; entry != null; entry = entry.next) { if (key == entry.key) return entry.value; } return null; } @Override
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // Path: src/main/java/org/spearal/impl/cache/IdentityMap.java import org.spearal.SpearalContext; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public class IdentityMap<K, P, V> extends AbstractAnyMap<K, P, V> { public IdentityMap(ValueProvider<K, P, V> provider) { super(provider); } public IdentityMap(ValueProvider<K, P, V> provider, int capacity) { super(provider, capacity); } @Override public V get(K key) { Entry<K, V>[] entries = this.entries; for (Entry<K, V> entry = entries[System.identityHashCode(key) & (entries.length - 1)]; entry != null; entry = entry.next) { if (key == entry.key) return entry.value; } return null; } @Override
public V putIfAbsent(SpearalContext context, K key) {
spearal/spearal-java
src/test/java/org/spearal/test/TestProxy.java
// Path: src/test/java/org/spearal/test/model/Nameable.java // public interface Nameable { // // String getFirstName(); // void setFirstName(String value); // // String getLastName(); // void setLastName(String value); // }
import java.io.IOException; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.Nameable;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestProxy extends AbstractSpearalTestUnit { private static class NameableInvocationHandler implements InvocationHandler { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ("getFirstName".equals(method.getName())) return "John"; if ("getLastName".equals(method.getName())) return "Doo"; return null; } } @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException { Object proxy = Proxy.newProxyInstance( getClass().getClassLoader(),
// Path: src/test/java/org/spearal/test/model/Nameable.java // public interface Nameable { // // String getFirstName(); // void setFirstName(String value); // // String getLastName(); // void setLastName(String value); // } // Path: src/test/java/org/spearal/test/TestProxy.java import java.io.IOException; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.spearal.test.model.Nameable; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.test; /** * @author Franck WOLFF */ public class TestProxy extends AbstractSpearalTestUnit { private static class NameableInvocationHandler implements InvocationHandler { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ("getFirstName".equals(method.getName())) return "John"; if ("getLastName".equals(method.getName())) return "Doo"; return null; } } @Before public void setUp() throws Exception { // printStream = System.out; } @After public void tearDown() throws Exception { printStream = NULL_PRINT_STREAM; } @Test public void test() throws IOException { Object proxy = Proxy.newProxyInstance( getClass().getClassLoader(),
new Class<?>[]{ Nameable.class, Serializable.class },
spearal/spearal-java
src/main/java/org/spearal/impl/util/ClassDescriptionUtil.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import java.lang.reflect.Proxy; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.util; /** * @author Franck WOLFF */ public class ClassDescriptionUtil { public static String classNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return description; return description.substring(0, iSharp); } public static String[] splitClassNames(String description) { int iSharp = description.indexOf('#'); return split(description, 0, (iSharp != -1 ? iSharp : description.length())); } public static String[] splitPropertyNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return new String[0]; return split(description, iSharp + 1, description.length()); } public static int propertiesCount(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return 0; int count = 1; for (int i = iSharp + 1; i < description.length(); i++) { if (description.charAt(i) == ',') count++; } return count; }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/impl/util/ClassDescriptionUtil.java import java.lang.reflect.Proxy; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.util; /** * @author Franck WOLFF */ public class ClassDescriptionUtil { public static String classNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return description; return description.substring(0, iSharp); } public static String[] splitClassNames(String description) { int iSharp = description.indexOf('#'); return split(description, 0, (iSharp != -1 ? iSharp : description.length())); } public static String[] splitPropertyNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return new String[0]; return split(description, iSharp + 1, description.length()); } public static int propertiesCount(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return 0; int count = 1; for (int i = iSharp + 1; i < description.length(); i++) { if (description.charAt(i) == ',') count++; } return count; }
public static String createAliasedDescription(SpearalContext context, Class<?> cls, Property[] properties) {
spearal/spearal-java
src/main/java/org/spearal/impl/util/ClassDescriptionUtil.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import java.lang.reflect.Proxy; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.util; /** * @author Franck WOLFF */ public class ClassDescriptionUtil { public static String classNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return description; return description.substring(0, iSharp); } public static String[] splitClassNames(String description) { int iSharp = description.indexOf('#'); return split(description, 0, (iSharp != -1 ? iSharp : description.length())); } public static String[] splitPropertyNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return new String[0]; return split(description, iSharp + 1, description.length()); } public static int propertiesCount(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return 0; int count = 1; for (int i = iSharp + 1; i < description.length(); i++) { if (description.charAt(i) == ',') count++; } return count; }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/impl/util/ClassDescriptionUtil.java import java.lang.reflect.Proxy; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.util; /** * @author Franck WOLFF */ public class ClassDescriptionUtil { public static String classNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return description; return description.substring(0, iSharp); } public static String[] splitClassNames(String description) { int iSharp = description.indexOf('#'); return split(description, 0, (iSharp != -1 ? iSharp : description.length())); } public static String[] splitPropertyNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return new String[0]; return split(description, iSharp + 1, description.length()); } public static int propertiesCount(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return 0; int count = 1; for (int i = iSharp + 1; i < description.length(); i++) { if (description.charAt(i) == ',') count++; } return count; }
public static String createAliasedDescription(SpearalContext context, Class<?> cls, Property[] properties) {
spearal/spearal-java
src/main/java/org/spearal/impl/util/ClassDescriptionUtil.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import java.lang.reflect.Proxy; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PropertyFactory.Property;
public static String[] splitPropertyNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return new String[0]; return split(description, iSharp + 1, description.length()); } public static int propertiesCount(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return 0; int count = 1; for (int i = iSharp + 1; i < description.length(); i++) { if (description.charAt(i) == ',') count++; } return count; } public static String createAliasedDescription(SpearalContext context, Class<?> cls, Property[] properties) { StringBuilder sb = new StringBuilder(64); if (!Proxy.isProxyClass(cls)) sb.append(context.alias(cls)).append('#'); else { Class<?>[] interfaces = cls.getInterfaces(); boolean first = true; for (int i = 0; i < interfaces.length; i++) {
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java // public interface PartialObjectProxy { // // boolean $hasUndefinedProperties(); // boolean $isDefined(String propertyName); // boolean $undefine(String propertyName); // Property[] $getDefinedProperties(); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/impl/util/ClassDescriptionUtil.java import java.lang.reflect.Proxy; import org.spearal.SpearalContext; import org.spearal.configuration.PartialObjectFactory.PartialObjectProxy; import org.spearal.configuration.PropertyFactory.Property; public static String[] splitPropertyNames(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return new String[0]; return split(description, iSharp + 1, description.length()); } public static int propertiesCount(String description) { int iSharp = description.indexOf('#'); if (iSharp == -1) return 0; int count = 1; for (int i = iSharp + 1; i < description.length(); i++) { if (description.charAt(i) == ',') count++; } return count; } public static String createAliasedDescription(SpearalContext context, Class<?> cls, Property[] properties) { StringBuilder sb = new StringBuilder(64); if (!Proxy.isProxyClass(cls)) sb.append(context.alias(cls)).append('#'); else { Class<?>[] interfaces = cls.getInterfaces(); boolean first = true; for (int i = 0; i < interfaces.length; i++) {
if (PartialObjectProxy.class.isAssignableFrom(interfaces[i]))
spearal/spearal-java
src/main/java/org/spearal/impl/coder/MapCoder.java
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import java.util.Map; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class MapCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (Map.class.isAssignableFrom(valueClass) ? this : null); } @Override
// Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface CoderProvider extends Repeatable { // // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Coder getCoder(Class<?> valueClass); // } // // Path: src/main/java/org/spearal/configuration/CoderProvider.java // public interface Coder { // // void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/impl/coder/MapCoder.java import java.io.IOException; import java.util.Map; import org.spearal.configuration.CoderProvider; import org.spearal.configuration.CoderProvider.Coder; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.coder; /** * @author Franck WOLFF */ public class MapCoder implements CoderProvider, Coder { @Override public Coder getCoder(Class<?> valueClass) { return (Map.class.isAssignableFrom(valueClass) ? this : null); } @Override
public void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException {
spearal/spearal-java
src/main/java/org/spearal/impl/cache/CopyOnWriteMap.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/impl/cache/AnyMap.java // public interface ValueProvider<K, P, V> { // // V createValue(SpearalContext context, K key, P param); // }
import org.spearal.SpearalContext; import org.spearal.impl.cache.AnyMap.ValueProvider;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class CopyOnWriteMap<K, P, V> { protected volatile AnyMap<K, P, V> map;
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/impl/cache/AnyMap.java // public interface ValueProvider<K, P, V> { // // V createValue(SpearalContext context, K key, P param); // } // Path: src/main/java/org/spearal/impl/cache/CopyOnWriteMap.java import org.spearal.SpearalContext; import org.spearal.impl.cache.AnyMap.ValueProvider; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class CopyOnWriteMap<K, P, V> { protected volatile AnyMap<K, P, V> map;
public CopyOnWriteMap(boolean identity, ValueProvider<K, P, V> provider) {
spearal/spearal-java
src/main/java/org/spearal/impl/cache/CopyOnWriteMap.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/impl/cache/AnyMap.java // public interface ValueProvider<K, P, V> { // // V createValue(SpearalContext context, K key, P param); // }
import org.spearal.SpearalContext; import org.spearal.impl.cache.AnyMap.ValueProvider;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class CopyOnWriteMap<K, P, V> { protected volatile AnyMap<K, P, V> map; public CopyOnWriteMap(boolean identity, ValueProvider<K, P, V> provider) { if (identity) this.map = new IdentityMap<K, P, V>(provider, 1); else this.map = new EqualityMap<K, P, V>(provider, 1); } public V get(K key) { return get().get(key); }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/impl/cache/AnyMap.java // public interface ValueProvider<K, P, V> { // // V createValue(SpearalContext context, K key, P param); // } // Path: src/main/java/org/spearal/impl/cache/CopyOnWriteMap.java import org.spearal.SpearalContext; import org.spearal.impl.cache.AnyMap.ValueProvider; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.impl.cache; /** * @author Franck WOLFF */ public final class CopyOnWriteMap<K, P, V> { protected volatile AnyMap<K, P, V> map; public CopyOnWriteMap(boolean identity, ValueProvider<K, P, V> provider) { if (identity) this.map = new IdentityMap<K, P, V>(provider, 1); else this.map = new EqualityMap<K, P, V>(provider, 1); } public V get(K key) { return get().get(key); }
public synchronized V putIfAbsent(SpearalContext context, K key, P param) {
spearal/spearal-java
src/main/java/org/spearal/configuration/CoderProvider.java
// Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface CoderProvider extends Repeatable { public interface Coder {
// Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/configuration/CoderProvider.java import java.io.IOException; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface CoderProvider extends Repeatable { public interface Coder {
void encode(ExtendedSpearalEncoder encoder, Object value) throws IOException;
spearal/spearal-java
src/main/java/org/spearal/configuration/PropertyFactory.java
// Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyFactory extends Repeatable { public static final Property[] ZERO_PROPERTIES = new Property[0]; public interface Property { String getName(); Class<?> getType(); Type getGenericType(); boolean hasField(); Field getField(); boolean hasGetter(); Method getGetter(); boolean hasSetter(); Method getSetter(); Class<?> getDeclaringClass();
// Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/configuration/PropertyFactory.java import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyFactory extends Repeatable { public static final Property[] ZERO_PROPERTIES = new Property[0]; public interface Property { String getName(); Class<?> getType(); Type getGenericType(); boolean hasField(); Field getField(); boolean hasGetter(); Method getGetter(); boolean hasSetter(); Method getSetter(); Class<?> getDeclaringClass();
Object init(ExtendedSpearalDecoder decoder, Object holder)
spearal/spearal-java
src/main/java/org/spearal/configuration/PropertyFactory.java
// Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // }
import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyFactory extends Repeatable { public static final Property[] ZERO_PROPERTIES = new Property[0]; public interface Property { String getName(); Class<?> getType(); Type getGenericType(); boolean hasField(); Field getField(); boolean hasGetter(); Method getGetter(); boolean hasSetter(); Method getSetter(); Class<?> getDeclaringClass(); Object init(ExtendedSpearalDecoder decoder, Object holder) throws InstantiationException, IllegalAccessException, InvocationTargetException; Object get(Object holder) throws IllegalAccessException, InvocationTargetException; void set(Object holder, Object value) throws IllegalAccessException, InvocationTargetException; boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); <A extends Annotation> A getAnnotation(Class<A> annotationClass); boolean isReadOnly();
// Path: src/main/java/org/spearal/impl/ExtendedSpearalDecoder.java // public interface ExtendedSpearalDecoder extends SpearalDecoder { // // Object readAny(int parameterizedType) throws IOException; // Object readAny(int parameterizedType, Type targetType) throws IOException; // void skipAny(int parameterizedType) throws IOException; // // SpearalDateTime readDateTime(int parameterizedType) throws IOException; // // long readIntegral(int parameterizedType) throws IOException; // // BigInteger readBigIntegral(int parameterizedType) throws IOException; // // double readFloating(int parameterizedType) throws IOException; // // BigDecimal readBigFloating(int parameterizedType) throws IOException; // // String readString(int parameterizedType) throws IOException; // // byte[] readByteArray(int parameterizedType) throws IOException; // // Object readCollection(int parameterizedType, Type targetType) throws IOException; // void readCollection(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Map<?, ?> readMap(int parameterizedType, Type targetType) throws IOException; // void readMap(int parameterizedType, Object holder, Property property) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // // Enum<?> readEnum(int parameterizedType, Type targetType) throws IOException; // // Class<?> readClass(int parameterizedType, Type targetType) throws IOException; // // Object readBean(int parameterizedType, Type targetType) throws IOException; // } // // Path: src/main/java/org/spearal/impl/ExtendedSpearalEncoder.java // public interface ExtendedSpearalEncoder extends SpearalEncoder { // // void writeNull() throws IOException; // // void writeBoolean(boolean value) throws IOException; // // void writeDateTime(SpearalDateTime value) throws IOException; // // void writeByte(byte value) throws IOException; // void writeShort(short value) throws IOException; // void writeInt(int value) throws IOException; // void writeLong(long value) throws IOException; // void writeBigInteger(BigInteger value) throws IOException; // // void writeFloat(float value) throws IOException; // void writeDouble(double value) throws IOException; // void writeBigDecimal(BigDecimal value) throws IOException; // // void writeChar(char value) throws IOException; // void writeString(String value) throws IOException; // // void writeByteArray(byte[] value) throws IOException; // void writeArray(Object value) throws IOException; // // void writeCollection(Collection<?> value) throws IOException; // void writeMap(Map<?, ?> value) throws IOException; // // void writeEnum(Enum<?> value) throws IOException; // void writeClass(Class<?> value) throws IOException; // void writeBean(Object value) throws IOException; // } // Path: src/main/java/org/spearal/configuration/PropertyFactory.java import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import org.spearal.impl.ExtendedSpearalDecoder; import org.spearal.impl.ExtendedSpearalEncoder; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyFactory extends Repeatable { public static final Property[] ZERO_PROPERTIES = new Property[0]; public interface Property { String getName(); Class<?> getType(); Type getGenericType(); boolean hasField(); Field getField(); boolean hasGetter(); Method getGetter(); boolean hasSetter(); Method getSetter(); Class<?> getDeclaringClass(); Object init(ExtendedSpearalDecoder decoder, Object holder) throws InstantiationException, IllegalAccessException, InvocationTargetException; Object get(Object holder) throws IllegalAccessException, InvocationTargetException; void set(Object holder, Object value) throws IllegalAccessException, InvocationTargetException; boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); <A extends Annotation> A getAnnotation(Class<A> annotationClass); boolean isReadOnly();
public void write(ExtendedSpearalEncoder encoder, Object holder)
spearal/spearal-java
src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyInstantiatorProvider extends Repeatable { public interface PropertyInstantiator {
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyInstantiatorProvider extends Repeatable { public interface PropertyInstantiator {
Object instantiate(SpearalContext context, Property property, Object param);
spearal/spearal-java
src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyInstantiatorProvider extends Repeatable { public interface PropertyInstantiator {
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/configuration/PropertyInstantiatorProvider.java import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PropertyInstantiatorProvider extends Repeatable { public interface PropertyInstantiator {
Object instantiate(SpearalContext context, Property property, Object param);
spearal/spearal-java
src/main/java/org/spearal/configuration/PartialObjectFactory.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PartialObjectFactory extends Configurable { public interface PartialObjectProxy { boolean $hasUndefinedProperties(); boolean $isDefined(String propertyName); boolean $undefine(String propertyName);
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PartialObjectFactory extends Configurable { public interface PartialObjectProxy { boolean $hasUndefinedProperties(); boolean $isDefined(String propertyName); boolean $undefine(String propertyName);
Property[] $getDefinedProperties();
spearal/spearal-java
src/main/java/org/spearal/configuration/PartialObjectFactory.java
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // }
import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property;
/** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PartialObjectFactory extends Configurable { public interface PartialObjectProxy { boolean $hasUndefinedProperties(); boolean $isDefined(String propertyName); boolean $undefine(String propertyName); Property[] $getDefinedProperties(); } public interface ExtendedPartialObjectProxy extends PartialObjectProxy { Class<?> $getActualClass(); } public static class UndefinedPropertyException extends RuntimeException { private static final long serialVersionUID = 1L; public UndefinedPropertyException(String propertyName) { super("Property '" + propertyName + "' is undefined"); } }
// Path: src/main/java/org/spearal/SpearalContext.java // public interface SpearalContext { // // void configure(Configurable configurable); // void configure(Configurable configurable, boolean append); // // Securizer getSecurizer(); // // String alias(Class<?> cls); // String unalias(String aliasedClassName); // // Class<?> loadClass(String classNames, Type target) // throws SecurityException; // Object newInstance(Class<?> cls); // // Property[] getProperties(Class<?> cls); // // Object instantiate(Type type, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiate(Property property, Object param) // throws InstantiationException, IllegalAccessException; // Object instantiatePartial(Class<?> cls, Property[] partialProperties) // throws InstantiationException, IllegalAccessException; // // Coder getCoder(Class<?> valueClass); // // String[] getUnfilterableProperties(Class<?> valueClass); // // Object convert(Object value, Type targetType); // // Property createProperty(String name, Field field, Method getter, Method setter); // // FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value); // } // // Path: src/main/java/org/spearal/configuration/PropertyFactory.java // public interface Property { // // String getName(); // Class<?> getType(); // Type getGenericType(); // // boolean hasField(); // Field getField(); // boolean hasGetter(); // Method getGetter(); // boolean hasSetter(); // Method getSetter(); // // Class<?> getDeclaringClass(); // // Object init(ExtendedSpearalDecoder decoder, Object holder) // throws InstantiationException, IllegalAccessException, InvocationTargetException; // // Object get(Object holder) // throws IllegalAccessException, InvocationTargetException; // // void set(Object holder, Object value) // throws IllegalAccessException, InvocationTargetException; // // boolean isAnnotationPresent(Class<? extends Annotation> annotationClass); // <A extends Annotation> A getAnnotation(Class<A> annotationClass); // // boolean isReadOnly(); // // public void write(ExtendedSpearalEncoder encoder, Object holder) // throws IOException, IllegalAccessException, InvocationTargetException; // // public void read(ExtendedSpearalDecoder decoder, Object holder, int parameterizedType) // throws IOException, InstantiationException, IllegalAccessException, InvocationTargetException; // } // Path: src/main/java/org/spearal/configuration/PartialObjectFactory.java import org.spearal.SpearalContext; import org.spearal.configuration.PropertyFactory.Property; /** * == @Spearal ==> * * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.spearal.configuration; /** * @author Franck WOLFF */ public interface PartialObjectFactory extends Configurable { public interface PartialObjectProxy { boolean $hasUndefinedProperties(); boolean $isDefined(String propertyName); boolean $undefine(String propertyName); Property[] $getDefinedProperties(); } public interface ExtendedPartialObjectProxy extends PartialObjectProxy { Class<?> $getActualClass(); } public static class UndefinedPropertyException extends RuntimeException { private static final long serialVersionUID = 1L; public UndefinedPropertyException(String propertyName) { super("Property '" + propertyName + "' is undefined"); } }
Object instantiatePartial(SpearalContext context, Class<?> cls, Property[] partialProperties)
CPPAlien/DaVinci
davinci/src/main/java/cn/hadcn/davinci/image/cache/DiskLruCache.java
// Path: davinci/src/main/java/cn/hadcn/davinci/image/base/Util.java // public final class Util { // public static final Charset US_ASCII = Charset.forName("US-ASCII"); // public static final Charset UTF_8 = Charset.forName("UTF-8"); // // private Util() { // } // // public static String readFully(Reader reader) throws IOException { // try { // StringWriter writer = new StringWriter(); // char[] buffer = new char[1024]; // int count; // while ((count = reader.read(buffer)) != -1) { // writer.write(buffer, 0, count); // } // return writer.toString(); // } finally { // reader.close(); // } // } // // /** // * Deletes the contents of {@code dir}. Throws an IOException if any file // * could not be deleted, or if {@code dir} is not a readable directory. // */ // public static void deleteContents(File dir) throws IOException { // File[] files = dir.listFiles(); // if (files == null) { // throw new IOException("not a readable directory: " + dir); // } // for (File file : files) { // if (file.isDirectory()) { // deleteContents(file); // } // if (!file.delete()) { // throw new IOException("failed to delete file: " + file); // } // } // } // // public static void closeQuietly(/*Auto*/Closeable closeable) { // if (closeable != null) { // try { // closeable.close(); // } catch (RuntimeException rethrown) { // throw rethrown; // } catch (Exception ignored) { // } // } // } // // /** // * Creates a unique cache key based on a url value // * because file name in linux is limited // * @param uri // * uri to be used in key creation // * @return // * cache key value // */ // public static String generateKey(String uri) { // String regEx = "[^a-zA-Z0-9_-]"; // Pattern p = Pattern.compile(regEx); // Matcher m = p.matcher(uri); // String key = m.replaceAll("").trim(); // int length = key.length(); // if ( length <= 120 ) { //limited by DisLruCache // return key; // } else { // return key.substring(0, 120); // } // } // // public static boolean doGif(ImageView imageView, byte[] data) { // if ( isGif( data ) ) { // try { // GifDrawable gifDrawable = new GifDrawable(data); // imageView.setImageDrawable(gifDrawable); // return true; // } catch (Throwable e) { // VinciLog.w("pl.droidsonroids.gif.GifDrawable not found"); // } // } // return false; // } // // public static boolean isGif(byte[] data) { // return data[0] == 'G' && data[1] == 'I' && data[2] == 'F'; // } // }
import java.io.BufferedWriter; import java.io.Closeable; import java.io.EOFException; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; import cn.hadcn.davinci.image.base.Util;
renameTo(backupFile, journalFile, false); } } // Prefer to pick up where we left off. DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize); if (cache.journalFile.exists()) { try { cache.readJournal(); cache.processJournal(); return cache; } catch (IOException journalIsCorrupt) { System.out .println("DiskLruCache " + directory + " is corrupt: " + journalIsCorrupt.getMessage() + ", removing"); cache.delete(); } } // Create a new empty cache. directory.mkdirs(); cache = new DiskLruCache(directory, appVersion, valueCount, maxSize); cache.rebuildJournal(); return cache; } private void readJournal() throws IOException {
// Path: davinci/src/main/java/cn/hadcn/davinci/image/base/Util.java // public final class Util { // public static final Charset US_ASCII = Charset.forName("US-ASCII"); // public static final Charset UTF_8 = Charset.forName("UTF-8"); // // private Util() { // } // // public static String readFully(Reader reader) throws IOException { // try { // StringWriter writer = new StringWriter(); // char[] buffer = new char[1024]; // int count; // while ((count = reader.read(buffer)) != -1) { // writer.write(buffer, 0, count); // } // return writer.toString(); // } finally { // reader.close(); // } // } // // /** // * Deletes the contents of {@code dir}. Throws an IOException if any file // * could not be deleted, or if {@code dir} is not a readable directory. // */ // public static void deleteContents(File dir) throws IOException { // File[] files = dir.listFiles(); // if (files == null) { // throw new IOException("not a readable directory: " + dir); // } // for (File file : files) { // if (file.isDirectory()) { // deleteContents(file); // } // if (!file.delete()) { // throw new IOException("failed to delete file: " + file); // } // } // } // // public static void closeQuietly(/*Auto*/Closeable closeable) { // if (closeable != null) { // try { // closeable.close(); // } catch (RuntimeException rethrown) { // throw rethrown; // } catch (Exception ignored) { // } // } // } // // /** // * Creates a unique cache key based on a url value // * because file name in linux is limited // * @param uri // * uri to be used in key creation // * @return // * cache key value // */ // public static String generateKey(String uri) { // String regEx = "[^a-zA-Z0-9_-]"; // Pattern p = Pattern.compile(regEx); // Matcher m = p.matcher(uri); // String key = m.replaceAll("").trim(); // int length = key.length(); // if ( length <= 120 ) { //limited by DisLruCache // return key; // } else { // return key.substring(0, 120); // } // } // // public static boolean doGif(ImageView imageView, byte[] data) { // if ( isGif( data ) ) { // try { // GifDrawable gifDrawable = new GifDrawable(data); // imageView.setImageDrawable(gifDrawable); // return true; // } catch (Throwable e) { // VinciLog.w("pl.droidsonroids.gif.GifDrawable not found"); // } // } // return false; // } // // public static boolean isGif(byte[] data) { // return data[0] == 'G' && data[1] == 'I' && data[2] == 'F'; // } // } // Path: davinci/src/main/java/cn/hadcn/davinci/image/cache/DiskLruCache.java import java.io.BufferedWriter; import java.io.Closeable; import java.io.EOFException; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; import cn.hadcn.davinci.image.base.Util; renameTo(backupFile, journalFile, false); } } // Prefer to pick up where we left off. DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize); if (cache.journalFile.exists()) { try { cache.readJournal(); cache.processJournal(); return cache; } catch (IOException journalIsCorrupt) { System.out .println("DiskLruCache " + directory + " is corrupt: " + journalIsCorrupt.getMessage() + ", removing"); cache.delete(); } } // Create a new empty cache. directory.mkdirs(); cache = new DiskLruCache(directory, appVersion, valueCount, maxSize); cache.rebuildJournal(); return cache; } private void readJournal() throws IOException {
StrictLineReader reader = new StrictLineReader(new FileInputStream(journalFile), Util.US_ASCII);
CPPAlien/DaVinci
davinci/src/main/java/cn/hadcn/davinci/volley/toolbox/AndroidAuthenticator.java
// Path: davinci/src/main/java/cn/hadcn/davinci/volley/AuthFailureError.java // @SuppressWarnings("serial") // public class AuthFailureError extends VolleyError { // /** An intent that can be used to resolve this exception. (Brings up the password dialog.) */ // private Intent mResolutionIntent; // // public AuthFailureError() { } // // public AuthFailureError(Intent intent) { // mResolutionIntent = intent; // } // // public AuthFailureError(NetworkResponse response) { // super(response); // } // // public AuthFailureError(String message) { // super(message); // } // // public AuthFailureError(String message, Exception reason) { // super(message, reason); // } // // public Intent getResolutionIntent() { // return mResolutionIntent; // } // // @Override // public String getMessage() { // if (mResolutionIntent != null) { // return "User needs to (re)enter credentials."; // } // return super.getMessage(); // } // }
import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AccountManagerFuture; import android.content.Context; import android.content.Intent; import android.os.Bundle; import cn.hadcn.davinci.volley.AuthFailureError;
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cn.hadcn.davinci.volley.toolbox; /** * An Authenticator that uses {@link AccountManager} to get auth * tokens of a specified type for a specified account. */ public class AndroidAuthenticator implements Authenticator { private final AccountManager mAccountManager; private final Account mAccount; private final String mAuthTokenType; private final boolean mNotifyAuthFailure; /** * Creates a new authenticator. * @param context Context for accessing AccountManager * @param account Account to authenticate as * @param authTokenType Auth token type passed to AccountManager */ public AndroidAuthenticator(Context context, Account account, String authTokenType) { this(context, account, authTokenType, false); } /** * Creates a new authenticator. * @param context Context for accessing AccountManager * @param account Account to authenticate as * @param authTokenType Auth token type passed to AccountManager * @param notifyAuthFailure Whether to raise a notification upon auth failure */ public AndroidAuthenticator(Context context, Account account, String authTokenType, boolean notifyAuthFailure) { this(AccountManager.get(context), account, authTokenType, notifyAuthFailure); } // Visible for testing. Allows injection of a mock AccountManager. AndroidAuthenticator(AccountManager accountManager, Account account, String authTokenType, boolean notifyAuthFailure) { mAccountManager = accountManager; mAccount = account; mAuthTokenType = authTokenType; mNotifyAuthFailure = notifyAuthFailure; } /** * Returns the Account being used by this authenticator. */ public Account getAccount() { return mAccount; } /** * Returns the Auth Token Type used by this authenticator. */ public String getAuthTokenType() { return mAuthTokenType; } // TODO: Figure out what to do about notifyAuthFailure @SuppressWarnings("deprecation") @Override
// Path: davinci/src/main/java/cn/hadcn/davinci/volley/AuthFailureError.java // @SuppressWarnings("serial") // public class AuthFailureError extends VolleyError { // /** An intent that can be used to resolve this exception. (Brings up the password dialog.) */ // private Intent mResolutionIntent; // // public AuthFailureError() { } // // public AuthFailureError(Intent intent) { // mResolutionIntent = intent; // } // // public AuthFailureError(NetworkResponse response) { // super(response); // } // // public AuthFailureError(String message) { // super(message); // } // // public AuthFailureError(String message, Exception reason) { // super(message, reason); // } // // public Intent getResolutionIntent() { // return mResolutionIntent; // } // // @Override // public String getMessage() { // if (mResolutionIntent != null) { // return "User needs to (re)enter credentials."; // } // return super.getMessage(); // } // } // Path: davinci/src/main/java/cn/hadcn/davinci/volley/toolbox/AndroidAuthenticator.java import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AccountManagerFuture; import android.content.Context; import android.content.Intent; import android.os.Bundle; import cn.hadcn.davinci.volley.AuthFailureError; /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cn.hadcn.davinci.volley.toolbox; /** * An Authenticator that uses {@link AccountManager} to get auth * tokens of a specified type for a specified account. */ public class AndroidAuthenticator implements Authenticator { private final AccountManager mAccountManager; private final Account mAccount; private final String mAuthTokenType; private final boolean mNotifyAuthFailure; /** * Creates a new authenticator. * @param context Context for accessing AccountManager * @param account Account to authenticate as * @param authTokenType Auth token type passed to AccountManager */ public AndroidAuthenticator(Context context, Account account, String authTokenType) { this(context, account, authTokenType, false); } /** * Creates a new authenticator. * @param context Context for accessing AccountManager * @param account Account to authenticate as * @param authTokenType Auth token type passed to AccountManager * @param notifyAuthFailure Whether to raise a notification upon auth failure */ public AndroidAuthenticator(Context context, Account account, String authTokenType, boolean notifyAuthFailure) { this(AccountManager.get(context), account, authTokenType, notifyAuthFailure); } // Visible for testing. Allows injection of a mock AccountManager. AndroidAuthenticator(AccountManager accountManager, Account account, String authTokenType, boolean notifyAuthFailure) { mAccountManager = accountManager; mAccount = account; mAuthTokenType = authTokenType; mNotifyAuthFailure = notifyAuthFailure; } /** * Returns the Account being used by this authenticator. */ public Account getAccount() { return mAccount; } /** * Returns the Auth Token Type used by this authenticator. */ public String getAuthTokenType() { return mAuthTokenType; } // TODO: Figure out what to do about notifyAuthFailure @SuppressWarnings("deprecation") @Override
public String getAuthToken() throws AuthFailureError {
rmichela/GiantTrees
src/main/java/com/ryanmichela/trees/CreateTreeCommand.java
// Path: src/main/java/com/ryanmichela/trees/rendering/TreeRenderer.java // public class TreeRenderer { // // private final Plugin plugin; // // public TreeRenderer(final Plugin plugin) { // this.plugin = plugin; // } // // public void renderTree(final Location refPoint, final File treeFile, // final File rootFile, final int seed, // final boolean withDelay) { // this.renderTree(refPoint, treeFile, rootFile, seed, false, null, withDelay); // } // // public void renderTreeWithHistory(final Location refPoint, // final File treeFile, final File rootFile, // final int seed, final Player forPlayer, // final boolean withDelay) { // this.renderTree(refPoint, treeFile, rootFile, seed, true, forPlayer, // withDelay); // } // // private Tree loadTree(final File treeFile, final int seed) throws Exception { // if (treeFile == null) { return null; } // // final Tree tree = new Tree(); // tree.setOutputType(Tree.CONES); // tree.readFromXML(new FileInputStream(treeFile)); // tree.params.Seed = seed; // tree.params.stopLevel = -1; // -1 for everything // tree.params.verbose = false; // return tree; // } // // private void logVerbose(final String message) { // if (this.plugin.getConfig().getBoolean("verbose-logging", false)) { // this.plugin.getLogger().info(message); // } // } // // private void renderTree(final Location refPoint, final File treeFile, // final File rootFile, final int seed, // final boolean recordHistory, final Player forPlayer, // final boolean withDelay) { // AbstractParam.loading = true; // // final WorldChangeTracker changeTracker = new WorldChangeTracker(); // // if (plugin.isEnabled()) { // this.plugin.getServer().getScheduler() // .runTaskAsynchronously(this.plugin, () -> { // try { // TreeRenderer.this.logVerbose("Rendering tree " + treeFile.getName()); // final Tree tree = TreeRenderer.this.loadTree(treeFile, seed); // tree.make(); // final TreeType treeType = new TreeType(tree.params.WoodType); // final Draw3d d3d = new Draw3d(refPoint, // tree.params.Smooth, // treeType, // changeTracker, // Draw3d.RenderOrientation.NORMAL); // // final MinecraftExporter treeExporter = new MinecraftExporter(tree, d3d); // treeExporter.write(); // // if (tree.params.WoodType.equals("Jungle")) { // JungleVinePopulator.populate(changeTracker, new Random(seed)); // } // // d3d.drawRootJunction(d3d.toMcVector(((Segment) ((Stem) tree.trunks.get(0)).stemSegments().nextElement()).posFrom()), // ((Stem) tree.trunks.get(0)).baseRadius); // // if ((rootFile != null) && rootFile.exists()) { // TreeRenderer.this.logVerbose("Rendering root " // + rootFile.getName()); // final Tree root = TreeRenderer.this.loadTree(rootFile, // seed); // // Turn off leaves for roots and scale the roots the same // // as the tree // root.params.Leaves = -1; // root.params.scale_tree = tree.params.scale_tree; // root.make(); // final TreeType rootType = new TreeType(root.params.WoodType); // final Draw3d d3dInverted = new Draw3d(refPoint, // root.params.Smooth, // rootType, // changeTracker, // Draw3d.RenderOrientation.INVERTED); // // final MinecraftExporter treeExporterInverted = new MinecraftExporter(root, d3dInverted); // treeExporterInverted.write(); // } // AbstractParam.loading = false; // // final long generationDelay = withDelay ? TreeRenderer.this.plugin.getConfig().getInt("generation-delay", 0) * 20 : 0; // // if (plugin.isEnabled()) { // TreeRenderer.this.plugin.getServer() // .getScheduler() // .runTaskLater(TreeRenderer.this.plugin, // () -> { // try { // d3d.applyChanges(); // } catch (final Exception e) { // TreeRenderer.this.plugin.getLogger().severe("Error rendering tree: " + e.getMessage()); // } // }, generationDelay); // } // // } catch (final Exception e) { // TreeRenderer.this.plugin.getLogger().severe("Error rendering tree: " + e.getMessage()); // } // }); // } // } // }
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.Plugin; import com.ryanmichela.trees.rendering.TreeRenderer; import java.io.File; import java.util.Random; import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender;
/* * Copyright (C) 2014 Ryan Michela * Copyright (C) 2016 Ronald Jack Jenkins Jr. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.ryanmichela.trees; public class CreateTreeCommand implements CommandExecutor { private final Plugin plugin; private final PopupHandler popup;
// Path: src/main/java/com/ryanmichela/trees/rendering/TreeRenderer.java // public class TreeRenderer { // // private final Plugin plugin; // // public TreeRenderer(final Plugin plugin) { // this.plugin = plugin; // } // // public void renderTree(final Location refPoint, final File treeFile, // final File rootFile, final int seed, // final boolean withDelay) { // this.renderTree(refPoint, treeFile, rootFile, seed, false, null, withDelay); // } // // public void renderTreeWithHistory(final Location refPoint, // final File treeFile, final File rootFile, // final int seed, final Player forPlayer, // final boolean withDelay) { // this.renderTree(refPoint, treeFile, rootFile, seed, true, forPlayer, // withDelay); // } // // private Tree loadTree(final File treeFile, final int seed) throws Exception { // if (treeFile == null) { return null; } // // final Tree tree = new Tree(); // tree.setOutputType(Tree.CONES); // tree.readFromXML(new FileInputStream(treeFile)); // tree.params.Seed = seed; // tree.params.stopLevel = -1; // -1 for everything // tree.params.verbose = false; // return tree; // } // // private void logVerbose(final String message) { // if (this.plugin.getConfig().getBoolean("verbose-logging", false)) { // this.plugin.getLogger().info(message); // } // } // // private void renderTree(final Location refPoint, final File treeFile, // final File rootFile, final int seed, // final boolean recordHistory, final Player forPlayer, // final boolean withDelay) { // AbstractParam.loading = true; // // final WorldChangeTracker changeTracker = new WorldChangeTracker(); // // if (plugin.isEnabled()) { // this.plugin.getServer().getScheduler() // .runTaskAsynchronously(this.plugin, () -> { // try { // TreeRenderer.this.logVerbose("Rendering tree " + treeFile.getName()); // final Tree tree = TreeRenderer.this.loadTree(treeFile, seed); // tree.make(); // final TreeType treeType = new TreeType(tree.params.WoodType); // final Draw3d d3d = new Draw3d(refPoint, // tree.params.Smooth, // treeType, // changeTracker, // Draw3d.RenderOrientation.NORMAL); // // final MinecraftExporter treeExporter = new MinecraftExporter(tree, d3d); // treeExporter.write(); // // if (tree.params.WoodType.equals("Jungle")) { // JungleVinePopulator.populate(changeTracker, new Random(seed)); // } // // d3d.drawRootJunction(d3d.toMcVector(((Segment) ((Stem) tree.trunks.get(0)).stemSegments().nextElement()).posFrom()), // ((Stem) tree.trunks.get(0)).baseRadius); // // if ((rootFile != null) && rootFile.exists()) { // TreeRenderer.this.logVerbose("Rendering root " // + rootFile.getName()); // final Tree root = TreeRenderer.this.loadTree(rootFile, // seed); // // Turn off leaves for roots and scale the roots the same // // as the tree // root.params.Leaves = -1; // root.params.scale_tree = tree.params.scale_tree; // root.make(); // final TreeType rootType = new TreeType(root.params.WoodType); // final Draw3d d3dInverted = new Draw3d(refPoint, // root.params.Smooth, // rootType, // changeTracker, // Draw3d.RenderOrientation.INVERTED); // // final MinecraftExporter treeExporterInverted = new MinecraftExporter(root, d3dInverted); // treeExporterInverted.write(); // } // AbstractParam.loading = false; // // final long generationDelay = withDelay ? TreeRenderer.this.plugin.getConfig().getInt("generation-delay", 0) * 20 : 0; // // if (plugin.isEnabled()) { // TreeRenderer.this.plugin.getServer() // .getScheduler() // .runTaskLater(TreeRenderer.this.plugin, // () -> { // try { // d3d.applyChanges(); // } catch (final Exception e) { // TreeRenderer.this.plugin.getLogger().severe("Error rendering tree: " + e.getMessage()); // } // }, generationDelay); // } // // } catch (final Exception e) { // TreeRenderer.this.plugin.getLogger().severe("Error rendering tree: " + e.getMessage()); // } // }); // } // } // } // Path: src/main/java/com/ryanmichela/trees/CreateTreeCommand.java import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.Plugin; import com.ryanmichela.trees.rendering.TreeRenderer; import java.io.File; import java.util.Random; import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; /* * Copyright (C) 2014 Ryan Michela * Copyright (C) 2016 Ronald Jack Jenkins Jr. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.ryanmichela.trees; public class CreateTreeCommand implements CommandExecutor { private final Plugin plugin; private final PopupHandler popup;
private final TreeRenderer renderer;
rmichela/GiantTrees
src/arbaro/java/net/sourceforge/arbaro/tree/MeshCreator.java
// Path: src/arbaro/java/net/sourceforge/arbaro/export/Progress.java // public final class Progress { // String phase; // long maxProgress; // long progress; // // public Progress() { // maxProgress=100; // progress=0; // } // // synchronized public void beginPhase(String ph, long max) { // phase = ph; // maxProgress = max; // progress = 0; // } // // synchronized public void endPhase() { // progress = maxProgress; // } // // synchronized public void setProgress(long prog) throws ProgressError { // if (prog>maxProgress) // throw new ProgressError("Error in progress. The progress "+prog+ // " shouldn't exceed "+maxProgress+"."); // progress = prog; // } // // synchronized public void incProgress(long inc) { // progress += inc; // } // // synchronized public int getPercent() { // if (maxProgress<=0) return -1; // indeterminate // else { // int percent = (int)(progress/(float)maxProgress*100); // if (percent<0) return 0; // else if (percent>100) return 100; // else return percent; // } // } // // synchronized public String getPhase() { // return phase; // } // // synchronized public long getMaxProgress() { // return maxProgress; // } // }
import net.sourceforge.arbaro.export.Progress; import net.sourceforge.arbaro.mesh.*;
/* * This copy of Arbaro is redistributed to you under GPLv3 or (at your option) * any later version. The original copyright notice is retained below. */ // #************************************************************************** // # // # Copyright (C) 2003-2006 Wolfram Diestel // # // # This program is free software; you can redistribute it and/or modify // # it under the terms of the GNU General Public License as published by // # the Free Software Foundation; either version 2 of the License, or // # (at your option) any later version. // # // # This program is distributed in the hope that it will be useful, // # but WITHOUT ANY WARRANTY; without even the implied warranty of // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // # GNU General Public License for more details. // # // # You should have received a copy of the GNU General Public License // # along with this program; if not, write to the Free Software // # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // # // # Send comments and bug fixes to diestel@steloj.de // # // #**************************************************************************/ package net.sourceforge.arbaro.tree; /** * Create a mesh from the tree's stems using then TreeTraversal interface * * @author wolfram * */ public class MeshCreator implements TreeTraversal { Mesh mesh; Tree tree;
// Path: src/arbaro/java/net/sourceforge/arbaro/export/Progress.java // public final class Progress { // String phase; // long maxProgress; // long progress; // // public Progress() { // maxProgress=100; // progress=0; // } // // synchronized public void beginPhase(String ph, long max) { // phase = ph; // maxProgress = max; // progress = 0; // } // // synchronized public void endPhase() { // progress = maxProgress; // } // // synchronized public void setProgress(long prog) throws ProgressError { // if (prog>maxProgress) // throw new ProgressError("Error in progress. The progress "+prog+ // " shouldn't exceed "+maxProgress+"."); // progress = prog; // } // // synchronized public void incProgress(long inc) { // progress += inc; // } // // synchronized public int getPercent() { // if (maxProgress<=0) return -1; // indeterminate // else { // int percent = (int)(progress/(float)maxProgress*100); // if (percent<0) return 0; // else if (percent>100) return 100; // else return percent; // } // } // // synchronized public String getPhase() { // return phase; // } // // synchronized public long getMaxProgress() { // return maxProgress; // } // } // Path: src/arbaro/java/net/sourceforge/arbaro/tree/MeshCreator.java import net.sourceforge.arbaro.export.Progress; import net.sourceforge.arbaro.mesh.*; /* * This copy of Arbaro is redistributed to you under GPLv3 or (at your option) * any later version. The original copyright notice is retained below. */ // #************************************************************************** // # // # Copyright (C) 2003-2006 Wolfram Diestel // # // # This program is free software; you can redistribute it and/or modify // # it under the terms of the GNU General Public License as published by // # the Free Software Foundation; either version 2 of the License, or // # (at your option) any later version. // # // # This program is distributed in the hope that it will be useful, // # but WITHOUT ANY WARRANTY; without even the implied warranty of // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // # GNU General Public License for more details. // # // # You should have received a copy of the GNU General Public License // # along with this program; if not, write to the Free Software // # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // # // # Send comments and bug fixes to diestel@steloj.de // # // #**************************************************************************/ package net.sourceforge.arbaro.tree; /** * Create a mesh from the tree's stems using then TreeTraversal interface * * @author wolfram * */ public class MeshCreator implements TreeTraversal { Mesh mesh; Tree tree;
Progress progress;
rmichela/GiantTrees
src/arbaro/java/net/sourceforge/arbaro/gui/ParamGroupsView.java
// Path: src/arbaro/java/net/sourceforge/arbaro/params/AbstractParam.java // public abstract class AbstractParam { // public static final int GENERAL = -999; // no level - general params // String name; // String group; // int level; // int order; // String shortDesc; // String longDesc; // boolean enabled; // // protected ChangeEvent changeEvent = null; // protected EventListenerList listenerList = new EventListenerList(); // // public AbstractParam(String nam, String grp, int lev, int ord, String sh, String lng) { // name = nam; // group = grp; // level = lev; // order = ord; // shortDesc = sh; // longDesc = lng; // enabled=true; // } // // public abstract void setValue(String val) throws ParamError; // public abstract String getValue(); // public abstract String getDefaultValue(); // public abstract void clear(); // public abstract boolean empty(); // // public static boolean loading=false; // // protected static void warn(String warning) { // if (! loading) System.err.println("WARNING: "+warning); // } // // public void setEnabled(boolean en) { // enabled = en; // fireStateChanged(); // } // // public boolean getEnabled() { // return enabled; // } // // public String getName() { // return name; // } // // public String getGroup() { // return group; // } // // public int getLevel() { // return level; // } // // public int getOrder() { // return order; // } // // public String getShortDesc() { // return shortDesc; // } // // public String toString() { // if (! empty()) { // return getValue(); // } else { // return getDefaultValue(); // } // } // // public String getLongDesc() { // return longDesc; // } // // public void addChangeListener(ChangeListener l) { // listenerList.add(ChangeListener.class, l); // } // // public void removeChangeListener(ChangeListener l) { // listenerList.remove(ChangeListener.class, l); // } // // protected void fireStateChanged() { // Object [] listeners = listenerList.getListenerList(); // for (int i = listeners.length -2; i>=0; i-=2) { // if (listeners[i] == ChangeListener.class) { // if (changeEvent == null) { // changeEvent = new ChangeEvent(this); // } // ((ChangeListener)listeners[i+1]).stateChanged(changeEvent); // } // } // } // }
import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.*; import net.sourceforge.arbaro.params.AbstractParam; import java.awt.Color; import javax.swing.JTree; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener;
} ); } public String getGroupName() throws Exception { DefaultMutableTreeNode node = (DefaultMutableTreeNode) getLastSelectedPathComponent(); if (!node.isRoot()) { return ((GroupNode)node).getGroupName(); } // no group selected throw new Exception("no group selected"); } public int getGroupLevel() throws Exception { // FIXME: higher nodes could return the level too DefaultMutableTreeNode node = (DefaultMutableTreeNode) getLastSelectedPathComponent(); if (!node.isRoot()) { return ((GroupNode)node).getGroupLevel(); } // no group selected throw new Exception("no group selected"); } private void createNodes() {
// Path: src/arbaro/java/net/sourceforge/arbaro/params/AbstractParam.java // public abstract class AbstractParam { // public static final int GENERAL = -999; // no level - general params // String name; // String group; // int level; // int order; // String shortDesc; // String longDesc; // boolean enabled; // // protected ChangeEvent changeEvent = null; // protected EventListenerList listenerList = new EventListenerList(); // // public AbstractParam(String nam, String grp, int lev, int ord, String sh, String lng) { // name = nam; // group = grp; // level = lev; // order = ord; // shortDesc = sh; // longDesc = lng; // enabled=true; // } // // public abstract void setValue(String val) throws ParamError; // public abstract String getValue(); // public abstract String getDefaultValue(); // public abstract void clear(); // public abstract boolean empty(); // // public static boolean loading=false; // // protected static void warn(String warning) { // if (! loading) System.err.println("WARNING: "+warning); // } // // public void setEnabled(boolean en) { // enabled = en; // fireStateChanged(); // } // // public boolean getEnabled() { // return enabled; // } // // public String getName() { // return name; // } // // public String getGroup() { // return group; // } // // public int getLevel() { // return level; // } // // public int getOrder() { // return order; // } // // public String getShortDesc() { // return shortDesc; // } // // public String toString() { // if (! empty()) { // return getValue(); // } else { // return getDefaultValue(); // } // } // // public String getLongDesc() { // return longDesc; // } // // public void addChangeListener(ChangeListener l) { // listenerList.add(ChangeListener.class, l); // } // // public void removeChangeListener(ChangeListener l) { // listenerList.remove(ChangeListener.class, l); // } // // protected void fireStateChanged() { // Object [] listeners = listenerList.getListenerList(); // for (int i = listeners.length -2; i>=0; i-=2) { // if (listeners[i] == ChangeListener.class) { // if (changeEvent == null) { // changeEvent = new ChangeEvent(this); // } // ((ChangeListener)listeners[i+1]).stateChanged(changeEvent); // } // } // } // } // Path: src/arbaro/java/net/sourceforge/arbaro/gui/ParamGroupsView.java import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.*; import net.sourceforge.arbaro.params.AbstractParam; import java.awt.Color; import javax.swing.JTree; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; } ); } public String getGroupName() throws Exception { DefaultMutableTreeNode node = (DefaultMutableTreeNode) getLastSelectedPathComponent(); if (!node.isRoot()) { return ((GroupNode)node).getGroupName(); } // no group selected throw new Exception("no group selected"); } public int getGroupLevel() throws Exception { // FIXME: higher nodes could return the level too DefaultMutableTreeNode node = (DefaultMutableTreeNode) getLastSelectedPathComponent(); if (!node.isRoot()) { return ((GroupNode)node).getGroupLevel(); } // no group selected throw new Exception("no group selected"); } private void createNodes() {
GroupNode general = new GroupNode("","General",AbstractParam.GENERAL);
rmichela/GiantTrees
src/arbaro/java/net/sourceforge/arbaro/transformation/Vector.java
// Path: src/arbaro/java/net/sourceforge/arbaro/params/FloatFormat.java // public class FloatFormat { // // public static NumberFormat getInstance() { // NumberFormat form = NumberFormat.getNumberInstance(Locale.US); // form.setMaximumFractionDigits(5); // form.setMinimumFractionDigits(0); // return form; // } // }
import net.sourceforge.arbaro.params.FloatFormat; import java.lang.String; import java.lang.Math; import java.text.NumberFormat;
/* * This copy of Arbaro is redistributed to you under GPLv3 or (at your option) * any later version. The original copyright notice is retained below. */ // #************************************************************************** // # // # Copyright (C) 2003-2006 Wolfram Diestel // # // # This program is free software; you can redistribute it and/or modify // # it under the terms of the GNU General Public License as published by // # the Free Software Foundation; either version 2 of the License, or // # (at your option) any later version. // # // # This program is distributed in the hope that it will be useful, // # but WITHOUT ANY WARRANTY; without even the implied warranty of // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // # GNU General Public License for more details. // # // # You should have received a copy of the GNU General Public License // # along with this program; if not, write to the Free Software // # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // # // # Send comments and bug fixes to diestel@steloj.de // # // #**************************************************************************/ package net.sourceforge.arbaro.transformation; /** * A x,y,z-vector class * * @author Wolfram Diestel */ public class Vector { final int X=0; final int Y=1; final int Z=2; public final static Vector X_AXIS = new Vector(1,0,0); public final static Vector Y_AXIS = new Vector(0,1,0); public final static Vector Z_AXIS = new Vector(0,0,1); private double[] coord = {0,0,0}; public Vector() { coord = new double[Z+1]; //coord = {0,0,0}; } public Vector(double x, double y, double z) { coord = new double[Z+1]; coord[X] = x; coord[Y] = y; coord[Z] = z; } public double abs() { //returns the length of the vector return Math.sqrt(coord[X]*coord[X] + coord[Y]*coord[Y] + coord[Z]*coord[Z]); } // public String povray() { // NumberFormat fmt = FloatFormat.getInstance(); // return "<"+fmt.format(coord[X])+"," // +fmt.format(coord[Z])+"," // +fmt.format(coord[Y])+">"; // } public String toString() {
// Path: src/arbaro/java/net/sourceforge/arbaro/params/FloatFormat.java // public class FloatFormat { // // public static NumberFormat getInstance() { // NumberFormat form = NumberFormat.getNumberInstance(Locale.US); // form.setMaximumFractionDigits(5); // form.setMinimumFractionDigits(0); // return form; // } // } // Path: src/arbaro/java/net/sourceforge/arbaro/transformation/Vector.java import net.sourceforge.arbaro.params.FloatFormat; import java.lang.String; import java.lang.Math; import java.text.NumberFormat; /* * This copy of Arbaro is redistributed to you under GPLv3 or (at your option) * any later version. The original copyright notice is retained below. */ // #************************************************************************** // # // # Copyright (C) 2003-2006 Wolfram Diestel // # // # This program is free software; you can redistribute it and/or modify // # it under the terms of the GNU General Public License as published by // # the Free Software Foundation; either version 2 of the License, or // # (at your option) any later version. // # // # This program is distributed in the hope that it will be useful, // # but WITHOUT ANY WARRANTY; without even the implied warranty of // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // # GNU General Public License for more details. // # // # You should have received a copy of the GNU General Public License // # along with this program; if not, write to the Free Software // # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // # // # Send comments and bug fixes to diestel@steloj.de // # // #**************************************************************************/ package net.sourceforge.arbaro.transformation; /** * A x,y,z-vector class * * @author Wolfram Diestel */ public class Vector { final int X=0; final int Y=1; final int Z=2; public final static Vector X_AXIS = new Vector(1,0,0); public final static Vector Y_AXIS = new Vector(0,1,0); public final static Vector Z_AXIS = new Vector(0,0,1); private double[] coord = {0,0,0}; public Vector() { coord = new double[Z+1]; //coord = {0,0,0}; } public Vector(double x, double y, double z) { coord = new double[Z+1]; coord[X] = x; coord[Y] = y; coord[Z] = z; } public double abs() { //returns the length of the vector return Math.sqrt(coord[X]*coord[X] + coord[Y]*coord[Y] + coord[Z]*coord[Z]); } // public String povray() { // NumberFormat fmt = FloatFormat.getInstance(); // return "<"+fmt.format(coord[X])+"," // +fmt.format(coord[Z])+"," // +fmt.format(coord[Y])+">"; // } public String toString() {
NumberFormat fmt = FloatFormat.getInstance();
ryantenney/passkit4j
src/main/java/com/ryantenney/passkit4j/PassResource.java
// Path: src/main/java/com/ryantenney/passkit4j/io/InputStreamSupplier.java // public interface InputStreamSupplier { // // public InputStream getInputStream() throws IOException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // }
import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.concurrent.atomic.AtomicBoolean; import com.ryantenney.passkit4j.io.InputStreamSupplier; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier;
package com.ryantenney.passkit4j; public class PassResource implements NamedInputStreamSupplier { private final String name;
// Path: src/main/java/com/ryantenney/passkit4j/io/InputStreamSupplier.java // public interface InputStreamSupplier { // // public InputStream getInputStream() throws IOException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // Path: src/main/java/com/ryantenney/passkit4j/PassResource.java import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.concurrent.atomic.AtomicBoolean; import com.ryantenney.passkit4j.io.InputStreamSupplier; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; package com.ryantenney.passkit4j; public class PassResource implements NamedInputStreamSupplier { private final String name;
private final InputStreamSupplier dataSupplier;
ryantenney/passkit4j
src/main/java/com/ryantenney/passkit4j/BufferedPassResource.java
// Path: src/main/java/com/ryantenney/passkit4j/io/InputStreamSupplier.java // public interface InputStreamSupplier { // // public InputStream getInputStream() throws IOException; // // }
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import com.ryantenney.passkit4j.io.InputStreamSupplier;
package com.ryantenney.passkit4j; public class BufferedPassResource extends PassResource { private static final int DEFAULT_BUFFER_SIZE = 32768; public BufferedPassResource(final String filename) throws IOException { this(new File(filename)); } public BufferedPassResource(final File file) throws IOException { this(file.getName(), file); } public BufferedPassResource(final String name, final File file) throws IOException { this(name, read(new FileInputStream(file), (int) file.length())); }
// Path: src/main/java/com/ryantenney/passkit4j/io/InputStreamSupplier.java // public interface InputStreamSupplier { // // public InputStream getInputStream() throws IOException; // // } // Path: src/main/java/com/ryantenney/passkit4j/BufferedPassResource.java import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import com.ryantenney.passkit4j.io.InputStreamSupplier; package com.ryantenney.passkit4j; public class BufferedPassResource extends PassResource { private static final int DEFAULT_BUFFER_SIZE = 32768; public BufferedPassResource(final String filename) throws IOException { this(new File(filename)); } public BufferedPassResource(final File file) throws IOException { this(file.getName(), file); } public BufferedPassResource(final String name, final File file) throws IOException { this(name, read(new FileInputStream(file), (int) file.length())); }
public BufferedPassResource(final String name, final InputStreamSupplier dataSupplier) throws IOException {
ryantenney/passkit4j
src/main/java/com/ryantenney/passkit4j/PassSerializer.java
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // }
import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException;
package com.ryantenney.passkit4j; public class PassSerializer { public static final String PKPASS_TYPE = "application/vnd.apple.pkpass"; private static final ObjectMapper objectMapper; static { objectMapper = new ObjectMapper(); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new ISO8601DateFormat()); objectMapper.setVisibilityChecker(objectMapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY)); objectMapper.setSerializationInclusion(Include.NON_EMPTY); }
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // } // Path: src/main/java/com/ryantenney/passkit4j/PassSerializer.java import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException; package com.ryantenney.passkit4j; public class PassSerializer { public static final String PKPASS_TYPE = "application/vnd.apple.pkpass"; private static final ObjectMapper objectMapper; static { objectMapper = new ObjectMapper(); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new ISO8601DateFormat()); objectMapper.setVisibilityChecker(objectMapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY)); objectMapper.setSerializationInclusion(Include.NON_EMPTY); }
public static void writePkPassArchive(Pass pass, PassSigner signer, OutputStream out) throws PassSigningException, PassSerializationException {
ryantenney/passkit4j
src/main/java/com/ryantenney/passkit4j/PassSerializer.java
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // }
import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException;
package com.ryantenney.passkit4j; public class PassSerializer { public static final String PKPASS_TYPE = "application/vnd.apple.pkpass"; private static final ObjectMapper objectMapper; static { objectMapper = new ObjectMapper(); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new ISO8601DateFormat()); objectMapper.setVisibilityChecker(objectMapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY)); objectMapper.setSerializationInclusion(Include.NON_EMPTY); }
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // } // Path: src/main/java/com/ryantenney/passkit4j/PassSerializer.java import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException; package com.ryantenney.passkit4j; public class PassSerializer { public static final String PKPASS_TYPE = "application/vnd.apple.pkpass"; private static final ObjectMapper objectMapper; static { objectMapper = new ObjectMapper(); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.setDateFormat(new ISO8601DateFormat()); objectMapper.setVisibilityChecker(objectMapper.getVisibilityChecker().withFieldVisibility(Visibility.ANY)); objectMapper.setSerializationInclusion(Include.NON_EMPTY); }
public static void writePkPassArchive(Pass pass, PassSigner signer, OutputStream out) throws PassSigningException, PassSerializationException {
ryantenney/passkit4j
src/main/java/com/ryantenney/passkit4j/PassSerializer.java
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // }
import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException;
Map<String, String> manifest = writeAndHashFiles(pass.files(), zip); manifest.put("pass.json", write(generatePass(pass), hasher(zipEntry("pass.json", zip))).hash()); byte[] manifestData = write(generateManifest(manifest), new ByteArrayOutputStream()).toByteArray(); write(manifestData, zipEntry("manifest.json", zip)); byte[] signatureData = signer.generateSignature(manifestData); write(signatureData, zipEntry("signature", zip)); } catch (NoSuchAlgorithmException e) { throw new PassSerializationException(e); } catch (DigestException e) { throw new PassSerializationException(e); } catch (NoSuchProviderException e) { throw new PassSerializationException(e); } catch (IOException e) { throw new PassSerializationException(e); } finally { try { if (zip != null) zip.close(); } catch (IOException e) { throw new PassSerializationException("Error closing output stream", e); } } } protected static ObjectNode generatePass(Pass pass) { ObjectNode tree = objectMapper.valueToTree(pass);
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // } // Path: src/main/java/com/ryantenney/passkit4j/PassSerializer.java import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException; Map<String, String> manifest = writeAndHashFiles(pass.files(), zip); manifest.put("pass.json", write(generatePass(pass), hasher(zipEntry("pass.json", zip))).hash()); byte[] manifestData = write(generateManifest(manifest), new ByteArrayOutputStream()).toByteArray(); write(manifestData, zipEntry("manifest.json", zip)); byte[] signatureData = signer.generateSignature(manifestData); write(signatureData, zipEntry("signature", zip)); } catch (NoSuchAlgorithmException e) { throw new PassSerializationException(e); } catch (DigestException e) { throw new PassSerializationException(e); } catch (NoSuchProviderException e) { throw new PassSerializationException(e); } catch (IOException e) { throw new PassSerializationException(e); } finally { try { if (zip != null) zip.close(); } catch (IOException e) { throw new PassSerializationException("Error closing output stream", e); } } } protected static ObjectNode generatePass(Pass pass) { ObjectNode tree = objectMapper.valueToTree(pass);
PassInformation info = pass.passInformation();
ryantenney/passkit4j
src/main/java/com/ryantenney/passkit4j/PassSerializer.java
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // }
import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException;
} catch (NoSuchProviderException e) { throw new PassSerializationException(e); } catch (IOException e) { throw new PassSerializationException(e); } finally { try { if (zip != null) zip.close(); } catch (IOException e) { throw new PassSerializationException("Error closing output stream", e); } } } protected static ObjectNode generatePass(Pass pass) { ObjectNode tree = objectMapper.valueToTree(pass); PassInformation info = pass.passInformation(); tree.put(info.typeName(), objectMapper.valueToTree(info)); return tree; } protected static ObjectNode generateManifest(Map<String, String> files) { ObjectNode node = new ObjectNode(JsonNodeFactory.instance); for (Map.Entry<String, String> file : files.entrySet()) { node.put(file.getKey(), file.getValue()); } return node; }
// Path: src/main/java/com/ryantenney/passkit4j/io/NamedInputStreamSupplier.java // public interface NamedInputStreamSupplier extends InputStreamSupplier { // // public String getName(); // // } // // Path: src/main/java/com/ryantenney/passkit4j/model/PassInformation.java // @Data // public abstract class PassInformation { // // @JsonIgnore private final String typeName; // // private List<Field<?>> headerFields; // private List<Field<?>> primaryFields; // private List<Field<?>> secondaryFields; // private List<Field<?>> backFields; // private List<Field<?>> auxiliaryFields; // // protected PassInformation(final String typeName) { // this.typeName = typeName; // } // // public String typeName() { // return this.typeName; // } // // public PassInformation headerFields(Field<?>... fields) { // this.headerFields = Arrays.asList(fields); // return this; // } // // public PassInformation headerFields(List<Field<?>> fields) { // this.headerFields = fields; // return this; // } // // public PassInformation primaryFields(Field<?>... fields) { // this.primaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation primaryFields(List<Field<?>> fields) { // this.primaryFields = fields; // return this; // } // // public PassInformation secondaryFields(Field<?>... fields) { // this.secondaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation secondaryFields(List<Field<?>> fields) { // this.secondaryFields = fields; // return this; // } // // public PassInformation backFields(Field<?>... fields) { // this.backFields = Arrays.asList(fields); // return this; // } // // public PassInformation backFields(List<Field<?>> fields) { // this.backFields = fields; // return this; // } // // public PassInformation auxiliaryFields(Field<?>... fields) { // this.auxiliaryFields = Arrays.asList(fields); // return this; // } // // public PassInformation auxiliaryFields(List<Field<?>> fields) { // this.auxiliaryFields = fields; // return this; // } // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigner.java // public interface PassSigner { // // public byte[] generateSignature(byte[] data) throws PassSigningException; // // } // // Path: src/main/java/com/ryantenney/passkit4j/sign/PassSigningException.java // public class PassSigningException extends Exception { // // private static final long serialVersionUID = 6021707149897120829L; // // public PassSigningException(String message) { // super(message); // } // // public PassSigningException(Throwable cause) { // super(cause); // } // // public PassSigningException(String message, Throwable cause) { // super(message, cause); // } // // } // Path: src/main/java/com/ryantenney/passkit4j/PassSerializer.java import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.DigestException; import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import lombok.Delegate; import lombok.Getter; import lombok.experimental.Accessors; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Hex; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.util.ISO8601DateFormat; import com.ryantenney.passkit4j.io.NamedInputStreamSupplier; import com.ryantenney.passkit4j.model.PassInformation; import com.ryantenney.passkit4j.sign.PassSigner; import com.ryantenney.passkit4j.sign.PassSigningException; } catch (NoSuchProviderException e) { throw new PassSerializationException(e); } catch (IOException e) { throw new PassSerializationException(e); } finally { try { if (zip != null) zip.close(); } catch (IOException e) { throw new PassSerializationException("Error closing output stream", e); } } } protected static ObjectNode generatePass(Pass pass) { ObjectNode tree = objectMapper.valueToTree(pass); PassInformation info = pass.passInformation(); tree.put(info.typeName(), objectMapper.valueToTree(info)); return tree; } protected static ObjectNode generateManifest(Map<String, String> files) { ObjectNode node = new ObjectNode(JsonNodeFactory.instance); for (Map.Entry<String, String> file : files.entrySet()) { node.put(file.getKey(), file.getValue()); } return node; }
protected static Map<String, String> writeAndHashFiles(List<NamedInputStreamSupplier> files, ZipOutputStream output) throws IOException, NoSuchAlgorithmException, DigestException, NoSuchProviderException {
copygirl/BetterStorage
src/main/java/net/mcft/copy/betterstorage/item/ItemBetterStorage.java
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // }
import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.misc.Constants; import net.mcft.copy.betterstorage.utils.MiscUtils; import net.mcft.copy.betterstorage.utils.StackUtils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package net.mcft.copy.betterstorage.item; public abstract class ItemBetterStorage extends Item { public static final String TAG_COLOR = "color"; public static final String TAG_FULL_COLOR = "fullColor"; public static final String TAG_KEYLOCK_ID = "id"; private String name; public ItemBetterStorage() { setMaxStackSize(1);
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // } // Path: src/main/java/net/mcft/copy/betterstorage/item/ItemBetterStorage.java import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.misc.Constants; import net.mcft.copy.betterstorage.utils.MiscUtils; import net.mcft.copy.betterstorage.utils.StackUtils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package net.mcft.copy.betterstorage.item; public abstract class ItemBetterStorage extends Item { public static final String TAG_COLOR = "color"; public static final String TAG_FULL_COLOR = "fullColor"; public static final String TAG_KEYLOCK_ID = "id"; private String name; public ItemBetterStorage() { setMaxStackSize(1);
setCreativeTab(BetterStorage.creativeTab);
copygirl/BetterStorage
src/main/java/net/mcft/copy/betterstorage/item/cardboard/ItemCardboardHoe.java
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // }
import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.misc.Constants; import net.mcft.copy.betterstorage.utils.MiscUtils; import net.mcft.copy.betterstorage.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package net.mcft.copy.betterstorage.item.cardboard; public class ItemCardboardHoe extends ItemHoe implements ICardboardItem { private String name; public ItemCardboardHoe() { super(ItemCardboardSheet.toolMaterial);
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // } // Path: src/main/java/net/mcft/copy/betterstorage/item/cardboard/ItemCardboardHoe.java import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.misc.Constants; import net.mcft.copy.betterstorage.utils.MiscUtils; import net.mcft.copy.betterstorage.utils.StackUtils; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package net.mcft.copy.betterstorage.item.cardboard; public class ItemCardboardHoe extends ItemHoe implements ICardboardItem { private String name; public ItemCardboardHoe() { super(ItemCardboardSheet.toolMaterial);
setCreativeTab(BetterStorage.creativeTab);
copygirl/BetterStorage
src/main/java/net/mcft/copy/betterstorage/tile/entity/TileEntityPresent.java
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // } // // Path: src/main/java/net/mcft/copy/betterstorage/misc/SetBlockFlag.java // public final class SetBlockFlag { // // /** When set, causes a block update to the surrounding blocks. */ // public static final int BLOCK_UPDATE = 0x1; // /** When set on server, sends the block change to the client. */ // public static final int SEND_TO_CLIENT = 0x2; // /** When set on client, will not render the chunk again. */ // public static final int DONT_RERENDER = 0x4; // // /** The default setting, will cause a block // * update and send the change to the client. */ // public static final int DEFAULT = BLOCK_UPDATE | SEND_TO_CLIENT; // // private SetBlockFlag() { } // // }
import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.content.BetterStorageTiles; import net.mcft.copy.betterstorage.item.tile.ItemCardboardBox; import net.mcft.copy.betterstorage.misc.SetBlockFlag; import net.mcft.copy.betterstorage.network.packet.PacketPresentOpen; import net.mcft.copy.betterstorage.utils.StackUtils; import net.mcft.copy.betterstorage.utils.WorldUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
@Override protected void onItemDropped(ItemStack stack) { super.onItemDropped(stack); NBTTagCompound compound = stack.getTagCompound(); compound.setByte(TAG_COLOR_INNER, (byte)colorInner); compound.setByte(TAG_COLOR_OUTER, (byte)colorOuter); compound.setBoolean(TAG_SKOJANZA_MODE, skojanzaMode); if (nameTag != null) compound.setString(TAG_NAMETAG, nameTag); StackUtils.remove(stack, "display", "color"); compound.setInteger("color", color); } @Override public void updateEntity() { breakPause = Math.max(0, breakPause - 1); if (breakPause <= 0) breakProgress = Math.max(0, breakProgress - 1); } // TileEntityContainer stuff @Override public void onBlockPlaced(EntityLivingBase player, ItemStack stack) { super.onBlockPlaced(player, stack); colorInner = StackUtils.get(stack, (byte)14, TAG_COLOR_INNER); colorOuter = StackUtils.get(stack, (byte)0, TAG_COLOR_OUTER); skojanzaMode = (StackUtils.get(stack, (byte)0, TAG_SKOJANZA_MODE) > 0); nameTag = StackUtils.get(stack, (String)null, TAG_NAMETAG); color = StackUtils.get(stack, -1, "color");
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // } // // Path: src/main/java/net/mcft/copy/betterstorage/misc/SetBlockFlag.java // public final class SetBlockFlag { // // /** When set, causes a block update to the surrounding blocks. */ // public static final int BLOCK_UPDATE = 0x1; // /** When set on server, sends the block change to the client. */ // public static final int SEND_TO_CLIENT = 0x2; // /** When set on client, will not render the chunk again. */ // public static final int DONT_RERENDER = 0x4; // // /** The default setting, will cause a block // * update and send the change to the client. */ // public static final int DEFAULT = BLOCK_UPDATE | SEND_TO_CLIENT; // // private SetBlockFlag() { } // // } // Path: src/main/java/net/mcft/copy/betterstorage/tile/entity/TileEntityPresent.java import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.content.BetterStorageTiles; import net.mcft.copy.betterstorage.item.tile.ItemCardboardBox; import net.mcft.copy.betterstorage.misc.SetBlockFlag; import net.mcft.copy.betterstorage.network.packet.PacketPresentOpen; import net.mcft.copy.betterstorage.utils.StackUtils; import net.mcft.copy.betterstorage.utils.WorldUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @Override protected void onItemDropped(ItemStack stack) { super.onItemDropped(stack); NBTTagCompound compound = stack.getTagCompound(); compound.setByte(TAG_COLOR_INNER, (byte)colorInner); compound.setByte(TAG_COLOR_OUTER, (byte)colorOuter); compound.setBoolean(TAG_SKOJANZA_MODE, skojanzaMode); if (nameTag != null) compound.setString(TAG_NAMETAG, nameTag); StackUtils.remove(stack, "display", "color"); compound.setInteger("color", color); } @Override public void updateEntity() { breakPause = Math.max(0, breakPause - 1); if (breakPause <= 0) breakProgress = Math.max(0, breakProgress - 1); } // TileEntityContainer stuff @Override public void onBlockPlaced(EntityLivingBase player, ItemStack stack) { super.onBlockPlaced(player, stack); colorInner = StackUtils.get(stack, (byte)14, TAG_COLOR_INNER); colorOuter = StackUtils.get(stack, (byte)0, TAG_COLOR_OUTER); skojanzaMode = (StackUtils.get(stack, (byte)0, TAG_SKOJANZA_MODE) > 0); nameTag = StackUtils.get(stack, (String)null, TAG_NAMETAG); color = StackUtils.get(stack, -1, "color");
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, colorInner, SetBlockFlag.SEND_TO_CLIENT);
copygirl/BetterStorage
src/main/java/net/mcft/copy/betterstorage/tile/entity/TileEntityPresent.java
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // } // // Path: src/main/java/net/mcft/copy/betterstorage/misc/SetBlockFlag.java // public final class SetBlockFlag { // // /** When set, causes a block update to the surrounding blocks. */ // public static final int BLOCK_UPDATE = 0x1; // /** When set on server, sends the block change to the client. */ // public static final int SEND_TO_CLIENT = 0x2; // /** When set on client, will not render the chunk again. */ // public static final int DONT_RERENDER = 0x4; // // /** The default setting, will cause a block // * update and send the change to the client. */ // public static final int DEFAULT = BLOCK_UPDATE | SEND_TO_CLIENT; // // private SetBlockFlag() { } // // }
import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.content.BetterStorageTiles; import net.mcft.copy.betterstorage.item.tile.ItemCardboardBox; import net.mcft.copy.betterstorage.misc.SetBlockFlag; import net.mcft.copy.betterstorage.network.packet.PacketPresentOpen; import net.mcft.copy.betterstorage.utils.StackUtils; import net.mcft.copy.betterstorage.utils.WorldUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, colorInner, SetBlockFlag.SEND_TO_CLIENT); } @Override public boolean onBlockActivated(EntityPlayer player, int side, float hitX, float hitY, float hitZ) { ItemStack holding = player.getCurrentEquippedItem(); if (holding == null) { if (breakPause > 0) return false; breakPause = 10 - breakProgress / 10; if ((nameTag != null) && !player.getCommandSenderName().equalsIgnoreCase(nameTag)) { breakPause = 40; if (!worldObj.isRemote) ((EntityPlayerMP)player).addChatMessage(new ChatComponentText( EnumChatFormatting.YELLOW + "This present is for " + nameTag + ", not you!")); return false; } if ((breakProgress += 20) > 100) destroyed = true; if (worldObj.isRemote) return true; double x = xCoord + 0.5; double y = yCoord + 0.5; double z = zCoord + 0.5; String sound = Block.soundTypeCloth.getBreakSound(); worldObj.playSoundEffect(x, y, z, sound, 0.75F, 0.8F + breakProgress / 80.0F); worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, sound, 1.0F, 0.4F + breakProgress / 160.0F);
// Path: src/main/java/net/mcft/copy/betterstorage/BetterStorage.java // @Mod(modid = Constants.modId, // name = Constants.modName, // dependencies = "required-after:Forge; after:Thaumcraft; after:NotEnoughItems;", // guiFactory = "net.mcft.copy.betterstorage.client.gui.BetterStorageGuiFactory") // public class BetterStorage { // // @Instance(Constants.modId) // public static BetterStorage instance; // // @SidedProxy(serverSide = Constants.commonProxy, // clientSide = Constants.clientProxy) // public static CommonProxy proxy; // // public static ChannelHandler networkChannel; // // public static Logger log; // // public static CreativeTabs creativeTab; // // public static Config globalConfig; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // // networkChannel = new ChannelHandler(); // log = event.getModLog(); // creativeTab = new CreativeTabBetterStorage(); // // Addon.initialize(); // // globalConfig = new GlobalConfig(event.getSuggestedConfigurationFile()); // Addon.setupConfigsAll(); // globalConfig.load(); // globalConfig.save(); // // BetterStorageTiles.initialize(); // BetterStorageItems.initialize(); // // EnchantmentBetterStorage.initialize(); // // BetterStorageTileEntities.register(); // BetterStorageEntities.register(); // DungeonLoot.add(); // // } // // @EventHandler // public void load(FMLInitializationEvent event) { // // Recipes.add(); // proxy.initialize(); // // } // // @EventHandler // public void postInit(FMLPostInitializationEvent event) { // Addon.postInitializeAll(); // } // // } // // Path: src/main/java/net/mcft/copy/betterstorage/misc/SetBlockFlag.java // public final class SetBlockFlag { // // /** When set, causes a block update to the surrounding blocks. */ // public static final int BLOCK_UPDATE = 0x1; // /** When set on server, sends the block change to the client. */ // public static final int SEND_TO_CLIENT = 0x2; // /** When set on client, will not render the chunk again. */ // public static final int DONT_RERENDER = 0x4; // // /** The default setting, will cause a block // * update and send the change to the client. */ // public static final int DEFAULT = BLOCK_UPDATE | SEND_TO_CLIENT; // // private SetBlockFlag() { } // // } // Path: src/main/java/net/mcft/copy/betterstorage/tile/entity/TileEntityPresent.java import net.mcft.copy.betterstorage.BetterStorage; import net.mcft.copy.betterstorage.content.BetterStorageTiles; import net.mcft.copy.betterstorage.item.tile.ItemCardboardBox; import net.mcft.copy.betterstorage.misc.SetBlockFlag; import net.mcft.copy.betterstorage.network.packet.PacketPresentOpen; import net.mcft.copy.betterstorage.utils.StackUtils; import net.mcft.copy.betterstorage.utils.WorldUtils; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, colorInner, SetBlockFlag.SEND_TO_CLIENT); } @Override public boolean onBlockActivated(EntityPlayer player, int side, float hitX, float hitY, float hitZ) { ItemStack holding = player.getCurrentEquippedItem(); if (holding == null) { if (breakPause > 0) return false; breakPause = 10 - breakProgress / 10; if ((nameTag != null) && !player.getCommandSenderName().equalsIgnoreCase(nameTag)) { breakPause = 40; if (!worldObj.isRemote) ((EntityPlayerMP)player).addChatMessage(new ChatComponentText( EnumChatFormatting.YELLOW + "This present is for " + nameTag + ", not you!")); return false; } if ((breakProgress += 20) > 100) destroyed = true; if (worldObj.isRemote) return true; double x = xCoord + 0.5; double y = yCoord + 0.5; double z = zCoord + 0.5; String sound = Block.soundTypeCloth.getBreakSound(); worldObj.playSoundEffect(x, y, z, sound, 0.75F, 0.8F + breakProgress / 80.0F); worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, sound, 1.0F, 0.4F + breakProgress / 160.0F);
BetterStorage.networkChannel.sendToAllAround(
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/component/basic/BasicPanel.java
// Path: src/org/darkstorm/minecraft/gui/layout/LayoutManager.java // public interface LayoutManager { // public void reposition(Rectangle area, Rectangle[] componentAreas, // Constraint[][] constraints); // // public Dimension getOptimalPositionedSize(Rectangle[] componentAreas, // Constraint[][] constraints); // }
import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.layout.LayoutManager;
package org.darkstorm.minecraft.gui.component.basic; public class BasicPanel extends AbstractContainer implements Panel { public BasicPanel() { }
// Path: src/org/darkstorm/minecraft/gui/layout/LayoutManager.java // public interface LayoutManager { // public void reposition(Rectangle area, Rectangle[] componentAreas, // Constraint[][] constraints); // // public Dimension getOptimalPositionedSize(Rectangle[] componentAreas, // Constraint[][] constraints); // } // Path: src/org/darkstorm/minecraft/gui/component/basic/BasicPanel.java import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.layout.LayoutManager; package org.darkstorm.minecraft.gui.component.basic; public class BasicPanel extends AbstractContainer implements Panel { public BasicPanel() { }
public BasicPanel(LayoutManager layoutManager) {
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/component/Slider.java
// Path: src/org/darkstorm/minecraft/gui/listener/SliderListener.java // public interface SliderListener extends ComponentListener { // public void onSliderValueChanged(Slider slider); // }
import org.darkstorm.minecraft.gui.listener.SliderListener;
package org.darkstorm.minecraft.gui.component; public interface Slider extends Component, TextComponent, BoundedRangeComponent { public String getContentSuffix(); public boolean isValueChanging(); public void setContentSuffix(String suffix); public void setValueChanging(boolean changing);
// Path: src/org/darkstorm/minecraft/gui/listener/SliderListener.java // public interface SliderListener extends ComponentListener { // public void onSliderValueChanged(Slider slider); // } // Path: src/org/darkstorm/minecraft/gui/component/Slider.java import org.darkstorm.minecraft.gui.listener.SliderListener; package org.darkstorm.minecraft.gui.component; public interface Slider extends Component, TextComponent, BoundedRangeComponent { public String getContentSuffix(); public boolean isValueChanging(); public void setContentSuffix(String suffix); public void setValueChanging(boolean changing);
public void addSliderListener(SliderListener listener);
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/ExampleGuiManager.java
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // }
import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay;
int scale = minecraft.gameSettings.guiScale; if(scale == 0) scale = 1000; int scaleFactor = 0; while(scaleFactor < scale && minecraft.displayWidth / (scaleFactor + 1) >= 320 && minecraft.displayHeight / (scaleFactor + 1) >= 240) scaleFactor++; for(Frame frame : getFrames()) { frame.setX(offsetX); frame.setY(offsetY); offsetX += maxSize.width + 5; if(offsetX + maxSize.width + 5 > minecraft.displayWidth / scaleFactor) { offsetX = 5; offsetY += maxSize.height + 5; } } } private void createTestFrame() { Theme theme = getTheme(); Frame testFrame = new BasicFrame("Frame"); testFrame.setTheme(theme); testFrame.add(new BasicLabel("TEST LOL")); testFrame.add(new BasicLabel("TEST 23423")); testFrame.add(new BasicLabel("TE123123123ST LOL")); testFrame.add(new BasicLabel("31243 LO3242L432")); BasicButton testButton = new BasicButton("Duplicate this frame!"); testButton.addButtonListener(new ButtonListener() { @Override
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // } // Path: src/org/darkstorm/minecraft/gui/ExampleGuiManager.java import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay; int scale = minecraft.gameSettings.guiScale; if(scale == 0) scale = 1000; int scaleFactor = 0; while(scaleFactor < scale && minecraft.displayWidth / (scaleFactor + 1) >= 320 && minecraft.displayHeight / (scaleFactor + 1) >= 240) scaleFactor++; for(Frame frame : getFrames()) { frame.setX(offsetX); frame.setY(offsetY); offsetX += maxSize.width + 5; if(offsetX + maxSize.width + 5 > minecraft.displayWidth / scaleFactor) { offsetX = 5; offsetY += maxSize.height + 5; } } } private void createTestFrame() { Theme theme = getTheme(); Frame testFrame = new BasicFrame("Frame"); testFrame.setTheme(theme); testFrame.add(new BasicLabel("TEST LOL")); testFrame.add(new BasicLabel("TEST 23423")); testFrame.add(new BasicLabel("TE123123123ST LOL")); testFrame.add(new BasicLabel("31243 LO3242L432")); BasicButton testButton = new BasicButton("Duplicate this frame!"); testButton.addButtonListener(new ButtonListener() { @Override
public void onButtonPress(Button button) {
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/ExampleGuiManager.java
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // }
import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay;
} } private void createTestFrame() { Theme theme = getTheme(); Frame testFrame = new BasicFrame("Frame"); testFrame.setTheme(theme); testFrame.add(new BasicLabel("TEST LOL")); testFrame.add(new BasicLabel("TEST 23423")); testFrame.add(new BasicLabel("TE123123123ST LOL")); testFrame.add(new BasicLabel("31243 LO3242L432")); BasicButton testButton = new BasicButton("Duplicate this frame!"); testButton.addButtonListener(new ButtonListener() { @Override public void onButtonPress(Button button) { createTestFrame(); } }); testFrame.add(new BasicCheckButton("This is a checkbox")); testFrame.add(testButton); ComboBox comboBox = new BasicComboBox("Simple theme", "Other theme", "Other theme 2"); comboBox.addComboBoxListener(new ComboBoxListener() { @Override public void onComboBoxSelectionChanged(ComboBox comboBox) { Theme theme; switch(comboBox.getSelectedIndex()) { case 0:
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // } // Path: src/org/darkstorm/minecraft/gui/ExampleGuiManager.java import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay; } } private void createTestFrame() { Theme theme = getTheme(); Frame testFrame = new BasicFrame("Frame"); testFrame.setTheme(theme); testFrame.add(new BasicLabel("TEST LOL")); testFrame.add(new BasicLabel("TEST 23423")); testFrame.add(new BasicLabel("TE123123123ST LOL")); testFrame.add(new BasicLabel("31243 LO3242L432")); BasicButton testButton = new BasicButton("Duplicate this frame!"); testButton.addButtonListener(new ButtonListener() { @Override public void onButtonPress(Button button) { createTestFrame(); } }); testFrame.add(new BasicCheckButton("This is a checkbox")); testFrame.add(testButton); ComboBox comboBox = new BasicComboBox("Simple theme", "Other theme", "Other theme 2"); comboBox.addComboBoxListener(new ComboBoxListener() { @Override public void onComboBoxSelectionChanged(ComboBox comboBox) { Theme theme; switch(comboBox.getSelectedIndex()) { case 0:
theme = new SimpleTheme();
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/ExampleGuiManager.java
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // }
import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay;
createTestFrame(); } }); testFrame.add(new BasicCheckButton("This is a checkbox")); testFrame.add(testButton); ComboBox comboBox = new BasicComboBox("Simple theme", "Other theme", "Other theme 2"); comboBox.addComboBoxListener(new ComboBoxListener() { @Override public void onComboBoxSelectionChanged(ComboBox comboBox) { Theme theme; switch(comboBox.getSelectedIndex()) { case 0: theme = new SimpleTheme(); break; case 1: // Some other theme // break; case 2: // Another theme // break; default: return; } setTheme(theme); } }); testFrame.add(comboBox); Slider slider = new BasicSlider("Test"); slider.setContentSuffix("things");
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // } // Path: src/org/darkstorm/minecraft/gui/ExampleGuiManager.java import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay; createTestFrame(); } }); testFrame.add(new BasicCheckButton("This is a checkbox")); testFrame.add(testButton); ComboBox comboBox = new BasicComboBox("Simple theme", "Other theme", "Other theme 2"); comboBox.addComboBoxListener(new ComboBoxListener() { @Override public void onComboBoxSelectionChanged(ComboBox comboBox) { Theme theme; switch(comboBox.getSelectedIndex()) { case 0: theme = new SimpleTheme(); break; case 1: // Some other theme // break; case 2: // Another theme // break; default: return; } setTheme(theme); } }); testFrame.add(comboBox); Slider slider = new BasicSlider("Test"); slider.setContentSuffix("things");
slider.setValueDisplay(ValueDisplay.INTEGER);
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/ExampleGuiManager.java
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // }
import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay;
testFrame.add(comboBox); Slider slider = new BasicSlider("Test"); slider.setContentSuffix("things"); slider.setValueDisplay(ValueDisplay.INTEGER); testFrame.add(slider); testFrame.add(new BasicProgressBar(50, 0, 100, 1, ValueDisplay.PERCENTAGE)); testFrame.setX(50); testFrame.setY(50); Dimension defaultDimension = theme.getUIForComponent(testFrame).getDefaultSize(testFrame); testFrame.setWidth(defaultDimension.width); testFrame.setHeight(defaultDimension.height); testFrame.layoutChildren(); testFrame.setVisible(true); testFrame.setMinimized(true); addFrame(testFrame); } @Override protected void resizeComponents() { Theme theme = getTheme(); Frame[] frames = getFrames(); Button enable = new BasicButton("Enable"); Button disable = new BasicButton("Disable"); Dimension enableSize = theme.getUIForComponent(enable).getDefaultSize(enable); Dimension disableSize = theme.getUIForComponent(disable).getDefaultSize(disable); int buttonWidth = Math.max(enableSize.width, disableSize.width); int buttonHeight = Math.max(enableSize.height, disableSize.height); for(Frame frame : frames) { if(frame instanceof ModuleFrame) {
// Path: src/org/darkstorm/minecraft/gui/component/BoundedRangeComponent.java // public enum ValueDisplay { // DECIMAL, // INTEGER, // PERCENTAGE, // NONE // } // // Path: src/org/darkstorm/minecraft/gui/component/Button.java // public interface Button extends Component, TextComponent { // public void press(); // // public void addButtonListener(ButtonListener listener); // // public void removeButtonListener(ButtonListener listener); // // public ButtonGroup getGroup(); // // public void setGroup(ButtonGroup group); // } // // Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java // public class SimpleTheme extends AbstractTheme { // private final FontRenderer fontRenderer; // // public SimpleTheme() { // fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15)); // // installUI(new SimpleFrameUI(this)); // installUI(new SimplePanelUI(this)); // installUI(new SimpleLabelUI(this)); // installUI(new SimpleButtonUI(this)); // installUI(new SimpleCheckButtonUI(this)); // installUI(new SimpleComboBoxUI(this)); // installUI(new SimpleSliderUI(this)); // installUI(new SimpleProgressBarUI(this)); // } // // public FontRenderer getFontRenderer() { // return fontRenderer; // } // } // Path: src/org/darkstorm/minecraft/gui/ExampleGuiManager.java import org.darkstorm.minecraft.gui.component.*; import org.darkstorm.minecraft.gui.component.Button; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.component.basic.*; import org.darkstorm.minecraft.gui.listener.*; import org.darkstorm.minecraft.gui.theme.Theme; import org.darkstorm.minecraft.gui.theme.simple.SimpleTheme; import java.awt.*; import java.util.concurrent.atomic.AtomicBoolean; import net.minecraft.client.Minecraft; import org.darkstorm.minecraft.gui.component.BoundedRangeComponent.ValueDisplay; testFrame.add(comboBox); Slider slider = new BasicSlider("Test"); slider.setContentSuffix("things"); slider.setValueDisplay(ValueDisplay.INTEGER); testFrame.add(slider); testFrame.add(new BasicProgressBar(50, 0, 100, 1, ValueDisplay.PERCENTAGE)); testFrame.setX(50); testFrame.setY(50); Dimension defaultDimension = theme.getUIForComponent(testFrame).getDefaultSize(testFrame); testFrame.setWidth(defaultDimension.width); testFrame.setHeight(defaultDimension.height); testFrame.layoutChildren(); testFrame.setVisible(true); testFrame.setMinimized(true); addFrame(testFrame); } @Override protected void resizeComponents() { Theme theme = getTheme(); Frame[] frames = getFrames(); Button enable = new BasicButton("Enable"); Button disable = new BasicButton("Disable"); Dimension enableSize = theme.getUIForComponent(enable).getDefaultSize(enable); Dimension disableSize = theme.getUIForComponent(disable).getDefaultSize(disable); int buttonWidth = Math.max(enableSize.width, disableSize.width); int buttonHeight = Math.max(enableSize.height, disableSize.height); for(Frame frame : frames) { if(frame instanceof ModuleFrame) {
for(Component component : frame.getChildren()) {
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/theme/AbstractComponentUI.java
// Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Container.java // public interface Container extends Component { // public LayoutManager getLayoutManager(); // // public void setLayoutManager(LayoutManager layoutManager); // // public Component[] getChildren(); // // public void add(Component child, Constraint... constraints); // // public Constraint[] getConstraints(Component child); // // public Component getChildAt(int x, int y); // // public boolean hasChild(Component component); // // public boolean remove(Component child); // // public void layoutChildren(); // }
import java.awt.*; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Container; import org.lwjgl.opengl.GL11;
package org.darkstorm.minecraft.gui.theme; public abstract class AbstractComponentUI<T extends Component> implements ComponentUI { protected final Class<T> handledComponentClass; protected Color foreground, background; public AbstractComponentUI(Class<T> handledComponentClass) { this.handledComponentClass = handledComponentClass; } public void render(Component component) { if(component == null) throw new NullPointerException(); if(!handledComponentClass.isInstance(component)) throw new IllegalArgumentException(); if(!component.isVisible()) return; renderComponent(handledComponentClass.cast(component)); } protected abstract void renderComponent(T component); @Override
// Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Container.java // public interface Container extends Component { // public LayoutManager getLayoutManager(); // // public void setLayoutManager(LayoutManager layoutManager); // // public Component[] getChildren(); // // public void add(Component child, Constraint... constraints); // // public Constraint[] getConstraints(Component child); // // public Component getChildAt(int x, int y); // // public boolean hasChild(Component component); // // public boolean remove(Component child); // // public void layoutChildren(); // } // Path: src/org/darkstorm/minecraft/gui/theme/AbstractComponentUI.java import java.awt.*; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Container; import org.lwjgl.opengl.GL11; package org.darkstorm.minecraft.gui.theme; public abstract class AbstractComponentUI<T extends Component> implements ComponentUI { protected final Class<T> handledComponentClass; protected Color foreground, background; public AbstractComponentUI(Class<T> handledComponentClass) { this.handledComponentClass = handledComponentClass; } public void render(Component component) { if(component == null) throw new NullPointerException(); if(!handledComponentClass.isInstance(component)) throw new IllegalArgumentException(); if(!component.isVisible()) return; renderComponent(handledComponentClass.cast(component)); } protected abstract void renderComponent(T component); @Override
public Rectangle getChildRenderArea(Container container) {
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/theme/ComponentUI.java
// Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Container.java // public interface Container extends Component { // public LayoutManager getLayoutManager(); // // public void setLayoutManager(LayoutManager layoutManager); // // public Component[] getChildren(); // // public void add(Component child, Constraint... constraints); // // public Constraint[] getConstraints(Component child); // // public Component getChildAt(int x, int y); // // public boolean hasChild(Component component); // // public boolean remove(Component child); // // public void layoutChildren(); // }
import java.awt.*; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Container;
package org.darkstorm.minecraft.gui.theme; public interface ComponentUI { public void render(Component component);
// Path: src/org/darkstorm/minecraft/gui/component/Component.java // public interface Component { // public Theme getTheme(); // // public void setTheme(Theme theme); // // public void render(); // // public void update(); // // public int getX(); // // public int getY(); // // public int getWidth(); // // public int getHeight(); // // public void setX(int x); // // public void setY(int y); // // public void setWidth(int width); // // public void setHeight(int height); // // public Point getLocation(); // // public Dimension getSize(); // // public Rectangle getArea(); // // public Container getParent(); // // public Color getBackgroundColor(); // // public Color getForegroundColor(); // // public void setBackgroundColor(Color color); // // public void setForegroundColor(Color color); // // public void setParent(Container parent); // // public void onMousePress(int x, int y, int button); // // public void onMouseRelease(int x, int y, int button); // // public void resize(); // // public boolean isVisible(); // // public void setVisible(boolean visible); // // public boolean isEnabled(); // // public void setEnabled(boolean enabled); // } // // Path: src/org/darkstorm/minecraft/gui/component/Container.java // public interface Container extends Component { // public LayoutManager getLayoutManager(); // // public void setLayoutManager(LayoutManager layoutManager); // // public Component[] getChildren(); // // public void add(Component child, Constraint... constraints); // // public Constraint[] getConstraints(Component child); // // public Component getChildAt(int x, int y); // // public boolean hasChild(Component component); // // public boolean remove(Component child); // // public void layoutChildren(); // } // Path: src/org/darkstorm/minecraft/gui/theme/ComponentUI.java import java.awt.*; import org.darkstorm.minecraft.gui.component.Component; import org.darkstorm.minecraft.gui.component.Container; package org.darkstorm.minecraft.gui.theme; public interface ComponentUI { public void render(Component component);
public Rectangle getChildRenderArea(Container container);
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/component/Button.java
// Path: src/org/darkstorm/minecraft/gui/listener/ButtonListener.java // public interface ButtonListener extends ComponentListener { // public void onButtonPress(Button button); // }
import org.darkstorm.minecraft.gui.listener.ButtonListener;
package org.darkstorm.minecraft.gui.component; public interface Button extends Component, TextComponent { public void press();
// Path: src/org/darkstorm/minecraft/gui/listener/ButtonListener.java // public interface ButtonListener extends ComponentListener { // public void onButtonPress(Button button); // } // Path: src/org/darkstorm/minecraft/gui/component/Button.java import org.darkstorm.minecraft.gui.listener.ButtonListener; package org.darkstorm.minecraft.gui.component; public interface Button extends Component, TextComponent { public void press();
public void addButtonListener(ButtonListener listener);
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/GuiManager.java
// Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // }
import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.theme.Theme;
/* * Copyright (c) 2013, DarkStorm (darkstorm@evilminecraft.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.darkstorm.minecraft.gui; /** * Minecraft GUI API * * @author DarkStorm (darkstorm@evilminecraft.net) */ public interface GuiManager { public void setup();
// Path: src/org/darkstorm/minecraft/gui/component/Frame.java // public interface Frame extends Container, DraggableComponent { // public String getTitle(); // // public void setTitle(String title); // // public boolean isPinned(); // // public void setPinned(boolean pinned); // // public boolean isPinnable(); // // public void setPinnable(boolean pinnable); // // public boolean isMinimized(); // // public void setMinimized(boolean minimized); // // public boolean isMinimizable(); // // public void setMinimizable(boolean minimizable); // // public void close(); // // public boolean isClosable(); // // public void setClosable(boolean closable); // } // Path: src/org/darkstorm/minecraft/gui/GuiManager.java import org.darkstorm.minecraft.gui.component.Frame; import org.darkstorm.minecraft.gui.theme.Theme; /* * Copyright (c) 2013, DarkStorm (darkstorm@evilminecraft.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.darkstorm.minecraft.gui; /** * Minecraft GUI API * * @author DarkStorm (darkstorm@evilminecraft.net) */ public interface GuiManager { public void setup();
public void addFrame(Frame frame);
DarkStorm652/Minecraft-GUI-API
src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java
// Path: src/org/darkstorm/minecraft/gui/font/UnicodeFontRenderer.java // public class UnicodeFontRenderer extends FontRenderer { // private final UnicodeFont font; // // @SuppressWarnings("unchecked") // public UnicodeFontRenderer(Font awtFont) { // super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().getTextureManager(), false); // // font = new UnicodeFont(awtFont); // font.addAsciiGlyphs(); // font.getEffects().add(new ColorEffect(Color.WHITE)); // try { // font.loadGlyphs(); // } catch(SlickException exception) { // throw new RuntimeException(exception); // } // String alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; // FONT_HEIGHT = font.getHeight(alphabet) / 2; // } // // @Override // public int drawString(String string, int x, int y, int color) { // if(string == null) // return 0; // // glClear(256); // // glMatrixMode(GL_PROJECTION); // // glLoadIdentity(); // // IntBuffer buffer = BufferUtils.createIntBuffer(16); // // glGetInteger(GL_VIEWPORT, buffer); // // glOrtho(0, buffer.get(2), buffer.get(3), 0, 1000, 3000); // // glMatrixMode(GL_MODELVIEW); // // glLoadIdentity(); // // glTranslatef(0, 0, -2000); // glPushMatrix(); // glScaled(0.5, 0.5, 0.5); // // boolean blend = glIsEnabled(GL_BLEND); // boolean lighting = glIsEnabled(GL_LIGHTING); // boolean texture = glIsEnabled(GL_TEXTURE_2D); // if(!blend) // glEnable(GL_BLEND); // if(lighting) // glDisable(GL_LIGHTING); // if(texture) // glDisable(GL_TEXTURE_2D); // x *= 2; // y *= 2; // // glBegin(GL_LINES); // // glVertex3d(x, y, 0); // // glVertex3d(x + getStringWidth(string), y + FONT_HEIGHT, 0); // // glEnd(); // // font.drawString(x, y, string, new org.newdawn.slick.Color(color)); // // if(texture) // glEnable(GL_TEXTURE_2D); // if(lighting) // glEnable(GL_LIGHTING); // if(!blend) // glDisable(GL_BLEND); // glPopMatrix(); // return x; // } // // @Override // public int func_175063_a(String string, float x, float y, int color) { // return drawString(string, (int) x, (int) y, color); // } // // @Override // public int getCharWidth(char c) { // return getStringWidth(Character.toString(c)); // } // // @Override // public int getStringWidth(String string) { // return font.getWidth(string) / 2; // } // // public int getStringHeight(String string) { // return font.getHeight(string) / 2; // } // } // // Path: src/org/darkstorm/minecraft/gui/theme/AbstractTheme.java // public abstract class AbstractTheme implements Theme { // protected final Map<Class<? extends Component>, ComponentUI> uis; // // public AbstractTheme() { // uis = new HashMap<Class<? extends Component>, ComponentUI>(); // } // // protected void installUI(AbstractComponentUI<?> ui) { // uis.put(ui.handledComponentClass, ui); // } // // public ComponentUI getUIForComponent(Component component) { // if(component == null || !(component instanceof Component)) // throw new IllegalArgumentException(); // return getComponentUIForClass(component.getClass()); // } // // @SuppressWarnings("unchecked") // public ComponentUI getComponentUIForClass( // Class<? extends Component> componentClass) { // for(Class<?> componentInterface : componentClass.getInterfaces()) { // ComponentUI ui = uis.get(componentInterface); // if(ui != null) // return ui; // } // if(componentClass.getSuperclass().equals(Component.class)) // return uis.get(componentClass); // else if(!Component.class.isAssignableFrom(componentClass // .getSuperclass())) // return null; // WTF? // return getComponentUIForClass((Class<? extends Component>) componentClass // .getSuperclass()); // } // // }
import java.awt.Font; import net.minecraft.client.gui.FontRenderer; import org.darkstorm.minecraft.gui.font.UnicodeFontRenderer; import org.darkstorm.minecraft.gui.theme.AbstractTheme;
package org.darkstorm.minecraft.gui.theme.simple; public class SimpleTheme extends AbstractTheme { private final FontRenderer fontRenderer; public SimpleTheme() {
// Path: src/org/darkstorm/minecraft/gui/font/UnicodeFontRenderer.java // public class UnicodeFontRenderer extends FontRenderer { // private final UnicodeFont font; // // @SuppressWarnings("unchecked") // public UnicodeFontRenderer(Font awtFont) { // super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"), Minecraft.getMinecraft().getTextureManager(), false); // // font = new UnicodeFont(awtFont); // font.addAsciiGlyphs(); // font.getEffects().add(new ColorEffect(Color.WHITE)); // try { // font.loadGlyphs(); // } catch(SlickException exception) { // throw new RuntimeException(exception); // } // String alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; // FONT_HEIGHT = font.getHeight(alphabet) / 2; // } // // @Override // public int drawString(String string, int x, int y, int color) { // if(string == null) // return 0; // // glClear(256); // // glMatrixMode(GL_PROJECTION); // // glLoadIdentity(); // // IntBuffer buffer = BufferUtils.createIntBuffer(16); // // glGetInteger(GL_VIEWPORT, buffer); // // glOrtho(0, buffer.get(2), buffer.get(3), 0, 1000, 3000); // // glMatrixMode(GL_MODELVIEW); // // glLoadIdentity(); // // glTranslatef(0, 0, -2000); // glPushMatrix(); // glScaled(0.5, 0.5, 0.5); // // boolean blend = glIsEnabled(GL_BLEND); // boolean lighting = glIsEnabled(GL_LIGHTING); // boolean texture = glIsEnabled(GL_TEXTURE_2D); // if(!blend) // glEnable(GL_BLEND); // if(lighting) // glDisable(GL_LIGHTING); // if(texture) // glDisable(GL_TEXTURE_2D); // x *= 2; // y *= 2; // // glBegin(GL_LINES); // // glVertex3d(x, y, 0); // // glVertex3d(x + getStringWidth(string), y + FONT_HEIGHT, 0); // // glEnd(); // // font.drawString(x, y, string, new org.newdawn.slick.Color(color)); // // if(texture) // glEnable(GL_TEXTURE_2D); // if(lighting) // glEnable(GL_LIGHTING); // if(!blend) // glDisable(GL_BLEND); // glPopMatrix(); // return x; // } // // @Override // public int func_175063_a(String string, float x, float y, int color) { // return drawString(string, (int) x, (int) y, color); // } // // @Override // public int getCharWidth(char c) { // return getStringWidth(Character.toString(c)); // } // // @Override // public int getStringWidth(String string) { // return font.getWidth(string) / 2; // } // // public int getStringHeight(String string) { // return font.getHeight(string) / 2; // } // } // // Path: src/org/darkstorm/minecraft/gui/theme/AbstractTheme.java // public abstract class AbstractTheme implements Theme { // protected final Map<Class<? extends Component>, ComponentUI> uis; // // public AbstractTheme() { // uis = new HashMap<Class<? extends Component>, ComponentUI>(); // } // // protected void installUI(AbstractComponentUI<?> ui) { // uis.put(ui.handledComponentClass, ui); // } // // public ComponentUI getUIForComponent(Component component) { // if(component == null || !(component instanceof Component)) // throw new IllegalArgumentException(); // return getComponentUIForClass(component.getClass()); // } // // @SuppressWarnings("unchecked") // public ComponentUI getComponentUIForClass( // Class<? extends Component> componentClass) { // for(Class<?> componentInterface : componentClass.getInterfaces()) { // ComponentUI ui = uis.get(componentInterface); // if(ui != null) // return ui; // } // if(componentClass.getSuperclass().equals(Component.class)) // return uis.get(componentClass); // else if(!Component.class.isAssignableFrom(componentClass // .getSuperclass())) // return null; // WTF? // return getComponentUIForClass((Class<? extends Component>) componentClass // .getSuperclass()); // } // // } // Path: src/org/darkstorm/minecraft/gui/theme/simple/SimpleTheme.java import java.awt.Font; import net.minecraft.client.gui.FontRenderer; import org.darkstorm.minecraft.gui.font.UnicodeFontRenderer; import org.darkstorm.minecraft.gui.theme.AbstractTheme; package org.darkstorm.minecraft.gui.theme.simple; public class SimpleTheme extends AbstractTheme { private final FontRenderer fontRenderer; public SimpleTheme() {
fontRenderer = new UnicodeFontRenderer(new Font("Trebuchet MS", Font.PLAIN, 15));
IAmContent/public
public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange NORMAL_RANGE = range(0.0, 1.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange REVERSE_NORMAL_RANGE = range(1.0, 0.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // }
import static com.iamcontent.core.math.DoubleRange.NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.REVERSE_NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.range;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; /** * Converts Double objects linearly according to two corresponding {@link Range} objects. * @author Greg Elderfield */ public class InterRangeDoubleConverter implements DoubleConverter { public static final ClampingMode DEFAULT_MODE = ClampingMode.CLAMPED;
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange NORMAL_RANGE = range(0.0, 1.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange REVERSE_NORMAL_RANGE = range(1.0, 0.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // } // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java import static com.iamcontent.core.math.DoubleRange.NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.REVERSE_NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.range; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; /** * Converts Double objects linearly according to two corresponding {@link Range} objects. * @author Greg Elderfield */ public class InterRangeDoubleConverter implements DoubleConverter { public static final ClampingMode DEFAULT_MODE = ClampingMode.CLAMPED;
public static final InterRangeDoubleConverter REVERSE_NORMAL_CONVERTER = converterFromNormalTo(REVERSE_NORMAL_RANGE);
IAmContent/public
public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange NORMAL_RANGE = range(0.0, 1.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange REVERSE_NORMAL_RANGE = range(1.0, 0.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // }
import static com.iamcontent.core.math.DoubleRange.NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.REVERSE_NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.range;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; /** * Converts Double objects linearly according to two corresponding {@link Range} objects. * @author Greg Elderfield */ public class InterRangeDoubleConverter implements DoubleConverter { public static final ClampingMode DEFAULT_MODE = ClampingMode.CLAMPED; public static final InterRangeDoubleConverter REVERSE_NORMAL_CONVERTER = converterFromNormalTo(REVERSE_NORMAL_RANGE); /** * Indicates whether a converted value should be clamped to its target range or not. */ public static enum ClampingMode { CLAMPED { @Override double apply(double d, DoubleRange r) { return r.clamp(d); } }, UNCLAMPED { @Override double apply(double d, DoubleRange r) { return d; } }; abstract double apply(double d, DoubleRange r); }; private final DoubleRange fromRange, toRange; private final ClampingMode clampingMode; public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange) { this(fromRange, toRange, DEFAULT_MODE); } public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { this.fromRange = fromRange; this.toRange = toRange; this.clampingMode = clampingMode; } public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange NORMAL_RANGE = range(0.0, 1.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange REVERSE_NORMAL_RANGE = range(1.0, 0.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // } // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java import static com.iamcontent.core.math.DoubleRange.NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.REVERSE_NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.range; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.core.math; /** * Converts Double objects linearly according to two corresponding {@link Range} objects. * @author Greg Elderfield */ public class InterRangeDoubleConverter implements DoubleConverter { public static final ClampingMode DEFAULT_MODE = ClampingMode.CLAMPED; public static final InterRangeDoubleConverter REVERSE_NORMAL_CONVERTER = converterFromNormalTo(REVERSE_NORMAL_RANGE); /** * Indicates whether a converted value should be clamped to its target range or not. */ public static enum ClampingMode { CLAMPED { @Override double apply(double d, DoubleRange r) { return r.clamp(d); } }, UNCLAMPED { @Override double apply(double d, DoubleRange r) { return d; } }; abstract double apply(double d, DoubleRange r); }; private final DoubleRange fromRange, toRange; private final ClampingMode clampingMode; public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange) { this(fromRange, toRange, DEFAULT_MODE); } public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { this.fromRange = fromRange; this.toRange = toRange; this.clampingMode = clampingMode; } public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) {
return converterFromNormalTo(range(toLimit1, toLimit2));
IAmContent/public
public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange NORMAL_RANGE = range(0.0, 1.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange REVERSE_NORMAL_RANGE = range(1.0, 0.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // }
import static com.iamcontent.core.math.DoubleRange.NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.REVERSE_NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.range;
return r.clamp(d); } }, UNCLAMPED { @Override double apply(double d, DoubleRange r) { return d; } }; abstract double apply(double d, DoubleRange r); }; private final DoubleRange fromRange, toRange; private final ClampingMode clampingMode; public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange) { this(fromRange, toRange, DEFAULT_MODE); } public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { this.fromRange = fromRange; this.toRange = toRange; this.clampingMode = clampingMode; } public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { return converterFromNormalTo(range(toLimit1, toLimit2)); } public static InterRangeDoubleConverter converterFromNormalTo(DoubleRange toRange) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange NORMAL_RANGE = range(0.0, 1.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static final DoubleRange REVERSE_NORMAL_RANGE = range(1.0, 0.0); // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/DoubleRange.java // public static DoubleRange range(double limit1, double limit2) { // return new DoubleRange(limit1, limit2); // } // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java import static com.iamcontent.core.math.DoubleRange.NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.REVERSE_NORMAL_RANGE; import static com.iamcontent.core.math.DoubleRange.range; return r.clamp(d); } }, UNCLAMPED { @Override double apply(double d, DoubleRange r) { return d; } }; abstract double apply(double d, DoubleRange r); }; private final DoubleRange fromRange, toRange; private final ClampingMode clampingMode; public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange) { this(fromRange, toRange, DEFAULT_MODE); } public InterRangeDoubleConverter(DoubleRange fromRange, DoubleRange toRange, ClampingMode clampingMode) { this.fromRange = fromRange; this.toRange = toRange; this.clampingMode = clampingMode; } public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { return converterFromNormalTo(range(toLimit1, toLimit2)); } public static InterRangeDoubleConverter converterFromNormalTo(DoubleRange toRange) {
return interRangeConverter(NORMAL_RANGE, toRange, DEFAULT_MODE);
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/AbstractPololuMaestroServoCardIT.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/ThreadUtils.java // public class ThreadUtils { // // /** // * Invokes Thread.sleep(long), catching any {@link InterruptedException} that is thrown. // * @param millis The length of time to sleep in milliseconds. // * @return true if Thread.sleep(long) terminated normally, false if an {@link InterruptedException} was thrown. // */ // public static boolean sleepQuietly(long millis) { // try { // Thread.sleep(millis); // } catch (InterruptedException e) { // return false; // } // return true; // } // // /** // * Polls periodically to see whether a given condition ever becomes true. // * @param condition The condition to poll for. // * @param waitPeriodInMillis The total time to poll for, in milliseconds. // * @param pollPeriodInMillis The time between polls, in milliseconds. // * @return true if the condition ever returned true, false otherwise. // */ // public static boolean sleepUntil(Supplier<Boolean> condition, long waitPeriodInMillis, long pollPeriodInMillis) { // final long finishTime = currentTimeMillis() + waitPeriodInMillis; // while (finishTime > currentTimeMillis()) { // if (condition.get()) // return true; // ThreadUtils.sleepQuietly(pollPeriodInMillis); // } // return condition.get(); // } // // }
import static org.junit.Assert.assertEquals; import org.junit.Test; import com.iamcontent.core.ThreadUtils;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple abstract integration test for Pololu Maestro servo cards. * @author Greg Elderfield */ public abstract class AbstractPololuMaestroServoCardIT { private static final int CHANNEL = 0; private final double acceleration; private final double speed; private final double position; private final double midPosition; public AbstractPololuMaestroServoCardIT(double acceleration, double speed, double position, double midPosition) { this.acceleration = acceleration; this.speed = speed; this.position = position; this.midPosition = midPosition; } @Test public void testRawDynamics() throws Exception { resetDynamics(); setAcceleration(CHANNEL, acceleration); setSpeed(CHANNEL, speed); setPosition(CHANNEL, position); waitForServoPosition(CHANNEL, position); final double measuredPosition = getPosition(CHANNEL); assertEquals(position, measuredPosition, 0.0001); } protected abstract void setAcceleration(int channel, double acceleration); protected abstract void setSpeed(int channel, double speed); protected abstract void setPosition(int channel, double position); protected abstract double getPosition(int channel); private void waitForServoPosition(int channel, double position) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/ThreadUtils.java // public class ThreadUtils { // // /** // * Invokes Thread.sleep(long), catching any {@link InterruptedException} that is thrown. // * @param millis The length of time to sleep in milliseconds. // * @return true if Thread.sleep(long) terminated normally, false if an {@link InterruptedException} was thrown. // */ // public static boolean sleepQuietly(long millis) { // try { // Thread.sleep(millis); // } catch (InterruptedException e) { // return false; // } // return true; // } // // /** // * Polls periodically to see whether a given condition ever becomes true. // * @param condition The condition to poll for. // * @param waitPeriodInMillis The total time to poll for, in milliseconds. // * @param pollPeriodInMillis The time between polls, in milliseconds. // * @return true if the condition ever returned true, false otherwise. // */ // public static boolean sleepUntil(Supplier<Boolean> condition, long waitPeriodInMillis, long pollPeriodInMillis) { // final long finishTime = currentTimeMillis() + waitPeriodInMillis; // while (finishTime > currentTimeMillis()) { // if (condition.get()) // return true; // ThreadUtils.sleepQuietly(pollPeriodInMillis); // } // return condition.get(); // } // // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/test/java/com/iamcontent/device/controller/pololu/maestro/AbstractPololuMaestroServoCardIT.java import static org.junit.Assert.assertEquals; import org.junit.Test; import com.iamcontent.core.ThreadUtils; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro; /** * A simple abstract integration test for Pololu Maestro servo cards. * @author Greg Elderfield */ public abstract class AbstractPololuMaestroServoCardIT { private static final int CHANNEL = 0; private final double acceleration; private final double speed; private final double position; private final double midPosition; public AbstractPololuMaestroServoCardIT(double acceleration, double speed, double position, double midPosition) { this.acceleration = acceleration; this.speed = speed; this.position = position; this.midPosition = midPosition; } @Test public void testRawDynamics() throws Exception { resetDynamics(); setAcceleration(CHANNEL, acceleration); setSpeed(CHANNEL, speed); setPosition(CHANNEL, position); waitForServoPosition(CHANNEL, position); final double measuredPosition = getPosition(CHANNEL); assertEquals(position, measuredPosition, 0.0001); } protected abstract void setAcceleration(int channel, double acceleration); protected abstract void setSpeed(int channel, double speed); protected abstract void setPosition(int channel, double position); protected abstract double getPosition(int channel); private void waitForServoPosition(int channel, double position) {
ThreadUtils.sleepUntil(() -> getPosition(channel) == position, 5000, 20);
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServo.java // public class CalibratedServo extends CalibratedAnalogIO implements Servo { // // public CalibratedServo(Servo target, ServoCalibration calibration) { // super(target, calibration); // } // // @Override // public MutableDouble value() { // return delegate().value().calibrated(calibration().value()); // } // // @Override // public MutableDouble speed() { // return delegate().speed().calibrated(calibration().speed()); // } // // @Override // public MutableDouble acceleration() { // return delegate().acceleration().calibrated(calibration().acceleration()); // } // // @Override // protected ServoCalibration calibration() { // return (ServoCalibration) super.calibration(); // } // // @Override // protected Servo delegate() { // return (Servo) super.delegate(); // } // }
import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.servo.impl.CalibratedServo;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a Servo. * @author Greg Elderfield */ public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { /** * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. */ default Servo calibrated(ServoCalibration calibration) {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/MutableDouble.java // public interface MutableDouble { // double getValue(); // void setValue(double v); // // /** // * Returns a proxy MutableDouble that is a two-way calibrated representation of this value. // */ // default MutableDouble calibrated(DoubleConverter calibration) { // return new CalibratedMutableDouble(this, calibration); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIO.java // public interface AnalogIO extends AnalogIOFeatures<MutableDouble> { // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIO calibrated(AnalogIOCalibration calibration) { // return new CalibratedAnalogIO(this, calibration); // } // // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServo.java // public class CalibratedServo extends CalibratedAnalogIO implements Servo { // // public CalibratedServo(Servo target, ServoCalibration calibration) { // super(target, calibration); // } // // @Override // public MutableDouble value() { // return delegate().value().calibrated(calibration().value()); // } // // @Override // public MutableDouble speed() { // return delegate().speed().calibrated(calibration().speed()); // } // // @Override // public MutableDouble acceleration() { // return delegate().acceleration().calibrated(calibration().acceleration()); // } // // @Override // protected ServoCalibration calibration() { // return (ServoCalibration) super.calibration(); // } // // @Override // protected Servo delegate() { // return (Servo) super.delegate(); // } // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java import com.iamcontent.core.math.MutableDouble; import com.iamcontent.device.io.analog.AnalogIO; import com.iamcontent.device.servo.impl.CalibratedServo; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo; /** * Represents a Servo. * @author Greg Elderfield */ public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { /** * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. */ default Servo calibrated(ServoCalibration calibration) {
return new CalibratedServo(this, calibration);
IAmContent/public
public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // }
import com.iamcontent.io.usb.Usb; import java.util.function.Predicate; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * A factory for {@link AbstractUsbPololuMaestroServoCard}s. * @author Greg Elderfield */ public class UsbPololuMaestroServoCards { /** * Creates an instance with the first Pololu Maestro {@link UsbDevice} that is found. */ public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() {
// Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/PololuMaestroServoCard.java // public interface PololuMaestroServoCard { // // interface State { // short getPosition(short channel); // } // // void setPosition(short channel, short position); // void setSpeed(short channel, short speed); // void setAcceleration(short channel, short acceleration); // // short getPosition(short channel); // State getState(); // // MaestroCardType getType(); // // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java // public class Usb { // // public static EasyUsbDevice device(short vendorId, short productId) { // return first(devices(vendorId, productId)); // } // // public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { // return first(devices(shouldIncludeDevice)); // } // // public static List<EasyUsbDevice> devices(short vendorId, short productId) { // return devices(deviceHasVendorIdAndProductId(vendorId, productId)); // } // // public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) { // final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice); // deviceFinder.exploreRootUsbHub(); // return deviceFinder.getDevices(); // } // // public static UsbHub rootUsbHub() { // try { // return usbServices().getRootUsbHub(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // public static UsbServices usbServices() { // try { // return UsbHostManager.getUsbServices(); // } catch (Exception e) { // throw new UsbRuntimeException(e); // } // } // // private static <T> T first(List<T> l) { // try { // return l.get(0); // } catch (IndexOutOfBoundsException e) { // throw new UsbRuntimeException("No suitable USB Device found."); // } // } // // private Usb() { // } // } // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/usb/UsbPololuMaestroServoCards.java import com.iamcontent.io.usb.Usb; import java.util.function.Predicate; import javax.usb.UsbDevice; import com.iamcontent.device.controller.pololu.maestro.PololuMaestroServoCard; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.controller.pololu.maestro.usb; /** * A factory for {@link AbstractUsbPololuMaestroServoCard}s. * @author Greg Elderfield */ public class UsbPololuMaestroServoCards { /** * Creates an instance with the first Pololu Maestro {@link UsbDevice} that is found. */ public static PololuMaestroServoCard defaultUsbPololuMaestroServoCard() {
return usbPololuMaestroServoCard(Usb.device(isAMaestroUsbDevice()));
IAmContent/public
public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public interface ServoSourceCalibration<C> extends PerChannelSource<C, ServoCalibration> { // // // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration() { // return servoSourceCalibration(ServoCalibration.IDENTITY); // } // }
import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.device.servo.ServoSourceCalibration;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. * All {@link Servo}s are calibrated using the same {@link ServoSourceCalibration} * * @author Greg Elderfield */ public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { protected final ServoSourceCalibration<C> calibration; public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { super(target); this.calibration = calibration; } @Override
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/lang/Delegator.java // public abstract class Delegator<D> { // private final D delegate; // // public Delegator(D delegate) { // requireNonNull(delegate, "Delegate cannot be null."); // this.delegate = delegate; // } // // protected D delegate() { // return delegate; // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/Servo.java // public interface Servo extends AnalogIO, ServoFeatures<MutableDouble> { // // /** // * Returns a proxy {@link Servo} that is two-way calibrated representation of this instance. // */ // default Servo calibrated(ServoCalibration calibration) { // return new CalibratedServo(this, calibration); // } // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSource.java // public interface ServoSource<C> extends PerChannelSource<C, Servo> { // // /** // * Returns a ServoSource that has new channel ids, as defined by the given function. // */ // default <NewServoId> ServoSource<NewServoId> remapped(Function<NewServoId, C> remapping) { // return new RemappedServoSource<NewServoId, C>(this, remapping); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoSourceCalibration<C> calibration) { // return new CalibratedServoSource<C>(this, calibration); // } // // /** // * Returns a ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. // */ // default ServoSource<C> calibrated(ServoCalibration calibration) { // return calibrated(servoSourceCalibration(calibration)); // } // // /** // * @return A {@link ServoSource} of {@link RawServo}s for the given {@link ServoController}. // */ // public static <C> ServoSource<C> rawServoSource(final ServoController<C> controller) { // return new ServoSource<C>() { // @Override // public Servo forChannel(C channel) { // return new RawServo<C>(controller, channel); // } // }; // } // // } // // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/ServoSourceCalibration.java // public interface ServoSourceCalibration<C> extends PerChannelSource<C, ServoCalibration> { // // // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration(ServoCalibration calibration) { // return new DefaultingServoSourceCalibration<C>(calibration); // } // // public static <C> DefaultingServoSourceCalibration<C> servoSourceCalibration() { // return servoSourceCalibration(ServoCalibration.IDENTITY); // } // } // Path: public-java/io/iamcontent-servos/src/main/java/com/iamcontent/device/servo/impl/CalibratedServoSource.java import com.iamcontent.core.lang.Delegator; import com.iamcontent.device.servo.Servo; import com.iamcontent.device.servo.ServoSource; import com.iamcontent.device.servo.ServoSourceCalibration; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.device.servo.impl; /** * A ServoSource that returns calibrated proxies of the {@link Servo}s from another (target) {@link ServoSource}. * All {@link Servo}s are calibrated using the same {@link ServoSourceCalibration} * * @author Greg Elderfield */ public class CalibratedServoSource<C> extends Delegator<ServoSource<C>> implements ServoSource<C> { protected final ServoSourceCalibration<C> calibration; public CalibratedServoSource(ServoSource<C> target, ServoSourceCalibration<C> calibration) { super(target); this.calibration = calibration; } @Override
public Servo forChannel(C channelId) {
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) { // return new Predicate<UsbDevice>() { // public boolean test(UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device); // } // }; // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public class UsbDeviceFinder extends UsbTopologyExplorer { // // public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // super(shouldIncludeDevice); // } // // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); // // @Override // public void visit(UsbDevice usbDevice) { // devices.add(eased(usbDevice)); // } // // public List<EasyUsbDevice> getDevices() { // return Collections.unmodifiableList(devices); // } // }
import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId; import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHostManager; import javax.usb.UsbHub; import javax.usb.UsbServices; import com.iamcontent.io.usb.topology.UsbDeviceFinder;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * USB utility methods. * @author Greg Elderfield */ public class Usb { public static EasyUsbDevice device(short vendorId, short productId) { return first(devices(vendorId, productId)); } public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { return first(devices(shouldIncludeDevice)); } public static List<EasyUsbDevice> devices(short vendorId, short productId) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) { // return new Predicate<UsbDevice>() { // public boolean test(UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device); // } // }; // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public class UsbDeviceFinder extends UsbTopologyExplorer { // // public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // super(shouldIncludeDevice); // } // // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); // // @Override // public void visit(UsbDevice usbDevice) { // devices.add(eased(usbDevice)); // } // // public List<EasyUsbDevice> getDevices() { // return Collections.unmodifiableList(devices); // } // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId; import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHostManager; import javax.usb.UsbHub; import javax.usb.UsbServices; import com.iamcontent.io.usb.topology.UsbDeviceFinder; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * USB utility methods. * @author Greg Elderfield */ public class Usb { public static EasyUsbDevice device(short vendorId, short productId) { return first(devices(vendorId, productId)); } public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { return first(devices(shouldIncludeDevice)); } public static List<EasyUsbDevice> devices(short vendorId, short productId) {
return devices(deviceHasVendorIdAndProductId(vendorId, productId));
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) { // return new Predicate<UsbDevice>() { // public boolean test(UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device); // } // }; // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public class UsbDeviceFinder extends UsbTopologyExplorer { // // public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // super(shouldIncludeDevice); // } // // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); // // @Override // public void visit(UsbDevice usbDevice) { // devices.add(eased(usbDevice)); // } // // public List<EasyUsbDevice> getDevices() { // return Collections.unmodifiableList(devices); // } // }
import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId; import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHostManager; import javax.usb.UsbHub; import javax.usb.UsbServices; import com.iamcontent.io.usb.topology.UsbDeviceFinder;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * USB utility methods. * @author Greg Elderfield */ public class Usb { public static EasyUsbDevice device(short vendorId, short productId) { return first(devices(vendorId, productId)); } public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { return first(devices(shouldIncludeDevice)); } public static List<EasyUsbDevice> devices(short vendorId, short productId) { return devices(deviceHasVendorIdAndProductId(vendorId, productId)); } public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) { // return new Predicate<UsbDevice>() { // public boolean test(UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device); // } // }; // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public class UsbDeviceFinder extends UsbTopologyExplorer { // // public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // super(shouldIncludeDevice); // } // // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); // // @Override // public void visit(UsbDevice usbDevice) { // devices.add(eased(usbDevice)); // } // // public List<EasyUsbDevice> getDevices() { // return Collections.unmodifiableList(devices); // } // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId; import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHostManager; import javax.usb.UsbHub; import javax.usb.UsbServices; import com.iamcontent.io.usb.topology.UsbDeviceFinder; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * USB utility methods. * @author Greg Elderfield */ public class Usb { public static EasyUsbDevice device(short vendorId, short productId) { return first(devices(vendorId, productId)); } public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { return first(devices(shouldIncludeDevice)); } public static List<EasyUsbDevice> devices(short vendorId, short productId) { return devices(deviceHasVendorIdAndProductId(vendorId, productId)); } public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) {
final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice);
IAmContent/public
public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) { // return new Predicate<UsbDevice>() { // public boolean test(UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device); // } // }; // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public class UsbDeviceFinder extends UsbTopologyExplorer { // // public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // super(shouldIncludeDevice); // } // // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); // // @Override // public void visit(UsbDevice usbDevice) { // devices.add(eased(usbDevice)); // } // // public List<EasyUsbDevice> getDevices() { // return Collections.unmodifiableList(devices); // } // }
import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId; import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHostManager; import javax.usb.UsbHub; import javax.usb.UsbServices; import com.iamcontent.io.usb.topology.UsbDeviceFinder;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * USB utility methods. * @author Greg Elderfield */ public class Usb { public static EasyUsbDevice device(short vendorId, short productId) { return first(devices(vendorId, productId)); } public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { return first(devices(shouldIncludeDevice)); } public static List<EasyUsbDevice> devices(short vendorId, short productId) { return devices(deviceHasVendorIdAndProductId(vendorId, productId)); } public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) {
// Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/UsbDevicePredicates.java // public static Predicate<UsbDevice> deviceHasVendorIdAndProductId(final short vendorId, final short productId) { // return new Predicate<UsbDevice>() { // public boolean test(UsbDevice device) { // return vendorAndProductIdsMatch(vendorId, productId, device); // } // }; // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/topology/UsbDeviceFinder.java // public class UsbDeviceFinder extends UsbTopologyExplorer { // // public UsbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // super(shouldIncludeDevice); // } // // public static UsbDeviceFinder usbDeviceFinder(Predicate<UsbDevice> shouldIncludeDevice) { // return new UsbDeviceFinder(shouldIncludeDevice); // } // // private final List<EasyUsbDevice> devices = new ArrayList<EasyUsbDevice>(); // // @Override // public void visit(UsbDevice usbDevice) { // devices.add(eased(usbDevice)); // } // // public List<EasyUsbDevice> getDevices() { // return Collections.unmodifiableList(devices); // } // } // Path: public-java/io/iamcontent-usb/src/main/java/com/iamcontent/io/usb/Usb.java import static com.iamcontent.io.usb.UsbDevicePredicates.deviceHasVendorIdAndProductId; import static com.iamcontent.io.usb.topology.UsbDeviceFinder.usbDeviceFinder; import java.util.List; import java.util.function.Predicate; import javax.usb.UsbDevice; import javax.usb.UsbHostManager; import javax.usb.UsbHub; import javax.usb.UsbServices; import com.iamcontent.io.usb.topology.UsbDeviceFinder; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.io.usb; /** * USB utility methods. * @author Greg Elderfield */ public class Usb { public static EasyUsbDevice device(short vendorId, short productId) { return first(devices(vendorId, productId)); } public static EasyUsbDevice device(Predicate<UsbDevice> shouldIncludeDevice) { return first(devices(shouldIncludeDevice)); } public static List<EasyUsbDevice> devices(short vendorId, short productId) { return devices(deviceHasVendorIdAndProductId(vendorId, productId)); } public static List<EasyUsbDevice> devices(Predicate<UsbDevice> shouldIncludeDevice) {
final UsbDeviceFinder deviceFinder = usbDeviceFinder(shouldIncludeDevice);
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // }
import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() {
return rawAnalogIOSource()
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // }
import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() { return rawAnalogIOSource() .calibrated(normalization()) .remapped(remapping()) .calibrated(tuning()); }
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() { return rawAnalogIOSource() .calibrated(normalization()) .remapped(remapping()) .calibrated(tuning()); }
private static AnalogIOSourceCalibration<Integer> normalization() {
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // }
import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() { return rawAnalogIOSource() .calibrated(normalization()) .remapped(remapping()) .calibrated(tuning()); } private static AnalogIOSourceCalibration<Integer> normalization() {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() { return rawAnalogIOSource() .calibrated(normalization()) .remapped(remapping()) .calibrated(tuning()); } private static AnalogIOSourceCalibration<Integer> normalization() {
return AnalogIOSourceCalibration.analogIOSourceCalibration(new ImmutableAnalogIOCalibration(converterFromNormalTo(0.0, 255.0))); // FIXME: Create default normalization for Poulu IO
IAmContent/public
public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // }
import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova;
/** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() { return rawAnalogIOSource() .calibrated(normalization()) .remapped(remapping()) .calibrated(tuning()); } private static AnalogIOSourceCalibration<Integer> normalization() {
// Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/math/InterRangeDoubleConverter.java // public static InterRangeDoubleConverter converterFromNormalTo(double toLimit1, double toLimit2) { // return converterFromNormalTo(range(toLimit1, toLimit2)); // } // // Path: public-java/devices/iamcontent-pololu-servo-controllers/src/main/java/com/iamcontent/device/controller/pololu/maestro/DefaultPololuServoConfig.java // public static AnalogIOSource<Integer> rawAnalogIOSource() { // return AnalogIOSource.rawAnalogIOSource(servoController()); // } // // Path: public-java/iamcontent-core/src/main/java/com/iamcontent/core/geom/Geometry.java // public enum ThreeDimension { // X, Y, Z // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSource.java // public interface AnalogIOSource<C> extends PerChannelSource<C, AnalogIO> { // // /** // * Returns a AnalogIOSource that has new channel ids, as defined by the given function. // */ // default <NewChannelId> AnalogIOSource<NewChannelId> remapped(Function<NewChannelId, C> remapping) { // return new RemappedAnalogIOSource<NewChannelId, C>(this, remapping); // } // // /** // * Returns a proxy AnalogIO that is two-way calibrated representation of this instance. // */ // default AnalogIOSource<C> calibrated(AnalogIOSourceCalibration<C> calibration) { // return new CalibratedAnalogIOSource<C>(this, calibration); // } // // public static <C> AnalogIOSource<C> rawAnalogIOSource(final AnalogIOController<C> controller) { // return new AnalogIOSource<C>() { // @Override // public AnalogIO forChannel(C channelId) { // return new RawAnalogIO<C>(controller, channelId); // } // }; // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/AnalogIOSourceCalibration.java // public interface AnalogIOSourceCalibration<C> extends PerChannelSource<C, AnalogIOCalibration> { // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration(AnalogIOCalibration calibration) { // return new DefaultingAnalogIOSourceCalibration<C>(calibration); // } // // public static <C> DefaultingAnalogIOSourceCalibration<C> analogIOSourceCalibration() { // return analogIOSourceCalibration(AnalogIOCalibration.IDENTITY); // } // } // // Path: public-java/io/iamcontent-io-channels/src/main/java/com/iamcontent/device/io/analog/impl/ImmutableAnalogIOCalibration.java // public class ImmutableAnalogIOCalibration implements AnalogIOCalibration { // // private final DoubleConverter value; // // public ImmutableAnalogIOCalibration(DoubleConverter value) { // this.value = value; // } // // @Override // public DoubleConverter value() { // return value; // } // } // // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/Robonova.java // public interface Robonova { // ServoSource<ServoId> servos(); // AnalogIOSource<ThreeDimension> accelerometer(); // } // Path: public-java/robots/iamcontent-robonova-1/src/main/java/com/iamcontent/robot/robonova1/custom1/CustomRobonovaAccelerometer.java import static com.iamcontent.core.math.InterRangeDoubleConverter.converterFromNormalTo; import static com.iamcontent.device.controller.pololu.maestro.DefaultPololuServoConfig.rawAnalogIOSource; import java.util.function.Function; import com.iamcontent.core.geom.Geometry.ThreeDimension; import com.iamcontent.device.io.analog.AnalogIOSource; import com.iamcontent.device.io.analog.AnalogIOSourceCalibration; import com.iamcontent.device.io.analog.impl.ImmutableAnalogIOCalibration; import com.iamcontent.robot.robonova1.Robonova; /** IAmContent Public Libraries. Copyright (C) 2015-2021 Greg Elderfield @author Greg Elderfield, support@jarchitect.co.uk This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package com.iamcontent.robot.robonova1.custom1; /** * Provides a custom accelerometer for my own {@link Robonova}. * @author Greg Elderfield */ public class CustomRobonovaAccelerometer { public static AnalogIOSource<ThreeDimension> accelerometer() { return rawAnalogIOSource() .calibrated(normalization()) .remapped(remapping()) .calibrated(tuning()); } private static AnalogIOSourceCalibration<Integer> normalization() {
return AnalogIOSourceCalibration.analogIOSourceCalibration(new ImmutableAnalogIOCalibration(converterFromNormalTo(0.0, 255.0))); // FIXME: Create default normalization for Poulu IO