diff --git a/jaxb-maven-plugin/src/main/java/org/openjax/jaxb/JaxbMojo.java b/jaxb-maven-plugin/src/main/java/org/openjax/jaxb/JaxbMojo.java index ddeef0a..c42c464 100644 --- a/jaxb-maven-plugin/src/main/java/org/openjax/jaxb/JaxbMojo.java +++ b/jaxb-maven-plugin/src/main/java/org/openjax/jaxb/JaxbMojo.java @@ -48,84 +48,83 @@ /** * Mojo that creates compile-scope Java source or binaries from XML schema(s) by invoking the JAXB XJC binding compiler. */ -@Mojo(name="xjc", defaultPhase=LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution=ResolutionScope.TEST) -@Execute(goal="xjc") +@Mojo(name = "xjc", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.TEST) +@Execute(goal = "xjc") public class JaxbMojo extends GeneratorMojo { /** Turn on debug mode. */ - @Parameter(property="debug") + @Parameter(property = "debug") private boolean debug = false; /** Generated files will be in read-only mode. */ - @Parameter(property="readOnly") + @Parameter(property = "readOnly") private boolean readOnly = false; /** Suppress generation of a file header with timestamp. */ - @Parameter(property="noHeader") + @Parameter(property = "noHeader") private boolean noHeader = false; /** Generates code that works around issues specific to 1.4 runtime. */ - @Parameter(property="explicitAnnotation") + @Parameter(property = "explicitAnnotation") private boolean explicitAnnotation = false; /** If {@code true} XML security features when parsing XML documents will be disabled. The default value is {@code false}. */ - @Parameter(property="disableXmlSecurity") + @Parameter(property = "disableXmlSecurity") private boolean disableXmlSecurity = false; /** * When on, generates content property for types with multiple xs:any derived elements (which is supposed to be correct behavior). */ - @Parameter(property="contentForWildcard") + @Parameter(property = "contentForWildcard") private boolean contentForWildcard = false; /** If true, try to resolve name conflicts automatically by assigning mechanical numbers. */ - @Parameter(property="autoNameResolution") + @Parameter(property = "autoNameResolution") private boolean autoNameResolution = false; /** This allocator has the final say on deciding the class name. */ - @Parameter(property="testClassNameAllocator") + @Parameter(property = "testClassNameAllocator") private boolean testClassNameAllocator = false; /** Java module name in {@code module-info.java}. */ - @Parameter(property="javaModule") + @Parameter(property = "javaModule") private String javaModule; /** File defining proxyHost:proxyPort */ - @Parameter(property="httpProxyFile") + @Parameter(property = "httpProxyFile") private File httpProxyFile; /** String defining proxyHost:proxyPort */ - @Parameter(property="httpProxy") + @Parameter(property = "httpProxy") private String httpProxy; /** * Corresponding XJC parameter: mark-generated. This feature causes all of the generated code to have @Generated annotation. */ - @Parameter(property="addGeneratedAnnotation") + @Parameter(property = "addGeneratedAnnotation") private boolean addGeneratedAnnotation = false; /** - * Corresponding XJC parameter: catalog. - * Specify catalog files to resolve external entity references. Supports - * TR9401, XCatalog, and OASIS XML Catalog format. + * Corresponding XJC parameter: catalog. Specify catalog files to resolve external entity references. Supports TR9401, XCatalog, and + * OASIS XML Catalog format. */ - @Parameter(property="catalog") + @Parameter(property = "catalog") private File catalog; /** * Corresponding XJC parameter: enableIntrospection. Enable correct generation of Boolean getters/setters to enable Bean * Introspection APIs. */ - @Parameter(property="enableIntrospection") + @Parameter(property = "enableIntrospection") private boolean enableIntrospection = true; /** * Defines the encoding used by XJC (for generating Java Source files) and schemagen (for generating XSDs). The corresponding * argument parameter for XJC and SchemaGen is: encoding. The algorithm for finding the encoding to use is as follows (where the * first non-null value found is used for encoding): 1. If the configuration property is explicitly given within the plugin's - * configuration, use that value. 2. If the Maven property project.build.sourceEncoding is defined, use its value. 3. Otherwise - * use the value from the system property file.encoding. + * configuration, use that value. 2. If the Maven property project.build.sourceEncoding is defined, use its value. 3. Otherwise use + * the value from the system property file.encoding. */ - @Parameter(property="encoding", defaultValue="${project.build.sourceEncoding}") + @Parameter(property = "encoding", defaultValue = "${project.build.sourceEncoding}") private String encoding; /** @@ -134,7 +133,7 @@ public class JaxbMojo extends GeneratorMojo { * supported by JAXB v1.0. In some cases, you may be allowed to use them in the '-extension' mode enabled by this switch. In the * default (strict) mode, you are also limited to using only the binding customizations defined in the specification. */ - @Parameter(property="extension") + @Parameter(property = "extension") private boolean extension = false; /** @@ -143,31 +142,29 @@ public class JaxbMojo extends GeneratorMojo { * just a JAXB customization file (but with vendor extensions.) If this parameter is true, the episode file generated is called * META-INF/sun-jaxb.episode, and included in the artifact. */ - @Parameter(property="generateEpisode") + @Parameter(property = "generateEpisode") private boolean generateEpisode = false; /** * Corresponding XJC parameter: nv. By default, the XJC binding compiler performs strict validation of the source schema before - * processing it. Use this option to disable strict schema validation. This does not mean that the binding compiler will not - * perform any validation, it simply means that it will perform less-strict validation. + * processing it. Use this option to disable strict schema validation. This does not mean that the binding compiler will not perform + * any validation, it simply means that it will perform less-strict validation. */ - @Parameter(property="laxSchemaValidation") + @Parameter(property = "laxSchemaValidation") private boolean laxSchemaValidation = false; /** - * Corresponding XJC parameter: no-header. - * - * Suppress the generation of a file header comment that includes some note - * and timestamp. Using this makes the generated code more diff-friendly. + * Corresponding XJC parameter: no-header. Suppress the generation of a file header comment that includes some note and timestamp. + * Using this makes the generated code more diff-friendly. */ - @Parameter(property="noGeneratedHeaderComments") + @Parameter(property = "noGeneratedHeaderComments") private boolean noGeneratedHeaderComments = false; /** - * Corresponding XJC parameter: npa. Suppress the generation of package level annotations into package-info.java. Using this - * switch causes the generated code to internalize those annotations into the other generated classes. + * Corresponding XJC parameter: npa. Suppress the generation of package level annotations into package-info.java. Using this switch + * causes the generated code to internalize those annotations into the other generated classes. */ - @Parameter(property="noPackageLevelAnnotations") + @Parameter(property = "noPackageLevelAnnotations") private boolean noPackageLevelAnnotations = false; /** @@ -175,13 +172,13 @@ public class JaxbMojo extends GeneratorMojo { * 'Specifying a target package via this command-line option overrides any binding customization for package name and the default * package name algorithm defined in the specification'. */ - @Parameter(property="packageName") + @Parameter(property = "packageName") private String packageName; /** * Corresponding XJC parameter: quiet. Suppress compiler output, such as progress information and warnings. */ - @Parameter(property="quiet") + @Parameter(property = "quiet") private boolean quiet = false; /** @@ -189,27 +186,27 @@ public class JaxbMojo extends GeneratorMojo { * have the same type of content. This parameter replaces the previous multiple-choice boolean configuration options for the * jaxb2-maven-plugin (i.e. dtd, xmlschema, wsdl), and corresponds to setting one of those flags as an XJC argument. */ - @Parameter(property="sourceType") + @Parameter(property = "sourceType") private String sourceType = "xmlschema"; /** - * Corresponding XJC parameter: target. Permitted values: '2.0' and '2.1'. Avoid generating code that relies on JAXB newer than - * the version given. This will allow the generated code to run with JAXB 2.0 runtime (such as JavaSE 6.). + * Corresponding XJC parameter: target. Permitted values: '2.0' and '2.1'. Avoid generating code that relies on JAXB newer than the + * version given. This will allow the generated code to run with JAXB 2.0 runtime (such as JavaSE 6.). */ - @Parameter(property="target") + @Parameter(property = "target") private String targetVersion; /** - * Corresponding XJC parameter: verbose. Tells XJC to be extra verbose, such as printing informational messages or displaying - * stack traces. User property: xjc.verbose + * Corresponding XJC parameter: verbose. Tells XJC to be extra verbose, such as printing informational messages or displaying stack + * traces. User property: xjc.verbose */ - @Parameter(property="verbose") + @Parameter(property = "verbose") private boolean verbose = false; /** - * Parameter holding List of XSD paths to files and/or directories which should be recursively searched for XSD files. Only files - * or directories that actually exist will be included (in the case of files) or recursively searched for XSD files to include (in - * the case of directories). Configure using standard Maven structure for Lists: + * Parameter holding List of XSD paths to files and/or directories which should be recursively searched for XSD files. Only files or + * directories that actually exist will be included (in the case of files) or recursively searched for XSD files to include (in the + * case of directories). Configure using standard Maven structure for Lists: * *
    * {@code
@@ -225,14 +222,14 @@ public class JaxbMojo extends GeneratorMojo {
    * 
*/ @FilterParameter(FilterType.URL) - @Parameter(property="schemas", required=true) + @Parameter(property = "schemas", required = true) private List schemas; /** * Parameter holding List of XJB Files and/or directories which should be recursively searched for XJB files. Only files or - * directories that actually exist will be included (in the case of files) or recursively searched for XJB files to include (in - * the case of directories). JAXB binding files are used to configure parts of the Java source generation. Supply the - * configuration using the standard Maven structure for configuring plugin Lists: + * directories that actually exist will be included (in the case of files) or recursively searched for XJB files to include (in the + * case of directories). JAXB binding files are used to configure parts of the Java source generation. Supply the configuration + * using the standard Maven structure for configuring plugin Lists: * *
    * {@code
@@ -247,7 +244,7 @@ public class JaxbMojo extends GeneratorMojo {
    * 
*/ @FilterParameter(FilterType.URL) - @Parameter(property="bindings") + @Parameter(property = "bindings") private List bindings; private static final ArtifactHandler artifactHandler = new DefaultArtifactHandler("jar"); diff --git a/xjc/src/main/java/org/openjax/jaxb/xjc/JaxbUtil.java b/xjc/src/main/java/org/openjax/jaxb/xjc/JaxbUtil.java index eb38276..945cdde 100644 --- a/xjc/src/main/java/org/openjax/jaxb/xjc/JaxbUtil.java +++ b/xjc/src/main/java/org/openjax/jaxb/xjc/JaxbUtil.java @@ -64,11 +64,11 @@ public final class JaxbUtil { * * Or if an error was encountered while creating the {@link Marshaller} object. *

- * Or if the {@link ValidationEventHandler} returns false from its handleEvent method or the {@link Marshaller} is - * unable to marshal the binding. + * Or if the {@link ValidationEventHandler} returns false from its handleEvent method or the {@link Marshaller} is unable + * to marshal the binding. */ @SuppressWarnings("unchecked") - public static String toXmlString(final T binding) throws JAXBException { + public static String toXmlString(final T binding) throws JAXBException { final StringWriter stringWriter = new StringWriter(); final JAXBContext jaxbContext = JAXBContext.newInstance(binding.getClass()); final Marshaller marshaller = jaxbContext.createMarshaller(); @@ -110,7 +110,7 @@ public static String toXmlString(final T binding) throws JAXBException { * @throws UnmarshalException If {@code validate} is set to true, and validation of the XML document at {@code url} fails; or if * this method is unable to perform the XML to Java binding. */ - public static T parse(final Class cls, final URL url) throws IOException, UnmarshalException { + public static T parse(final Class cls, final URL url) throws IOException, UnmarshalException { return parse(cls, Thread.currentThread().getContextClassLoader(), url, new LoggingErrorHandler(), true); } @@ -126,7 +126,7 @@ public static T parse(final Class cls, final URL url) throws IOException, * @throws UnmarshalException If {@code validate} is set to true, and validation of the XML document at {@code url} fails; or if * this method is unable to perform the XML to Java binding. */ - public static T parse(final Class cls, final ClassLoader classLoader, final URL url) throws IOException, UnmarshalException { + public static T parse(final Class cls, final ClassLoader classLoader, final URL url) throws IOException, UnmarshalException { return parse(cls, classLoader, url, new LoggingErrorHandler(), true); } @@ -142,28 +142,24 @@ public static T parse(final Class cls, final ClassLoader classLoader, fina * @throws UnmarshalException If {@code validate} is set to true, and validation of the XML document at {@code url} fails; or if * this method is unable to perform the XML to Java binding. */ - public static T parse(final Class cls, final URL url, final boolean validate) throws IOException, UnmarshalException { + public static T parse(final Class cls, final URL url, final boolean validate) throws IOException, UnmarshalException { return parse(cls, Thread.currentThread().getContextClassLoader(), url, new LoggingErrorHandler(), validate); } /** - * Parses an XML document at the specified {@code url} as an instance of a - * JAXB binding class {@code cls}. + * Parses an XML document at the specified {@code url} as an instance of a JAXB binding class {@code cls}. * * @param The generic type of specified binding class {@code cls}. * @param cls The JAXB binding class. * @param classLoader Class loader used to locate the implementation classes. * @param url The location of the XML document to parse. - * @param validate If {@code true}, the XML document at {@code url} will first - * be validated. - * @return An XML document at the specified {@code url} as an instance of a - * JAXB binding class {@code cls}. + * @param validate If {@code true}, the XML document at {@code url} will first be validated. + * @return An XML document at the specified {@code url} as an instance of a JAXB binding class {@code cls}. * @throws IOException If an I/O error has occurred. - * @throws UnmarshalException If {@code validate} is set to true, and - * validation of the XML document at {@code url} fails; or if this - * method is unable to perform the XML to Java binding. + * @throws UnmarshalException If {@code validate} is set to true, and validation of the XML document at {@code url} fails; or if + * this method is unable to perform the XML to Java binding. */ - public static T parse(final Class cls, final ClassLoader classLoader, final URL url, final boolean validate) throws IOException, UnmarshalException { + public static T parse(final Class cls, final ClassLoader classLoader, final URL url, final boolean validate) throws IOException, UnmarshalException { return parse(cls, classLoader, url, new LoggingErrorHandler(), validate); } @@ -180,7 +176,7 @@ public static T parse(final Class cls, final ClassLoader classLoader, fina * @throws UnmarshalException If {@code validate} is set to true, and validation of the XML document at {@code url} fails; or if * this method is unable to perform the XML to Java binding. */ - public static T parse(final Class cls, final URL url, final ErrorHandler errorHandler, final boolean validate) throws IOException, UnmarshalException { + public static T parse(final Class cls, final URL url, final ErrorHandler errorHandler, final boolean validate) throws IOException, UnmarshalException { return parse(cls, Thread.currentThread().getContextClassLoader(), url, errorHandler, validate); } @@ -198,7 +194,7 @@ public static T parse(final Class cls, final URL url, final ErrorHandler e * @throws UnmarshalException If {@code validate} is true, and validation of the XML document at {@code url} fails; or if this * method is unable to perform the XML to Java binding. */ - public static T parse(final Class cls, final ClassLoader classLoader, final URL url, final ErrorHandler errorHandler, final boolean validate) throws IOException, UnmarshalException { + public static T parse(final Class cls, final ClassLoader classLoader, final URL url, final ErrorHandler errorHandler, final boolean validate) throws IOException, UnmarshalException { if (validate) { try { Validator.validate(url, errorHandler); diff --git a/xjc/src/main/java/org/openjax/jaxb/xjc/XJCompiler.java b/xjc/src/main/java/org/openjax/jaxb/xjc/XJCompiler.java index 9c5e683..1468e76 100644 --- a/xjc/src/main/java/org/openjax/jaxb/xjc/XJCompiler.java +++ b/xjc/src/main/java/org/openjax/jaxb/xjc/XJCompiler.java @@ -85,8 +85,7 @@ public static class Command { private boolean disableXmlSecurity; /** - * When on, generates content property for types with multiple xs:any derived elements (which is supposed to be correct - * behavior). + * When on, generates content property for types with multiple xs:any derived elements (which is supposed to be correct behavior). */ private boolean contentForWildcard; @@ -749,11 +748,14 @@ public void flush() throws IOException { final String line = buffer.toString(); buffer.setLength(0); if (line.startsWith("[ERROR] ")) - if (logger.isErrorEnabled()) logger.error(line.substring(8)); - else if (line.startsWith("[WARNING] ")) - if (logger.isWarnEnabled()) logger.warn(line.substring(10)); - else - if (logger.isInfoEnabled()) logger.info(line); + if (logger.isErrorEnabled()) { + logger.error(line.substring(8)); + } + else if (line.startsWith("[WARNING] ")) + if (logger.isWarnEnabled()) { + logger.warn(line.substring(10)); + } + else if (logger.isInfoEnabled()) { logger.info(line); } } };