01: /*
02: The contents of this file are subject to the Mozilla Public License Version 1.1
03: (the "License"); you may not use this file except in compliance with the
04: License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05:
06: Software distributed under the License is distributed on an "AS IS" basis,
07: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: for the specific language governing rights and
09: limitations under the License.
10:
11: The Original Code is "The Columba Project"
12:
13: The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
14: Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
15:
16: All Rights Reserved.
17: */
18: package org.columba.core.scripting.model;
19:
20: import java.io.File;
21:
22: /**
23: @author Celso Pinto (cpinto@yimports.com)
24: */
25: public class ColumbaScript {
26:
27: private final File scriptFile;
28:
29: private String name = "", author = "", description = "",
30: extension = "";
31:
32: public ColumbaScript(File file) {
33: scriptFile = file;
34: extension = extractExtensionFromFilename();
35: }
36:
37: private String extractExtensionFromFilename() {
38:
39: String name = scriptFile.getName();
40: int pos = name.lastIndexOf('.');
41: if (pos == -1 || pos + 1 == name.length())
42: return null;
43:
44: return name.substring(pos + 1);
45:
46: }
47:
48: public String getExtension() {
49: return extension;
50: }
51:
52: public void setMetadata(String name, String author, String desc) {
53: this .name = name;
54: this .author = author;
55: this .description = desc;
56: }
57:
58: public String getName() {
59: if (name.equals(""))
60: return scriptFile.getName();
61: else
62: return name;
63:
64: }
65:
66: public String getAuthor() {
67: return author;
68: }
69:
70: public String getDescription() {
71: return description;
72: }
73:
74: public long getLastModified() {
75: return scriptFile.lastModified();
76: }
77:
78: public String getPath() {
79: return scriptFile.getPath();
80: }
81:
82: public boolean exists() {
83: return scriptFile.exists();
84: }
85:
86: public boolean deleteFromDisk() {
87: return scriptFile.delete();
88: }
89: }
|