savefile.java
来自「Java Pattern Oriented Framework (Jt) 是为了」· Java 代码 · 共 121 行
JAVA
121 行
package Jt.wizard.struts;
import java.util.Collection;
import java.util.LinkedList;
import Jt.JtFactory;
import Jt.JtFile;
import Jt.JtMessage;
import Jt.JtObject;
/**
* Saves a file (no longer used).
*/
public class SaveFile extends JtObject {
private static final long serialVersionUID = 1L;
String path;
String content;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getContent() {
return path;
}
public void setContent(String path) {
this.path = path;
}
private void handleUIError (String error) {
Collection col;
if (error == null)
return;
col = (Collection) this.getObjErrors();
if (col == null) {
col = new LinkedList ();
setObjErrors (col);
}
col.add(error);
}
public Object saveFile (SaveFileForm form) {
JtFactory factory = new JtFactory ();
String fileContent;
JtFile file = new JtFile ();
JtMessage msg = new JtMessage (JtFile.JtSAVE_STRING);
if (form == null) {
return (null);
}
path = (String) form.getPath();
if (path == null || path.equals ("")) {
handleUIError ("Please enter a path.");
}
fileContent = (String) form.getContent ();
if (fileContent == null || fileContent.equals ("")) {
handleUIError ("Please enter the file content.");
}
if (getObjErrors() != null) {
return (null);
}
msg.setMsgContent(fileContent);
file.setName (path);
factory.sendMessage(file, msg);
// Propagate the exception
if (file.getObjException() != null)
this.setObjException(file.getObjException());
return (null);
}
/**
* Process object messages.
* <ul>
* <li> JtACTIVATE
* </ul>
* @param message message
*/
public Object processMessage (Object message) {
Object data;
JtMessage e = (JtMessage) message;
if (e == null || (e.getMsgId() == null))
return (null);
if (e.getMsgId().equals(JtObject.JtACTIVATE)) {
// pass the form information
data = e.getMsgData ();
//return ( saveFile ((SaveFileForm) data));
return null;
}
return (super.processMessage(message));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?