com.ibm.as400.util.html

Class FileListElement

  • java.lang.Object
    • com.ibm.as400.util.html.FileListElement
  • All Implemented Interfaces:
    java.io.Serializable


    public class FileListElement
    extends java.lang.Object
    implements java.io.Serializable
    The FileListElement class represents the contents of an Integrated File System directory.

    This example creates an FileListElement object:

      // Create a HTMLTree object.
      HTMLTree tree = new HTMLTree(req);
      
      // Create a URLParser object.
      URLParser urlParser = new URLParser(httpServletRequest.getRequestURI());
      
      // Create a object to represent the connection to the system.
      AS400 system = new AS400(mySystem, myUserId, myPassword);
      
      // Create an IFS object.
      IFSJavaFile root = new IFSJavaFile(system, "/QIBM");
      
      // Create a DirFilter object and get the directories.
      DirFilter filter = new DirFilter();
      File[] dirList = root.listFiles(filter);
      
      
      for (int i=0; i < dirList.length; i++)
      {  
         // Create a FileTreeElement.
         FileTreeElement element = new FileTreeElement(dirList[i]);
         
         // Set the Icon URL.
         ServletHyperlink sl = new ServletHyperlink(urlParser.getURI());
         sl.setHttpServletResponse(resp);
         element.setIconUrl(sl);
         
         // Set the text url so it calls another
         // servlet to display the contents of the FileTreeElement.
         ServletHyperlink tl = new ServletHyperlink("/servlet/myListServlet");        
         tl.setTarget("listFrame");
         
         // Set the TextUrl for the FileTreeElement.
         element.setTextUrl(tl);
         
         // Add the FileTreeElement to the tree.
         tree.addElement(element);
      }
    
      
      // When the user clicks on text url in the HTMLTree it should call another
      // servlet to display the contents.  It is here that the FileListElement
      // will be created.
      AS400 sys = new AS400(mySystem, myUserId, myPassword);
      
      // The FileTreeElment will properly create the text url and pass the
      // file and path information through the httpservletrequest.  If the
      // list is meant to display the contents of the local file system,
      // then only pass the HttpServletRequest on the constructor.
      FileListElement fileList = new FileListElement(sys, httpservletrequest);
      
      // Output the content of the FileListElement.
      out.println(fileList.list());
      
    Once the contents are listed and a user traverses the HTML tree down to /QIBM/ProdData/Http/Public/ and clicks on the jt400 directory link, the FileListElement will look something like the following:
    Name Size Type Modified
    ../ (Parent Directory)
    com Directory 06/09/2000 11:00:46 AM
    lib Directory 09/11/2000 10:32:24 AM
    MRI2924 Directory 06/09/2000 11:03:12 PM
    SSL128 Directory 09/22/2000 10:46:29 AM
    SSL56 Directory 09/22/2000 10:43:52 PM
    utilities Directory 06/09/2000 11:01:58 AM
    ACCESS.LST 15950 File 06/29/2000 06:26:25 PM
    ACCESS.LVL 23 File 06/29/2000 06:26:09 PM
    CKSETUP.INI 88 File 06/29/2000 06:26:21 PM
    GTXSETUP.ini 102 File 05/16/2000 05:51:46 PM
    JT400.PKG 19 File 09/08/1999 04:25:51 PM
    OPNAV.LST 16827 File 09/08/1999 04:26:08 PM
    OPNAV.LVL 19 File 05/16/2000 05:51:31 AM
    OPV4R5M0.LST 24121 File 09/08/1999 04:26:14 PM
    OPV4R5M01.LST 104 File 05/16/2000 05:51:46 AM
    PROXY.LST 4636 File 09/08/1999 04:26:00 AM
    PROXY.LVL 29 File 06/29/2000 06:26:26 AM
    PXV4R5M0.LST 7101 File 09/08/1999 04:25:58 PM
    PXV4R5M01.LST 38 File 06/29/2000 06:27:46 PM
    QSF631215769JC10004R05M00505000000005 4518 File 05/10/2000 10:35:10 AM
    QSF631215769JC10004R05M00505000000006 20 File 05/10/2000 10:35:00 AM
    QSF631215769JC10004R05M00505000000007 15 File 05/10/2000 10:35:19 AM
    QSF631215769JC10004R05M00505000000008 15950 File 05/10/2000 10:34:57 AM
    QSF631215769JC10004R05M00505000000009 38 File 05/10/2000 10:35:13 AM
    QSF631215769JC10004R05M00505000000010 38586 File 05/10/2000 10:35:06 AM
    QSF631215769JC10004R05M00505000000011 33 File 05/10/2000 10:35:09 AM
    QSF631215769JC10004R05M00505000000013 88 File 05/10/2000 10:35:03 AM
    READMEGT.TXT 3480 File 05/16/2000 05:52:27 AM
    READMESP.TXT 5161 File 06/29/2000 06:26:14 PM
    V4R5M0.LST 38586 File 06/29/2000 06:26:19 PM
    V4R5M01.LST 33 File 06/29/2000 06:26:33 PM
    V4R5M02.LST 33 File 06/29/2000 06:26:26 PM

    FileListElement objects generate the following events:

    • PropertyChangeEvent
    See Also:
    DirFilter, FileListRenderer, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      FileListElement()
      Constructs a default FileListElement object.
      FileListElement(AS400 system, javax.servlet.http.HttpServletRequest request)
      Constructs an FileListElement for an IBM i file system using the pathInfo from the specified request, and the designated system.
      FileListElement(AS400 system, javax.servlet.http.HttpServletRequest request, HTMLTable table)
      Constructs an FileListElement with the specified system, request, and table.
      FileListElement(AS400 system, javax.servlet.http.HttpServletRequest request, java.lang.String parameterPathInfo)
      Constructs an FileListElement for an IBM i file system using the pathInfo from the specified request, and the designated system.
      FileListElement(AS400 system, javax.servlet.http.HttpServletRequest request, java.lang.String shareName, java.lang.String sharePath)
      Constructs a FileListElement with the specified system, requst, NetServer sharePath, and NetServer shareName.
      FileListElement(AS400 system, javax.servlet.http.HttpServletRequest request, java.lang.String shareName, java.lang.String sharePath, java.lang.String parameterPathInfo)
      Constructs a FileListElement with the specified system, requst, NetServer sharePath, and NetServer shareName.
      FileListElement(javax.servlet.http.HttpServletRequest request)
      Constructs an FileListElement for the local file system using the pathInfo from the specified request.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
      Adds a PropertyChangeListener.
      java.text.Collator getCollator()
      Returns the Collator.
      javax.servlet.http.HttpServletRequest getHttpServletRequest()
      Returns the Http servlet request.
      FileListRenderer getRenderer()
      Return the file list renderer.
      java.lang.String getShareName()
      Return the name of the NetServer share.
      java.lang.String getSharePath()
      Return the NetServer share point.
      AS400 getSystem()
      Returns the system.
      HTMLTable getTable()
      Returns the HTMLTable.
      java.lang.String list()
      Returns a string containing the list of files and directories in the path defined in the HttpServletRequest.
      java.lang.String list(HTMLTableConverter conv)
      Returns a string containing the list of files and directories in the path defined in the HttpServletRequest.
      void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
      Removes the PropertyChangeListener from the internal list.
      void setCollator(java.text.Collator collator)
      Sets the collator.
      void setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
      Sets the Http servlet request for the element.
      void setPatternMatching(int patternMatching)
      Sets the pattern-matching behavior used when files are listed.
      void setRenderer(FileListRenderer renderer)
      Set the renderer for the FileListElement.
      void setShareName(java.lang.String shareName)
      Set the name of the NetServer share.
      void setSharePath(java.lang.String sharePath)
      Set the NetServer share path.
      void setSystem(AS400 system)
      Set the system.
      void setTable(HTMLTable table)
      Set the HTMLTable to use when displaying the file list.
      void sort(boolean sort)
      Sorts the list elements.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileListElement

        public FileListElement()
        Constructs a default FileListElement object.
      • FileListElement

        public FileListElement(javax.servlet.http.HttpServletRequest request)
        Constructs an FileListElement for the local file system using the pathInfo from the specified request. Internally a java.io.File object will be used to retrieve the contents of the file system.
        Parameters:
        request - The Http servlet request.
      • FileListElement

        public FileListElement(AS400 system,
                       javax.servlet.http.HttpServletRequest request)
        Constructs an FileListElement for an IBM i file system using the pathInfo from the specified request, and the designated system. Internally a com.ibm.as400.access.IFSJavaFile object will be used to retrieve the contents of the file system.
        Parameters:
        system - The system.
        request - The Http servlet request.
      • FileListElement

        public FileListElement(AS400 system,
                       javax.servlet.http.HttpServletRequest request,
                       java.lang.String parameterPathInfo)
        Constructs an FileListElement for an IBM i file system using the pathInfo from the specified request, and the designated system. Internally a com.ibm.as400.access.IFSJavaFile object will be used to retrieve the contents of the file system.
        Parameters:
        system - The system.
        request - The Http servlet request.
        parameterPathInfo -
      • FileListElement

        public FileListElement(AS400 system,
                       javax.servlet.http.HttpServletRequest request,
                       HTMLTable table)
        Constructs an FileListElement with the specified system, request, and table. Internally a com.ibm.as400.access.IFSJavaFile object will be used to retrieve the contents of the file system.
        Parameters:
        system - The system.
        request - The Http servlet request.
        table - The HTML table.
      • FileListElement

        public FileListElement(AS400 system,
                       javax.servlet.http.HttpServletRequest request,
                       java.lang.String shareName,
                       java.lang.String sharePath)
        Constructs a FileListElement with the specified system, requst, NetServer sharePath, and NetServer shareName. Internally a com.ibm.as400.access.IFSJavaFile object will be used to retrieve the contents of the file system at the network share point.
        Parameters:
        system - The IBM i system.
        request - The Http servlet request.
        shareName - The NetServer share name.
        sharePath - The NetServer share path.
      • FileListElement

        public FileListElement(AS400 system,
                       javax.servlet.http.HttpServletRequest request,
                       java.lang.String shareName,
                       java.lang.String sharePath,
                       java.lang.String parameterPathInfo)
        Constructs a FileListElement with the specified system, requst, NetServer sharePath, and NetServer shareName. Internally a com.ibm.as400.access.IFSJavaFile object will be used to retrieve the contents of the file system at the network share point.
        Parameters:
        system - The IBM i system.
        request - The Http servlet request.
        shareName - The NetServer share name.
        sharePath - The NetServer share path.
        parameterPathInfo -
    >
    • Method Detail

      • addPropertyChangeListener

        public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
        Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange method is called each time the value of any bound property is changed.
        Parameters:
        listener - The PropertyChangeListener.
        See Also:
        removePropertyChangeListener(java.beans.PropertyChangeListener)
      • getCollator

        public java.text.Collator getCollator()
        Returns the Collator.
        Returns:
        The collator.
      • getHttpServletRequest

        public javax.servlet.http.HttpServletRequest getHttpServletRequest()
        Returns the Http servlet request.
        Returns:
        The request.
      • getRenderer

        public FileListRenderer getRenderer()
        Return the file list renderer.
        Returns:
        The renderer.
      • getSharePath

        public java.lang.String getSharePath()
        Return the NetServer share point.
        Returns:
        The NetServer share path.
      • getShareName

        public java.lang.String getShareName()
        Return the name of the NetServer share.
        Returns:
        The name of the NetServer share.
      • getSystem

        public AS400 getSystem()
        Returns the system.
        Returns:
        The system.
      • getTable

        public HTMLTable getTable()
        Returns the HTMLTable.
        Returns:
        The table.
      • list

        public java.lang.String list()
        Returns a string containing the list of files and directories in the path defined in the HttpServletRequest. If the system has not been set, a java.io.File object will be created with the pathInfo from the HttpServletRequest to retrieve the list of file and directories from the local file system.
        Returns:
        The list.
      • list

        public java.lang.String list(HTMLTableConverter conv)
        Returns a string containing the list of files and directories in the path defined in the HttpServletRequest. If the system has not been set, a java.io.File object will be created with the pathInfo from the HttpServletRequest to retrieve the list of file and directories from the local file system.
        Parameters:
        conv - An HTMLTableConverter used to format the list of files.
        Returns:
        The list.
      • removePropertyChangeListener

        public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
        Removes the PropertyChangeListener from the internal list. If the PropertyChangeListener is not on the list, nothing is done.
        Parameters:
        listener - The PropertyChangeListener.
        See Also:
        addPropertyChangeListener(java.beans.PropertyChangeListener)
      • setCollator

        public void setCollator(java.text.Collator collator)
        Sets the collator. The collator allows the tree to perform locale-sensitive String comparisons when sorting the file list elements.
        Parameters:
        collator - The Collator.
      • setHttpServletRequest

        public void setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
        Sets the Http servlet request for the element.
        Parameters:
        request - The Http servlet request.
      • setRenderer

        public void setRenderer(FileListRenderer renderer)
        Set the renderer for the FileListElement. The default is FileListRenderer.
        Parameters:
        renderer - The file list renderer.
      • setSharePath

        public void setSharePath(java.lang.String sharePath)
        Set the NetServer share path.
        Parameters:
        sharePath - The NetServer share path.
      • setShareName

        public void setShareName(java.lang.String shareName)
        Set the name of the NetServer share.
        Parameters:
        shareName - The NetServer share name.
      • setSystem

        public void setSystem(AS400 system)
        Set the system.
        Parameters:
        system - The system.
      • setTable

        public void setTable(HTMLTable table)
        Set the HTMLTable to use when displaying the file list. This will replace the default HTMLTable used.
        Parameters:
        table - The HTML table.
      • sort

        public void sort(boolean sort)
        Sorts the list elements.
        Parameters:
        sort - true if the elements are sorted; false otherwise. The default is true.
      • setPatternMatching

        public void setPatternMatching(int patternMatching)
        Sets the pattern-matching behavior used when files are listed. The default is PATTERN_POSIX.
        Parameters:
        patternMatching - Either PATTERN_POSIX, PATTERN_POSIX_ALL, or PATTERN_OS2