[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trim Fix... (fwd)



Do take a look at the attached code. 
Donovan did have a problem. If you already took care of it. Dont worry.

Ullas

"Well Begun is Half Done"

---------- Forwarded message ----------
Date: Wed, 28 Mar 2001 18:08:09 -0700
From: Donovan <elvis@inficad.com>
To: Ullas Nambiar <mallu@asu.edu>
Subject: Trim Fix...

As per our discussion earlier
The Links and Citation methods may return file names with a ' ' before
them.  This can cause the Links method to crash your program if strings
from it are used to grow the the Authority Hub cluster.

The following Links and Citations methods fix this problem by
1. keeping the method from crashing and
2. removing the spaces

Thanks for the help!!!

Donovan

  /** Returns a list of files/URLs to which the given filename/URL
points to */
    public ArrayList Links(String fileName)
    {

   String list = (String)hashids.get(fileName);
   int j=0;
   ArrayList retList = new ArrayList();
   if(list == null)
   {
    System.out.println("Links found NOTHING for :" + fileName + ":");
    return (retList);
   }
   while((j=list.indexOf(","))!=-1)
     {
    String tmp = list.substring(0,j);
    tmp = tmp.trim();
    retList.add(tmp);
    list = list.substring(j+1,list.length());
   }
   if (list.length() >0)
   {
    list = list.trim();
    retList.add(list);
   }

   return retList;
    }

    /** Returns a list of files/URLs that point to the given file/URL */

    public ArrayList Citations(String fileName)
    {
   Enumeration enumval = hashids.keys();
   ArrayList retList =  new ArrayList();
   while(enumval.hasMoreElements())  //comments by donovan: for all hash
table roots
     {
    String key = (String)enumval.nextElement();  //get each root key
    String cmpstring = (String)hashids.get(key); //try getting the list
off of each root key
    if(cmpstring == null)
    {
     System.out.println("Citations found NOTHING for " + cmpstring);
     return (retList);
    }
    if(cmpstring.indexOf(fileName)!=-1)  //here check to see if page
fileName is in the list.. if it IS then add the key to this hash to the
list of pages that have a link to (cite) fileName
    {
     key = key.trim();
     if(key.equals(" www.asu.edu1lib1help1help.htm"))
      System.out.println("Citations " + fileName + " link:" + key);
     retList.add(key);
    }
     }

   return retList;
}