科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道最快最省构建漂亮合理的Java程序

最快最省构建漂亮合理的Java程序

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

  一、编译运行示例:      >javac -classpath ..\..\libnakedobjects.jar;..\..\liblog4j.jar;..\..libxerces.jar;classes;. Run.java      二、

作者:中国IT实验室 来源:中国IT实验室 2007年9月26日

关键字: 编程 java

  • 评论
  • 分享微博
  • 分享邮件

  一、编译运行示例:
  
  >javac -classpath ..\..\libnakedobjects.jar;..\..\liblog4j.jar;..\..libxerces.jar;classes;. Run.java
  
  二、示例程序(地址簿):
  
  // Address.java
  import org.nakedobjects.object.*;
  
  public class Address extends NakedObject {
  private final TextString name = new TextString();
  private final TextString address = new TextString();
  private final TextString telephone = new TextString();
  private final TextString mobile = new TextString();
  private final TextString email = new TextString();
  
  public TextString getName() {
  return name;
  }
  
  public TextString getAddress() {
  return address;
  }
  
  public TextString getTelephone() {
  return telephone;
  }
  
  public TextString getMobile() {
  return mobile;
  }
  
  public TextString getEmail() {
  return email;
  }
  
  public Title title() {
  return name.title();
  }
  }
  
  // Run.java
  import org.nakedobjects.*;
  import org.nakedobjects.object.ClassSet;
  import org.nakedobjects.utility.ConfigurationException;
  import org.nakedobjects.object.ObjectStore;
  import org.nakedobjects.xmlpersistence.XMLObjectStore;
  import org.apache.log4j.Category;
  import org.apache.log4j.Priority;
  
  public class Run extends DefaultApplication {
  public static void main(String args[]){
  new Run();
  }
  
  public void classSet(ClassSet set){
  set.addClass(Address.class);
  }
  
  protected void configureLogging() throws ConfigurationException {
  super.configureLogging();
  Category.getDefaultHierarchy().disable(Priority.INFO);
  }
  
  protected ObjectStore installObjectStore() throws ConfigurationException {
  return new XMLObjectStore();
  }
  }
  

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件