KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > server > repo > pseudo > PseudoFile


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17
18 package org.alfresco.filesys.smb.server.repo.pseudo;
19
20 import java.io.File JavaDoc;
21
22 import org.alfresco.filesys.server.filesys.FileAttribute;
23 import org.alfresco.filesys.server.filesys.FileInfo;
24 import org.alfresco.filesys.server.filesys.NetworkFile;
25
26 /**
27  * Pseudo File Class
28  *
29  * <p>Creates a pseudo file entry for a folder that maps to a file outside of the usual file area but appears
30  * in folder listings for the owner folder.
31  *
32  * @author gkspencer
33  */

34 public abstract class PseudoFile
35 {
36     // Dummy creation date/time to use for pseudo files
37

38     protected static long _creationDateTime = System.currentTimeMillis();
39     
40     // File name for pseudo file
41

42     private String JavaDoc m_fileName;
43
44     // File flags/attributes
45

46     private int m_fileFlags = FileAttribute.ReadOnly;
47     
48     // File information, used for file information/folder searches
49

50     protected FileInfo m_fileInfo;
51     
52     /**
53      * Class constructor
54      *
55      * @param name String
56      */

57     protected PseudoFile(String JavaDoc name)
58     {
59         m_fileName = name;
60     }
61     
62     /**
63      * Class constructor
64      *
65      * @param name String
66      * @param flags int
67      */

68     protected PseudoFile(String JavaDoc name, int flags)
69     {
70         m_fileName = name;
71         m_fileFlags = flags;
72     }
73     
74     /**
75      * Return the pseudo file name as it will appear in folder listings
76      *
77      * @return String
78      */

79     public final String JavaDoc getFileName()
80     {
81         return m_fileName;
82     }
83     
84     /**
85      * Return the standard file attributes
86      *
87      * @return int
88      */

89     public final int getAttributes()
90     {
91         return m_fileFlags;
92     }
93     
94     /**
95      * Return the file information for the pseudo file
96      *
97      * @return FileInfo
98      */

99     public abstract FileInfo getFileInfo();
100     
101     /**
102      * Return a network file for reading/writing the pseudo file
103      *
104      * @param netPath String
105      * @return NetworkFile
106      */

107     public abstract NetworkFile getFile(String JavaDoc netPath);
108     
109     /**
110      * Return the pseudo file as a string
111      *
112      * @return String
113      */

114     public String JavaDoc toString()
115     {
116         StringBuilder JavaDoc str = new StringBuilder JavaDoc();
117         
118         str.append("[");
119         str.append(getFileName());
120         str.append(",");
121         str.append(getFileInfo());
122         str.append("]");
123         
124         return str.toString();
125     }
126 }
127
Popular Tags