Example usage for org.apache.poi.hssf.record Record serialize

List of usage examples for org.apache.poi.hssf.record Record serialize

Introduction

In this page you can find the example usage for org.apache.poi.hssf.record Record serialize.

Prototype

public final byte[] serialize() 

Source Link

Document

called by the class that is responsible for writing this sucker.

Usage

From source file:org.ddt.listener.records.DConRefListener.java

License:Apache License

public void processRecord(Record record) {
    if (record.getSid() == DConRefRecord.sid) {
        DConRefRecord dcr = new DConRefRecord(record.serialize());
        if (!dcr.isExternalRef()) {
            log.log(Level.FINE, "Not an external ref: {0}", dcr.toString());
            return;
        }/* w w w  .j a  va  2  s.co  m*/

        byte[] path = dcr.getPath();
        String linkString = cleanPath(path);

        if (linkString != null && !linkString.trim().equals(""))
            ;
        {
            Link l = new Link(5);
            byte type = path[1];
            //types relative to startup dir | alt-startup dir | library dir | simple-file-path
            if (type == 0x06 || type == 0x07 || type == 0x08 || type > 0x40)
                l.addRelativePath(linkString);
            else if (type == 0x01) {
                if (path[2] == 0x40) //UNC path.
                {
                    l.addAbsolutePath(linkString);
                } else if (path[2] > 0x40) //relative to drive letter, remove drive letter
                {
                    char drive = (char) path[2];
                    l.addRelativePath(linkString.replaceFirst(String.valueOf(drive), ""));
                }
            } else
                l.addUnkownPath(linkString);
            this.add(l);
        }
    }
}