Package net.sf.jpluck.plucker.functions

Source Code of net.sf.jpluck.plucker.functions.LinkStart

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);
  }
}
TOP

Related Classes of net.sf.jpluck.plucker.functions.LinkStart

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.