package org.sonny.filemanager.util;
import java.io.File; import java.util.ResourceBundle;
public class XMLBuilder {
public XMLBuilder() { } public String getFileSpaceXML(String path) { FileProxy fproxy = new FileProxy(); String rootdir = fproxy.getValidPatch(path, false); String newline = "\n"; File f = new File(rootdir); String [] list = f.list(); String element = "<file "; String elementend = "</file>"; StringBuffer xmlBuffer = new StringBuffer("<?xml version=‘1.0‘ encoding=‘utf-8‘?>"); xmlBuffer.append("\n") .append("<root>") .append("<Code>0</Code>") .append("<Message>ok</Message>") .append("<Data>"); if(list != null) { for(String ff : list) { if(FileProxy.isFolder(ff)) { element = "<folder "; elementend = "</folder>"; }else{ element = "<file "; elementend = "</file>"; } xmlBuffer.append(newline) .append(element) .append("name=‘") .append(ff) .append("‘>") .append(elementend); } } return xmlBuffer.append("</Data>") .append("\n </root>") .toString(); } public static String buildNormalDoc() { return "<?xml version=‘1.0‘ encoding=‘utf-8‘?><root><Code>0</Code><Message>ok</Message></root>"; } public String getShareSpaceXML() { return null; } }
|