@ Nullable public static PDBusinessCard parseBusinessCard ( @ Nonnull final Node aNode ) { ValueEnforcer . notNull ( aNode , "Node" ) ; { // Read version 1 final PD1BusinessCardMarshaller aMarshaller1 = new PD1BusinessCardMarshaller ( ) ; aMarshaller1 . readExceptionCallbacks ( ) . removeAll ( ) ; final PD1BusinessCardType aBC1 = aMarshaller1 . read ( aNode ) ; if ( aBC1 != null ) try { return PD1APIHelper . createBusinessCard ( aBC1 ) ; } catch ( final IllegalArgumentException ex ) { // If the BC does not adhere to the XSD // Happens if e.g. name is null return null ; } } { // Read as version 2 final PD2BusinessCardMarshaller aMarshaller2 = new PD2BusinessCardMarshaller ( ) ; aMarshaller2 . readExceptionCallbacks ( ) . removeAll ( ) ; final PD2BusinessCardType aBC2 = aMarshaller2 . read ( aNode ) ; if ( aBC2 != null ) try { return PD2APIHelper . createBusinessCard ( aBC2 ) ; } catch ( final IllegalArgumentException ex ) { // If the BC does not adhere to the XSD // Happens if e.g. name is null return null ; } } { // Read as version 3 final PD3BusinessCardMarshaller aMarshaller3 = new PD3BusinessCardMarshaller ( ) ; aMarshaller3 . readExceptionCallbacks ( ) . removeAll ( ) ; final PD3BusinessCardType aBC3 = aMarshaller3 . read ( aNode ) ; if ( aBC3 != null ) try { return PD3APIHelper . createBusinessCard ( aBC3 ) ; } catch ( final IllegalArgumentException ex ) { // If the BC does not adhere to the XSD // Happens if e.g. name is null return null ; } } // Unsupported version return null ; }
A generic reading API to read all supported versions of the BusinessCard from a DOM node .