private void initProcessorIterator(Context context, Iterable<? extends Processor> processors) { Log log = Log.instance(context); Iterator<? extends Processor> processorIterator; if (options.isSet(XPRINT)) { try { Processor processor = PrintingProcessor.class.newInstance(); processorIterator = List.of(processor).iterator(); } catch (Throwable t) { AssertionError assertError = new AssertionError("Problem instantiating PrintingProcessor."); assertError.initCause(t); throw assertError; } } else if (processors != null) { processorIterator = processors.iterator(); } else { String processorNames = options.get(PROCESSOR); JavaFileManager fileManager = context.get(JavaFileManager.class); try { // If processorpath is not explicitly set, use the classpath. processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) : fileManager.getClassLoader(CLASS_PATH); /* * If the "-processor" option is used, search the appropriate * path for the named class. Otherwise, use a service * provider mechanism to create the processor iterator. */ if (processorNames != null) { processorIterator = new NameProcessIterator(processorNames, processorClassLoader, log); } else { processorIterator = new ServiceIterator(processorClassLoader, log); } } catch (SecurityException e) { /* * A security exception will occur if we can't create a classloader. * Ignore the exception if, with hindsight, we didn't need it anyway * (i.e. no processor was specified either explicitly, or implicitly, * in service configuration file.) Otherwise, we cannot continue. */ processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader", e); } } discoveredProcs = new DiscoveredProcessors(processorIterator); }
/** * Create a PropertyColumn from a property name, column name, row and column classes, and column * width. The render and editor default to null, and updateRow, updateSubsequentRows, and * updateTable all default to false. * * <p>This generates an editable column if a setter exists for this property, and a non-editable * property if the setter doesn't exist. For more complex behavior, override {@code * isEditable(_RowType)} * * @param pPropertyName The name of the property of instances of the specified row class * @param pColumnName The name of the column * @param pRowClass The class of the table row instances * @param pValueClass The class of the values of this column * @param pPrefWidth the preferred width of this column * @throws AssertionError if pRowClass doesn't have a getter for this property name. */ public PropertyColumn( String pPropertyName, String pColumnName, Class pRowClass, Class pValueClass, int pPrefWidth) { super(pColumnName, getWrapper(pValueClass), pPrefWidth); try { mGetterMethod = generateGetter(pPropertyName, pRowClass, this); } catch (NoSuchMethodException e) { AssertionError err = new AssertionError(e.getMessage()); err.initCause(e); throw err; } Method setter = null; try { setter = generateSetter(pPropertyName, pRowClass, this); setEditable(true); } catch (NoSuchMethodException nsme) { setEditable(false); } mSetterMethod = setter; }