/*
- * FreenetSone - TemplateBucket.java - Copyright © 2010 David Roden
+ * Sone - StringBucket.java - Copyright © 2010–2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
package net.pterodactylus.sone.freenet;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
-import com.db4o.ObjectContainer;
-
import freenet.support.api.Bucket;
+import com.db4o.ObjectContainer;
/**
* {@link Bucket} implementation wrapped around a {@link String}.
this.encoding = encoding;
}
- /**
- * {@inheritDoc}
- */
@Override
public Bucket createShadow() {
- return new StringBucket(string);
+ return new StringBucket(string, encoding);
}
- /**
- * {@inheritDoc}
- */
@Override
public void free() {
/* ignore. */
}
- /**
- * {@inheritDoc}
- */
@Override
- public InputStream getInputStream() throws IOException {
+ public InputStream getInputStream() {
return new ByteArrayInputStream(string.getBytes(encoding));
}
- /**
- * {@inheritDoc}
- */
@Override
public String getName() {
return getClass().getName() + "@" + hashCode();
}
- /**
- * {@inheritDoc}
- */
@Override
- public OutputStream getOutputStream() throws IOException {
+ public OutputStream getOutputStream() {
return null;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isReadOnly() {
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public void removeFrom(ObjectContainer objectContainer) {
/* ignore. */
}
- /**
- * {@inheritDoc}
- */
@Override
public void setReadOnly() {
/* ignore, it is already read-only. */
}
- /**
- * {@inheritDoc}
- */
@Override
public long size() {
return string.getBytes(encoding).length;
}
- /**
- * {@inheritDoc}
- */
@Override
public void storeTo(ObjectContainer objectContainer) {
/* ignore. */