BrightSide Workbench Full Report + Source Code
org.turro.elephant.documents.FileDocument Class Reference
Inheritance diagram for org.turro.elephant.documents.FileDocument:
Collaboration diagram for org.turro.elephant.documents.FileDocument:

Public Member Functions

 FileDocument (DocumentsRoot docsRoot, FileDocument parentDoc, String pathName)
 
DocumentsRoot getDocumentsRoot ()
 
FileDocument getParentDoc ()
 
int getLevel ()
 
boolean getCanNew ()
 
boolean getCanDelete ()
 
boolean getCanNewFolder ()
 
boolean getCanDelFolder ()
 
FileDocument[] getListDocuments ()
 
FileDocument[] getListFolders ()
 
FileDocument[] getNotValidated ()
 
String getFormattedName ()
 
String getFormattedPath ()
 
String getRelativeURL ()
 
String getUniqueId ()
 
String getExtension ()
 
boolean getSomethingToShow ()
 
String readConfig (String property)
 
String readConfig (String property, boolean moveUp)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 35 of file FileDocument.java.

Constructor & Destructor Documentation

◆ FileDocument()

org.turro.elephant.documents.FileDocument.FileDocument ( DocumentsRoot  docsRoot,
FileDocument  parentDoc,
String  pathName 
)

Creates a new instance of FileDocument

Definition at line 42 of file FileDocument.java.

