View Javadoc

1   /*
2    * Copyright 2011-2012 smartics, Kronseder & Reiner GmbH
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  package de.smartics.util.io;
17  
18  import java.io.IOException;
19  import java.io.InputStream;
20  import java.io.OutputStream;
21  
22  /**
23   * Provides access to streams to read from and write to a destination. This is a
24   * simple method to abstract access to the file system.
25   */
26  public interface StreamHandler
27  {
28    // ********************************* Fields *********************************
29  
30    // --- constants ------------------------------------------------------------
31  
32    // ****************************** Initializer *******************************
33  
34    // ****************************** Inner Classes *****************************
35  
36    // ********************************* Methods ********************************
37  
38    // --- get&set --------------------------------------------------------------
39  
40    // --- business -------------------------------------------------------------
41  
42    /**
43     * Opens a stream to the given resource for reading.
44     *
45     * @param resourceId the identifier of the resource that should be opened.
46     * @return the stream to the resource.
47     * @throws IOException on any problem opening the resource.
48     */
49    InputStream openToRead(String resourceId) throws IOException;
50  
51    /**
52     * Opens a stream to the given resource for writing.
53     *
54     * @param resourceId the identifier of the resource that should be opened.
55     * @return the stream to the resource.
56     * @throws IOException on any problem opening the resource.
57     */
58    OutputStream openToWrite(String resourceId) throws IOException;
59  
60    // --- object basics --------------------------------------------------------
61  
62  }