eb876f689c01ba6dd1d9a1e2c055305895d20f17
[yangtools.git] / yang / yang-maven-plugin / src / main / java / org / opendaylight / yangtools / yang2sources / plugin / YangSourceInZipFile.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang2sources.plugin;
9
10 import com.google.common.base.Preconditions;
11 import java.io.IOException;
12 import java.io.InputStream;
13 import java.util.zip.ZipEntry;
14 import java.util.zip.ZipFile;
15
16 class YangSourceInZipFile extends YangSourceFromDependency {
17
18     private final ZipFile file;
19     private final ZipEntry entry;
20
21     YangSourceInZipFile(ZipFile file, ZipEntry entry) {
22         this.file = Preconditions.checkNotNull(file);
23         this.entry = Preconditions.checkNotNull(entry);
24     }
25
26     @Override
27     public long size() {
28         return entry.getSize();
29     }
30
31     @Override
32     public InputStream openStream() throws IOException {
33         return file.getInputStream(entry);
34     }
35 }