Subversion Repository Public Repository

litesoft

Diff Revisions 789 vs 791 for /trunk/Java/core/Server/src/org/litesoft/textfiledirectory/TextFileDirectoryFileSystem.java

Diff revisions: vs.
  @@ -7,7 +7,7 @@
7 7 import org.litesoft.core.util.*;
8 8 import org.litesoft.util.*;
9 9
10 - public class TextFileDirectoryFileSystem implements TextFileDirectory
10 + public class TextFileDirectoryFileSystem extends AbstractTextFileDirectory
11 11 {
12 12 private final File mDirectory;
13 13
  @@ -21,6 +21,12 @@
21 21 }
22 22
23 23 @Override
24 + public String getDirectoryPath()
25 + {
26 + return mDirectory.getAbsolutePath();
27 + }
28 +
29 + @Override
24 30 public boolean exists()
25 31 {
26 32 return mDirectory.isDirectory();
  @@ -29,11 +35,7 @@
29 35 @Override
30 36 public String[] getFiles( String... pExtensions )
31 37 {
32 - final String[] zExtensions = UtilsCommon.deNull( pExtensions, UtilsCommon.EMPTY_STRING_ARRAY );
33 - for ( int i = 0; i < zExtensions.length; i++ )
34 - {
35 - zExtensions[i] = "." + UtilsCommon.assertNotNullNotEmpty( "Extension[" + i + "]", zExtensions[i] );
36 - }
38 + final String[] zExtensions = preprocessExtensions( pExtensions );
37 39 if ( !mDirectory.isDirectory() )
38 40 {
39 41 return UtilsCommon.EMPTY_STRING_ARRAY;
  @@ -61,6 +63,7 @@
61 63
62 64 @Override
63 65 public TextFile load( @NotNull String pFileName )
66 + throws FileDoesNotExists
64 67 {
65 68 String[] zLines = FileUtils.loadTextFile( getFile( pFileName = UtilsCommon.assertNotNullNotEmpty( "FileName", pFileName ) ) );
66 69 return new TextFile( pFileName, zLines );
  @@ -68,24 +71,28 @@
68 71
69 72 @Override
70 73 public void create( @NotNull TextFile pFile )
74 + throws FileAlreadExists
71 75 {
72 76 write( assertNotExist( getFile( pFile ) ), pFile );
73 77 }
74 78
75 79 @Override
76 80 public void update( @NotNull TextFile pFile )
81 + throws FileDoesNotExists
77 82 {
78 83 write( assertIsFile( getFile( pFile ) ), pFile );
79 84 }
80 85
81 86 @Override
82 87 public void delete( @NotNull TextFile pFile )
88 + throws FileDoesNotExists
83 89 {
84 90 delete( getFile( pFile ) );
85 91 }
86 92
87 93 @Override
88 94 public void delete( @NotNull String pFileName )
95 + throws FileDoesNotExists
89 96 {
90 97 delete( getFile( UtilsCommon.assertNotNullNotEmpty( "FileName", pFileName ) ) );
91 98 }
  @@ -103,19 +110,13 @@
103 110
104 111 private File assertIsFile( File pFile )
105 112 {
106 - if ( !pFile.isFile() )
107 - {
108 - throw new IllegalArgumentException( "Not a File: " + pFile.getAbsolutePath() );
109 - }
113 + assertExists( pFile.isFile(), pFile.getName() );
110 114 return pFile;
111 115 }
112 116
113 117 private File assertNotExist( File pFile )
114 118 {
115 - if ( pFile.exists() )
116 - {
117 - throw new IllegalArgumentException( "Existing directory entry: " + pFile.getAbsolutePath() );
118 - }
119 + assertNotExists( pFile.exists(), pFile.getName() );
119 120 return pFile;
120 121 }
121 122