public static void createEventInterface( Option option, String packageName, String rootDirectoryPathName) { JCodeModel model = new JCodeModel(); try { JDefinedClass jClass = model._class( packageName + "." + EventHelper.getEventNamePrefix(option) + EventHelper.EVENT_SUFFIX, ClassType.INTERFACE); // jClass._extends(NativeEvent.class); // TODO this logic should not be in an helper, pb it is duplicated // inside all helper, should have a common algo // write getter for Series / Point / Chart / Axis (context) inside // event if (option.getContext() != null) EventHelper.getType(option) .accept(new EventGetterWriterVisitor(option, jClass, model), OutputType.Interface); ClassRegistry.INSTANCE.put(option, OutputType.Interface, jClass); } catch (JClassAlreadyExistsException e) { throw new RuntimeException(e); } try { model.build(new File(rootDirectoryPathName)); } catch (IOException e) { throw new RuntimeException(e); } }
public static JDefinedClass createEventHandlerInterface( Option option, String packageName, String rootDirectoryPathName) { JCodeModel model = new JCodeModel(); JDefinedClass jClass = null; try { String eventName = EventHelper.getEventNamePrefix(option); String handlerName = eventName + EventHelper.HANDLER_SUFFIX; String fullyqualifiedName = packageName + "." + handlerName; jClass = model._class(fullyqualifiedName, ClassType.INTERFACE); JClass eventClass = ClassRegistry.INSTANCE .getRegistry() .get(new ClassRegistry.RegistryKey(option, OutputType.Interface)); jClass .method(JMod.NONE, void.class, EventHelper.ON_PREFIX + eventName) .param(eventClass, EventHelper.paramName(eventName)); EventRegistry.INSTANCE.put(EventHelper.getRegistryKey(option), jClass); logger.info("Handler created;" + handlerName); } catch (JClassAlreadyExistsException e) { throw new RuntimeException(e); } try { model.build(new File(rootDirectoryPathName)); } catch (IOException e) { throw new RuntimeException(e); } return jClass; }
public void validate(Source source, Result result) throws SAXException, IOException { if (result instanceof StAXResult || result == null) { StAXSource staxSource = (StAXSource) source; StAXResult staxResult = (StAXResult) result; try { XMLStreamReader streamReader = staxSource.getXMLStreamReader(); if (streamReader != null) { // Hand off to XMLStreamReader helper. if (fStreamHelper == null) { fStreamHelper = new StreamHelper(); } fStreamHelper.validate(streamReader, staxResult); } else { // Hand off to XMLEventReader helper. if (fEventHelper == null) { fEventHelper = new EventHelper(); } fEventHelper.validate(staxSource.getXMLEventReader(), staxResult); } } catch (XMLStreamException e) { throw new SAXException(e); } catch (XMLParseException e) { throw Util.toSAXParseException(e); } catch (XNIException e) { throw Util.toSAXException(e); } finally { // Release references to application objects fCurrentEvent = null; fStAXLocationWrapper.setLocation(null); fXMLStreamReaderLocation.setXMLStreamReader(null); if (fStAXValidatorHandler != null) { fStAXValidatorHandler.setStAXResult(null); } } return; } throw new IllegalArgumentException( JAXPValidationMessageFormatter.formatMessage( fComponentManager.getLocale(), "SourceResultMismatch", new Object[] {source.getClass().getName(), result.getClass().getName()})); }