Back to index

wims  3.65+svn20090927
Static Public Member Functions | Static Public Attributes | Static Package Functions
rene.util.FileName Class Reference

This is a static class to determine extensions etc. More...

List of all members.

Static Public Member Functions

static String purefilename (String filename)
static String path (String filename)
static String pathAndSeparator (String filename)
static String filename (String filename)
static String extension (String filename)
static String chop (String filename, int chop)
static String chop (String filename)
static String chop (int start, String filename, int chop)
static String chop (int start, String filename)
static String relative (String dir, String filename)
static String canonical (String filename)
static String toURL (String filename)
static boolean match (String filename, String filter)
static void main (String args[])

Static Public Attributes

static int ChopLength = 48

Static Package Functions

static boolean match (char filename[], int n, char filter[], int m)

Detailed Description

This is a static class to determine extensions etc.

from a file name.

Definition at line 9 of file FileName.java.


Member Function Documentation

static String rene.util.FileName.canonical ( String  filename) [inline, static]

Definition at line 110 of file FileName.java.

       {      File f=new File(filename); 
              try
              {      String s=f.getCanonicalPath();
                     if (s.length()>2 && s.charAt(1)==':')
                            s=s.substring(0,2).toLowerCase()+s.substring(2);
                     return s; 
              }
              catch (Exception e) {       return f.getAbsolutePath(); }
       }

Here is the caller graph for this function:

static String rene.util.FileName.chop ( String  filename,
int  chop 
) [inline, static]

Definition at line 81 of file FileName.java.

       {      if (filename.length()>chop)
              {      filename="... "+filename.substring(filename.length()-chop); 
              }
              return filename; 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

static String rene.util.FileName.chop ( String  filename) [inline, static]

Definition at line 88 of file FileName.java.

       {      return chop(filename,ChopLength);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

static String rene.util.FileName.chop ( int  start,
String  filename,
int  chop 
) [inline, static]

Definition at line 91 of file FileName.java.

       {      if (filename.length()>start+chop)
              {      filename=filename.substring(0,start)+
                            " ... "+
                            filename.substring(filename.length()-chop); 
              }
              return filename; 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

static String rene.util.FileName.chop ( int  start,
String  filename 
) [inline, static]

Definition at line 100 of file FileName.java.

       {      return chop(start,filename,ChopLength);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

static String rene.util.FileName.extension ( String  filename) [inline, static]

Definition at line 67 of file FileName.java.

       {      char a[]=filename.toCharArray(); 
              int i=a.length-1; 
              char fs=File.separatorChar; 
              while (i>0)
              {      if (a[i]=='.')
                     {      if (i+1<a.length) return new String(a,i+1,a.length-i-1); 
                            else return ""; 
                     }
                     if (a[i]==fs || a[i]=='/') break; 
                     i--; 
              }
              return ""; 
       }
static String rene.util.FileName.filename ( String  filename) [inline, static]

Definition at line 54 of file FileName.java.

       {      char a[]=filename.toCharArray(); 
              int i=a.length-1; 
              char fs=File.separatorChar; 
              while (i>0)
              {      if (a[i]==fs || a[i]=='/')
                     {      if (i+1<a.length) return new String(a,i+1,a.length-i-1); 
                            else return ""; 
                     }
                     i--; 
              }
              return filename; 
       }

Here is the caller graph for this function:

static void rene.util.FileName.main ( String  args[]) [inline, static]

Definition at line 148 of file FileName.java.

       {      System.out.println("-"+toURL(" test test test ")+"-");
       }

Here is the call graph for this function:

static boolean rene.util.FileName.match ( char  filename[],
int  n,
char  filter[],
int  m 
) [inline, static, package]

Definition at line 127 of file FileName.java.

       {      if (filter==null) return true;
              if (m>=filter.length) return n>=filename.length;
              if (n>=filename.length) return m==filter.length-1 && filter[m]=='*';
              if (filter[m]=='?')
              {      return match(filename,n+1,filter,m+1);
              }
              if (filter[m]=='*')
              {      if (m==filter.length-1) return true;
                     for (int i=n; i<filename.length; i++)
                     {      if (match(filename,i,filter,m+1)) return true;
                     }
                     return false;
              }
              if (filter[m]==filename[n]) return match(filename,n+1,filter,m+1);
              return false;
       }

Here is the caller graph for this function:

static boolean rene.util.FileName.match ( String  filename,
String  filter 
) [inline, static]

Definition at line 144 of file FileName.java.

       {      char fn[]=filename.toCharArray(),f[]=filter.toCharArray();
              return match(fn,0,f,0);
       }

Here is the call graph for this function:

static String rene.util.FileName.path ( String  filename) [inline, static]

Definition at line 30 of file FileName.java.

       {      char a[]=filename.toCharArray(); 
              int i=a.length-1; 
              char fs=File.separatorChar; 
              while (i>0)
              {      if (a[i]==fs || a[i]=='/')
                     {      return new String(a,0,i); 
                     }
                     i--; 
              }
              return ""; 
       }

Here is the caller graph for this function:

static String rene.util.FileName.pathAndSeparator ( String  filename) [inline, static]

Definition at line 42 of file FileName.java.

       {      char a[]=filename.toCharArray(); 
              int i=a.length-1; 
              char fs=File.separatorChar; 
              while (i>0)
              {      if (a[i]==fs || a[i]=='/')
                     {      return new String(a,0,i+1); 
                     }
                     i--; 
              }
              return ""; 
       }
static String rene.util.FileName.purefilename ( String  filename) [inline, static]

Definition at line 11 of file FileName.java.

       {      char a[]=filename.toCharArray(); 
              int i=a.length-1; 
              char fs=File.separatorChar; 
              while (i>=0)
              {      if (a[i]==fs || a[i]=='/' || i==0)
                     {      if (i==0) i=-1; 
                            if (i<a.length-1)
                            {      int j=a.length-1; 
                                   while (j>i && a[j]!='.') j--; 
                                   if (j>i+1) return new String(a,i+1,j-i-1); 
                                   else return ""; 
                            }
                            else return ""; 
                     }
                     i--; 
              }
              return filename; 
       }

Here is the call graph for this function:

static String rene.util.FileName.relative ( String  dir,
String  filename 
) [inline, static]

Definition at line 103 of file FileName.java.

       {      dir=dir+System.getProperty("file.separator"); 
              if (filename.startsWith(dir))
              {      return filename.substring(dir.length()); 
              }
              else return filename; 
       }

Here is the call graph for this function:

static String rene.util.FileName.toURL ( String  filename) [inline, static]

Definition at line 120 of file FileName.java.

       {      int n=filename.indexOf(' ');
              if (n>=0)
                     return filename.substring(0,n)+"%20"+toURL(filename.substring(n+1));
              else
                     return filename;
       }      

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

int rene.util.FileName.ChopLength = 48 [static]

Definition at line 10 of file FileName.java.


The documentation for this class was generated from the following file: