File Source: AtomMediaResource.java
/*
P/P * Method: org.apache.roller.weblogger.webservices.atomprotocol.AtomMediaResource__static_init
*/
1 /*
2 * Copyright 2007 Sun Microsystems, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not 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.
15 */
16
17 package org.apache.roller.weblogger.webservices.atomprotocol;
18
19 import java.io.File;
20 import java.io.FileInputStream;
21 import java.io.FileNotFoundException;
22 import java.io.InputStream;
23 import java.util.Date;
24 import javax.activation.FileTypeMap;
25 import javax.activation.MimetypesFileTypeMap;
26 import org.apache.roller.weblogger.pojos.ThemeResource;
27
28 /**
29 * Represents a media link entry.
30 */
31 public class AtomMediaResource {
32
33 private String contentType = null;
34 private int contentLength = 0;
35 private InputStream inputStream = null;
36 private Date lastModified = null;
37
/*
P/P * Method: void org.apache.roller.weblogger.webservices.atomprotocol.AtomMediaResource(ThemeResource)
*
* Preconditions:
* resource != null
*
* Presumptions:
* javax.activation.FileTypeMap:getDefaultFileTypeMap(...)@40 != null
* org.apache.roller.weblogger.pojos.ThemeResource:getLength(...)@48 in -231..232-1
*
* Postconditions:
* (soft) init'ed(this.contentLength)
* init'ed(this.contentType)
* init'ed(this.inputStream)
* this.lastModified == &new Date(AtomMediaResource#1)
* new Date(AtomMediaResource#1) num objects == 1
*/
38 public AtomMediaResource(ThemeResource resource) throws FileNotFoundException {
39 // TODO: figure out why PNG is missing from Java MIME types
40 FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
41 if (map instanceof MimetypesFileTypeMap) {
42 try {
43 ((MimetypesFileTypeMap) map).addMimeTypes("image/png png PNG");
44 } catch (Exception ignored) {
45 }
46 }
47 contentType = map.getContentType(resource.getName());
48 contentLength = (int)resource.getLength();
49 lastModified = new Date(resource.getLastModified());
50 inputStream = resource.getInputStream();
51 }
52
53 public String getContentType() {
/*
P/P * Method: String getContentType()
*
* Preconditions:
* init'ed(this.contentType)
*
* Postconditions:
* return_value == this.contentType
* init'ed(return_value)
*/
54 return contentType;
55 }
56
57 public void setContentType(String contentType) {
/*
P/P * Method: void setContentType(String)
*
* Postconditions:
* this.contentType == contentType
* init'ed(this.contentType)
*/
58 this.contentType = contentType;
59 }
60
61 public int getContentLength() {
/*
P/P * Method: int getContentLength()
*
* Preconditions:
* init'ed(this.contentLength)
*
* Postconditions:
* return_value == this.contentLength
* init'ed(return_value)
*/
62 return contentLength;
63 }
64
65 public void setContentLength(int contentLength) {
/*
P/P * Method: void setContentLength(int)
*
* Postconditions:
* this.contentLength == contentLength
* init'ed(this.contentLength)
*/
66 this.contentLength = contentLength;
67 }
68
69 public InputStream getInputStream() {
/*
P/P * Method: InputStream getInputStream()
*
* Preconditions:
* init'ed(this.inputStream)
*
* Postconditions:
* return_value == this.inputStream
* init'ed(return_value)
*/
70 return inputStream;
71 }
72
73 public void setInputStream(InputStream inputStream) {
/*
P/P * Method: void setInputStream(InputStream)
*
* Postconditions:
* this.inputStream == inputStream
* init'ed(this.inputStream)
*/
74 this.inputStream = inputStream;
75 }
76
77 public Date getLastModified() {
/*
P/P * Method: Date getLastModified()
*
* Preconditions:
* init'ed(this.lastModified)
*
* Postconditions:
* return_value == this.lastModified
* init'ed(return_value)
*/
78 return lastModified;
79 }
80
81 public void setLastModified(Date lastModified) {
/*
P/P * Method: void setLastModified(Date)
*
* Postconditions:
* this.lastModified == lastModified
* init'ed(this.lastModified)
*/
82 this.lastModified = lastModified;
83 }
84 }
SofCheck Inspector Build Version : 2.18479
| AtomMediaResource.java |
2009-Jan-02 14:25:26 |
| AtomMediaResource.class |
2009-Sep-04 03:12:46 |