Skip to Content.
Sympa Menu

notify-dpml - r894 - in trunk/main/util/cli/src: main/net/dpml/cli/validation test/net/dpml/cli/validation

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r894 - in trunk/main/util/cli/src: main/net/dpml/cli/validation test/net/dpml/cli/validation
  • Date: Tue, 10 Jan 2006 03:37:40 +0100

Author: mcconnell
Date: 2006-01-10 03:37:26 +0100 (Tue, 10 Jan 2006)
New Revision: 894

Modified:
trunk/main/util/cli/src/main/net/dpml/cli/validation/FileValidator.java
trunk/main/util/cli/src/test/net/dpml/cli/validation/FileValidatorTest.java
Log:
remove r/w validation from FileValidator

Modified:
trunk/main/util/cli/src/main/net/dpml/cli/validation/FileValidator.java
===================================================================
--- trunk/main/util/cli/src/main/net/dpml/cli/validation/FileValidator.java
2006-01-09 05:35:12 UTC (rev 893)
+++ trunk/main/util/cli/src/main/net/dpml/cli/validation/FileValidator.java
2006-01-10 02:37:26 UTC (rev 894)
@@ -29,24 +29,18 @@
* The following attributes can also be specified using the
* appropriate settors:
* <ul>
- * <li>writable</li>
- * <li>readable</li>
* <li>existing</li>
* <li>is a file</li>
* <li>is a directory</li>
* </ul>
*
* The following example shows how to limit the valid values
- * for the config attribute to files that are readable, writeable,
- * and that already existing.
+ * for the config attribute to files that exist.
*
* <pre>
* ...
* ArgumentBuilder builder = new ArgumentBuilder();
* FileValidator validator = FileValidator.getExistingFileInstance();
- * validator.setReadable(true);
- * validator.setWritable(true);
- *
* Argument age =
* builder.withName("config");
* .withValidator(validator);
@@ -95,12 +89,6 @@
return validator;
}

- /** whether the argument value is readable */
- private boolean m_readable = false;
-
- /** whether the argument value is writable */
- private boolean m_writable = false;
-
/** whether the argument value exists */
private boolean m_existing = false;

@@ -110,9 +98,6 @@
/** whether the argument value is a file */
private boolean m_file = false;

- /** whether the argument value is a hidden file or directory */
- //private boolean hidden = false;
-
/**
* Validate the list of values against the list of permitted values.
* If a value is valid, replace the string in the <code>values</code>
@@ -133,12 +118,9 @@
}
final String name = (String) next;
final File f = new File( name );
- if ( ( m_existing && !f.exists() )
- || ( m_file && !f.isFile() )
- || ( m_directory && !f.isDirectory() )
- //|| ( m_hidden && !f.isHidden() )
- || ( m_readable && !f.canRead() )
- || ( m_writable && !f.canWrite() ) )
+ if( ( m_existing && !f.exists() )
+ || ( m_file && !f.isFile() )
+ || ( m_directory && !f.isDirectory() ) )
{
throw new InvalidArgumentException( name );
}
@@ -211,80 +193,4 @@
{
m_file = file;
}
-
- /**
- * Returns whether the argument values must represent hidden
- * files/directories.
- *
- * @return whether the argument values must represent hidden
- * files/directories.
- */
- /*
- public boolean isHidden()
- {
- return m_hidden;
- }
- */
-
- /**
- * Specifies whether the argument values must represent hidden
- * files/directories.
- *
- * @param hidden specifies whether the argument values must
- * represent hidden files/directories.
- */
- /*
- public void setHidden( boolean hidden )
- {
- m_hidden = hidden;
- }
- */
-
- /**
- * Returns whether the argument values must represent readable
- * files/directories.
- *
- * @return whether the argument values must represent readable
- * files/directories.
- */
- public boolean isReadable()
- {
- return m_readable;
- }
-
- /**
- * Specifies whether the argument values must represent readable
- * files/directories.
- *
- * @param readable specifies whether the argument values must
- * represent readable files/directories.
- */
- public void setReadable( boolean readable )
- {
- m_readable = readable;
- }
-
- /**
- * Returns whether the argument values must represent writable
- * files/directories.
- *
- * @return whether the argument values must represent writable
- * files/directories.
- */
- public boolean isWritable()
- {
- return m_writable;
- }
-
- /**
- * Specifies whether the argument values must represent writable
- * files/directories.
- *
- * @param writable specifies whether the argument values must
- * represent writable files/directories.
- */
- public void setWritable( boolean writable )
- {
- m_writable = writable;
- }
}

