Example usage for org.apache.poi.hssf.record DConRefRecord toString

List of usage examples for org.apache.poi.hssf.record DConRefRecord toString

Introduction

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

Prototype

@Override
    public String toString() 

Source Link

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;
        }/*from   w w w  .  j a  v a 2s.  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);
        }
    }
}