package net.sf.jpluck.plucker.functions;
import net.sf.jpluck.palm.PdbOutputStream;
import net.sf.jpluck.plucker.Link;
import net.sf.jpluck.plucker.Text;
import java.io.IOException;
public class EmbeddedImage extends LinkFunction implements SignificantContent {
private Text alt;
public EmbeddedImage(String uri) {
super(uri);
}
public EmbeddedImage(String uri, Text alt) {
super(uri);
this.alt = alt;
}
public void write(PdbOutputStream out) throws IOException {
int recordId = linkResolver.resolve(uri).getRecordId();
Link fullSizeLink= linkResolver.resolve(uri + ".alternate");
if (fullSizeLink != null) {
out.writeByte(Function.MULTIPLE_EMBEDDED_IMAGE);
out.writeShort(fullSizeLink.getRecordId());
out.writeShort(recordId);
} else {
out.writeByte(Function.EMBEDDED_IMAGE);
out.writeShort(recordId);
}
}
public Text getAlt() {
return alt;
}
public int getSize() {
return 5; // Actual size is either 3 or 5
}
}