/** * [<PROT>://]domain:...:...:....:<active_int_boolean>[:...] * * @param address * @return */ public static boolean getActive(String address) { String domain; String[] protos = address.split(Pattern.quote(ADDR_PROT_INTERN_SEP)); if (protos.length > 1) domain = protos[1]; else domain = protos[0]; String[] ports = domain.split(Pattern.quote(ADDR_PART_SEP)); if (DEBUG) System.out.println("Address:getActive " + domain + " ports=" + Util.concat(ports, "==")); if (ports.length < 5) return true; return Util.stringInt2bool(ports[4], false); }
private void init(ArrayList<Object> in, D_Peer peer) { address = Util.getString(in.get(table.peer_address.PA_ADDRESS)); instance_ID_str = Util.getString(in.get(table.peer_address.PA_INSTANCE_ID)); _instance_ID = Util.lval(instance_ID_str, -1); if (_instance_ID > 0) { D_PeerInstance dpi = null; if (peer != null) { dpi = peer.getPeerInstance_ByID(instance_ID_str); // this._peer_ID = peer.get_ID(); } if (dpi != null) { instance = dpi.peer_instance; this.branch = dpi.branch; this.agent_version = dpi.agent_version; } else { try { System.out.println("Address:init: should not come here!"); ArrayList<ArrayList<Object>> inst = Application.db.select( "SELECT " + table.peer_instance.peer_instance + " FROM " + table.peer_instance.TNAME + " WHERE " + table.peer_instance.peer_instance_ID + "=?;", new String[] {instance_ID_str}, _DEBUG); if (inst.size() > 0) instance = Util.getString(inst.get(0)); } catch (P2PDDSQLException e) { e.printStackTrace(); } } } pure_protocol = Util.getString(in.get(table.peer_address.PA_TYPE)); domain = Util.getString(in.get(table.peer_address.PA_DOMAIN)); tcp_port = Util.ival(in.get(table.peer_address.PA_TCP_PORT), -1); udp_port = Util.ival(in.get(table.peer_address.PA_UDP_PORT), -1); certified = Util.stringInt2bool(in.get(table.peer_address.PA_CERTIFIED), false); priority = Util.ival(in.get(table.peer_address.PA_PRIORITY), 0); last_contact = Util.getString(in.get(table.peer_address.PA_CONTACT)); arrival_date = Util.getString(in.get(table.peer_address.PA_ARRIVAL)); peer_address_ID = Util.getString(in.get(table.peer_address.PA_PEER_ADDR_ID)); }