com.sun.tools.xjc.Options Java Examples
The following examples show how to use
com.sun.tools.xjc.Options.
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: RunPluginsForCases.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesSchema() throws Exception { new File("target/generated-sources/xjc").mkdirs(); URL schema = getClass().getResource("/cases.xsd"); // URL binding = getClass().getResource("/cases.xjb"); final String[] arguments = new String[] { "-xmlschema", schema.toExternalForm(), // "-b", binding.toExternalForm(), "-d", "target/generated-sources/xjc", "-extension", "-XsimpleHashCode", "-XsimpleEquals", // "-XsimpleToString" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #2
Source File: ToOneMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Object process(Mapping context, FieldOutline fieldOutline, Options options) { final Object toOne = context.getCustomizing().getToOne(fieldOutline); if (toOne instanceof ManyToOne) { return context.getManyToOneMapping().process(context, fieldOutline, options); } else if (toOne instanceof OneToOne) { return context.getOneToOneMapping().process(context, fieldOutline, options); } else if (toOne instanceof Embedded) { return context.getEmbeddedMapping().process(context, fieldOutline, options); } else { throw new AssertionError( "Either many-to-one or one-to-one mappings are expected."); } }
Example #3
Source File: MModelInfoLoader.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 6 votes |
public MModelInfo<NType, NClass> loadModel(String resource) throws Exception { System.setProperty("javax.xml.accessExternalSchema", "all"); new File("target/generated-sources/" + resource).mkdirs(); final String[] arguments = new String[] { "-xmlschema", getClass().getResource("/" + resource).toExternalForm(), "-d", "target/generated-sources/" + resource, "-extension", "-Xjsonix", "-Xjsonix-generateJsonSchema" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); final MModelInfo<NType, NClass> modelInfo = new XJCCMInfoFactory(model) .createModel(); return modelInfo; }
Example #4
Source File: ModifierPlugin.java From jaxb2-rich-contract-plugin with MIT License | 6 votes |
@Override public boolean run(final Outline outline, final Options opt, final ErrorHandler errorHandler) throws SAXException { final PluginContext pluginContext = PluginContext.get(outline, opt, errorHandler); for (final ClassOutline classOutline : outline.getClasses()) { try { final GroupInterfacePlugin groupInterfacePlugin = pluginContext.findPlugin(GroupInterfacePlugin.class); if (groupInterfacePlugin != null) { ModifierGenerator.generateClass(pluginContext, new DefinedClassOutline(pluginContext, classOutline), this.modifierClassName, this.modifierClassName, groupInterfacePlugin.getGroupInterfacesForClass(pluginContext, classOutline.implClass.fullName()), this.modifierMethodName); } else { ModifierGenerator.generateClass(pluginContext, new DefinedClassOutline(pluginContext, classOutline), this.modifierClassName, this.modifierMethodName); } } catch (final JClassAlreadyExistsException e) { errorHandler.error(new SAXParseException(e.getMessage(), classOutline.target.getLocator())); } } return true; }
Example #5
Source File: EjbPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
@Override public int parseArgument(Options opt, String[] args, int start) throws BadCommandLineException, IOException { final int result = super.parseArgument(opt, args, start); for (int i = 0; i < args.length; i++) { if (args[i].length() != 0) { if (args[i].charAt(0) != '-') { if (args[i].endsWith(".jar")) { episodeURLs.add(new File(args[i]).toURI().toURL()); } } } } return result; }
Example #6
Source File: CompileIssues.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesIssues() throws Exception { new File("target/generated-sources/xjc").mkdirs(); URL schema = getClass().getResource("/schema.xsd"); URL binding = getClass().getResource("/binding.xjb"); final String[] arguments = new String[] { "-xmlschema", schema.toExternalForm(), "-b", binding.toExternalForm(), "-d", "target/generated-sources/xjc", "-extension", "-Xjsonix", "-Xjsonix-generateJsonSchema" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #7
Source File: JsonixPluginTest.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesOWS_V_1_1_0() throws Exception { new File("target/generated-sources/ows-v_1_1_0").mkdirs(); URL schema = getClass().getResource("/ogc/ows/1.1.0/owsAll.xsd"); URL binding = getClass().getResource("/ogc/ows-v_1_1_0.xjb"); final String[] arguments = new String[] { "-xmlschema", schema.toExternalForm(), "-b", binding.toExternalForm(), "-d", "target/generated-sources/ows-v_1_1_0", "-extension", "-Xjsonix" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #8
Source File: EjbPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void onActivated(Options options) throws BadCommandLineException { Thread.currentThread().setContextClassLoader( getClass().getClassLoader()); super.onActivated(options); final FieldRendererFactory fieldRendererFactory = new FieldRendererFactory() { public FieldRenderer getList(JClass coreList) { return new UntypedListFieldRenderer(coreList); } }; options.setFieldRendererFactory(fieldRendererFactory, this); }
Example #9
Source File: RunPlugins.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesSchema() throws Exception { new File("target/generated-sources/xjc").mkdirs(); URL schema = getClass().getResource("/schema.xsd"); URL binding = getClass().getResource("/binding.xjb"); final String[] arguments = new String[] { "-xmlschema", schema.toExternalForm(), "-b", binding.toExternalForm(), "-d", "target/generated-sources/xjc", "-extension", "-XtoString", "-Xequals", "-XhashCode", "-Xcopyable", "-Xmergeable" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #10
Source File: BasicMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Basic process(Mapping context, FieldOutline fieldOutline, Options options) { final Basic basic = context.getCustomizing().getBasic(fieldOutline); createBasic$Name(context, fieldOutline, basic); createBasic$Column(context, fieldOutline, basic); if (basic.getLob() == null && basic.getTemporal() == null && basic.getEnumerated() == null) { if (context.getAttributeMapping().isTemporal(context, fieldOutline)) { basic.setTemporal(context.getAttributeMapping().createTemporalType( context, fieldOutline)); } else if (context.getAttributeMapping().isEnumerated(context, fieldOutline)) { basic.setEnumerated(context.getAttributeMapping() .createEnumerated(context, fieldOutline)); } else if (context.getAttributeMapping().isLob(context, fieldOutline)) { basic.setLob(context.getAttributeMapping().createLob(context, fieldOutline)); } } return basic; }
Example #11
Source File: ExecuteJAXB1058.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesContext_V_1_1_0() throws Exception { new File("target/generated-sources/xjc").mkdirs(); final String[] arguments = new String[] { "-xmlschema", new File("src/main/resources/schema.xsd").toURI().toString(), "-d", "target/generated-sources/xjc", "-XfixJAXB1058", "-extension", "-XtoString", "-Xequals", "-XhashCode", "-Xcopyable", "-Xmergeable"}; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #12
Source File: JsonixPluginZeroTest.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesBasicZero() throws Exception { new File("target/generated-sources/basic/zero").mkdirs(); final String[] arguments = new String[] { "-xmlschema", getClass().getResource("/basic/zero/schema.xsd") .toExternalForm(), "-d", "target/generated-sources/basic/zero", "-extension", "-Xjsonix", "-Xjsonix-generateJsonSchema" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #13
Source File: JsonixPluginTest.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesContext_V_1_1_0() throws Exception { new File("target/generated-sources/context-v_1_1_0").mkdirs(); final String[] arguments = new String[] { "-xmlschema", getClass().getResource("/ogc/context/1.1.0/wmcAll.xsd") .toExternalForm(), "-b", getClass().getResource("/ogc/context-v_1_1_0.xjb") .toExternalForm(), "-d", "target/generated-sources/context-v_1_1_0", "-extension", "-Xjsonix" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #14
Source File: EmbeddableAttributesMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public EmbeddableAttributes process(Mapping context, ClassOutline classOutline, Options options) { final EmbeddableAttributes attributes = new EmbeddableAttributes(); final FieldOutline[] fieldOutlines = classOutline.getDeclaredFields(); for (final FieldOutline fieldOutline : fieldOutlines) { final Object attributeMapping = getAttributeMapping(context, fieldOutline, options).process(context, fieldOutline, options); if (attributeMapping instanceof Basic) { attributes.getBasic().add((Basic) attributeMapping); } else if (attributeMapping instanceof Transient) { attributes.getTransient().add((Transient) attributeMapping); } } return attributes; }
Example #15
Source File: Driver.java From mxjc with MIT License | 6 votes |
/** * Prints the usage screen and exits the process. * * @param opts * If the parsing of options have started, set a partly populated * {@link Options} object. */ public static void usage( @Nullable Options opts, boolean privateUsage ) { if( privateUsage ) { System.out.println(Messages.format(Messages.DRIVER_PRIVATE_USAGE)); } else { System.out.println(Messages.format(Messages.DRIVER_PUBLIC_USAGE)); } // do not show plugin usage // if( opts!=null && opts.getAllPlugins().size()!=0 ) { // System.out.println(Messages.format(Messages.ADDON_USAGE)); // for (Plugin p : opts.getAllPlugins()) { // System.out.println(p.getUsage()); // } // } }
Example #16
Source File: LombokPlugin.java From jaxb-lombok-plugin with MIT License | 6 votes |
@Override public boolean run(Outline outline, Options options, ErrorHandler errorHandler) { // for each generated classes for (ClassOutline generatedClassOutline : outline.getClasses()) { JDefinedClass generatedClass = generatedClassOutline.implClass; if (!isAbstractClass(generatedClass) && !generatedClass.fields().isEmpty()) { boolean commandExecuted = false; for (Command command : commands.values()) { if (command.isEnabled()) { command.editGeneratedClass(generatedClass); commandExecuted = true; } } if (!commandExecuted) { defaultCommand.editGeneratedClass(generatedClass); } } } return true; }
Example #17
Source File: JaxbValidationsPlugins.java From krasa-jaxb-tools with Apache License 2.0 | 6 votes |
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) { try { for (ClassOutline co : model.getClasses()) { List<CPropertyInfo> properties = co.target.getProperties(); for (CPropertyInfo property : properties) { if (property instanceof CElementPropertyInfo) { processElement((CElementPropertyInfo) property, co, model); } else if (property instanceof CAttributePropertyInfo) { processAttribute((CAttributePropertyInfo) property, co, model); } else if (property instanceof CValuePropertyInfo) { processAttribute((CValuePropertyInfo) property, co, model); } } } return true; } catch (Exception e) { log(e); return false; } }
Example #18
Source File: JsonixPluginTest.java From jsonix-schema-compiler with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void compilesWFS_V_2_0() throws Exception { new File("target/generated-sources/wfs-v_2_0").mkdirs(); URL schema = getClass().getResource("/ogc/wfs/2.0/wfs.xsd"); URL binding = getClass().getResource("/ogc/wfs-v_2_0.xjb"); final String[] arguments = new String[] { "-xmlschema", schema.toExternalForm(), "-b", binding.toExternalForm(), "-d", "target/generated-sources/wfs-v_2_0", "-extension", "-Xjsonix" }; Options options = new Options(); options.parseArguments(arguments); ConsoleErrorReporter receiver = new ConsoleErrorReporter(); Model model = ModelLoader.load(options, new JCodeModel(), receiver); model.generateCode(options, receiver); com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); }
Example #19
Source File: MarshalMappings.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 6 votes |
public Collection<ClassOutline> process(EjbPlugin context, Outline outline, Options options) throws Exception { logger.debug("Processing outline with context path [" + OutlineUtils.getContextPath(outline) + "]."); final Collection<? extends ClassOutline> classes = outline.getClasses(); final Collection<ClassOutline> processedClassOutlines = new ArrayList<ClassOutline>( classes.size()); for (final ClassOutline classOutline : classes) { if (!getIgnoring() .isClassOutlineIgnored(getMapping(), classOutline)) { final ClassOutline processedClassOutline = process(this, classOutline, options); if (processedClassOutline != null) { processedClassOutlines.add(processedClassOutline); } } } return processedClassOutlines; }
Example #20
Source File: XJC22Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
Example #21
Source File: MappedSuperclassMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public MappedSuperclass process(Mapping context, ClassOutline classOutline, Options options) { final MappedSuperclass entity = context.getCustomizing() .getMappedSuperclass(classOutline); createMappedSuperclass(context, classOutline, entity); return entity; }
Example #22
Source File: XJC20Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 5 votes |
protected Model loadModel(Options options) throws MojoExecutionException { if (getVerbose()) { getLog().info("Parsing input schema(s)..."); } final Model model = ModelLoader.load(options, new JCodeModel(), new LoggingErrorReceiver("Error while parsing schema(s).", getLog(), getVerbose())); if (model == null) throw new MojoExecutionException( "Unable to parse input schema(s). Error messages should have been provided."); return model; }
Example #23
Source File: ElementCollectionMapping.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public ElementCollection process(Mapping context, FieldOutline fieldOutline, Options options) { final ElementCollection elementCollection = context.getCustomizing() .getElementCollection(fieldOutline); createElementCollection$Name(context, fieldOutline, elementCollection); createElementCollection$Column(context, fieldOutline, elementCollection); createElementCollection$OrderColumn(context, fieldOutline, elementCollection); createElementCollection$CollectionTable(context, fieldOutline, elementCollection); if (elementCollection.getLob() == null && elementCollection.getTemporal() == null && elementCollection.getEnumerated() == null) { if (context.getAttributeMapping().isTemporal(context, fieldOutline)) { elementCollection.setTemporal(context.getAttributeMapping() .createTemporalType(context, fieldOutline)); } else if (context.getAttributeMapping().isEnumerated(context, fieldOutline)) { elementCollection.setEnumerated(context.getAttributeMapping() .createEnumerated(context, fieldOutline)); } else if (context.getAttributeMapping().isLob(context, fieldOutline)) { elementCollection.setLob(context.getAttributeMapping() .createLob(context, fieldOutline)); } } return elementCollection; }
Example #24
Source File: CopyablePlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) { for (final ClassOutline classOutline : outline.getClasses()) if (!getIgnoring().isIgnored(classOutline)) { processClassOutline(classOutline); } return true; }
Example #25
Source File: MergeablePlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) { for (final ClassOutline classOutline : outline.getClasses()) if (!getIgnoring().isIgnored(classOutline)) { processClassOutline(classOutline); } return true; }
Example #26
Source File: SimpleToStringPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) { for (final ClassOutline classOutline : outline.getClasses()) if (!getIgnoring().isIgnored(classOutline)) { processClassOutline(classOutline); } return true; }
Example #27
Source File: SettersPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) { for (final ClassOutline classOutline : outline.getClasses()) if (!getIgnoring().isIgnored(classOutline)) { processClassOutline(classOutline); } return true; }
Example #28
Source File: AbstractModelPlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected boolean run(Outline outline, Options options) throws Exception { if (modelInfo.getOrigin() instanceof ModelOutlineGeneratorFactory) { MModelOutlineGenerator generator = ((ModelOutlineGeneratorFactory) modelInfo .getOrigin()).createGenerator(outline); MModelOutline modelOutline = generator.generate(modelInfo); Ring.add(MModelOutline.class, modelOutline); } else { throw new AssertionError("Model is expected to be generateable"); } return true; }
Example #29
Source File: HashCodePlugin.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
@Override public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) { for (final ClassOutline classOutline : outline.getClasses()) { if (!getIgnoring().isIgnored(classOutline)) { processClassOutline(classOutline); } } return true; }
Example #30
Source File: DefaultOutlineProcessor.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 5 votes |
public Map<ClassOutline, T> process(C context, Outline outline, Options options) throws Exception { final Map<ClassOutline, T> classMappingsMap = new HashMap<ClassOutline, T>(); for (final ClassOutline classOutline : outline.getClasses()) { final T result = getClassOutlineProcessor().process(context, classOutline, options); if (result != null) { classMappingsMap.put(classOutline, result); } } return classMappingsMap; }