Class FileListQuestion


  • public abstract class FileListQuestion
    extends Question
    A question to which the response is one or more filenames.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.File[] value
      The current (default or latest) response to this question.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected FileListQuestion​(Interview interview, java.lang.String tag)
      Create a question with a nominated tag.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear any response to this question, resetting the value back to its initial state.
      protected static boolean equal​(java.io.File[] f1, java.io.File... f2)
      Determine if two arrays of filenames are equal.
      java.io.File getBaseDirectory()
      Get the default directory for files for a response to this question.
      java.io.File[] getDefaultValue()
      Get the default response for this question.
      FileFilter[] getFilters()
      Get the filters used to select valid files for a response to this question.
      FileFilter[] getHintFilters()
      A set of filters to help users locate the right file/dir.
      java.lang.String getStringValue()
      Get the response to this question as a string.
      java.io.File[] getValue()
      Get the current (default or latest) response to this question.
      java.io.File[] getValueOnPath()
      Verify this question is on the current path, and if it is, return the current value.
      boolean isBaseRelativeOnly()
      Determine whether all valid responses to this question should be relative to the base directory (i.e.
      boolean isDuplicatesAllowed()
      Check whether or not duplicates should be allowed in the list.
      boolean isValueAlwaysValid()
      Check if the question always has a valid response.
      boolean isValueValid()
      Simple validation, upgrade if needed.
      static java.lang.String join​(java.io.File... ff)
      Convert a list of filenames to a newline separated string.
      protected void load​(java.util.Map<java.lang.String,​java.lang.String> data)
      Load the value for this question from a dictionary, using the tag as the key.
      protected void save​(java.util.Map<java.lang.String,​java.lang.String> data)
      Save the value for this question in a dictionary, using the tag as the key.
      void setBaseDirectory​(java.io.File dir)
      Set the default directory for files for a response to this question.
      void setBaseRelativeOnly​(boolean b)
      Specify whether all valid responses to this question should be relative to the base directory (i.e.
      void setDefaultValue​(java.io.File... v)
      Set the default response for this question, used by the clear method.
      void setDuplicatesAllowed​(boolean b)
      Specify whether or not duplicates should be allowed in the list.
      void setFilter​(FileFilter filter)
      Set a filter used to select valid files for a response to this question.
      void setFilters​(FileFilter... fs)
      Set the filters used to select valid files for a response to this question.
      void setHintFilters​(FileFilter... fs)
      Set the filters which the user can use to help find files among a list of files - this is somewhat exposing of the fact that there is a user interface.
      void setValue​(java.io.File... newValue)
      Set the current value.
      void setValue​(java.lang.String paths)
      Set the response to this question to the value represented by a string-valued argument.
      static java.io.File[] split​(java.lang.String s)
      Break apart a string containing a white-space separate list of file names into an array of individual files.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • value

        protected java.io.File[] value
        The current (default or latest) response to this question.
    • Constructor Detail

      • FileListQuestion

        protected FileListQuestion​(Interview interview,
                                   java.lang.String tag)
        Create a question with a nominated tag.
        Parameters:
        interview - The interview containing this question.
        tag - A unique tag to identify this specific question.
    • Method Detail

      • split

        public static java.io.File[] split​(java.lang.String s)
        Break apart a string containing a white-space separate list of file names into an array of individual files. If the string is null or empty, an empty array is returned. The preferred separator is a newline character; if there are no newline characters in the string, then (for backward compatibility) space is accepted instead.
        Parameters:
        s - The string to be broken apart
        Returns:
        An array of files determined from the parameter string.
        See Also:
        join(java.io.File...)
      • join

        public static java.lang.String join​(java.io.File... ff)
        Convert a list of filenames to a newline separated string.
        Parameters:
        ff - an array of filenames
        Returns:
        a string containing the filenames separated by newline characters. If there is just one filename, and if it contains space characters in its path, the list is terminated by a newline as well. If the parameter array is null or empty, an empty string is returned.
        See Also:
        split(java.lang.String)
      • equal

        protected static boolean equal​(java.io.File[] f1,
                                       java.io.File... f2)
        Determine if two arrays of filenames are equal.
        Parameters:
        f1 - the first array to be compared
        f2 - the other array to be compared
        Returns:
        true if both arrays are null, or if neither are null and if their contents match, element for element, in order
      • getDefaultValue

        public java.io.File[] getDefaultValue()
        Get the default response for this question.
        Returns:
        the default response for this question.
        See Also:
        setDefaultValue(java.io.File...)
      • setDefaultValue

        public void setDefaultValue​(java.io.File... v)
        Set the default response for this question, used by the clear method.
        Parameters:
        v - the default response for this question.
        See Also:
        getDefaultValue()
      • isDuplicatesAllowed

        public boolean isDuplicatesAllowed()
        Check whether or not duplicates should be allowed in the list.
        Returns:
        true if duplicates should be allowed, and false otherwise
        See Also:
        setDuplicatesAllowed(boolean)
      • setDuplicatesAllowed

        public void setDuplicatesAllowed​(boolean b)
        Specify whether or not duplicates should be allowed in the list. By default, duplicates are allowed.
        Parameters:
        b - true if duplicates should be allowed, and false otherwise
        See Also:
        isDuplicatesAllowed()
      • getValue

        public java.io.File[] getValue()
        Get the current (default or latest) response to this question.
        Returns:
        The current value.
        See Also:
        setValue(java.lang.String)
      • setValue

        public void setValue​(java.lang.String paths)
        Set the response to this question to the value represented by a string-valued argument.
        Specified by:
        setValue in class Question
        Parameters:
        paths - The new value for the question, can be null to set no value.
        See Also:
        getValue()
      • setValue

        public void setValue​(java.io.File... newValue)
        Set the current value.
        Parameters:
        newValue - The value to be set.
        See Also:
        getValue()
      • getValueOnPath

        public java.io.File[] getValueOnPath()
                                      throws Interview.NotOnPathFault
        Verify this question is on the current path, and if it is, return the current value.
        Returns:
        the current value of this question
        Throws:
        Interview.NotOnPathFault - if this question is not on the current path
        See Also:
        getValue()
      • getStringValue

        public java.lang.String getStringValue()
        Description copied from class: Question
        Get the response to this question as a string.
        Specified by:
        getStringValue in class Question
        Returns:
        a string representing the current response to this question, or null.
        See Also:
        Question.setValue(String)
      • isValueValid

        public boolean isValueValid()
        Simple validation, upgrade if needed. Iterates values, checks against filters, except if interview semantics are set to an pre-50 version, in which case true is always returned. Using semantics greater than 50 is highly recommended and recommended if an old interview is being modernized.
        Specified by:
        isValueValid in class Question
        Returns:
        False if any values are rejected by filters, true otherwise. True if there are no values or no filters.
        See Also:
        Interview.getInterviewSemantics(), Interview.SEMANTIC_VERSION_50
      • isValueAlwaysValid

        public boolean isValueAlwaysValid()
        Description copied from class: Question
        Check if the question always has a valid response. This may be true, for example, for a choice question with a default response.
        Specified by:
        isValueAlwaysValid in class Question
        Returns:
        true if the question always has a valid response, and false otherwise.
      • setFilters

        public void setFilters​(FileFilter... fs)
        Set the filters used to select valid files for a response to this question. For pre-50 behavior, both the filters and the hint filter values are treated the same, and neither is used for validation (e.g. isValid().
        Parameters:
        fs - An array of filters used to select valid files for a response to this question
        See Also:
        getFilters(), getHintFilters()
      • setHintFilters

        public void setHintFilters​(FileFilter... fs)
        Set the filters which the user can use to help find files among a list of files - this is somewhat exposing of the fact that there is a user interface. This should not be confused with setFilters(), which in version 5.0 or later of the harness, are used to do validity checks on the actual value (e.g.. in isValid().
        Parameters:
        fs - Filters which might be offered to the user.
        Since:
        5.0
        See Also:
        setFilters(com.sun.interview.FileFilter...), isValueValid()
      • getBaseDirectory

        public java.io.File getBaseDirectory()
        Get the default directory for files for a response to this question.
        Returns:
        the default directory in which files should be found/placed
        See Also:
        setBaseDirectory(java.io.File), isBaseRelativeOnly()
      • setBaseDirectory

        public void setBaseDirectory​(java.io.File dir)
        Set the default directory for files for a response to this question.
        Parameters:
        dir - the default directory in which files should be found/placed
        See Also:
        getBaseDirectory()
      • isBaseRelativeOnly

        public boolean isBaseRelativeOnly()
        Determine whether all valid responses to this question should be relative to the base directory (i.e. in or under it.)
        Returns:
        true if all valid responses to this question should be relative to the base directory
        See Also:
        setBaseRelativeOnly(boolean)
      • setBaseRelativeOnly

        public void setBaseRelativeOnly​(boolean b)
        Specify whether all valid responses to this question should be relative to the base directory (i.e. in or under it.)
        Parameters:
        b - this parameter should be true if all valid responses to this question should be relative to the base directory
      • clear

        public void clear()
        Clear any response to this question, resetting the value back to its initial state.
        Specified by:
        clear in class Question
      • load

        protected void load​(java.util.Map<java.lang.String,​java.lang.String> data)
        Load the value for this question from a dictionary, using the tag as the key.
        Overrides:
        load in class Question
        Parameters:
        data - The map from which to load the value for this question.
      • save

        protected void save​(java.util.Map<java.lang.String,​java.lang.String> data)
        Save the value for this question in a dictionary, using the tag as the key.
        Specified by:
        save in class Question
        Parameters:
        data - The map in which to save the value for this question.