|
|
@@ -21,21 +21,36 @@ import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.RandomAccessFile;
|
|
|
|
|
|
+import org.apache.commons.lang.builder.ToStringBuilder;
|
|
|
+
|
|
|
+import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
+
|
|
|
public class FileState {
|
|
|
+ @JsonIgnore
|
|
|
private File file;
|
|
|
private String directory;
|
|
|
+ private String fileName;
|
|
|
+ @JsonIgnore
|
|
|
private long lastModified;
|
|
|
+ @JsonIgnore
|
|
|
private long size;
|
|
|
+ @JsonIgnore
|
|
|
private boolean deleted = false;
|
|
|
private long signature;
|
|
|
private int signatureLength;
|
|
|
+ @JsonIgnore
|
|
|
private boolean changed = false;
|
|
|
+ @JsonIgnore
|
|
|
private RandomAccessFile randomAccessFile;
|
|
|
private long pointer = 0;
|
|
|
+ @JsonIgnore
|
|
|
private FileState oldFileState;
|
|
|
- private String fileName;
|
|
|
+ @JsonIgnore
|
|
|
private Event fields;
|
|
|
|
|
|
+ public FileState() {
|
|
|
+ }
|
|
|
+
|
|
|
public FileState(File file) throws IOException {
|
|
|
this.file = file;
|
|
|
directory = file.getCanonicalFile().getParent();
|
|
|
@@ -44,6 +59,10 @@ public class FileState {
|
|
|
lastModified = file.lastModified();
|
|
|
size = file.length();
|
|
|
}
|
|
|
+
|
|
|
+ private void setFileFromDirectoryAndName() {
|
|
|
+ this.file = new File(directory + File.pathSeparator + fileName);
|
|
|
+ }
|
|
|
|
|
|
public File getFile() {
|
|
|
return file;
|
|
|
@@ -61,6 +80,24 @@ public class FileState {
|
|
|
return directory;
|
|
|
}
|
|
|
|
|
|
+ public void setDirectory(String directory) {
|
|
|
+ this.directory = directory;
|
|
|
+ if(fileName != null && directory != null) {
|
|
|
+ setFileFromDirectoryAndName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getFileName() {
|
|
|
+ return fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setFileName(String fileName) {
|
|
|
+ this.fileName = fileName;
|
|
|
+ if(fileName != null && directory != null) {
|
|
|
+ setFileFromDirectoryAndName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public boolean isDeleted() {
|
|
|
return deleted;
|
|
|
}
|
|
|
@@ -113,10 +150,6 @@ public class FileState {
|
|
|
this.oldFileState = oldFileState;
|
|
|
}
|
|
|
|
|
|
- public String getFileName() {
|
|
|
- return fileName;
|
|
|
- }
|
|
|
-
|
|
|
public Event getFields() {
|
|
|
return fields;
|
|
|
}
|
|
|
@@ -125,4 +158,15 @@ public class FileState {
|
|
|
this.fields = fields;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return new ToStringBuilder(this).
|
|
|
+ append("fileName", fileName).
|
|
|
+ append("directory", directory).
|
|
|
+ append("pointer", pointer).
|
|
|
+ append("signature", signature).
|
|
|
+ append("signatureLength", signatureLength).
|
|
|
+ toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|