All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.daisy.streamline.api.media.DefaultAnnotatedInputStream Maven / Gradle / Ivy

The newest version!
package org.daisy.streamline.api.media;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

/**
 * Provides a default implementation of {@link AnnotatedInputStream}.
 * @author Joel Håkansson
 */
public final class DefaultAnnotatedInputStream implements AnnotatedInputStream {
	private final InputStreamSupplier stream;
	private final FileDetails details;
	
	/**
	 * Provides a builder for {@link DefaultAnnotatedInputStream}s.
	 */
	public static class Builder {
		private final InputStreamSupplier stream;
		private FileDetails details;
		
		/**
		 * Creates a new builder with the specified input stream.
		 * @param stream the input stream
		 */
		public Builder(InputStreamSupplier stream) {
			this.stream = stream;
			DefaultFileDetails.Builder detailsBuilder = new DefaultFileDetails.Builder();
			if (stream.getSystemId()!=null) {
				detailsBuilder.extension(findExtension(stream.getSystemId()));
			}
			this.details = detailsBuilder.build();
		}
		
		private static String findExtension(String inp) {
			int inx = inp.lastIndexOf('.');
			return (inx>-1 && inx getProperties() {
		return details.getProperties();
	}

	@Override
	public InputStream newInputStream() throws IOException {
		return stream.newInputStream();
	}

	@Override
	public String getSystemId() {
		return stream.getSystemId();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy