com.sun.tools.xjc.ErrorReceiver Java Examples
The following examples show how to use
com.sun.tools.xjc.ErrorReceiver.
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: ModelBuilder.java From mxjc with MIT License | 6 votes |
public static CGModel buildCodeGenModel(Outline outline, ErrorReceiver errorReceiver) { CGModel cgModel = new CGModel(); if (errorReceiver != null) errorReceiver.debug("Building class model ..."); // build class/bean model ClassModelBuilder.buildClassModel(outline, cgModel, errorReceiver); if (errorReceiver != null) errorReceiver.debug("Building enum model ..."); // build enum model EnumModelBuilder.buildEnumModel(outline, cgModel, errorReceiver); return cgModel; }
Example #2
Source File: DynamicCompiler.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public void execute() throws IOException, BadCommandLineException { final Options options = createOptions(); final JCodeModel codeModel = createCodeModel(); final CodeWriter codeWriter = createCodeWriter(); final ErrorReceiver errorReceiver = createErrorReceiver(); execute(options, codeModel, codeWriter, errorReceiver); }
Example #3
Source File: JAXBDataBinding.java From cxf with Apache License 2.0 | 5 votes |
private void hackInNewInternalizationLogic(SchemaCompiler schemaCompiler, final OASISCatalogManager catalog, Options opts) { try { Field f = schemaCompiler.getClass().getDeclaredField("forest"); ReflectionUtil.setAccessible(f); XMLSchemaInternalizationLogic logic = new XMLSchemaInternalizationLogic() { public XMLFilterImpl createExternalReferenceFinder(DOMForest parent) { return new ReferenceFinder(parent, catalog); } }; Constructor<DOMForest> c = null; DOMForest forest = null; try { c = DOMForest.class.getConstructor(InternalizationLogic.class, Options.class); forest = c.newInstance(logic, opts); } catch (Throwable t) { c = DOMForest.class.getConstructor(InternalizationLogic.class); forest = c.newInstance(logic); } forest.setErrorHandler((ErrorReceiver)schemaCompiler); f.set(schemaCompiler, forest); } catch (Throwable ex) { //ignore } }
Example #4
Source File: EnumModelBuilder.java From mxjc with MIT License | 5 votes |
public static void buildEnumModel(Outline outline, CGModel cgModel, ErrorReceiver errorReceiver) { for (EnumOutline eo : outline.getEnums()) { EnumInfo enumInfo = new EnumInfo(); enumInfo.setPackageName(eo._package()._package().name()); enumInfo.setName(eo.clazz.name()); if (!StringUtil.isEmpty(enumInfo.getPackageName())) { enumInfo.setFullName(enumInfo.getPackageName() + "." + enumInfo.getName()); } else { enumInfo.setFullName(enumInfo.getName()); } // enum constant for (EnumConstantOutline eco : eo.constants) { EnumConstantInfo enumConstant = new EnumConstantInfo(); // name of this enum constant enumConstant.setName(eco.target.getName()); // value of this enum constant enumConstant.setValue(eco.target.getLexicalValue()); // java doc on this enum constant enumConstant.setDocComment(eco.target.javadoc); // add this enum constant in the enum model enumInfo.getEnumConstants().add(enumConstant); } // xsd annotation as doc comment String docComment = ModelBuilder.getDocumentation(eo.target .getSchemaComponent()); enumInfo.setDocComment(docComment); // add this enum in the codegen model cgModel.getEnums().add(enumInfo); } }
Example #5
Source File: DynamicCompiler.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 4 votes |
public ErrorReceiver createErrorReceiver() { return new ConsoleErrorReporter(); }
Example #6
Source File: DynamicCompiler.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 4 votes |
protected void execute(final Options options, final JCodeModel codeModel, final CodeWriter codeWriter, final ErrorReceiver errorReceiver) throws IOException { logger.debug("Loading the model."); final Model model = ModelLoader.load(options, codeModel, errorReceiver); logger.debug("Generating the code."); final Outline outline = model.generateCode(options, errorReceiver); logger.debug("Writing the code."); model.codeModel.build(codeWriter); this.outline = outline; final StringBuffer contextPathStringBuffer = new StringBuffer(); String delimiter = ""; for (final PackageOutline packageOutline : this.outline .getAllPackageContexts()) { contextPathStringBuffer.append(delimiter); contextPathStringBuffer.append(packageOutline._package().name()); delimiter = ":"; } this.contextPath = contextPathStringBuffer.toString(); logger.debug("Compiling the code."); final JavaCompiler systemJavaCompiler = ToolProvider .getSystemJavaCompiler(); final DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); final StandardJavaFileManager standardFileManager = systemJavaCompiler .getStandardFileManager(diagnostics, null, null); final Collection<File> javaFiles = FileUtils.listFiles(targetDirectory, FileFilterUtils.suffixFileFilter(".java"), TrueFileFilter.INSTANCE); final Iterable<? extends JavaFileObject> fileObjects = standardFileManager .getJavaFileObjectsFromFiles(javaFiles); ClassLoader contextClassLoader = Thread.currentThread() .getContextClassLoader(); final List<String> compilerOptions = new LinkedList<String>(); if (contextClassLoader instanceof URLClassLoader) { final URLClassLoader urlClassLoader = (URLClassLoader) contextClassLoader; final URL[] urls = urlClassLoader.getURLs(); if (urls.length > 0) { compilerOptions.add("-classpath"); final StringBuffer classpathStringBuffer = new StringBuffer(); String separator = ""; for (final URL url : urls) { logger.debug("URL:" + url); classpathStringBuffer.append(separator); try { classpathStringBuffer. // append("\""). append(new File(url.toURI()).getAbsolutePath()) // .append("\"") ; separator = SystemUtils.PATH_SEPARATOR; } catch (URISyntaxException ignored) { } } compilerOptions.add(classpathStringBuffer.toString()); } } compilerOptions.add("-verbose"); compilerOptions.add("-d"); compilerOptions.add(targetDirectory.getAbsolutePath()); logger.debug("Compiler options:" + StringUtils.join(compilerOptions.iterator(), " ")); // // conte // // final String[] compilerOptions = new String[] { "-d", // targetDirectory.getAbsolutePath(), "-verbose" }; systemJavaCompiler.getTask(null, standardFileManager, null, compilerOptions, null, fileObjects).call(); standardFileManager.close(); }
Example #7
Source File: JsonixMain.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 4 votes |
private void execute() { final ErrorReceiver errorHandler = new ConsoleErrorReporter(); final Model model = ModelLoader.load(getOptions(), new JCodeModel(), errorHandler); final File targetDirectory = getOptions().targetDir; final ProgramWriter<NType, NClass> programWriter = new TargetDirectoryProgramWriter( targetDirectory, errorHandler); final JsonStructureWriter<NType, NClass> jsonStructureWriter = new TargetDirectoryJsonStructureWriter( targetDirectory, errorHandler); new JsonixInvoker().execute(settings, model, programWriter, jsonStructureWriter); }
Example #8
Source File: TargetDirectoryJsonStructureWriter.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 4 votes |
TargetDirectoryJsonStructureWriter(File targetDirectory, ErrorReceiver errorReceiver) { this.targetDirectory = Validate.notNull(targetDirectory); this.errorReceiver = Validate.notNull(errorReceiver); }
Example #9
Source File: TargetDirectoryProgramWriter.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 4 votes |
TargetDirectoryProgramWriter(File targetDirectory, ErrorReceiver errorReceiver) { this.targetDirectory = Validate.notNull(targetDirectory); this.errorReceiver = Validate.notNull(errorReceiver); }
Example #10
Source File: AbstractClientModule.java From mxjc with MIT License | 4 votes |
/** * Set ErrorReceiver instance to be used for error reporting */ public void setErrorReceiver(ErrorReceiver errorReceiver) { this.errorReceiver = errorReceiver; }
Example #11
Source File: ClientModule.java From mxjc with MIT License | 2 votes |
/** * Set ErrorReceiver to be used for error reporting * * @param errorReceiver */ public void setErrorReceiver(ErrorReceiver errorReceiver);