1 15 package org.apache.tapestry.workbench.tree.examples.fsmodel; 16 17 import java.io.File ; 18 import java.util.Collection ; 19 import java.util.Date ; 20 21 import org.apache.tapestry.contrib.tree.model.ITreeNode; 22 23 public abstract class SFObject implements IFileSystemTreeNode{ 24 protected File m_objFile; 25 protected ITreeNode m_objParent; 26 private Date m_objDate; 27 protected transient AssetsHolder m_objAssetsHolder = null; 28 29 public SFObject(ITreeNode objParent, File objFile) { 30 m_objParent = objParent; 31 m_objFile = objFile; 32 } 34 35 protected void init() { 36 if(m_objFile.isFile() || m_objFile.isDirectory()) 37 m_objDate = new Date (m_objFile.lastModified()); 38 } 39 40 public String getName() { 41 if (m_objFile.getName().equals("")) { 42 return m_objFile.toString(); 43 } 44 return m_objFile.getName(); 45 } 46 47 public Date getDate() { 48 return m_objDate; 49 } 50 51 public Object getAttributes() { 52 return null; 53 } 54 55 protected File getFile() { 56 return m_objFile; 57 } 58 59 62 public ITreeNode getParent() { 63 return m_objParent; 64 } 65 66 69 public boolean containsChild(ITreeNode node) { 70 return false; 71 } 72 73 76 public boolean getAllowsChildren() { 77 return false; 78 } 79 80 83 public int getChildCount() { 84 return 0; 85 } 86 87 90 public Collection getChildren() { 91 return null; 92 } 93 94 97 public boolean isLeaf() { 98 return false; 99 } 100 101 104 public boolean equals(Object arg0) { 105 if (!(arg0 instanceof SFObject)) { 106 return false; 107 } 108 SFObject objSF = (SFObject)arg0; 109 if (getFile().equals(objSF.getFile())) { 110 return true; 111 } 112 return false; 113 } 114 115 118 public int hashCode() { 119 return m_objFile.hashCode(); 120 } 121 122 125 public String toString() { 126 return getName(); 127 } 128 129 132 public String getAbsolutePath() { 133 return getFile().getAbsolutePath(); 134 } 135 } 136 | Popular Tags |