FileDocCategorySizeDatePackage
Tool.javaAPI DocExample2673Thu Apr 05 20:28:16 BST 2001None

Tool

public class Tool extends Object

Fields Summary
public int
id
public String
name
public String
homeURL
public String
comments
public String
stateFlag
public Timestamp
createdTime
public Timestamp
modifiedTime
Constructors Summary
Methods Summary
public java.lang.StringgetComments()

 return comments; 
public intgetCreatedAgeInDays()

    return (int) ((System.currentTimeMillis() - createdTime.getTime()) /
            (24 * 60 * 60 * 1000));  // millis in a day
  
public java.sql.TimestampgetCreatedTime()

 return createdTime; 
public java.lang.StringgetHomeURL()

 return homeURL; 
public intgetId()

 return id; 
public intgetModifiedAgeInDays()

    return (int) ((System.currentTimeMillis() - modifiedTime.getTime()) /
            (24 * 60 * 60 * 1000));  // millis in a day
  
public java.sql.TimestampgetModifiedTime()

 return modifiedTime; 
public java.lang.StringgetName()

 return name; 
public java.lang.StringgetStateFlag()

 return stateFlag; 
public booleanisNewWithin(int days)

    return getCreatedAgeInDays() < days;
  
public booleanisUpdatedWithin(int days)

    return getModifiedAgeInDays() < days;
  
public static Tool[]loadTools(java.lang.String toolsFile)

    // Read the tool data from an XML file containing <tool> elements
    // Use the JDOM API to keep things simple (http://jdom.org)
    List toolObjects = new LinkedList();

    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(new File(toolsFile));
    Element root = document.getRootElement();
    List toolElements = root.getChildren("tool");
    Iterator i = toolElements.iterator();
    while (i.hasNext()) {
      Element tool = (Element) i.next();
      Tool t = new Tool();
      t.id = tool.getAttribute("id").getIntValue();
      t.name = tool.getChild("name").getTextTrim();
      t.homeURL = tool.getChild("homeURL").getTextTrim();
      t.comments = tool.getChild("comments").getTextTrim();
      t.stateFlag = tool.getChild("stateFlag").getTextTrim();
      t.createdTime = Timestamp.valueOf(
                        tool.getChild("createdTime").getTextTrim());
      t.modifiedTime = Timestamp.valueOf(
                         tool.getChild("modifiedTime").getTextTrim());
      toolObjects.add(t);
    }

    return (Tool[]) toolObjects.toArray(new Tool[0]);