Java Code Examples for com.sun.tools.xjc.outline.Outline#getCodeModel()
The following examples show how to use
com.sun.tools.xjc.outline.Outline#getCodeModel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NoJavadocPlugin.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean run(Outline outline, Options options, ErrorHandler errorHandler){ JCodeModel codeModel = outline.getCodeModel(); Collection<? extends ClassOutline> classOutlines = outline.getClasses(); for(ClassOutline classOutline : classOutlines){ JDefinedClass beanClazz = classOutline.implClass; nullifyJavadoc(beanClazz); } Collection<? extends EnumOutline> enumOutlines = outline.getEnums(); for(EnumOutline enumOutline : enumOutlines){ JDefinedClass clazz = enumOutline.clazz; nullifyJavadoc(clazz); } return true; }
Example 2
Source File: JsonixPlugin.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 6 votes |
@Override public boolean run(Outline outline, Options opt, final ErrorHandler errorHandler) throws SAXException { final Model model = outline.getModel(); final JCodeModel codeModel = outline.getCodeModel(); final ProgramWriter<NType, NClass> programWriter = new CodeModelProgramWriter( codeModel, errorHandler); final JsonStructureWriter<NType, NClass> jsonStructureWriter = new CodeModelJsonStructureWriter( codeModel, errorHandler); new JsonixInvoker().execute(getSettings(), model, programWriter, jsonStructureWriter); return true; }
Example 3
Source File: ConnectPlugin.java From kafka-connect-transform-xml with Apache License 2.0 | 5 votes |
@Override public boolean run(Outline model, Options options, ErrorHandler errorHandler) throws SAXException { JCodeModel codeModel = model.getCodeModel(); for (ClassOutline classOutline : model.getClasses()) { log.trace("run - {}", classOutline.implClass.name()); JFieldVar schemaField = processSchema(codeModel, classOutline); processToStruct(schemaField, codeModel, classOutline); processFromStruct(codeModel, classOutline); } return true; }
Example 4
Source File: BoundPropertiesPlugin.java From jaxb2-rich-contract-plugin with MIT License | 5 votes |
private void createSupportProperty(final Outline outline, final ClassOutline classOutline, final Class<?> supportClass, final Class<?> listenerClass, final String aspectName) { final JCodeModel m = outline.getCodeModel(); final JDefinedClass definedClass = classOutline.implClass; final String aspectNameCap = aspectName.substring(0, 1).toUpperCase() + aspectName.substring(1); if (classOutline.getSuperClass() == null) { // only generate fields in topmost classes final JFieldVar supportField = definedClass.field(JMod.PROTECTED | JMod.FINAL | JMod.TRANSIENT, supportClass, aspectName + BoundPropertiesPlugin.SUPPORT_FIELD_SUFFIX, JExpr._new(m.ref(supportClass)).arg(JExpr._this())); final JMethod addMethod = definedClass.method(JMod.PUBLIC, m.VOID, "add" + aspectNameCap + "Listener"); final JVar addParam = addMethod.param(JMod.FINAL, listenerClass, aspectName + "Listener"); addMethod.body().invoke(JExpr._this().ref(supportField), "add" + aspectNameCap + "Listener").arg(addParam); final JMethod removeMethod = definedClass.method(JMod.PUBLIC, m.VOID, "remove" + aspectNameCap + "Listener"); final JVar removeParam = removeMethod.param(JMod.FINAL, listenerClass, aspectName + "Listener"); removeMethod.body().invoke(JExpr._this().ref(supportField), "remove" + aspectNameCap + "Listener").arg(removeParam); } final JMethod withMethod = definedClass.method(JMod.PUBLIC, definedClass, "with" + aspectNameCap + "Listener"); final JVar withParam = withMethod.param(JMod.FINAL, listenerClass, aspectName + "Listener"); withMethod.body().invoke("add" + aspectNameCap + "Listener").arg(withParam); withMethod.body()._return(JExpr._this()); if (classOutline.getSuperClass() != null) { withMethod.annotate(Override.class); } }
Example 5
Source File: BoundPropertiesPlugin.java From jaxb2-rich-contract-plugin with MIT License | 4 votes |
@Override public boolean run(final Outline outline, final Options opt, final ErrorHandler errorHandler) throws SAXException { if (!this.constrained && !this.bound) { return true; } final PluginContext pluginContext = PluginContext.get(outline, opt, errorHandler); final JCodeModel m = outline.getCodeModel(); if (this.generateTools) { // generate bound collection helper classes pluginContext.writeSourceFile(BoundList.class); pluginContext.writeSourceFile(BoundListProxy.class); pluginContext.writeSourceFile(CollectionChangeEventType.class); pluginContext.writeSourceFile(CollectionChangeEvent.class); pluginContext.writeSourceFile(CollectionChangeListener.class); pluginContext.writeSourceFile(VetoableCollectionChangeListener.class); } if(pluginContext.hasPlugin(ImmutablePlugin.class)) { errorHandler.error(new SAXParseException(getMessage("error.immutableAndConstrainedProperties"), outline.getModel().getLocator())); } final int setterAccess = JMod.PUBLIC; for (final ClassOutline classOutline : outline.getClasses()) { final JDefinedClass definedClass = classOutline.implClass; // Create bound collection proxies for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) { if (fieldOutline.getPropertyInfo().isCollection() && !definedClass.fields().get(fieldOutline.getPropertyInfo().getName(false)).type().isArray()) { generateProxyField(classOutline, fieldOutline); generateLazyProxyInitGetter(classOutline, fieldOutline); } } if (this.constrained && this.setterThrows) { for (final JMethod method : definedClass.methods()) { if (method.name().startsWith("with") && !"withVetoableChangeListener".equals(method.name()) && !"withPropertyChangeListener".equals(method.name()) ) { method._throws(PropertyVetoException.class); } } } if (this.constrained) createSupportProperty(outline, classOutline, VetoableChangeSupport.class, VetoableChangeListener.class, "vetoableChange"); if (this.bound) createSupportProperty(outline, classOutline, PropertyChangeSupport.class, PropertyChangeListener.class, "propertyChange"); for (final JFieldVar field : definedClass.fields().values()) { //final JFieldVar field = definedClass.fields().get(fieldOutline.getPropertyInfo().getName(false)); final JMethod oldSetter = definedClass.getMethod("set" + outline.getModel().getNameConverter().toPropertyName(field.name()), new JType[]{field.type()}); if (oldSetter != null && !field.type().isArray()) { definedClass.methods().remove(oldSetter); final JMethod setter = definedClass.method(setterAccess, m.VOID, "set" + outline.getModel().getNameConverter().toPropertyName(field.name())); final JVar setterArg = setter.param(JMod.FINAL, field.type(), "value"); final JBlock body = setter.body(); final JVar oldValueVar = body.decl(JMod.FINAL, field.type(), BoundPropertiesPlugin.OLD_VALUE_VAR_NAME, JExpr._this().ref(field)); if (this.constrained) { final JTryBlock tryBlock; final JBlock block; if (this.setterThrows) { block = body; setter._throws(PropertyVetoException.class); } else { tryBlock = body._try(); block = tryBlock.body(); final JCatchBlock catchBlock = tryBlock._catch(m.ref(PropertyVetoException.class)); final JVar exceptionVar = catchBlock.param("x"); catchBlock.body()._throw(JExpr._new(m.ref(RuntimeException.class)).arg(exceptionVar)); } invokeListener(block, field, oldValueVar, setterArg, "vetoableChange"); } body.assign(JExpr._this().ref(field), setterArg); if (this.bound) { invokeListener(body, field, oldValueVar, setterArg, "propertyChange"); } } } } return true; }
Example 6
Source File: AnnotatePlugin.java From jpmml-model with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public boolean run(Outline outline, Options options, ErrorHandler errorHandler){ JCodeModel codeModel = outline.getCodeModel(); Collection<? extends ClassOutline> classOutlines = outline.getClasses(); for(ClassOutline classOutline : classOutlines){ JDefinedClass beanClazz = classOutline.implClass; CPluginCustomization classCustomization = CustomizationUtils.findCustomization(classOutline, AnnotatePlugin.ANNOTATE_CLASS_QNAME); if(classCustomization != null){ annotate(codeModel, beanClazz, classCustomization); } Map<String, JFieldVar> fieldVars = beanClazz.fields(); FieldOutline[] fieldOutlines = classOutline.getDeclaredFields(); for(FieldOutline fieldOutline : fieldOutlines){ CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo(); List<CPluginCustomization> propertyCustomizations = CustomizationUtils.findPropertyCustomizationsInProperty(propertyInfo, AnnotatePlugin.ANNOTATE_PROPERTY_QNAME); for(CPluginCustomization propertyCustomization : propertyCustomizations){ JFieldVar fieldVar = fieldVars.get(propertyInfo.getName(false)); annotate(codeModel, fieldVar, propertyCustomization); } } } Collection<? extends EnumOutline> enumOutlines = outline.getEnums(); for(EnumOutline enumOutline : enumOutlines){ JDefinedClass clazz = enumOutline.clazz; CPluginCustomization enumCustomization = CustomizationUtils.findCustomization(enumOutline, AnnotatePlugin.ANNOTATE_ENUM_QNAME); if(enumCustomization != null){ annotate(codeModel, clazz, enumCustomization); } List<EnumConstantOutline> enumConstantOutlines = enumOutline.constants; for(EnumConstantOutline enumConstantOutline : enumConstantOutlines){ CCustomizations enumConstantCustomizations = enumConstantOutline.target.getCustomizations(); for(CPluginCustomization enumConstantCustomization : enumConstantCustomizations){ Element element = enumConstantCustomization.element; if((AnnotatePlugin.ANNOTATE_ENUM_CONSTANT_QNAME.getNamespaceURI()).equals(element.getNamespaceURI()) && (AnnotatePlugin.ANNOTATE_ENUM_CONSTANT_QNAME.getLocalPart()).equals(element.getLocalName())){ annotate(codeModel, enumConstantOutline.constRef, enumConstantCustomization); enumConstantCustomization.markAsAcknowledged(); } } } } return true; }