package net.sf.jpluck.plucker.functions;
import net.sf.jpluck.palm.PdbOutputStream;
import net.sf.jpluck.plucker.Link;
import java.io.IOException;
public class LinkStart extends LinkFunction {
public LinkStart(String uri) {
super(uri);
}
public void write(PdbOutputStream out) throws IOException {
Link link = linkResolver.resolve(uri);
if (link != null) {
int recordId = link.getRecordId();
int paragraph = link.getParagraph();
if (paragraph == -1) {
out.writeByte(Function.PAGE_LINK_BEGINS);
out.writeShort(recordId);
} else {
out.writeByte(Function.PARAGRAPH_LINK_BEGINS);
out.writeShort(recordId);
out.writeShort(paragraph);
}
} else {
// Write dummy record ID
out.writeByte(Function.PAGE_LINK_BEGINS);
out.writeShort(0xfffe);
}
}
public int getSize() {
return (uri.indexOf('#') > -1? 5 : 3);
}
}