Subversion Repositories XServices

Compare Revisions

No changes between revisions

Ignore whitespace Rev 91 → Rev 92

/xservices/trunk/src/java/net/brutex/xservices/types/FileInfoListType.java
0,0 → 1,47
package net.brutex.xservices.types;
 
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
 
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
 
@XmlRootElement
public class FileInfoListType {
private List<FileInfoType> list = new ArrayList<FileInfoType>();
public void setDirectory(File dir, final boolean withDirectories, final boolean withFiles, int depth) {
if(depth <=0) return;
File[] files = dir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
if(!withFiles && !pathname.isFile()) return false;
return true;
}
});
if(files==null) return;
for( File e : files) {
if(e.isDirectory()) setDirectory(e, withDirectories, withFiles, depth-1);
if( (withDirectories && e.isDirectory())
|| withFiles && e.isFile()) {
this.list.add(new FileInfoType(e));
}
}
}
public void setDirectory(String dir, final boolean withDirectories, final boolean withFiles, int depth) {
setDirectory( (new File(dir)), withDirectories, withFiles, depth);
}
@XmlElement(name="FileInfoList")
public List<FileInfoType> getFiles() {
return list;
}
 
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property
/xservices/trunk/src/java/net/brutex/xservices/types/FileInfoType.java
0,0 → 1,91
package net.brutex.xservices.types;
 
import java.io.File;
 
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
 
@XmlRootElement
public class FileInfoType {
 
private String name;
private String path;
private long filesize;
private boolean canWrite;
private boolean isDirectory;
public FileInfoType() {
}
public FileInfoType(File file) {
this.name = file.getName();
this.path = file.getAbsolutePath().replace('\\', '/');
this.canWrite = file.canWrite();
this.filesize = file.length();
this.isDirectory = file.isDirectory(); }
 
/**
* @return the name
*/
@XmlElement(name="name")
public String getName() {
return name;
}
 
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
 
/**
* @return the path
*/
@XmlElement(name="path")
public String getPath() {
return path;
}
 
/**
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
 
/**
* @return the filesize
*/
@XmlElement(name="size")
public long getFilesize() {
return filesize;
}
 
/**
* @param filesize the filesize to set
*/
public void setFilesize(long filesize) {
this.filesize = filesize;
}
 
/**
* @return the canWrite
*/
@XmlElement(name="isWritable")
public boolean isCanWrite() {
return canWrite;
}
 
/**
* @return the isDirectory
*/
@XmlElement(name="isDirectory")
public boolean isDirectory() {
return isDirectory;
}
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property