⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genericrpattributes.java

📁 这是一个基于java编写的torrent的P2P源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        attributes.put("max_download_rate",   int.class);
        attributes.put("max_upload_rate",     int.class);
        attributes.put("position",            int.class);
        attributes.put("save_path",           String.class);
        attributes.put("seeding_rank",        int.class);
        attributes.put("state",               int.class);
        attributes.put("sub_state",           int.class);
        attributes.put("torrent_file",        String.class);
        attributes.put("checking",            boolean.class);
        attributes.put("complete",            boolean.class);
        attributes.put("messaging_enabled",   boolean.class);
        attributes.put("paused",              boolean.class);
        attributes.put("persistent",          boolean.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = DownloadAnnounceResult.class;
        attributes.put("seed_count",          int.class);
        attributes.put("non_seed_count",      int.class);
        attributes.put("error",               String.class);
        attributes.put("reported_peer_count", int.class);
        attributes.put("response_type",       int.class);
        attributes.put("time_to_wait",        long.class);
        attributes.put("url",                 URL.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = DownloadScrapeResult.class;
        attributes.put("seed_count",      int.class);
        attributes.put("non_seed_count",  int.class);
        attributes.put("next_start_time", long.class);
        attributes.put("response_type",   int.class);
        attributes.put("start_time",      long.class);
        attributes.put("status",          String.class);
        attributes.put("url",             URL.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = DownloadStats.class;
        attributes.put("downloaded",              long.class);
        attributes.put("uploaded",                long.class);
        attributes.put("completed",               int.class);
        attributes.put("downloadCompletedLive",   int.class);
        attributes.put("downloadCompletedStored", int.class);
        attributes.put("status",                  String.class);
        attributes.put("status_localised",        String.class);
        attributes.put("upload_average",          long.class);
        attributes.put("download_average",        long.class);
        attributes.put("eta",                     String.class);
        attributes.put("share_ratio",             int.class);
        attributes.put("availability",            float.class);
        attributes.put("health",                  int.class);
        attributes.put("discarded",               long.class);
        attributes.put("elapsed_time",            String.class);
        attributes.put("hash_fails",              long.class);
        attributes.put("seconds_downloading",     long.class);
        attributes.put("seconds_only_seeding",    long.class);
        attributes.put("download_directory",      String.class);
        attributes.put("target_file_or_dir",      String.class);
        attributes.put("time_started",            long.class);
        attributes.put("time_started_seeding",    long.class);
        attributes.put("total_average",           long.class);
        attributes.put("tracker_status",          String.class);
        attributes.put("remaining",               long.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = IPFilter.class;
        attributes.put("last_update_time",      long.class);
        attributes.put("number_of_ranges",      int.class);
        attributes.put("number_of_blocked_ips", int.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = IPRange.class;
        attributes.put("description", String.class);
        attributes.put("start_ip",    String.class);
        attributes.put("end_ip",      String.class);
        class_definitions.put(plugin_class, attributes);
        
        attributes = new HashMap();
        plugin_class = LoggerChannel.class;
        attributes.put("enabled", boolean.class);
        attributes.put("name",    String.class);
        class_definitions.put(plugin_class, attributes);
        
        attributes = new HashMap();
        plugin_class = Peer.class;
        attributes.put("stats",              PeerStats.class);
        attributes.put("ip"  ,               String.class);
        attributes.put("port",               int.class);
        attributes.put("client",             String.class);
        attributes.put("id",                 byte[].class);
        attributes.put("percent_done",       int.class);
        attributes.put("snubbed_time",       long.class);
        attributes.put("state",              int.class);
        attributes.put("choked",             boolean.class);
        attributes.put("choking",            boolean.class);
        attributes.put("download_possible",  boolean.class);
        attributes.put("incoming",           boolean.class);
        attributes.put("interested",         boolean.class);
        attributes.put("interesting",        boolean.class);
        attributes.put("optimistic_unchoke", boolean.class);
        attributes.put("seed",               boolean.class);
        attributes.put("snubbed",            boolean.class);
        attributes.put("transfer_available", boolean.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = PeerStats.class;
        attributes.put("download_average",                  int.class);
        attributes.put("reception",                         int.class);
        attributes.put("statistic_sent_average",            int.class);
        attributes.put("time_since_connection_established", long.class);
        attributes.put("total_average",                     int.class);
        attributes.put("total_discarded",                   long.class);
        attributes.put("total_received",                    long.class);
        attributes.put("total_sent",                        long.class);
        attributes.put("upload_average",                    int.class);
        class_definitions.put(plugin_class, attributes);
        
        attributes = new HashMap();
        plugin_class = PluginConfig.class;
        attributes.put("cached_property_names",  new String[0].getClass());
        attributes.put("cached_property_values", new Object[0].getClass());
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = PluginInterface.class;
        attributes.put("azureus_name",    String.class);
        attributes.put("azureus_version", String.class);
        attributes.put("plugin_id",       String.class);
        attributes.put("plugin_name",     String.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = TrackerTorrent.class;
        attributes.put("torrent",                Torrent.class);
        attributes.put("status",                 int.class);
        attributes.put("total_uploaded",         long.class);
        attributes.put("total_downloaded",       long.class);
        attributes.put("average_uploaded",       long.class);
        attributes.put("average_downloaded",     long.class);
        attributes.put("total_left",             long.class);
        attributes.put("completed_count",        long.class);
        attributes.put("total_bytes_in",         long.class);
        attributes.put("average_bytes_in",       long.class);
        attributes.put("total_bytes_out",        long.class);
        attributes.put("average_bytes_out",      long.class);
        attributes.put("scrape_count",           long.class);
        attributes.put("average_scrape_count",   long.class);
        attributes.put("announce_count",         long.class);
        attributes.put("average_announce_count", long.class);
        attributes.put("seed_count",             int.class);
        attributes.put("leecher_count",          int.class);
        attributes.put("bad_NAT_count",          int.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = Torrent.class;
        attributes.put("name",          String.class);
        attributes.put("size",          long.class);
        attributes.put("hash",          new byte[0].getClass());
        attributes.put("comment",       String.class);
        attributes.put("created_by",    String.class);
        attributes.put("creation_date", long.class);
        attributes.put("encoding",      String.class);
        attributes.put("piece_count",   long.class);
        attributes.put("piece_size",    long.class);
        attributes.put("private",       boolean.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = RPObject.class;
        attributes.put("_object_id", int.class);
        class_definitions.put(plugin_class, attributes);

        attributes = new HashMap();
        plugin_class = RPPluginInterface.class;
        attributes.put("_object_id",     long.class);
        attributes.put("_connection_id", long.class);
        class_definitions.put(plugin_class, attributes);
    }

    public static Map getAttributeTypes(Class c) {
        Map result = (Map)class_definitions.get(c);
        if (result == null) {
            result = Collections.EMPTY_MAP;
        }
        return result;
    }

    public static Map getRPAttributeTypes(Class c) {
        Map result = null;
        if (RPPluginInterface.class.isAssignableFrom(c)) {
            result = (Map)class_definitions.get(RPPluginInterface.class);
        }
        else /* (RPObject.class.isAssignableFrom(c)) */ {
            result = (Map)class_definitions.get(RPObject.class);
        }
        return result;
    }

    public static Map getRPAttributes(RPObject object, Class obj_class, Map attribute_types) {
        RemoteClassMap map = new RemoteClassMap(attribute_types);
        if (RPPluginInterface.class.isAssignableFrom(obj_class)) {
            map.put("_connection_id", ((RPPluginInterface)object)._connection_id);
        }
        map.put("_object_id", object._getOID());
        return map;
    }


    private static class RemoteClassMap extends HashMap {

        private static RemoteMethodInvoker invoker = RemoteMethodInvoker.create(null, true);

        private Map attribute_types;

        public RemoteClassMap(Map attribute_types) {
            super();
            this.attribute_types = attribute_types;
        }

        public Object put(Object key, Object value) {
            try {
                Class c_type = (Class)attribute_types.get(key);
                if (c_type == null) {
                    throw new RuntimeException("error - missing type definition for " + key + " in RemoteClassMap");
                }
                return super.put(key, invoker.prepareRemoteResult(value, c_type));
            }
            catch (java.lang.reflect.InvocationTargetException ite) {
                throw new RuntimeException(ite);
            }
            catch (NoSuchMethodException nsme) {
                throw new RuntimeException(nsme);
            }
        }

        public Object put(String key, byte[] value) {
            return super.put(key, value);
        }

        public Object put(String key, boolean value) {
            return super.put(key, Boolean.valueOf(value));
        }

        public Object put(String key, float value) {
            return super.put(key, new Float(value));
        }

        public Object put(String key, int value) {
            return super.put(key, new Integer(value));
        }

        public Object put(String key, long value) {
            return super.put(key, new Long(value));
        }

        public Object put(String key, File value) {
            return super.put(key, value);
        }

        public Object put(String key, URL value) {
            return super.put(key, value);
        }


        public Object put(String key, String value) {
            return super.put(key, value);
        }

        public Object put(String key, String[] value) {
            return super.put(key, value);
        }

        public Object put(String key, int[] value) {
            return super.put(key, value);
        }

    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -