KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > scripting > model > ColumbaScript


1 /*
2   The contents of this file are subject to the Mozilla Public License Version 1.1
3   (the "License"); you may not use this file except in compliance with the
4   License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5   
6   Software distributed under the License is distributed on an "AS IS" basis,
7   WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8   for the specific language governing rights and
9   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 JavaDoc;
21
22 /**
23     @author Celso Pinto (cpinto@yimports.com)
24  */

25 public class ColumbaScript
26 {
27
28     private final File JavaDoc scriptFile;
29
30     private String JavaDoc
31         name = "",
32         author = "",
33         description = "",
34         extension = "";
35
36     public ColumbaScript(File JavaDoc file)
37     {
38         scriptFile = file;
39         extension = extractExtensionFromFilename();
40     }
41
42     private String JavaDoc extractExtensionFromFilename()
43     {
44
45         String JavaDoc name = scriptFile.getName();
46         int pos = name.lastIndexOf('.');
47         if (pos == -1 || pos + 1 == name.length()) return null;
48
49         return name.substring(pos + 1);
50
51     }
52
53     public String JavaDoc getExtension()
54     {
55         return extension;
56     }
57
58     public void setMetadata(String JavaDoc name, String JavaDoc author, String JavaDoc desc)
59     {
60         this.name = name;
61         this.author = author;
62         this.description = desc;
63     }
64
65     public String JavaDoc getName()
66     {
67         if (name.equals("")) return scriptFile.getName();
68         else return name;
69
70     }
71
72     public String JavaDoc getAuthor()
73     {
74         return author;
75     }
76
77     public String JavaDoc getDescription()
78     {
79         return description;
80     }
81
82     public long getLastModified()
83     {
84         return scriptFile.lastModified();
85     }
86
87     public String JavaDoc getPath()
88     {
89         return scriptFile.getPath();
90     }
91
92     public boolean exists()
93     {
94         return scriptFile.exists();
95     }
96
97     public boolean deleteFromDisk()
98     {
99         return scriptFile.delete();
100     }
101 }
102
Popular Tags