View Javadoc

1   /*
2    * Copyright [2006] [University Corporation for Advanced Internet Development, 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.opensaml.util.resource;
18  
19  import java.io.InputStream;
20  
21  import org.joda.time.DateTime;
22  
23  /**
24   * An interface representing an data resource.
25   */
26  public interface Resource {
27  
28      /**
29       * Gets resource location information.  Examples might be filesystem path, URL, etc.
30       * 
31       * @return resource location information
32       */
33      public String getLocation();
34      
35      /**
36       * Checks whether the resource exists.
37       * 
38       * @return true if the resource exists, false if not
39       * 
40       * @throws ResourceException thrown if there is a problem determining if the resource exists
41       */
42      public boolean exists() throws ResourceException;
43      
44      /**
45       * Gets the inputstream to the resource's data.
46       * 
47       * @return inputstream to the resource's data
48       * 
49       * @throws ResourceException thrown if an input stream can not be created for the resource
50       */
51      public InputStream getInputStream() throws ResourceException;
52      
53      /**
54       * Gets the date and time the resource was last modified.
55       * 
56       * @return date and time the resource was last modified
57       * 
58       * @throws ResourceException thrown if the last modified time can not be determined
59       */
60      public DateTime getLastModifiedTime() throws ResourceException;
61  }