/* PROGRAMME: PROGRAMMER: DATE: PROJECT: MODIFIED DATE: */ package rtree; import java.io.*; import java.net.*; import java.util.List; public class RTreeClient { private Socket socket; public RTreeClient(String host,int port) { try { socket=new Socket(host,port); } catch(Exception e) { e.printStackTrace(); } } public void insert(Element element) throws RTreeException { try { String command="insert"; Object obj[]={element}; sendRequest(command,obj); } catch(RTreeException e) { throw e; } } public void delete(LeafElement element) throws RTreeException { try { String command="delete"; Object obj[]={element}; sendRequest(command,obj); } catch(RTreeException e) { throw e; } } public List overlaps(Rect rect) throws RTreeException { try { String command="overlaps"; Object obj[]={rect}; Object[] response=sendRequest(command,obj); return (List) response[0]; } catch(RTreeException e) { throw e; } } public List nonDisjoint(Rect rect) throws RTreeException { try { String command="nondisjoint"; Object obj[]={rect}; Object[] response=sendRequest(command,obj); return (List) response[0]; } catch(RTreeException e) { throw e; } } public List containedBy(Rect rect) throws RTreeException { try { String command="containedby"; Object obj[]={rect}; Object[] response=sendRequest(command,obj); return (List) response[0]; } catch(RTreeException e) { throw e; } } public List equal(Rect rect) throws RTreeException { try { String command="equal"; Object obj[]={rect}; Object[] response=sendRequest(command,obj); return (List) response[0]; } catch(RTreeException e) { throw e; } } public List meet(Rect rect) throws RTreeException { try { String command="meet"; Object obj[]={rect}; Object[] response=sendRequest(command,obj); return (List) response[0]; } catch(RTreeException e) { throw e; } } public List contains(Rect rect) throws RTreeException { try { String command="contains"; Object obj[]={rect}; Object[] response=sendRequest(command,obj); return (List) response[0]; } catch(RTreeException e) { throw e; } } public List getAllElements() throws RTreeException { try { String command="getallelements"; Object[] response=sendRequest(command,null); //List v=(List)response[0]; return (List) response[0]; } catch(RTreeException e) { throw e; } } public Rect getTreeMBR() throws RTreeException { try { String command="gettreembr"; Object[] response=sendRequest(command,null); return (Rect) response[0]; } catch(RTreeException e) { throw e; } } public ABL[] nearestSearch(Point pt,long ln,int in) throws RTreeException { try { String command="nearest"; Object obj[]={pt,new Long(ln),new Integer(in)}; Object[] response=sendRequest(command,obj); if(response!=null) { ABL abl[]=new ABL[response.length]; for(int i=0;i=total && total!=-1) { //System.out.println("read completed..."+bbf.length); break; } } byte tby[]=new byte[bbf.length-10]; System.arraycopy(bbf,10,tby,0,tby.length); ByteArrayInputStream bin=new ByteArrayInputStream(tby); ObjectInputStream oIn=new ObjectInputStream(bin); Boolean bool=(Boolean) oIn.readObject(); //System.out.println("boolean.........."+bool); Integer count=(Integer) oIn.readObject(); //System.out.println("count.........."+count); if(bool.booleanValue()) { Object[] obj=new Object[count.intValue()]; for(int j=0;j