2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.yangtools.yang.parser.util;
11 import java.io.ByteArrayInputStream;
12 import java.io.IOException;
13 import java.io.InputStream;
14 import org.apache.commons.io.IOUtils;
16 public class NamedByteArrayInputStream extends ByteArrayInputStream implements NamedInputStream {
17 private final String toString;
18 public NamedByteArrayInputStream(byte[] buf, String toString) {
20 this.toString = toString;
23 public static ByteArrayInputStream create(InputStream originalIS) throws IOException {
24 String content = IOUtils.toString(originalIS);
25 if (originalIS instanceof NamedInputStream) {
26 return new NamedByteArrayInputStream(content.getBytes(), originalIS.toString());
28 return new ByteArrayInputStream(content.getBytes());
33 public String toString() {