You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2002/03/08 16:11:44 UTC

cvs commit: xml-xalan/test/java/src/org/apache/qetest FileDatalet.java

curcuru     02/03/08 07:11:44

  Modified:    test/java/src/org/apache/qetest FileDatalet.java
  Log:
  Add validate() method to allow FileDatalets to self-validate their own file resources
  
  Revision  Changes    Path
  1.2       +44 -1     xml-xalan/test/java/src/org/apache/qetest/FileDatalet.java
  
  Index: FileDatalet.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/FileDatalet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileDatalet.java	5 Mar 2002 21:25:32 -0000	1.1
  +++ FileDatalet.java	8 Mar 2002 15:11:44 -0000	1.2
  @@ -75,7 +75,7 @@
    * handling proper URI/URL's according to the RFCs.
    * 
    * @author Shane_Curcuru@us.ibm.com
  - * @version $Id: FileDatalet.java,v 1.1 2002/03/05 21:25:32 curcuru Exp $
  + * @version $Id: FileDatalet.java,v 1.2 2002/03/08 15:11:44 curcuru Exp $
    */
   public class FileDatalet implements Datalet
   {
  @@ -96,6 +96,49 @@
   
       /** Accessor method for gold.  */
       public String getGold() { return gold; }
  +
  +
  +    /** 
  +     * Worker method to validate the files/dirs we represent.  
  +     * 
  +     * By default, ensures that the input already exists in some 
  +     * format, and for both the output and gold, attempts to create 
  +     * them if they don't already exist.
  +     *
  +     * @param strict if true, requires that output and gold must 
  +     * be created; otherwise they're optional
  +     * @return false if input doesn't already exist; true otherwise
  +     */
  +    public boolean validate(boolean strict)
  +    {
  +        File f = new File(getInput());
  +        if (!f.exists())
  +            return false;
  +
  +        f = new File(getOutput());
  +        if (!f.exists())
  +        {
  +            if (!f.mkdirs())
  +            {
  +                // Only fail if asked to be strict
  +                if (strict)
  +                    return false;
  +            }
  +        }        
  +
  +        f = new File(getGold());
  +        if (!f.exists())
  +        {
  +            if (!f.mkdirs())
  +            {
  +                // Only fail if asked to be strict
  +                if (strict)
  +                    return false;
  +            }
  +        }        
  +        // If we get here, we're happy either way
  +        return true;
  +    }
   
   
       /** 
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org