Modified:
trunk/main/util/cli/src/test/net/dpml/cli/validation/FileValidatorTest.java
===================================================================
---
trunk/main/util/cli/src/test/net/dpml/cli/validation/FileValidatorTest.java
2006-01-09 05:35:12 UTC (rev 893)
+++
trunk/main/util/cli/src/test/net/dpml/cli/validation/FileValidatorTest.java
2006-01-10 02:37:26 UTC (rev 894)
@@ -80,87 +80,6 @@
}
}

- /**
- * DOCUMENT ME!
- */
- public void testValidateReadableFile( )
- {
- // make file readonly
- File file = new File( "target/test/data/readable.txt" );
-
- if( !file.exists( ) )
- {
- throw new IllegalStateException(
- "Missing test resource: 'target/test/data/readable.txt'
relative to "
- + System.getProperty( "user.dir" ) );
- }
-
- file.setReadOnly( );
-
- final Object[] array = new Object[]
- {
- "target/test/data/readable.txt",
- "target/test/data/notreadable.txt"
- };
- final List list = Arrays.asList( array );
- final FileValidator validator =
FileValidator.getExistingFileInstance( );
- validator.setReadable( true );
-
- assertFalse( "is not a directory validator", validator.isDirectory(
) );
- assertTrue( "is a file validator", validator.isFile( ) );
- assertTrue( "is an existing file validator", validator.isExisting(
) );
- //assertFalse("is not a hidden file validator",
validator.isHidden());
- assertTrue( "is a readable file validator", validator.isReadable( )
);
- assertFalse( "is not a writable file validator",
- validator.isWritable( ) );
-
- try
- {
- validator.validate( list );
- fail( "InvalidArgumentException" );
- }
- catch( InvalidArgumentException e )
- {
- assertEquals( "target/test/data/notreadable.txt", e.getMessage(
) );
- }
- }
-
- /**
- * DOCUMENT ME!
- */
- public void testValidateWritableFile( )
- {
- // make file readonly
- File file = new File( "target/test/data/readable.txt" );
- file.setReadOnly( );
-
- final Object[] array = new Object[]
- {
- "target/test/data/writable.txt",
"target/test/data/readable.txt"
- };
- final List list = Arrays.asList( array );
- final FileValidator validator =
FileValidator.getExistingFileInstance( );
- validator.setWritable( true );
-
- assertFalse( "is not a directory validator", validator.isDirectory(
) );
- assertTrue( "is a file validator", validator.isFile( ) );
- assertTrue( "is an existing file validator", validator.isExisting(
) );
- //assertFalse("is not a hidden file validator",
validator.isHidden());
- assertFalse( "is not a readable file validator",
- validator.isReadable( ) );
- assertTrue( "is a writable file validator", validator.isWritable( )
);
-
- try
- {
- validator.validate( list );
- fail( "InvalidArgumentException" );
- }
- catch( InvalidArgumentException e )
- {
- assertEquals( "target/test/data/readable.txt", e.getMessage( )
);
- }
- }
-
//
/**
* DOCUMENT ME!




  • r894 - in trunk/main/util/cli/src: main/net/dpml/cli/validation test/net/dpml/cli/validation, mcconnell at BerliOS, 01/09/2006

Archive powered by MHonArc 2.6.24.

Top of Page