blob: 9f16aace40ef39fb2150e6764a3af0044284d854 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.linuxtools.changelog.tests.fixtures;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IPath;
/**
* Helper class for a IStorageEditorInput fixture.
*
*/
public class CStringStorage implements IStorage {
private String string;
public CStringStorage(String input) {
this.string = input;
}
@Override
public InputStream getContents() {
return new ByteArrayInputStream(string.getBytes());
}
@Override
public IPath getFullPath() {
return null;
}
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
return null;
}
@Override
public String getName() {
int len = Math.min(5, string.length());
return string.substring(0, len).concat("..."); //$NON-NLS-1$
}
@Override
public boolean isReadOnly() {
return true;
}
}