Awesome, thanks. FWIW, I agree about null. I really like the zero run-time cost Option<T> type that languages like Rust have.
On Fri, Feb 26, 2016 at 5:10 AM, Tilman Hausherr <[email protected]> wrote: > done > https://issues.apache.org/jira/browse/PDFBOX-3249 > > Tilman > > > Am 24.02.2016 um 23:45 schrieb Tilman Hausherr: > >> Am 24.02.2016 um 23:38 schrieb David Lattimore: >> >>> On Wed, Feb 24, 2016 at 6:39 PM, Tilman Hausherr<[email protected]> >>> wrote: >>> >>> >Am 24.02.2016 um 06:21 schrieb David Lattimore: >>>> > >>>> >>>>> >>I'm trying to read annotations from PDFs and am having trouble >>>>> matching up >>>>> >>replies with the annotations they're in reply to. >>>>> >> >>>>> >>PDPage.getAnnotations() returns a list of PDAnnotation. When I have >>>>> >>a PDAnnotationMarkup, I try to call getInReplyTo to get the previous >>>>> >>annotation in the thread. But I have two problems: >>>>> >> >>>>> >>1) getInReplyTo() crashes if the annotation isn't a reply. It'd be >>>>> nice if >>>>> >>it just returned null. I can work around this by getting the >>>>> COSDictionary >>>>> >>and checking for an IRT entry first. >>>>> >> >>>>> >>>> > >>>> >Please post a stack trace >>>> >>> java.io.IOException: Error: Unknown annotation type null >>> at >>> org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.createAnnotation(PDAnnotation.java:167) >>> >>> at >>> org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup.getInReplyTo(PDAnnotationMarkup.java:225) >>> >>> >>> The following code can be used to reproduce this: >>> new PDAnnotationMarkup().getInReplyTo(); >>> >>> >> So it is an IOException, this isn't as bad as a nullpointerexception. But >> it is kindof weird indeed, usually we just return null when something >> doesn't exist. (I know that this is bad design >> http://www.yegor256.com/2014/05/13/why-null-is-bad.html but it's too >> late now). I'll sleep over it and then probably change it. >> >> Tilman >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

