Changeset 18147 for other-projects


Ignore:
Timestamp:
2008-12-08T17:08:06+13:00 (15 years ago)
Author:
cc108
Message:

remove Java 1.5 method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/trunk/greenstone3-extension/mat/src/org/greenstone/gsdl3_extension/mat/DataMaker.java

    r18093 r18147  
    554554        return row;
    555555    }
    556        
     556       
     557    /**
     558     * This method will use Arrays.sort for sorting Map
     559     * @param map
     560     * @return outputList of Map.Entries
     561     */
     562
    557563    public ArrayList sortMap(Map map) {
    558564    ArrayList outputList = null;
     
    560566    Set set = null;
    561567    Map.Entry[] entries = null;
     568    //     Logic:
     569    //     get a set from Map
     570    //     Build a Map.Entry[] from set
     571    //     Sort the list using Arrays.sort
     572    //     Add the sorted Map.Entries into arrayList and return
    562573   
    563574    set = (Set) map.entrySet();
     
    568579    }
    569580   
     581    //     Sort the entries with your own comparator for the values:
    570582    Arrays.sort(entries, new Comparator() {
    571583        public int compareTo(Object lhs, Object rhs) {
     
    587599    }
    588600    return outputList;
    589     }
     601    }//End of sortMap
    590602   
    591603    private Double div(Double d1, Double d2){
     
    596608   
    597609    private Double mul(Double d1,Double d2){
    598     BigDecimal b1 = new BigDecimal(d1.toString());
     610        //System.out.println(d1);
     611        BigDecimal b1 = new BigDecimal(d1.toString());
    599612        BigDecimal b2 = new BigDecimal(d2.toString());
    600613        return new Double(b1.multiply(b2).doubleValue());
     
    627640        }
    628641    }
    629    
    630     double x = (double)totalElementUsed/totalElement;
    631     Double d1 = new Double(x);
    632     Double d2 = new Double(100);
     642        //System.out.println(totalElementUsed +" "+ totalElement);
     643        double x = (double)totalElementUsed/totalElement;
     644        //System.out.println(x);
     645        Double d1 = new Double(x);
     646        //System.out.println(d1);
     647        Double d2 = new Double(100);
    633648        Double result = mul(d1,d2);
    634649        return round(result.doubleValue(),1);
     
    750765   
    751766    public HashMap getLinks(String[] args, String core_element){
    752         Element rootElement = getRootNode(core_element);
    753         HashMap hp = new HashMap();
    754         NodeList listOfDocument = rootElement.getElementsByTagName("Document");
    755         ArrayList tempList = new ArrayList();
    756        
    757        
    758         for(int i = 0; i<args.length; i++){
     767        Element rootElement = getRootNode(core_element);
     768        HashMap hp = new HashMap();
     769        NodeList listOfDocument = rootElement.getElementsByTagName("Document");
     770        ArrayList tempList = new ArrayList();
     771
     772       
     773        for(int i = 0; i<args.length; i++){
    759774            tempList.add(args[i]);     
    760         }
    761        
    762         for(int s=0; s<listOfDocument.getLength() ; s++){
     775        }
     776       
     777        for(int s=0; s<listOfDocument.getLength() ; s++){
    763778            Node docNode = listOfDocument.item(s);
    764779            Element docElement = (Element)docNode;
     
    766781       
    767782            if(valueList.getLength()==1){
    768             String id = docNode.getAttributes().item(0).getNodeValue();
    769             Element valueElement = (Element)valueList.item(0);
    770             NodeList textFNList = valueElement.getChildNodes();
    771             String text = ((Node)textFNList.item(0)).getNodeValue();
    772            
    773             if(tempList.contains(text)){
    774             hp.put(id, text);
    775             }
     783                String id = docNode.getAttributes().item(0).getNodeValue();
     784               
     785                Element valueElement = (Element)valueList.item(0);
     786                NodeList textFNList = valueElement.getChildNodes();
     787                String text = ((Node)textFNList.item(0)).getNodeValue();
     788               
     789                if(tempList.contains(text)){
     790                    hp.put(id, text);
     791                }
    776792            }   
    777         }
    778        
    779         rootElement = getRootNode(urlFile);
    780         listOfDocument = rootElement.getElementsByTagName(documentTag);
    781         HashMap newHp = new HashMap();
    782        
    783         for(int a=0; a<listOfDocument.getLength(); a++){
     793        }
     794       
     795        rootElement = getRootNode(urlFile);
     796        listOfDocument = rootElement.getElementsByTagName(documentTag);
     797        HashMap newHp = new HashMap();
     798       
     799        for(int a=0; a<listOfDocument.getLength(); a++){
    784800            Node docNode = listOfDocument.item(a);
    785801            Element docElement = (Element)docNode;
     
    787803       
    788804            if(valueList.getLength()==1){
    789             String id = docNode.getAttributes().item(0).getNodeValue();
    790             Element valueElement = (Element)valueList.item(0);
    791             NodeList textFNList = valueElement.getChildNodes();
    792             String text = ((Node)textFNList.item(0)).getNodeValue();
    793             newHp.put(text,id);             
     805                String id = docNode.getAttributes().item(0).getNodeValue();
     806               
     807                Element valueElement = (Element)valueList.item(0);
     808                NodeList textFNList = valueElement.getChildNodes();
     809                String text = ((Node)textFNList.item(0)).getNodeValue();
     810                newHp.put(text,id);             
    794811            }   
    795         }
    796        
    797         HashMap tempMap = new HashMap();
    798         Collection c = hp.values();
    799         Iterator i = c.iterator();
    800        
    801         while(i.hasNext()){
     812        }
     813       
     814        HashMap tempMap = new HashMap();
     815        Collection c = hp.values();
     816        Iterator i = c.iterator();
     817        while(i.hasNext()){
    802818            String id = (String)i.next();
    803819            if(newHp.containsKey(id)){
    804             String text = (String)newHp.get(id);
    805             if(text.contains("http")){
    806             tempMap.put((String)tempMap.get(id),text);
    807             }
     820                String text = (String)newHp.get(id);
     821                if(text.indexOf("http")!=-1){
     822                    tempMap.put((String)tempMap.get(id),text);
     823                }
    808824            }
    809         }
    810        
    811         return tempMap;
    812     }
    813    
     825        }
     826       
     827        return tempMap;
     828    }
     829   
    814830   
    815831    public ArrayList getURLMap(String elementName){
     
    820836
    821837        if(rootElement.equals(null)){
    822         return new ArrayList();
     838            return new ArrayList();
    823839        }
    824840           
     
    827843        if(listOfDocument.getLength()==0){return new ArrayList();}
    828844       
    829     for(int a=0; a<listOfDocument.getLength(); a++){
     845        //System.out.println(listOfDocument.getLength());
     846        for(int a=0; a<listOfDocument.getLength(); a++){
    830847            Node docNode = listOfDocument.item(a);
    831848            Element docElement = (Element)docNode;
    832849            NodeList valueList = docElement.getElementsByTagName(valueTag);
    833850           
    834         for(int b=0; b<valueList.getLength(); b++){
     851            //System.out.println(valueList.getLength());
     852            for(int b=0; b<valueList.getLength(); b++){
    835853                Element valueElement = (Element)valueList.item(b);
    836854                NodeList textFNList = valueElement.getChildNodes();
     
    838856
    839857                if(!text.equals(" ")){
    840             NamedNodeMap NodeIDMap = docNode .getAttributes();
    841             Node DocNodeID = NodeIDMap.item(0);
    842             String DocID = DocNodeID.getNodeValue();
    843             if(alist.contains(DocID)){}
    844             else{
    845             alist.add(DocID);
    846             }
     858                    NamedNodeMap NodeIDMap = docNode .getAttributes();
     859                    Node DocNodeID = NodeIDMap.item(0);
     860                    String DocID = DocNodeID.getNodeValue();
     861                    if(alist.contains(DocID)){}
     862                    else{
     863                        alist.add(DocID);
     864                    }
    847865                }
    848866            }
    849     }             
    850     return alist;
    851     }
     867       }             
     868
     869            return alist;
     870}
    852871
    853872    public HashMap getIdentifierLink(String core_element){
     
    882901            }
    883902            }
    884     }               
    885     return hp;
    886     }
     903            }               
     904            return hp;
     905        }
     906
    887907   
    888908    public String[] getDocumentIDList(String core_element){
    889    
     909       
    890910        Element rootElement = getRootNode(core_element);
    891911        NodeList listOfDocument = rootElement.getElementsByTagName(documentTag);
     
    935955            }
    936956            }
    937     }               
    938     return hp;
    939     }
    940    
     957            }               
     958            return hp;
     959        }
     960
    941961    public HashMap getIdentifierLinkNoIdentifier(){
    942    
     962       
    943963        Element rootElement = getRootNode(rootDocument);
    944964        HashMap hp = new HashMap();
    945965        NodeList listOfDocument = rootElement.getElementsByTagName(documentTag);
    946966        String url ="No Source Available";
    947        
    948     for(int s=0; s<listOfDocument.getLength() ; s++){
     967        for(int s=0; s<listOfDocument.getLength() ; s++){
    949968            Node docNode = listOfDocument.item(s);
    950969            String HashID = docNode.getAttributes().item(0).getNodeValue();
    951970            InternalLink il = new InternalLink();
    952         il.increaseElement(HashID);
    953         hp.put(HashID, il);
    954     }               
    955     return hp;
    956     }   
     971            il.increaseElement(HashID);
     972            hp.put(HashID, il);
     973            }               
     974            return hp;
     975        }   
    957976}
Note: See TracChangeset for help on using the changeset viewer.