midletinfo.java

来自「MoMEUnit是一个单元测试的J2ME的应用程序xUnit架构实例。这是来自J」· Java 代码 · 共 153 行

JAVA
153
字号
package org.momeunit.ant.jad;import java.util.regex.Matcher;import java.util.regex.Pattern;/** * Class that describes <code>MIDlet-&lt;n&gt;</code> JAD attribute. *  * @author Sergio Morozov * @version 1.1.2 */public class MIDletInfo{  private static final Pattern midletPattern = Pattern      .compile("([^,]+),([^,]*),(.*)");  private String name = null;  private String icon = null;  private String classname = null;  /**   * Instantiates MIDletInfo instance.   *    * @since 1.1   */  public MIDletInfo()  {    super();  }  /**   * Instantiates MIDletInfo instance by parsing value of attribute.   *    * @param line   *          value of attribute to parse.   * @since 1.1   */  public MIDletInfo(String line)  {    if (line == null) throw new NullPointerException();    Matcher matcher = midletPattern.matcher(line);    if (!matcher.matches()) throw new IllegalArgumentException();    setName(matcher.group(1));    setIcon(matcher.group(2));    setClass(matcher.group(3));  }  /**   * Instantiates MIDletInfo instance with specified name, icon and classname of   * midlet.   *    * @param name   *          name of midlet.   * @param icon   *          icon of midlet.   * @param classname   *          classname of midlet.   * @since 1.1   */  public MIDletInfo(String name, String icon, String classname)  {    super();    this.setName(name);    this.setIcon(icon);    this.setClass(classname);  }  /**   * Returns classname of midlet.   *    * @return the classname of midlet to set.   * @since 1.1   */  public String getClassName()  {    return this.classname;  }  /**   * Sets classname of midlet.   *    * @param classname   *          the classname of midlet to set   * @since 1.1   */  public void setClass(String classname)  {    if (classname == null) throw new NullPointerException("classname");    this.classname = classname;  }  /**   * Returns icon of midlet.   *    * @return the icon of midlet.   * @since 1.1   */  public String getIcon()  {    return this.icon;  }  /**   * Sets icon of midlet.   *    * @param icon   *          the icon of midlet to set.   * @since 1.1   */  public void setIcon(String icon)  {    this.icon = icon;  }  /**   * Returns name of midlet.   *    * @return the name of midlet.   * @since 1.1   */  public String getName()  {    return this.name;  }  /**   * Sets name of midlet.   *    * @param name   *          name of midlet to set.   * @since 1.1   */  public void setName(String name)  {    if (name == null) throw new NullPointerException("name");    this.name = name;  }  /**   * Returns attribute value that this MIDletInfo describes.   *    * @return the attribute value that this MIDletInfo describes.   * @since 1.1   */  public String getProperty()  {    return this.name + "," + (this.icon != null ? this.icon : "") + ","        + this.classname;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?