public Object createRunner( @Nonnull Class<?> runnerType ) { return Reflection.constructor().in( runnerType ).newInstance(); }
@VisibleForTesting static void installAWTExceptionHandler(@Nonnull Class<?> exceptionHandlerType, SystemPropertyWriter writer) { try { constructor().in(exceptionHandlerType).info(); } catch (RuntimeException e) { throw new IllegalArgumentException("The exception handler type should have a default constructor"); } writer.updateSystemProperty("sun.awt.exception.handler", exceptionHandlerType.getName()); }
public void setExternalParserForPartOfDocument(int id, String externalParserClassName) throws CollectionException { if (externalParserClassName != null) { Class<?> externalParserClass; try { externalParserClass = Class.forName(externalParserClassName.trim()); } catch (ClassNotFoundException e) { LOGGER.error("ExternalParser " + externalParserClassName + " for document text part " + id + " returns a ClassNotFoundException", e); throw new CollectionException(e); } DocumentTextPartParser parser = (DocumentTextPartParser) constructor().in(externalParserClass).newInstance(); this.docTextData.get(id).setParser(parser); } }
/** * Overrides the parser and sets an external parser * * @param trim a String containing the full qualified Classname of the parser * @throws CollectionException */ public void setParser(String trim) throws CollectionException { if (trim != null) { externalParser = true; Class<?> externalParserClass; try { externalParserClass = Class.forName(trim); } catch (ClassNotFoundException e) { LOGGER.error("ExternalParser " + trim + " for type or feature " + fullClassName + " returns a ClassNotFoundException", e); throw new CollectionException(e); } this.parser = (TypeParser) constructor().in(externalParserClass).newInstance(); }else{ this.parser = null; } }
type = (Annotation) constructor().withParameterTypes(JCas.class).in(typeClass).newInstance(jcas);