Class BeanValidationPlugin


  • public class BeanValidationPlugin
    extends com.sun.tools.xjc.Plugin
    XJC Plugin for generation of JSR349 (Bean Validation) annotations.

    Has two mods:

      "jsr303" - enables backward compatibility.
      "simpleRegex" - disables translation of UNICODE XML regex into UNICODE Java regex.
      Java ASCII regex are shorter to read.
     
    Is capable of generating the following annotations:
      - @DecimalMax
      - @DecimalMin
      - @Digits
      - @NotNull
      - @Pattern
      - @Size
      - @Valid
      - @AssertTrue
      - @AssertFalse
      - @Future
      - @Past
     
    Reacts to the following XSD restrictions and facets:
      - maxExclusive
      - minExclusive
      - maxInclusive
      - minInclusive
      - nillable
      - pattern
      - length
      - maxLength
      - minLength
      - minOccurs
      - maxOccurs
     
    Basic usage:
      xjc file.xsd -XBeanVal
     
    Example usage with mods:
      xjc file.xsd -XBeanVal jsr303 simpleRegex
     
    Programmatic usage, with mods and extensions enabled:
      Driver.run(new String[] { schemaPath, "-extension", "-XBeanVal", "jsr303", "simpleRegex" }, System.out,
      System.out);
     
    Supports setting Target groups and Error message through binding customizations. Example:
     <xs:appinfo>
       <jxb:bindings node="/xs:schema/xs:complexType/xs:sequence/xs:element[@name='generic']">
        <bv:facet type="maxLength" message="Hello, world!" groups="Object"/>
        <bv:facet type="future" message="Welcome to the Future!"/>
       </jxb:bindings>
      </xs:appinfo>
     

    Supports custom-created BV annotations. Example:

     <xs:appinfo>
       <jxb:bindings node="/xs:schema/xs:complexType/xs:sequence/xs:element[@name='generic']">
        <bv:facet type="org.eclipse.persistence.annotations.AdditionalCriteria" value="This is a real custom annotation."/>
       </jxb:bindings>
      </xs:appinfo>
     
    Author:
    Marcel Valovy - marcel.valovy@oracle.com
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> getCustomizationURIs()  
      java.lang.String getOptionName()  
      java.lang.String getUsage()  
      boolean isCustomizationTagName​(java.lang.String nsUri, java.lang.String localName)  
      int parseArgument​(com.sun.tools.xjc.Options opt, java.lang.String[] args, int i)  
      boolean run​(com.sun.tools.xjc.outline.Outline outline, com.sun.tools.xjc.Options opts, org.xml.sax.ErrorHandler errorHandler)  
      • Methods inherited from class com.sun.tools.xjc.Plugin

        onActivated, postProcessModel
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BeanValidationPlugin

        public BeanValidationPlugin()
    • Method Detail

      • getOptionName

        public java.lang.String getOptionName()
        Specified by:
        getOptionName in class com.sun.tools.xjc.Plugin
      • getUsage

        public java.lang.String getUsage()
        Specified by:
        getUsage in class com.sun.tools.xjc.Plugin
      • getCustomizationURIs

        public java.util.List<java.lang.String> getCustomizationURIs()
        Overrides:
        getCustomizationURIs in class com.sun.tools.xjc.Plugin
      • isCustomizationTagName

        public boolean isCustomizationTagName​(java.lang.String nsUri,
                                              java.lang.String localName)
        Overrides:
        isCustomizationTagName in class com.sun.tools.xjc.Plugin
      • parseArgument

        public int parseArgument​(com.sun.tools.xjc.Options opt,
                                 java.lang.String[] args,
                                 int i)
                          throws com.sun.tools.xjc.BadCommandLineException,
                                 java.io.IOException
        Overrides:
        parseArgument in class com.sun.tools.xjc.Plugin
        Throws:
        com.sun.tools.xjc.BadCommandLineException
        java.io.IOException
      • run

        public boolean run​(com.sun.tools.xjc.outline.Outline outline,
                           com.sun.tools.xjc.Options opts,
                           org.xml.sax.ErrorHandler errorHandler)
        Specified by:
        run in class com.sun.tools.xjc.Plugin