List of usage examples for org.apache.poi.hssf.record DConRefRecord getPath
public byte[] getPath()
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 ww .jav a 2s.c o 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); } } }
From source file:org.ddt.listener.records.DConRefRecordTest.java
License:Apache License
/** * Test of getPath method, of class DConRefRecord. * @todo different types of paths./*from w w w.ja v a2 s .c o m*/ */ @Test public void testGetPath() { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data1)); byte[] expResult = Arrays.copyOfRange(data1, 9, data1.length); byte[] result = instance.getPath(); assertArrayEquals("get path", expResult, result); }
From source file:org.ddt.listener.records.DConRefRecordTest.java
License:Apache License
/** * This one doesn't fail (unless the constructor dies), but is there to show the output of * different path types.//from w w w .j ava 2s.c o m */ @Test public void testGetReadablePath() { System.out.println("Testing Readableness of the Path:-------------------"); DConRefRecord r = new DConRefRecord(TestcaseRecordInputStream.create(81, transferProtocolString)); System.out.print(new String(r.getPath()) + " --> "); System.out.println(r.getReadablePath()); r = new DConRefRecord(TestcaseRecordInputStream.create(81, simpleFilePathDconString)); System.out.print(new String(r.getPath()) + " --> "); System.out.println(r.getReadablePath()); r = new DConRefRecord(TestcaseRecordInputStream.create(81, uncVolumeString)); System.out.print(new String(r.getPath()) + " --> "); System.out.println(r.getReadablePath()); r = new DConRefRecord(TestcaseRecordInputStream.create(81, volumeString)); System.out.print(new String(r.getPath()) + " --> "); System.out.println(r.getReadablePath()); r = new DConRefRecord(TestcaseRecordInputStream.create(81, startupString)); System.out.print(new String(r.getPath()) + " --> "); System.out.println(r.getReadablePath()); r = new DConRefRecord(TestcaseRecordInputStream.create(81, altStartupString)); System.out.print(new String(r.getPath()) + " --> "); System.out.println(r.getReadablePath()); r = new DConRefRecord(TestcaseRecordInputStream.create(81, libraryString)); System.out.print(new String(r.getPath()) + " --> "); System.out.println(r.getReadablePath()); }