001/**
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 *
006 */
007package org.fcrepo.migration.foxml;
008
009import java.io.ByteArrayInputStream;
010import java.io.IOException;
011import java.io.InputStream;
012
013/**
014 * A CachedContent implementation that stores the entirety of the content
015 * in memory as String.
016 * @author mdurbin
017 */
018public class MemoryCachedContent implements CachedContent {
019
020    private String content;
021
022    /**
023     * memory cached content.
024     * @param content the content
025     */
026    public MemoryCachedContent(final String content) {
027        this.content = content;
028    }
029
030    @Override
031    public InputStream getInputStream() throws IOException {
032        return new ByteArrayInputStream(content.getBytes("UTF-8"));
033    }
034}