File Source: SharedThemeResourceFromDir.java
/*
P/P * Method: org.apache.roller.weblogger.business.themes.SharedThemeResourceFromDir__static_init
*/
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */
18
19 package org.apache.roller.weblogger.business.themes;
20
21 import java.io.File;
22 import java.io.FileInputStream;
23 import java.io.InputStream;
24 import java.io.Serializable;
25 import org.apache.roller.weblogger.pojos.ThemeResource;
26
27
28 /**
29 * A FileManagerImpl specific implementation of a ThemeResource.
30 *
31 * ThemeResources from the FileManagerImpl are backed by a java.io.File
32 * object which represents the resource on a filesystem.
33 *
34 * This class is internal to the FileManagerImpl class because there should
35 * not be any external classes which need to construct their own instances
36 * of this class.
37 */
38 public class SharedThemeResourceFromDir
39 implements ThemeResource, Serializable, Comparable {
40
41 // the physical java.io.File backing this resource
42 private File resourceFile = null;
43
44 // the relative path of the resource within the theme
45 private String relativePath = null;
46
47
/*
P/P * Method: void org.apache.roller.weblogger.business.themes.SharedThemeResourceFromDir(String, File)
*
* Postconditions:
* this.relativePath == path
* init'ed(this.relativePath)
* this.resourceFile == file
* init'ed(this.resourceFile)
*/
48 public SharedThemeResourceFromDir(String path, File file) {
49 relativePath = path;
50 resourceFile = file;
51 }
52
53
54 /**
55 * @see java.lang.Comparable#compareTo(java.lang.Object)
56 */
57 public int compareTo(Object o) {
/*
P/P * Method: int compareTo(Object)
*
* Preconditions:
* o != null
* this.relativePath != null
*
* Postconditions:
* init'ed(return_value)
*/
58 ThemeResource other = (ThemeResource) o;
59 return getPath().compareTo(other.getPath());
60 }
61
62
63 public ThemeResource[] getChildren() {
/*
P/P * Method: ThemeResource[] getChildren()
*
* Postconditions:
* return_value == null
*/
64 return null;
65 }
66
67
68 public String getName() {
/*
P/P * Method: String getName()
*
* Preconditions:
* this.resourceFile != null
*
* Postconditions:
* init'ed(return_value)
*/
69 return resourceFile.getName();
70 }
71
72 public String getPath() {
/*
P/P * Method: String getPath()
*
* Preconditions:
* init'ed(this.relativePath)
*
* Postconditions:
* return_value == this.relativePath
* init'ed(return_value)
*/
73 return relativePath;
74 }
75
76 public long getLastModified() {
/*
P/P * Method: long getLastModified()
*
* Preconditions:
* this.resourceFile != null
*
* Postconditions:
* init'ed(return_value)
*/
77 return resourceFile.lastModified();
78 }
79
80 public long getLength() {
/*
P/P * Method: long getLength()
*
* Preconditions:
* this.resourceFile != null
*
* Postconditions:
* init'ed(return_value)
*/
81 return resourceFile.length();
82 }
83
84 public boolean isDirectory() {
/*
P/P * Method: bool isDirectory()
*
* Preconditions:
* this.resourceFile != null
*
* Postconditions:
* init'ed(return_value)
*/
85 return resourceFile.isDirectory();
86 }
87
88 public boolean isFile() {
/*
P/P * Method: bool isFile()
*
* Preconditions:
* this.resourceFile != null
*
* Postconditions:
* init'ed(return_value)
*/
89 return resourceFile.isFile();
90 }
91
92 public InputStream getInputStream() {
93 try {
/*
P/P * Method: InputStream getInputStream()
*
* Preconditions:
* init'ed(this.resourceFile)
*
* Postconditions:
* return_value == &new FileInputStream(getInputStream#1)
* new FileInputStream(getInputStream#1) num objects == 1
*/
94 return new FileInputStream(resourceFile);
95 } catch (java.io.FileNotFoundException ex) {
96 // should never happen, rethrow as runtime exception
97 throw new RuntimeException("Error constructing input stream", ex);
98 }
99 }
100
101 }
SofCheck Inspector Build Version : 2.18479
| SharedThemeResourceFromDir.java |
2009-Jan-02 14:25:44 |
| SharedThemeResourceFromDir.class |
2009-Sep-04 03:12:31 |