42  {
43  super(pathName);
44  this.docsRoot = docsRoot;
45  this.parentDoc = parentDoc;
46  this.level = (parentDoc != null ? parentDoc.getLevel() + 1 : 0);
47  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ getCanDelete()

boolean org.turro.elephant.documents.FileDocument.getCanDelete ( )

Definition at line 65 of file FileDocument.java.

65  {
66  return docsRoot.getCanDelete();
67  }
Here is the call graph for this function:

◆ getCanDelFolder()

boolean org.turro.elephant.documents.FileDocument.getCanDelFolder ( )

Definition at line 73 of file FileDocument.java.

73  {
74  return docsRoot.getCanDelFolder();
75  }
Here is the call graph for this function:

◆ getCanNew()

boolean org.turro.elephant.documents.FileDocument.getCanNew ( )

Definition at line 61 of file FileDocument.java.

61  {
62  return docsRoot.getCanNew();
63  }
Here is the call graph for this function:

◆ getCanNewFolder()

boolean org.turro.elephant.documents.FileDocument.getCanNewFolder ( )

Definition at line 69 of file FileDocument.java.

69  {
70  return docsRoot.getCanNewFolder();
71  }
Here is the call graph for this function:

◆ getDocumentsRoot()

DocumentsRoot org.turro.elephant.documents.FileDocument.getDocumentsRoot ( )

Definition at line 49 of file FileDocument.java.

49  {
50  return docsRoot;
51  }
Here is the caller graph for this function:

◆ getExtension()

String org.turro.elephant.documents.FileDocument.getExtension ( )

Definition at line 203 of file FileDocument.java.

203  {
204  String name = getName();
205  int p = name.lastIndexOf(".");
206  if(p > -1) return name.substring(p + 1).toLowerCase();
207  return "bin";
208  }

◆ getFormattedName()

String org.turro.elephant.documents.FileDocument.getFormattedName ( )

Definition at line 134 of file FileDocument.java.

134  {
135  String result = isFile() ? null : readConfig("root.name", false);
136  if(result == null) {
137  result = "";
138  String tmp = getName();
139  if(tmp.startsWith(".")) tmp = tmp.substring(1);
140  int p = tmp.lastIndexOf(".");
141  if(p > -1) tmp = tmp.substring(0, p);
142  String s[] = tmp.split("\\_");
143  for(int i = 0; i < s.length; i++) {
144  // append an space if there is already content
145  if(result.length() > 0) result += " - ";
146  // this part could be the period phase
147  if(s[i].matches("[0-9]*")) {
148  switch(s[i].length()) {
149  case 12:
150  result += docsRoot.getDocumentsBean().getLocalizer().parseString("date", "yyyyMMddHHmm", "date_time", s[i]);
151  break;
152  case 8:
153  result += docsRoot.getDocumentsBean().getLocalizer().parseString("date", "yyyyMMdd", "full", s[i]);
154  break;
155  case 6:
156  result += docsRoot.getDocumentsBean().getLocalizer().parseString("date", "yyyyMM", "month_year", s[i]);
157  break;
158  case 4:
159  result += docsRoot.getDocumentsBean().getLocalizer().parseString("date", "yyyy", "year", s[i]);
160  break;
161  case 2:
162  result += docsRoot.getDocumentsBean().getLocalizer().parseString("date", "yy", "year", s[i]);
163  break;
164  }
165  }
166  // otherwise name phase
167  else {
168  tmp = readConfig("name." + s[i]);
169  result += (tmp == null ? s[i] : tmp);
170  }
171  }
172  }
173  if(result == null) result = getName();
174  if(isFile() && "true".equals(readConfig("file.size"))) {
175  result += " [" + docsRoot.getDocumentsBean().getLocalizer().parseValue("bytes", null, new Long(length())) + "]";
176  }
177  return result;
178  }
String parseValue(String type, String outFormat, Object value)
Definition: Localizer.java:96
String parseString(String type, String inFormat, String outFormat, String value)
Definition: Localizer.java:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFormattedPath()

String org.turro.elephant.documents.FileDocument.getFormattedPath ( )

Definition at line 180 of file FileDocument.java.

180  {
181  String result = "";
182  FileDocument p = isFile() ? getParentDoc() : this;
183  while(p != null) {
184  result = p.getFormattedName() + " / " + result;
185  p = p.getParentDoc();
186  }
187  return result;
188  }
FileDocument(DocumentsRoot docsRoot, FileDocument parentDoc, String pathName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLevel()

int org.turro.elephant.documents.FileDocument.getLevel ( )

Definition at line 57 of file FileDocument.java.

57  {
58  return level;
59  }
Here is the caller graph for this function:

◆ getListDocuments()

FileDocument [] org.turro.elephant.documents.FileDocument.getListDocuments ( )

Definition at line 77 of file FileDocument.java.

77  {
78  FileDocument tmp;
79  if(children == null) {
80  Set s = new TreeSet(new FileComparator());
81  if(exists()) {
82  File[] fs = listFiles();
83  for(int i = 0; i < fs.length; i++) {
84  if(!fs[i].getName().startsWith(".")) {
85  tmp = new FileDocument(docsRoot, this, fs[i].getPath());
86  String role = tmp.readConfig("root.role", false);
87  if((role == null || docsRoot.getDocumentsBean().getConstructor().isInRole(role)) && tmp.getSomethingToShow()) {
88  s.add(tmp);
89  }
90  }
91  }
92  }
93  children = (FileDocument[]) s.toArray(new FileDocument[0]);
94  }
95  return children;
96  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getListFolders()

FileDocument [] org.turro.elephant.documents.FileDocument.getListFolders ( )

Definition at line 98 of file FileDocument.java.

98  {
99  FileDocument tmp;
100  Set s = new TreeSet(new FileComparator());
101  if(exists()) {
102  File[] fs = listFiles();
103  for(int i = 0; i < fs.length; i++) {
104  if(!fs[i].getName().startsWith(".") && fs[i].isDirectory()) {
105  tmp = new FileDocument(docsRoot, this, fs[i].getPath());
106  String role = tmp.readConfig("root.role", false);
107  if(role == null || docsRoot.getDocumentsBean().getConstructor().isInRole(role)) {
108  s.add(tmp);
109  }
110  }
111  }
112  }
113  return (FileDocument[]) s.toArray(new FileDocument[0]);
114  }
Here is the call graph for this function:

◆ getNotValidated()

FileDocument [] org.turro.elephant.documents.FileDocument.getNotValidated ( )

Definition at line 116 of file FileDocument.java.

116  {
117  FileDocument tmp;
118  Set s = new TreeSet(new FileComparator());
119  if(exists()) {
120  File[] fs = listFiles();
121  for(int i = 0; i < fs.length; i++) {
122  if(fs[i].isDirectory() || (fs[i].isHidden() && !".docs.properties".equals(fs[i].getName()))) {
123  tmp = new FileDocument(docsRoot, this, fs[i].getPath());
124  String role = tmp.readConfig("root.role", false);
125  if(role == null || docsRoot.getDocumentsBean().getConstructor().isInRole(role)) {
126  s.add(tmp);
127  }
128  }
129  }
130  }
131  return (FileDocument[]) s.toArray(new FileDocument[0]);
132  }
Here is the call graph for this function:

◆ getParentDoc()

FileDocument org.turro.elephant.documents.FileDocument.getParentDoc ( )

Definition at line 53 of file FileDocument.java.

53  {
54  return parentDoc;
55  }
Here is the caller graph for this function:

◆ getRelativeURL()

String org.turro.elephant.documents.FileDocument.getRelativeURL ( )

Definition at line 190 of file FileDocument.java.

190  {
191  try {
192  return docsRoot.getDownloadURL() + "&down_file=" + URLEncoder.encode(docsRoot.getRelativePath(getPath()), "UTF-8");
193  } catch (UnsupportedEncodingException ex) {
194  Logger.getLogger(FileDocument.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
195  }
196  return null;
197  }
Here is the call graph for this function:

◆ getSomethingToShow()

boolean org.turro.elephant.documents.FileDocument.getSomethingToShow ( )

Definition at line 210 of file FileDocument.java.

210  {
211  return isFile() || getListDocuments().length > 0;
212  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUniqueId()

String org.turro.elephant.documents.FileDocument.getUniqueId ( )

Definition at line 199 of file FileDocument.java.

199  {
200  return Cipher.digest(getPath(), 40);
201  }

◆ readConfig() [1/2]

String org.turro.elephant.documents.FileDocument.readConfig ( String  property)

Definition at line 214 of file FileDocument.java.

214  {
215  return readConfig(property, true);
216  }
Here is the caller graph for this function:

◆ readConfig() [2/2]

String org.turro.elephant.documents.FileDocument.readConfig ( String  property,
boolean  moveUp 
)

Definition at line 218 of file FileDocument.java.

218  {
219  String result = null;
220  File startPoint = this;
221  if(isFile()) {
222  startPoint = getParentDoc();
223  }
224  Properties props = docsRoot.getDocumentsBean().getPropertiesFile(startPoint.getAbsolutePath() + "/.docs.properties");
225  if(props != null) {
226  result = props.getProperty(property);
227  }
228  if(moveUp && result == null) {
229  if(getParentDoc() != null) {
230  result = getParentDoc().readConfig(property);
231  }
232  else {
233  result = docsRoot.readRootConfig(property);
234  }
235  }
236  return result;
237  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: