Changeset 6455


Ignore:
Timestamp:
2004-01-12T15:56:41+13:00 (20 years ago)
Author:
cs025
Message:

Layout changes only.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/util/URLString.java

    r6344 r6455  
    128128
    129129    fromdir = from.substring(0, from.lastIndexOf('/'));
    130     todir   = to.substring(0, to.lastIndexOf('/'));
     130    todir   = to.substring(0, to.lastIndexOf('/'));
    131131
    132132    if (fromdir.equals(todir))
     
    315315
    316316  public void tidy()
    317     { this.url = tidyURL(this.url);
    318     }
    319 
    320     public boolean isNull()
    321     { if (this.url == null)
    322         { return true;
    323         }
    324         return false;
    325     }
    326 
    327     public static boolean isForeign(String home, URL url)
    328     { if (url.toString().length() < home.length())
    329         { return true;
    330         }
    331 
    332         if (home.equals(url.toString().substring(0, home.length())))
    333         { return false;
    334         }
    335         return true;
    336     }
    337 
    338     /**
    339     *  Remove any trailing "#localanchor" local reference from a URL string
    340     *
    341     *  @param  <code>String</code> the original url
    342     *  @return <code>String</code> the cleaned url, sans local references
    343     */
    344     public static String noRef(String target)
    345     {   if (target == null)
    346         {   return null;
    347         }
    348         if (target.indexOf('#') >= 0)
    349         { if (target.indexOf('#') == 0)
    350             { return null;
    351             }
    352             target = target.substring(0, target.indexOf('#'));
    353         }
    354         return target;
    355     }
    356 
    357     /**
    358     *  Obtain the trailing local anchor reference from a URL,
    359     *  if it exists.
    360     *    e.g. for http://www.test.mdx.ac.uk/example/index.html#credits the
    361     *         response would be "credits"
    362     *
    363     *  @param  <code>String</code> the original url.
    364     *  @return <code>String</code> the local reference.  <code>null</code> is
    365     *                              returned if no local reference exists.
    366     */
    367     public static String subRef(String target)
    368     {   if (target.indexOf('#') >= 0)
    369         {   return target.substring(target.indexOf('#')+1);
    370         }
    371         return null;
    372     }
    373 
    374     /**
    375     *  Clean a URL of the form GET parameters.
    376     *
    377     *  @param  <code>String</code> the original url, with GET message parameters
    378     *  @return <code>String</code> the cleaned url.
    379     */
    380     public static String noParameters(String url)
    381     {   int                     c;
    382 
    383         c = url.indexOf("?");
    384         if (c < 0)
    385         {   return url;
    386         }
    387         return url.substring(0, c);
    388     }
     317  { this.url = tidyURL(this.url);
     318  }
     319
     320  public boolean isNull()
     321  { if (this.url == null)
     322    { return true;
     323    }
     324    return false;
     325  }
     326
     327  public static boolean isForeign(String home, URL url)
     328  { if (url.toString().length() < home.length())
     329    { return true;
     330    }
     331
     332    if (home.equals(url.toString().substring(0, home.length())))
     333    { return false;
     334    }
     335    return true;
     336  }
     337 
     338  /**
     339  *    Remove any trailing "#localanchor" local reference from a URL string
     340  *
     341  *  @param  <code>String</code> the original url
     342  *  @return <code>String</code> the cleaned url, sans local references
     343  */
     344  public static String noRef(String target)
     345  { if (target == null)
     346    { return null;
     347    }
     348    if (target.indexOf('#') >= 0)
     349    { if (target.indexOf('#') == 0)
     350      { return null;
     351      }
     352      target = target.substring(0, target.indexOf('#'));
     353    }
     354    return target;
     355  }
     356
     357  /**
     358  *    Obtain the trailing local anchor reference from a URL,
     359  *  if it exists.
     360  *    e.g. for http://www.test.mdx.ac.uk/example/index.html#credits the
     361  *         response would be "credits"
     362  *
     363  *  @param  <code>String</code> the original url.
     364  *  @return <code>String</code> the local reference.  <code>null</code> is
     365  *                              returned if no local reference exists.
     366  */
     367  public static String subRef(String target)
     368  { if (target.indexOf('#') >= 0)
     369    {   return target.substring(target.indexOf('#')+1);
     370    }
     371    return null;
     372  }
     373
     374  /**
     375  *    Clean a URL of the form GET parameters.
     376  *
     377  *  @param  <code>String</code> the original url, with GET message parameters
     378  *  @return <code>String</code> the cleaned url.
     379  */
     380  public static String noParameters(String url)
     381  { int                     c;
     382
     383    c = url.indexOf("?");
     384    if (c < 0)
     385    { return url;
     386    }
     387    return url.substring(0, c);
     388  }
    389389
    390390    /**
     
    610610    }
    611611
    612     public static String extension(URL url)
    613     { return extension(url.toString());
    614     }
    615 
    616     public String toString()
    617     { return this.url;
    618     }
     612  public static String extension(URL url)
     613  { return extension(url.toString());
     614  }
     615
     616  public String toString()
     617  { return this.url;
     618  }
    619619}
Note: See TracChangeset for help on using the changeset viewer.