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