public static SignedDocumentValidator fromDocument(final DSSDocument dssDocument){
  if (CollectionUtils.isEmpty(registredDocumentValidators)) {
    throw new DSSException("No validator registred");
  }
  for (  Class<SignedDocumentValidator> clazz : registredDocumentValidators) {
    try {
      Constructor<SignedDocumentValidator> defaultAndPrivateConstructor=clazz.getDeclaredConstructor();
      defaultAndPrivateConstructor.setAccessible(true);
      SignedDocumentValidator validator=defaultAndPrivateConstructor.newInstance();
      if (validator.isSupported(dssDocument)) {
        Constructor<? extends SignedDocumentValidator> constructor=clazz.getDeclaredConstructor(DSSDocument.class);
        return constructor.newInstance(dssDocument);
      }
    }
 catch (    Exception e) {
      LOG.error("Cannot instanciate class '" + clazz.getName() + "' : "+ e.getMessage(),e);
    }
  }
  throw new DSSException("Document format not recognized/handled");
}

public static SignedDocumentValidator fromDocument ( final DSSDocument dssDocument ) { if ( CollectionUtils . isEmpty ( registredDocumentValidators ) ) { throw new DSSException ( "No validator registred" ) ; } for ( Class < SignedDocumentValidator > clazz : registredDocumentValidators ) { try { Constructor < SignedDocumentValidator > defaultAndPrivateConstructor = clazz . getDeclaredConstructor ( ) ; defaultAndPrivateConstructor . setAccessible ( true ) ; SignedDocumentValidator validator = defaultAndPrivateConstructor . newInstance ( ) ; if ( validator . isSupported ( dssDocument ) ) { Constructor < ? extends SignedDocumentValidator > constructor = clazz . getDeclaredConstructor ( DSSDocument . class ) ; return constructor . newInstance ( dssDocument ) ; } } catch ( Exception e ) { LOG . error ( "Cannot instanciate class '" + clazz . getName ( ) + "' : " + e . getMessage ( ) , e ) ; } } throw new DSSException ( "Document format not recognized/handled" ) ; }
this method guesses the document format and returns an appropriate document validator .
