1 /* Copyright 2002-2020 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.data;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21
22 /** Container for holding named data that can be {@link DataFilter filtered}.
23 * <p>
24 * This class is a simple container without any processing methods.
25 * </p>
26 * @see DataFilter
27 * @author Luc Maisonobe
28 * @since 9.2
29 */
30 public class NamedData {
31
32 /** Name of the data (file name, zip entry name...). */
33 private final String name;
34
35 /** Supplier for data stream. */
36 private final StreamOpener streamOpener;
37
38 /** Simple constructor.
39 * @param name data name
40 * @param streamOpener opener for the data stream
41 */
42 public NamedData(final String name, final StreamOpener streamOpener) {
43 this.name = name;
44 this.streamOpener = streamOpener;
45 }
46
47 /** Get the name of the data.
48 * @return name of the data
49 */
50 public String getName() {
51 return name;
52 }
53
54 /** Get the data stream opener.
55 * @return data stream opener
56 */
57 public StreamOpener getStreamOpener() {
58 return streamOpener;
59 }
60
61 /** Interface for lazy-opening a stream. */
62 public interface StreamOpener {
63 /** Open the stream.
64 * @return opened stream
65 * @exception IOException if stream cannot be opened
66 */
67 InputStream openStream() throws IOException;
68
69 }
70
71 }
72