KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > model > filefolder > FileInfoImpl


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 package org.alfresco.repo.model.filefolder;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.Date JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.alfresco.model.ContentModel;
24 import org.alfresco.service.cmr.model.FileInfo;
25 import org.alfresco.service.cmr.repository.ContentData;
26 import org.alfresco.service.cmr.repository.NodeRef;
27 import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
28 import org.alfresco.service.namespace.QName;
29
30 /**
31  * Common file information implementation.
32  *
33  * @author Derek Hulley
34  */

35 public class FileInfoImpl implements FileInfo
36 {
37     private NodeRef nodeRef;
38     private boolean isFolder;
39     private Map JavaDoc<QName, Serializable JavaDoc> properties;
40
41     /**
42      * Package-level constructor
43      */

44     /* package */ FileInfoImpl(NodeRef nodeRef, boolean isFolder, Map JavaDoc<QName, Serializable JavaDoc> properties)
45     {
46         this.nodeRef = nodeRef;
47         this.isFolder = isFolder;
48         this.properties = properties;
49     }
50     
51     @Override JavaDoc
52     public String JavaDoc toString()
53     {
54         StringBuilder JavaDoc sb = new StringBuilder JavaDoc(80);
55         sb.append("FileInfo")
56           .append("[name=").append(getName())
57           .append(", isFolder=").append(isFolder)
58           .append(", nodeRef=").append(nodeRef)
59           .append("]");
60         return sb.toString();
61     }
62     
63     public NodeRef getNodeRef()
64     {
65         return nodeRef;
66     }
67
68     public boolean isFolder()
69     {
70         return isFolder;
71     }
72
73     public String JavaDoc getName()
74     {
75         return (String JavaDoc) properties.get(ContentModel.PROP_NAME);
76     }
77
78     public Date JavaDoc getCreatedDate()
79     {
80         return DefaultTypeConverter.INSTANCE.convert(Date JavaDoc.class, properties.get(ContentModel.PROP_CREATED));
81     }
82
83     public Date JavaDoc getModifiedDate()
84     {
85         return DefaultTypeConverter.INSTANCE.convert(Date JavaDoc.class, properties.get(ContentModel.PROP_MODIFIED));
86     }
87     
88     public ContentData getContentData()
89     {
90         return DefaultTypeConverter.INSTANCE.convert(ContentData.class, properties.get(ContentModel.PROP_CONTENT));
91     }
92
93     public Map JavaDoc<QName, Serializable JavaDoc> getProperties()
94     {
95         return properties;
96     }
97 }
98
Popular Tags