openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r967325 [2/13] - /websites/staging/openjpa/trunk/content/
Date Wed, 30 Sep 2015 17:03:08 GMT
Modified: websites/staging/openjpa/trunk/content/bean-validation-primer.html
==============================================================================
--- websites/staging/openjpa/trunk/content/bean-validation-primer.html (original)
+++ websites/staging/openjpa/trunk/content/bean-validation-primer.html Wed Sep 30 17:03:02 2015
@@ -145,8 +145,19 @@ limitations under the License.
                                         </td>
                                         <td valign="top" width="100%" style="overflow:hidden;">
                                             <div class="wiki-content">
-                                                <p><a name="BeanValidationPrimer-OpenJPABeanValidationPrimer"></a></p>
-<h1 id="openjpa-bean-validation-primer">OpenJPA Bean Validation Primer</h1>
+                                                <style type="text/css">
+/* The following code is added by mdx_elementid.py
+   It was originally lifted from http://subversion.apache.org/style/site.css */
+/*
+ * Hide class="elementid-permalink", except when an enclosing heading
+ * has the :hover property.
+ */
+.headerlink, .elementid-permalink {
+  visibility: hidden;
+}
+h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
+<p><a name="BeanValidationPrimer-OpenJPABeanValidationPrimer"></a></p>
+<h1 id="openjpa-bean-validation-primer">OpenJPA Bean Validation Primer<a class="headerlink" href="#openjpa-bean-validation-primer" title="Permanent link">&para;</a></h1>
 <p>A new feature defined by the JPA 2.0 specification is the ability to
 seamlessly integrate with a <a href="http://jcp.org/en/jsr/detail?id=303">JSR-303</a>
  bean validation provider.   With minimal effort, <a href="http://openjpa.apache.org/openjpa-200.html">OpenJPA 2.0</a>
@@ -155,7 +166,7 @@ seamlessly integrate with a <a href="htt
 these two technologies, you get a standardized persistence solution with
 the added ability to perform standardized java bean validation.</p>
 <p><a name="BeanValidationPrimer-WhatisBeanValidation?"></a></p>
-<h2 id="what-is-bean-validation">What is Bean Validation?</h2>
+<h2 id="what-is-bean-validation">What is Bean Validation?<a class="headerlink" href="#what-is-bean-validation" title="Permanent link">&para;</a></h2>
 <p>Most applications, especially those that gather input from a user, contain
 a significant amount of code to perform data validation.  It is typically
 custom code, fragmented and littered throughout the application.  Worse,
@@ -181,7 +192,7 @@ violation handling, and the validator it
 integrated environment like JPA, you will rarely have to concern yourself
 with the validator; simplifying things even further.</p>
 <p><a name="BeanValidationPrimer-ValidationConstraints"></a></p>
-<h2 id="validation-constraints">Validation Constraints</h2>
+<h2 id="validation-constraints">Validation Constraints<a class="headerlink" href="#validation-constraints" title="Permanent link">&para;</a></h2>
 <p>Constraints are a fundamental component of bean validation.  Constraints
 can be placed on Java beans and/or fields and properties (collectively
 labeled attributes in JPA terminology) to constrain the data within the
@@ -194,7 +205,7 @@ very easily build your own custom valida
 Let's start by looking at some simple constraints and then move to creating
 some custom constraints.</p>
 <p><a name="BeanValidationPrimer-ConstraininganEntity"></a></p>
-<h2 id="constraining-an-entity">Constraining an Entity</h2>
+<h2 id="constraining-an-entity">Constraining an Entity<a class="headerlink" href="#constraining-an-entity" title="Permanent link">&para;</a></h2>
 <p>For the purposes of an example, let's start building the JPA domain model
 for a digital image storage system. For the sake of simplicity, we'll start
 with a simple entity "Image".  An <a href="http://svn.apache.org/repos/asf/openjpa/trunk/openjpa-examples/image-gallery/src/main/java/org/apache/openjpa/example/gallery/model/Image.java">Image</a>
@@ -203,60 +214,60 @@ requirement that the image type must be
 must include a valid JPEG or GIF extension.  The code below shows the
 annotated Image entity with some built-in bean validation constraints
 applied.</p>
-<div class="codehilite"><pre><span class="nb">package</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">model</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">model</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">Entity</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">EnumType</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">Enumerated</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">GeneratedValue</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">Id</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">constraints</span><span class="o">.</span><span class="n">NotNull</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">constraints</span><span class="o">.</span><span class="n">Pattern</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">Entity</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">EnumType</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">Enumerated</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">GeneratedValue</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">Id</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">constraints</span><span class="p">.</span><span class="n">NotNull</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">constraints</span><span class="p">.</span><span class="n">Pattern</span><span class="p">;</span>
 
-<span class="nv">@Entity</span>
+<span class="p">@</span><span class="n">Entity</span>
 <span class="n">public</span> <span class="n">class</span> <span class="n">Image</span> <span class="p">{</span>
 
     <span class="n">private</span> <span class="n">long</span> <span class="n">id</span><span class="p">;</span>
     <span class="n">private</span> <span class="n">ImageType</span> <span class="n">type</span><span class="p">;</span>
     <span class="n">private</span> <span class="n">String</span> <span class="n">fileName</span><span class="p">;</span>
-    <span class="n">private</span> <span class="n">byte</span><span class="o">[]</span> <span class="n">data</span><span class="p">;</span>
+    <span class="n">private</span> <span class="n">byte</span><span class="p">[]</span> <span class="n">data</span><span class="p">;</span>
 
-    <span class="nv">@Id</span>
-    <span class="nv">@GeneratedValue</span>
+    <span class="p">@</span><span class="n">Id</span>
+    <span class="p">@</span><span class="n">GeneratedValue</span>
     <span class="n">public</span> <span class="n">long</span> <span class="n">getId</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">id</span><span class="p">;</span>
     <span class="p">}</span>
 
     <span class="n">public</span> <span class="n">void</span> <span class="n">setId</span><span class="p">(</span><span class="n">long</span> <span class="n">id</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">id</span> <span class="o">=</span> <span class="n">id</span><span class="p">;</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">id</span> <span class="p">=</span> <span class="n">id</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="nv">@NotNull</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="s">&quot;Image type must be specified.&quot;</span><span class="p">)</span>
-    <span class="nv">@Enumerated</span><span class="p">(</span><span class="n">EnumType</span><span class="o">.</span><span class="n">STRING</span><span class="p">)</span>
+    <span class="p">@</span><span class="n">NotNull</span><span class="p">(</span><span class="n">message</span><span class="p">=</span>&quot;<span class="n">Image</span> <span class="n">type</span> <span class="n">must</span> <span class="n">be</span> <span class="n">specified</span><span class="p">.</span>&quot;<span class="p">)</span>
+    <span class="p">@</span><span class="n">Enumerated</span><span class="p">(</span><span class="n">EnumType</span><span class="p">.</span><span class="n">STRING</span><span class="p">)</span>
     <span class="n">public</span> <span class="n">ImageType</span> <span class="n">getType</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">type</span><span class="p">;</span>
     <span class="p">}</span>
 
     <span class="n">public</span> <span class="n">void</span> <span class="n">setType</span><span class="p">(</span><span class="n">ImageType</span> <span class="n">type</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">;</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">type</span> <span class="p">=</span> <span class="n">type</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="nv">@Pattern</span><span class="p">(</span><span class="n">regexp</span> <span class="o">=</span> <span class="s">&quot;.*\\.jpg|.*\\.jpeg|.*\\.gif&quot;</span><span class="p">,</span>
-             <span class="n">message</span><span class="o">=</span><span class="s">&quot;Only images of type JPEG or GIF are supported.&quot;</span><span class="p">)</span>
+    <span class="p">@</span><span class="n">Pattern</span><span class="p">(</span><span class="n">regexp</span> <span class="p">=</span> &quot;<span class="o">.*\\</span><span class="p">.</span><span class="n">jpg</span><span class="o">|.*\\</span><span class="p">.</span><span class="n">jpeg</span><span class="o">|.*\\</span><span class="p">.</span><span class="n">gif</span>&quot;<span class="p">,</span>
+             <span class="n">message</span><span class="p">=</span>&quot;<span class="n">Only</span> <span class="n">images</span> <span class="n">of</span> <span class="n">type</span> <span class="n">JPEG</span> <span class="n">or</span> <span class="n">GIF</span> <span class="n">are</span> <span class="n">supported</span><span class="p">.</span>&quot;<span class="p">)</span>
     <span class="n">public</span> <span class="n">String</span> <span class="n">getFileName</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">fileName</span><span class="p">;</span>
     <span class="p">}</span>
 
     <span class="n">public</span> <span class="n">void</span> <span class="n">setFileName</span><span class="p">(</span><span class="n">String</span> <span class="n">fileName</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">fileName</span> <span class="o">=</span> <span class="n">fileName</span><span class="p">;</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">fileName</span> <span class="p">=</span> <span class="n">fileName</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="n">public</span> <span class="n">byte</span><span class="o">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">public</span> <span class="n">byte</span><span class="p">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">data</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="n">public</span> <span class="n">void</span> <span class="n">setData</span><span class="p">(</span><span class="n">byte</span><span class="o">[]</span> <span class="n">data</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="p">;</span>
+    <span class="n">public</span> <span class="n">void</span> <span class="n">setData</span><span class="p">(</span><span class="n">byte</span><span class="p">[]</span> <span class="n">data</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">data</span> <span class="p">=</span> <span class="n">data</span><span class="p">;</span>
     <span class="p">}</span>
 <span class="p">}</span>
 </pre></div>
@@ -278,7 +289,7 @@ That allows for environment specific mes
 , section 4.1.3 for additional details regarding the customization and
 localization of messages.</p>
 <p><a name="BeanValidationPrimer-CustomConstraintsandValidators"></a></p>
-<h2 id="custom-constraints-and-validators">Custom Constraints and Validators</h2>
+<h2 id="custom-constraints-and-validators">Custom Constraints and Validators<a class="headerlink" href="#custom-constraints-and-validators" title="Permanent link">&para;</a></h2>
 <p>If the built-in constraints do not meet your needs, you can create your own
 custom validators and constraints.  In our previous example, the Image
 entity used the @Pattern constraint to validate the file name of the image.
@@ -287,29 +298,29 @@ pattern-based constraint could potential
 inflexible and will get messy.  A custom constraint and validator provides
 a more robust and flexible solution.  First, let's create a custom method
 level constraint annotation named <a href="http://svn.apache.org/repos/asf/openjpa/trunk/openjpa-examples/image-gallery/src/main/java/org/apache/openjpa/example/gallery/constraint/ImageContent.java">ImageContent</a>.</p>
-<div class="codehilite"><pre><span class="x">package org.apache.openjpa.example.gallery.constraint;</span>
+<div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">gallery</span><span class="p">.</span><span class="n">constraint</span><span class="p">;</span>
 
-<span class="x">import java.lang.annotation.Documented;</span>
-<span class="x">import java.lang.annotation.Retention;</span>
-<span class="x">import java.lang.annotation.Target;</span>
-<span class="x">import static java.lang.annotation.ElementType.METHOD;</span>
-<span class="x">import static java.lang.annotation.ElementType.FIELD;</span>
-<span class="x">import static java.lang.annotation.RetentionPolicy.RUNTIME;</span>
-
-<span class="x">import javax.validation.Constraint;</span>
-<span class="x">import javax.validation.Payload;</span>
-
-<span class="x">import org.apache.openjpa.example.gallery.model.ImageType;</span>
-
-<span class="x">@Documented</span>
-<span class="x">@Constraint(validatedBy = ImageContentValidator.class)</span>
-<span class="x">@Target({ METHOD, FIELD })</span>
-<span class="x">@Retention(RUNTIME)</span>
-<span class="x">public @interface ImageContent {</span>
-<span class="x">    String message() default &quot;Image data is not a supported format.&quot;;</span>
-<span class="x">    Class</span><span class="cp">&lt;?</span><span class="o">&gt;</span><span class="p">[]</span> <span class="nx">groups</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
-    <span class="nx">Class</span><span class="o">&lt;?</span> <span class="k">extends</span> <span class="nx">Payload</span><span class="o">&gt;</span><span class="p">[]</span> <span class="nx">payload</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
-    <span class="nx">ImageType</span><span class="p">[]</span> <span class="nx">value</span><span class="p">()</span> <span class="k">default</span> <span class="p">{</span> <span class="nx">ImageType</span><span class="o">.</span><span class="nx">GIF</span><span class="p">,</span> <span class="nx">ImageType</span><span class="o">.</span><span class="nx">JPEG</span> <span class="p">};</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">Documented</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">Retention</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">Target</span><span class="p">;</span>
+<span class="n">import</span> <span class="k">static</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">ElementType</span><span class="p">.</span><span class="n">METHOD</span><span class="p">;</span>
+<span class="n">import</span> <span class="k">static</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">ElementType</span><span class="p">.</span><span class="n">FIELD</span><span class="p">;</span>
+<span class="n">import</span> <span class="k">static</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">RetentionPolicy</span><span class="p">.</span><span class="n">RUNTIME</span><span class="p">;</span>
+
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">Constraint</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">Payload</span><span class="p">;</span>
+
+<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">gallery</span><span class="p">.</span><span class="n">model</span><span class="p">.</span><span class="n">ImageType</span><span class="p">;</span>
+
+<span class="err">@</span><span class="n">Documented</span>
+<span class="err">@</span><span class="n">Constraint</span><span class="p">(</span><span class="n">validatedBy</span> <span class="o">=</span> <span class="n">ImageContentValidator</span><span class="p">.</span><span class="n">class</span><span class="p">)</span>
+<span class="err">@</span><span class="n">Target</span><span class="p">({</span> <span class="n">METHOD</span><span class="p">,</span> <span class="n">FIELD</span> <span class="p">})</span>
+<span class="err">@</span><span class="n">Retention</span><span class="p">(</span><span class="n">RUNTIME</span><span class="p">)</span>
+<span class="n">public</span> <span class="err">@</span><span class="n">interface</span> <span class="n">ImageContent</span> <span class="p">{</span>
+    <span class="n">String</span> <span class="n">message</span><span class="p">()</span> <span class="k">default</span> <span class="s">&quot;Image data is not a supported format.&quot;</span><span class="p">;</span>
+    <span class="n">Class</span><span class="o">&lt;?&gt;</span><span class="p">[]</span> <span class="n">groups</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
+    <span class="n">Class</span><span class="o">&lt;?</span> <span class="n">extends</span> <span class="n">Payload</span><span class="o">&gt;</span><span class="p">[]</span> <span class="n">payload</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
+    <span class="n">ImageType</span><span class="p">[]</span> <span class="n">value</span><span class="p">()</span> <span class="k">default</span> <span class="p">{</span> <span class="n">ImageType</span><span class="p">.</span><span class="n">GIF</span><span class="p">,</span> <span class="n">ImageType</span><span class="p">.</span><span class="n">JPEG</span> <span class="p">};</span>
 <span class="p">}</span>
 </pre></div>
 
@@ -319,56 +330,56 @@ level constraint annotation named <a hre
 when the constraint is validated.  Notice, the validator class is bound to
 the constraint annotation via the validatedBy attribute on the @Constraint
 annotation.</p>
-<div class="codehilite"><pre><span class="nb">package</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">constraint</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">constraint</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">Arrays</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">List</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">util</span><span class="p">.</span><span class="n">Arrays</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">util</span><span class="p">.</span><span class="n">List</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">ConstraintValidator</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">ConstraintValidatorContext</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">ConstraintValidator</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">ConstraintValidatorContext</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">ImageType</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">model</span><span class="p">.</span><span class="n">ImageType</span><span class="p">;</span>
 
 <span class="o">/**</span>
- <span class="o">*</span> <span class="n">Simple</span> <span class="n">check</span> <span class="n">that</span> <span class="n">file</span> <span class="nb">format</span> <span class="n">is</span> <span class="n">of</span> <span class="n">a</span> <span class="n">supported</span> <span class="n">type</span>
+ <span class="o">*</span> <span class="n">Simple</span> <span class="n">check</span> <span class="n">that</span> <span class="n">file</span> <span class="n">format</span> <span class="n">is</span> <span class="n">of</span> <span class="n">a</span> <span class="n">supported</span> <span class="n">type</span>
  <span class="o">*/</span>
-<span class="n">public</span> <span class="n">class</span> <span class="n">ImageContentValidator</span> <span class="n">implements</span> <span class="n">ConstraintValidator</span><span class="o">&lt;</span><span class="n">ImageContent</span><span class="p">,</span> <span class="n">byte</span><span class="o">[]</span> <span class="p">{</span>
-    <span class="n">private</span> <span class="n">List</span><span class="sr">&lt;ImageType&gt;</span> <span class="n">allowedTypes</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">ImageContentValidator</span> <span class="n">implements</span> <span class="n">ConstraintValidator</span><span class="o">&lt;</span><span class="n">ImageContent</span><span class="p">,</span> <span class="n">byte</span><span class="p">[]</span> <span class="p">{</span>
+    <span class="n">private</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">ImageType</span><span class="o">&gt;</span> <span class="n">allowedTypes</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span>
     <span class="o">/**</span>
      <span class="o">*</span> <span class="n">Configure</span> <span class="n">the</span> <span class="n">constraint</span> <span class="n">validator</span> <span class="n">based</span> <span class="n">on</span> <span class="n">the</span> <span class="n">image</span>
-     <span class="o">*</span> <span class="n">types</span> <span class="n">it</span> <span class="n">should</span> <span class="n">support</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">constraint</span> <span class="n">the</span> <span class="n">constraint</span> <span class="n">definition</span>
+     <span class="o">*</span> <span class="n">types</span> <span class="n">it</span> <span class="n">should</span> <span class="n">support</span><span class="p">.</span>
+     <span class="o">*</span> <span class="p">@</span><span class="n">param</span> <span class="n">constraint</span> <span class="n">the</span> <span class="n">constraint</span> <span class="n">definition</span>
      <span class="o">*/</span>
     <span class="n">public</span> <span class="n">void</span> <span class="n">initialize</span><span class="p">(</span><span class="n">ImageContent</span> <span class="n">constraint</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">allowedTypes</span> <span class="o">=</span> <span class="n">Arrays</span><span class="o">.</span><span class="n">asList</span><span class="p">(</span><span class="n">constraint</span><span class="o">.</span><span class="n">value</span><span class="p">());</span>
+        <span class="n">allowedTypes</span> <span class="p">=</span> <span class="n">Arrays</span><span class="p">.</span><span class="n">asList</span><span class="p">(</span><span class="n">constraint</span><span class="p">.</span><span class="n">value</span><span class="p">());</span>
     <span class="p">}</span>
 
     <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Validate</span> <span class="n">a</span> <span class="n">specified</span> <span class="n">value</span><span class="o">.</span>
+     <span class="o">*</span> <span class="n">Validate</span> <span class="n">a</span> <span class="n">specified</span> <span class="n">value</span><span class="p">.</span>
      <span class="o">*/</span>
-    <span class="n">public</span> <span class="n">boolean</span> <span class="n">isValid</span><span class="p">(</span><span class="n">byte</span><span class="o">[]</span> <span class="n">value</span><span class="p">,</span> <span class="n">ConstraintValidatorContext</span> <span class="n">context</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">public</span> <span class="n">boolean</span> <span class="n">isValid</span><span class="p">(</span><span class="n">byte</span><span class="p">[]</span> <span class="n">value</span><span class="p">,</span> <span class="n">ConstraintValidatorContext</span> <span class="n">context</span><span class="p">)</span> <span class="p">{</span>
         <span class="k">if</span> <span class="p">(</span><span class="n">value</span> <span class="o">==</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
             <span class="k">return</span> <span class="n">false</span><span class="p">;</span>
         <span class="p">}</span>
-        <span class="sr">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">GIF</span> <span class="n">header</span> <span class="n">is</span> <span class="n">either</span> <span class="n">GIF87</span> <span class="ow">or</span> <span class="n">GIF89</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="o">.</span><span class="n">GIF</span><span class="p">))</span> <span class="p">{</span>
-            <span class="n">String</span> <span class="n">gifHeader</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">6</span><span class="p">);</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="nb">length</span> <span class="o">&gt;=</span> <span class="mi">6</span> <span class="o">&amp;&amp;</span>
-            <span class="p">(</span><span class="n">gifHeader</span><span class="o">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span><span class="s">&quot;GIF87a&quot;</span><span class="p">)</span> <span class="o">||</span>
-             <span class="n">gifHeader</span><span class="o">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span><span class="s">&quot;GIF89a&quot;</span><span class="p">)))</span> <span class="p">{</span>
+        <span class="o">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">GIF</span> <span class="n">header</span> <span class="n">is</span> <span class="n">either</span> <span class="n">GIF87</span> <span class="n">or</span> <span class="n">GIF89</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="p">.</span><span class="n">GIF</span><span class="p">))</span> <span class="p">{</span>
+            <span class="n">String</span> <span class="n">gifHeader</span> <span class="p">=</span> <span class="n">new</span> <span class="n">String</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> 0<span class="p">,</span> 6<span class="p">);</span>
+            <span class="k">if</span> <span class="p">(</span><span class="n">value</span><span class="p">.</span><span class="nb">length</span> <span class="o">&gt;</span><span class="p">=</span> 6 <span class="o">&amp;&amp;</span>
+            <span class="p">(</span><span class="n">gifHeader</span><span class="p">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span>&quot;<span class="n">GIF87a</span>&quot;<span class="p">)</span> <span class="o">||</span>
+             <span class="n">gifHeader</span><span class="p">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span>&quot;<span class="n">GIF89a</span>&quot;<span class="p">)))</span> <span class="p">{</span>
             <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
             <span class="p">}</span>
         <span class="p">}</span>
-        <span class="sr">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">JPEG</span> <span class="n">begins</span> <span class="n">with</span> <span class="n">SOI</span> <span class="o">&amp;</span> <span class="n">ends</span> <span class="n">with</span> <span class="n">EOI</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="o">.</span><span class="n">JPEG</span><span class="p">))</span> <span class="p">{</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="nb">length</span> <span class="o">&gt;=</span> <span class="mi">4</span> <span class="o">&amp;&amp;</span>
-                <span class="n">value</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xff</span> <span class="o">&amp;&amp;</span> <span class="n">value</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xd8</span> <span class="o">&amp;&amp;</span>
-                <span class="n">value</span><span class="p">[</span><span class="n">value</span><span class="o">.</span><span class="nb">length</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xff</span> <span class="o">&amp;&amp;</span>
-                <span class="n">value</span><span class="p">[</span><span class="n">value</span><span class="o">.</span><span class="nb">length</span> <span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xd9</span><span class="p">)</span> <span class="p">{</span>
+        <span class="o">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">JPEG</span> <span class="n">begins</span> <span class="n">with</span> <span class="n">SOI</span> <span class="o">&amp;</span> <span class="n">ends</span> <span class="n">with</span> <span class="n">EOI</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="p">.</span><span class="n">JPEG</span><span class="p">))</span> <span class="p">{</span>
+            <span class="k">if</span> <span class="p">(</span><span class="n">value</span><span class="p">.</span><span class="nb">length</span> <span class="o">&gt;</span><span class="p">=</span> 4 <span class="o">&amp;&amp;</span>
+                <span class="n">value</span><span class="p">[</span>0<span class="p">]</span> <span class="o">==</span> 0<span class="n">xff</span> <span class="o">&amp;&amp;</span> <span class="n">value</span><span class="p">[</span>1<span class="p">]</span> <span class="o">==</span> 0<span class="n">xd8</span> <span class="o">&amp;&amp;</span>
+                <span class="n">value</span><span class="p">[</span><span class="n">value</span><span class="p">.</span><span class="nb">length</span> <span class="o">-</span> 2<span class="p">]</span> <span class="o">==</span> 0<span class="n">xff</span> <span class="o">&amp;&amp;</span>
+                <span class="n">value</span><span class="p">[</span><span class="n">value</span><span class="p">.</span><span class="nb">length</span> <span class="o">-</span>1<span class="p">]</span> <span class="o">==</span> 0<span class="n">xd9</span><span class="p">)</span> <span class="p">{</span>
                 <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
             <span class="p">}</span>
         <span class="p">}</span>
-        <span class="sr">//</span> <span class="n">Unknown</span> <span class="n">file</span> <span class="nb">format</span>
+        <span class="o">//</span> <span class="n">Unknown</span> <span class="n">file</span> <span class="n">format</span>
         <span class="k">return</span> <span class="n">false</span><span class="p">;</span>
     <span class="p">}</span>
 <span class="p">}</span>
@@ -377,8 +388,8 @@ annotation.</p>
 
 <p>Finally, let's apply the new constraint to the getData() method on our
 Image class.</p>
-<div class="codehilite"><pre>    <span class="nv">@ImageContent</span>
-    <span class="n">public</span> <span class="n">byte</span><span class="o">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
+<div class="codehilite"><pre>    <span class="p">@</span><span class="n">ImageContent</span>
+    <span class="n">public</span> <span class="n">byte</span><span class="p">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">data</span><span class="p">;</span>
     <span class="p">}</span>
 </pre></div>
@@ -391,8 +402,8 @@ the <a href="http://svn.apache.org/repos
  is that it can also validate for a specific image type.  By definition, it
 accepts for JPEG or GIF formats, but it can also validate for a specific
 format.  For example, by changing the annotation to:</p>
-<div class="codehilite"><pre>    <span class="nv">@ImageContent</span><span class="p">(</span><span class="n">ImageType</span><span class="o">.</span><span class="n">JPEG</span><span class="p">)</span>
-    <span class="n">public</span> <span class="n">byte</span><span class="o">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
+<div class="codehilite"><pre>    <span class="p">@</span><span class="n">ImageContent</span><span class="p">(</span><span class="n">ImageType</span><span class="p">.</span><span class="n">JPEG</span><span class="p">)</span>
+    <span class="n">public</span> <span class="n">byte</span><span class="p">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">data</span><span class="p">;</span>
     <span class="p">}</span>
 </pre></div>
@@ -400,7 +411,7 @@ format.  For example, by changing the an
 
 <p>instructs the validator to only permit image data with valid JPEG content.</p>
 <p><a name="BeanValidationPrimer-Type-levelConstraints"></a></p>
-<h2 id="type-level-constraints">Type-level Constraints</h2>
+<h2 id="type-level-constraints">Type-level Constraints<a class="headerlink" href="#type-level-constraints" title="Permanent link">&para;</a></h2>
 <p>The examples thus far have shown the use of validation constraints on
 individual attributes.  That is sufficient in many cases, but validation
 logic often needs to consider combinations of attributes when validating an
@@ -415,66 +426,66 @@ constraints geared for each of these typ
 simpler option is a type-level constraint.  Let's modify our Image class to
 use a custom type-level constraint.  Here is the updated Image entity with
 the new type-level constraint.</p>
-<div class="codehilite"><pre><span class="nb">package</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">model</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">model</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">Embedded</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">Entity</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">EnumType</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">Enumerated</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">GeneratedValue</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">Id</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">persistence</span><span class="o">.</span><span class="n">ManyToOne</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">Valid</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">constraints</span><span class="o">.</span><span class="n">NotNull</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">Embedded</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">Entity</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">EnumType</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">Enumerated</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">GeneratedValue</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">Id</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">persistence</span><span class="p">.</span><span class="n">ManyToOne</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">Valid</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">constraints</span><span class="p">.</span><span class="n">NotNull</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">constraint</span><span class="o">.</span><span class="n">ImageConstraint</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">constraint</span><span class="o">.</span><span class="n">SequencedImageGroup</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">constraint</span><span class="p">.</span><span class="n">ImageConstraint</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">constraint</span><span class="p">.</span><span class="n">SequencedImageGroup</span><span class="p">;</span>
 
-<span class="nv">@Entity</span>
-<span class="nv">@ImageConstraint</span><span class="p">(</span><span class="n">groups</span><span class="o">=</span><span class="n">ImageGroup</span><span class="o">.</span><span class="n">class</span><span class="p">)</span>
+<span class="p">@</span><span class="n">Entity</span>
+<span class="p">@</span><span class="n">ImageConstraint</span><span class="p">(</span><span class="n">groups</span><span class="p">=</span><span class="n">ImageGroup</span><span class="p">.</span><span class="n">class</span><span class="p">)</span>
 <span class="n">public</span> <span class="n">class</span> <span class="n">Image</span> <span class="p">{</span>
 
     <span class="n">private</span> <span class="n">long</span> <span class="n">id</span><span class="p">;</span>
     <span class="n">private</span> <span class="n">ImageType</span> <span class="n">type</span><span class="p">;</span>
     <span class="n">private</span> <span class="n">String</span> <span class="n">fileName</span><span class="p">;</span>
-    <span class="n">private</span> <span class="n">byte</span><span class="o">[]</span> <span class="n">data</span><span class="p">;</span>
+    <span class="n">private</span> <span class="n">byte</span><span class="p">[]</span> <span class="n">data</span><span class="p">;</span>
 
-    <span class="nv">@Id</span>
-    <span class="nv">@GeneratedValue</span>
+    <span class="p">@</span><span class="n">Id</span>
+    <span class="p">@</span><span class="n">GeneratedValue</span>
     <span class="n">public</span> <span class="n">long</span> <span class="n">getId</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">id</span><span class="p">;</span>
     <span class="p">}</span>
 
     <span class="n">public</span> <span class="n">void</span> <span class="n">setId</span><span class="p">(</span><span class="n">long</span> <span class="n">id</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">id</span> <span class="o">=</span> <span class="n">id</span><span class="p">;</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">id</span> <span class="p">=</span> <span class="n">id</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="nv">@NotNull</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="s">&quot;Image type must be specified.&quot;</span><span class="p">)</span>
-    <span class="nv">@Enumerated</span><span class="p">(</span><span class="n">EnumType</span><span class="o">.</span><span class="n">STRING</span><span class="p">)</span>
+    <span class="p">@</span><span class="n">NotNull</span><span class="p">(</span><span class="n">message</span><span class="p">=</span>&quot;<span class="n">Image</span> <span class="n">type</span> <span class="n">must</span> <span class="n">be</span> <span class="n">specified</span><span class="p">.</span>&quot;<span class="p">)</span>
+    <span class="p">@</span><span class="n">Enumerated</span><span class="p">(</span><span class="n">EnumType</span><span class="p">.</span><span class="n">STRING</span><span class="p">)</span>
     <span class="n">public</span> <span class="n">ImageType</span> <span class="n">getType</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">type</span><span class="p">;</span>
     <span class="p">}</span>
 
     <span class="n">public</span> <span class="n">void</span> <span class="n">setType</span><span class="p">(</span><span class="n">ImageType</span> <span class="n">type</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">type</span><span class="p">;</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">type</span> <span class="p">=</span> <span class="n">type</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="nv">@NotNull</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="s">&quot;Image file name must not be null.&quot;</span><span class="p">)</span>
+    <span class="p">@</span><span class="n">NotNull</span><span class="p">(</span><span class="n">message</span><span class="p">=</span>&quot;<span class="n">Image</span> <span class="n">file</span> <span class="n">name</span> <span class="n">must</span> <span class="n">not</span> <span class="n">be</span> <span class="n">null</span><span class="p">.</span>&quot;<span class="p">)</span>
     <span class="n">public</span> <span class="n">String</span> <span class="n">getFileName</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">fileName</span><span class="p">;</span>
     <span class="p">}</span>
 
     <span class="n">public</span> <span class="n">void</span> <span class="n">setFileName</span><span class="p">(</span><span class="n">String</span> <span class="n">fileName</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">fileName</span> <span class="o">=</span> <span class="n">fileName</span><span class="p">;</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">fileName</span> <span class="p">=</span> <span class="n">fileName</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="nv">@NotNull</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="s">&quot;Image data must not be null.&quot;</span><span class="p">)</span>
-    <span class="n">public</span> <span class="n">byte</span><span class="o">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
+    <span class="p">@</span><span class="n">NotNull</span><span class="p">(</span><span class="n">message</span><span class="p">=</span>&quot;<span class="n">Image</span> <span class="n">data</span> <span class="n">must</span> <span class="n">not</span> <span class="n">be</span> <span class="n">null</span><span class="p">.</span>&quot;<span class="p">)</span>
+    <span class="n">public</span> <span class="n">byte</span><span class="p">[]</span> <span class="n">getData</span><span class="p">()</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">data</span><span class="p">;</span>
     <span class="p">}</span>
 
-    <span class="n">public</span> <span class="n">void</span> <span class="n">setData</span><span class="p">(</span><span class="n">byte</span><span class="o">[]</span> <span class="n">data</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">this</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="p">;</span>
+    <span class="n">public</span> <span class="n">void</span> <span class="n">setData</span><span class="p">(</span><span class="n">byte</span><span class="p">[]</span> <span class="n">data</span><span class="p">)</span> <span class="p">{</span>
+        <span class="n">this</span><span class="p">.</span><span class="n">data</span> <span class="p">=</span> <span class="n">data</span><span class="p">;</span>
     <span class="p">}</span>
 <span class="p">}</span>
 </pre></div>
@@ -489,28 +500,28 @@ complex validation.  Sequenced validatio
 groups and group sequences.  These concepts will be explained shortly.</p>
 <p>Here is the code for the new <a href="http://svn.apache.org/repos/asf/openjpa/trunk/openjpa-examples/image-gallery/src/main/java/org/apache/openjpa/example/gallery/constraint/ImageConstraint.java">ImageConstraint</a>
  annotation:</p>
-<div class="codehilite"><pre><span class="x">package org.apache.openjpa.example.gallery.constraint;</span>
+<div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">gallery</span><span class="p">.</span><span class="n">constraint</span><span class="p">;</span>
 
-<span class="x">import java.lang.annotation.Documented;</span>
-<span class="x">import java.lang.annotation.Retention;</span>
-<span class="x">import java.lang.annotation.Target;</span>
-<span class="x">import static java.lang.annotation.ElementType.TYPE;</span>
-<span class="x">import static java.lang.annotation.RetentionPolicy.RUNTIME;</span>
-
-<span class="x">import javax.validation.Constraint;</span>
-<span class="x">import javax.validation.Payload;</span>
-
-<span class="x">import org.apache.openjpa.example.gallery.model.ImageType;</span>
-
-<span class="x">@Documented</span>
-<span class="x">@Constraint(validatedBy = ImageValidator.class)</span>
-<span class="x">@Target({ TYPE })</span>
-<span class="x">@Retention(RUNTIME)</span>
-<span class="x">public @interface ImageConstraint {</span>
-<span class="x">    String message() default &quot;Image data is not a supported format.&quot;;</span>
-<span class="x">    Class</span><span class="cp">&lt;?</span><span class="o">&gt;</span><span class="p">[]</span> <span class="nx">groups</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
-    <span class="nx">Class</span><span class="o">&lt;?</span> <span class="k">extends</span> <span class="nx">Payload</span><span class="o">&gt;</span><span class="p">[]</span> <span class="nx">payload</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
-    <span class="nx">ImageType</span><span class="p">[]</span> <span class="nx">value</span><span class="p">()</span> <span class="k">default</span> <span class="p">{</span> <span class="nx">ImageType</span><span class="o">.</span><span class="nx">GIF</span><span class="p">,</span> <span class="nx">ImageType</span><span class="o">.</span><span class="nx">JPEG</span> <span class="p">};</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">Documented</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">Retention</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">Target</span><span class="p">;</span>
+<span class="n">import</span> <span class="k">static</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">ElementType</span><span class="p">.</span><span class="n">TYPE</span><span class="p">;</span>
+<span class="n">import</span> <span class="k">static</span> <span class="n">java</span><span class="p">.</span><span class="n">lang</span><span class="p">.</span><span class="n">annotation</span><span class="p">.</span><span class="n">RetentionPolicy</span><span class="p">.</span><span class="n">RUNTIME</span><span class="p">;</span>
+
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">Constraint</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">Payload</span><span class="p">;</span>
+
+<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="n">gallery</span><span class="p">.</span><span class="n">model</span><span class="p">.</span><span class="n">ImageType</span><span class="p">;</span>
+
+<span class="err">@</span><span class="n">Documented</span>
+<span class="err">@</span><span class="n">Constraint</span><span class="p">(</span><span class="n">validatedBy</span> <span class="o">=</span> <span class="n">ImageValidator</span><span class="p">.</span><span class="n">class</span><span class="p">)</span>
+<span class="err">@</span><span class="n">Target</span><span class="p">({</span> <span class="n">TYPE</span> <span class="p">})</span>
+<span class="err">@</span><span class="n">Retention</span><span class="p">(</span><span class="n">RUNTIME</span><span class="p">)</span>
+<span class="n">public</span> <span class="err">@</span><span class="n">interface</span> <span class="n">ImageConstraint</span> <span class="p">{</span>
+    <span class="n">String</span> <span class="n">message</span><span class="p">()</span> <span class="k">default</span> <span class="s">&quot;Image data is not a supported format.&quot;</span><span class="p">;</span>
+    <span class="n">Class</span><span class="o">&lt;?&gt;</span><span class="p">[]</span> <span class="n">groups</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
+    <span class="n">Class</span><span class="o">&lt;?</span> <span class="n">extends</span> <span class="n">Payload</span><span class="o">&gt;</span><span class="p">[]</span> <span class="n">payload</span><span class="p">()</span> <span class="k">default</span> <span class="p">{};</span>
+    <span class="n">ImageType</span><span class="p">[]</span> <span class="n">value</span><span class="p">()</span> <span class="k">default</span> <span class="p">{</span> <span class="n">ImageType</span><span class="p">.</span><span class="n">GIF</span><span class="p">,</span> <span class="n">ImageType</span><span class="p">.</span><span class="n">JPEG</span> <span class="p">};</span>
 <span class="p">}</span>
 </pre></div>
 
@@ -521,72 +532,72 @@ groups and group sequences.  These conce
 type level (class or interface).  This constraint has a new validator
 class, <a href="http://svn.apache.org/repos/asf/openjpa/trunk/openjpa-examples/image-gallery/src/main/java/org/apache/openjpa/example/gallery/constraint/ImageValidator.java">ImageValidator</a>
 .</p>
-<div class="codehilite"><pre><span class="nb">package</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">constraint</span><span class="p">;</span>
+<div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">constraint</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">Arrays</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">List</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">util</span><span class="p">.</span><span class="n">Arrays</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">util</span><span class="p">.</span><span class="n">List</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">ConstraintValidator</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">javax</span><span class="o">.</span><span class="n">validation</span><span class="o">.</span><span class="n">ConstraintValidatorContext</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">ConstraintValidator</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">validation</span><span class="p">.</span><span class="n">ConstraintValidatorContext</span><span class="p">;</span>
 
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">Image</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">org</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">openjpa</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">gallery</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">ImageType</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">model</span><span class="p">.</span><span class="n">Image</span><span class="p">;</span>
+<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">openjpa</span><span class="p">.</span><span class="n">example</span><span class="p">.</span><span class="nb">gallery</span><span class="p">.</span><span class="n">model</span><span class="p">.</span><span class="n">ImageType</span><span class="p">;</span>
 
 <span class="o">/**</span>
- <span class="o">*</span> <span class="n">Simple</span> <span class="n">check</span> <span class="n">that</span> <span class="n">an</span> <span class="n">Image</span> <span class="n">is</span> <span class="n">consistent</span> <span class="n">in</span> <span class="n">type</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="ow">and</span> <span class="nb">format</span><span class="o">.</span>
+ <span class="o">*</span> <span class="n">Simple</span> <span class="n">check</span> <span class="n">that</span> <span class="n">an</span> <span class="n">Image</span> <span class="n">is</span> <span class="n">consistent</span> <span class="n">in</span> <span class="n">type</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">and</span> <span class="n">format</span><span class="p">.</span>
  <span class="o">*/</span>
-<span class="n">public</span> <span class="n">class</span> <span class="n">ImageValidator</span> <span class="n">implements</span> <span class="n">ConstraintValidator</span><span class="sr">&lt;ImageConstraint,Image&gt;</span> <span class="p">{</span>
-    <span class="n">private</span> <span class="n">List</span><span class="sr">&lt;ImageType&gt;</span> <span class="n">allowedTypes</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
+<span class="n">public</span> <span class="n">class</span> <span class="n">ImageValidator</span> <span class="n">implements</span> <span class="n">ConstraintValidator</span><span class="o">&lt;</span><span class="n">ImageConstraint</span><span class="p">,</span><span class="n">Image</span><span class="o">&gt;</span> <span class="p">{</span>
+    <span class="n">private</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">ImageType</span><span class="o">&gt;</span> <span class="n">allowedTypes</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span>
     <span class="o">/**</span>
      <span class="o">*</span> <span class="n">Configure</span> <span class="n">the</span> <span class="n">constraint</span> <span class="n">validator</span> <span class="n">based</span> <span class="n">on</span> <span class="n">the</span> <span class="n">image</span>
-     <span class="o">*</span> <span class="n">types</span> <span class="n">it</span> <span class="n">should</span> <span class="n">support</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">constraint</span> <span class="n">the</span> <span class="n">constraint</span> <span class="n">definition</span>
+     <span class="o">*</span> <span class="n">types</span> <span class="n">it</span> <span class="n">should</span> <span class="n">support</span><span class="p">.</span>
+     <span class="o">*</span> <span class="p">@</span><span class="n">param</span> <span class="n">constraint</span> <span class="n">the</span> <span class="n">constraint</span> <span class="n">definition</span>
      <span class="o">*/</span>
     <span class="n">public</span> <span class="n">void</span> <span class="n">initialize</span><span class="p">(</span><span class="n">ImageConstraint</span> <span class="n">constraint</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">allowedTypes</span> <span class="o">=</span> <span class="n">Arrays</span><span class="o">.</span><span class="n">asList</span><span class="p">(</span><span class="n">constraint</span><span class="o">.</span><span class="n">value</span><span class="p">());</span>
+        <span class="n">allowedTypes</span> <span class="p">=</span> <span class="n">Arrays</span><span class="p">.</span><span class="n">asList</span><span class="p">(</span><span class="n">constraint</span><span class="p">.</span><span class="n">value</span><span class="p">());</span>
     <span class="p">}</span>
 
     <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Validate</span> <span class="n">a</span> <span class="n">specified</span> <span class="n">value</span><span class="o">.</span>
+     <span class="o">*</span> <span class="n">Validate</span> <span class="n">a</span> <span class="n">specified</span> <span class="n">value</span><span class="p">.</span>
      <span class="o">*/</span>
     <span class="n">public</span> <span class="n">boolean</span> <span class="n">isValid</span><span class="p">(</span><span class="n">Image</span> <span class="n">value</span><span class="p">,</span> <span class="n">ConstraintValidatorContext</span> <span class="n">context</span><span class="p">)</span> <span class="p">{</span>
         <span class="k">if</span> <span class="p">(</span><span class="n">value</span> <span class="o">==</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
             <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
         <span class="p">}</span>
 
-        <span class="sr">//</span> <span class="n">All</span> <span class="n">these</span> <span class="n">fields</span> <span class="n">will</span> <span class="n">be</span> <span class="n">pre</span><span class="o">-</span><span class="n">validated</span> <span class="n">with</span> <span class="nv">@NotNull</span> <span class="n">constraints</span>
-        <span class="sr">//</span> <span class="n">so</span> <span class="n">they</span> <span class="n">are</span> <span class="n">safe</span> <span class="n">to</span> <span class="k">use</span> <span class="n">without</span> <span class="n">null</span> <span class="n">checks</span><span class="o">.</span>
-        <span class="n">byte</span><span class="o">[]</span> <span class="n">data</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">getData</span><span class="p">();</span>
-        <span class="n">String</span> <span class="n">fileName</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">getFileName</span><span class="p">();</span>
-        <span class="n">ImageType</span> <span class="n">type</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">getType</span><span class="p">();</span>
-
-        <span class="sr">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">GIF</span> <span class="n">type</span> <span class="n">is</span> <span class="n">correct</span><span class="p">,</span> <span class="n">has</span> <span class="n">the</span> <span class="n">correct</span> <span class="n">extension</span> <span class="ow">and</span>
-        <span class="sr">//</span> <span class="n">the</span> <span class="n">data</span> <span class="n">header</span> <span class="n">is</span> <span class="n">either</span> <span class="n">GIF87</span> <span class="ow">or</span> <span class="n">GIF89</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="o">.</span><span class="n">GIF</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
-            <span class="n">type</span> <span class="o">==</span> <span class="n">ImageType</span><span class="o">.</span><span class="n">GIF</span> <span class="o">&amp;&amp;</span>
-            <span class="n">fileName</span><span class="o">.</span><span class="n">endsWith</span><span class="p">(</span><span class="s">&quot;.gif&quot;</span><span class="p">))</span> <span class="p">{</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">data</span> <span class="o">!=</span> <span class="n">null</span> <span class="o">&amp;&amp;</span> <span class="n">data</span><span class="o">.</span><span class="nb">length</span> <span class="o">&gt;=</span> <span class="mi">6</span><span class="p">)</span> <span class="p">{</span>
-                <span class="n">String</span> <span class="n">gifHeader</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">6</span><span class="p">);</span>
-                <span class="k">if</span> <span class="p">(</span><span class="n">gifHeader</span><span class="o">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span><span class="s">&quot;GIF87a&quot;</span><span class="p">)</span> <span class="o">||</span>
-                     <span class="n">gifHeader</span><span class="o">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span><span class="s">&quot;GIF89a&quot;</span><span class="p">))</span> <span class="p">{</span>
+        <span class="o">//</span> <span class="n">All</span> <span class="n">these</span> <span class="n">fields</span> <span class="n">will</span> <span class="n">be</span> <span class="n">pre</span><span class="o">-</span><span class="n">validated</span> <span class="n">with</span> <span class="p">@</span><span class="n">NotNull</span> <span class="n">constraints</span>
+        <span class="o">//</span> <span class="n">so</span> <span class="n">they</span> <span class="n">are</span> <span class="n">safe</span> <span class="n">to</span> <span class="n">use</span> <span class="n">without</span> <span class="n">null</span> <span class="n">checks</span><span class="p">.</span>
+        <span class="n">byte</span><span class="p">[]</span> <span class="n">data</span> <span class="p">=</span> <span class="n">value</span><span class="p">.</span><span class="n">getData</span><span class="p">();</span>
+        <span class="n">String</span> <span class="n">fileName</span> <span class="p">=</span> <span class="n">value</span><span class="p">.</span><span class="n">getFileName</span><span class="p">();</span>
+        <span class="n">ImageType</span> <span class="n">type</span> <span class="p">=</span> <span class="n">value</span><span class="p">.</span><span class="n">getType</span><span class="p">();</span>
+
+        <span class="o">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">GIF</span> <span class="n">type</span> <span class="n">is</span> <span class="n">correct</span><span class="p">,</span> <span class="n">has</span> <span class="n">the</span> <span class="n">correct</span> <span class="n">extension</span> <span class="n">and</span>
+        <span class="o">//</span> <span class="n">the</span> <span class="n">data</span> <span class="n">header</span> <span class="n">is</span> <span class="n">either</span> <span class="n">GIF87</span> <span class="n">or</span> <span class="n">GIF89</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="p">.</span><span class="n">GIF</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
+            <span class="n">type</span> <span class="o">==</span> <span class="n">ImageType</span><span class="p">.</span><span class="n">GIF</span> <span class="o">&amp;&amp;</span>
+            <span class="n">fileName</span><span class="p">.</span><span class="n">endsWith</span><span class="p">(</span>&quot;<span class="p">.</span><span class="n">gif</span>&quot;<span class="p">))</span> <span class="p">{</span>
+            <span class="k">if</span> <span class="p">(</span><span class="n">data</span> !<span class="p">=</span> <span class="n">null</span> <span class="o">&amp;&amp;</span> <span class="n">data</span><span class="p">.</span><span class="nb">length</span> <span class="o">&gt;</span><span class="p">=</span> 6<span class="p">)</span> <span class="p">{</span>
+                <span class="n">String</span> <span class="n">gifHeader</span> <span class="p">=</span> <span class="n">new</span> <span class="n">String</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> 0<span class="p">,</span> 6<span class="p">);</span>
+                <span class="k">if</span> <span class="p">(</span><span class="n">gifHeader</span><span class="p">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span>&quot;<span class="n">GIF87a</span>&quot;<span class="p">)</span> <span class="o">||</span>
+                     <span class="n">gifHeader</span><span class="p">.</span><span class="n">equalsIgnoreCase</span><span class="p">(</span>&quot;<span class="n">GIF89a</span>&quot;<span class="p">))</span> <span class="p">{</span>
                     <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
                 <span class="p">}</span>
             <span class="p">}</span>
         <span class="p">}</span>
-        <span class="sr">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">JPEG</span> <span class="n">type</span> <span class="n">is</span> <span class="n">correct</span><span class="p">,</span> <span class="n">has</span> <span class="n">the</span> <span class="n">correct</span> <span class="n">extension</span> <span class="ow">and</span>
-        <span class="sr">//</span> <span class="n">the</span> <span class="n">data</span> <span class="n">begins</span> <span class="n">with</span> <span class="n">SOI</span> <span class="o">&amp;</span> <span class="n">ends</span> <span class="n">with</span> <span class="n">EOI</span> <span class="n">markers</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="o">.</span><span class="n">JPEG</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
-            <span class="n">value</span><span class="o">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ImageType</span><span class="o">.</span><span class="n">JPEG</span> <span class="o">&amp;&amp;</span>
-            <span class="p">(</span><span class="n">fileName</span><span class="o">.</span><span class="n">endsWith</span><span class="p">(</span><span class="s">&quot;.jpg&quot;</span><span class="p">)</span> <span class="o">||</span>
-             <span class="n">fileName</span><span class="o">.</span><span class="n">endsWith</span><span class="p">(</span><span class="s">&quot;.jpeg&quot;</span><span class="p">)))</span> <span class="p">{</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="nb">length</span> <span class="o">&gt;=</span> <span class="mi">4</span> <span class="o">&amp;&amp;</span>
-                <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xff</span> <span class="o">&amp;&amp;</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xd8</span> <span class="o">&amp;&amp;</span>
-                <span class="n">data</span><span class="p">[</span><span class="n">data</span><span class="o">.</span><span class="nb">length</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xff</span> <span class="o">&amp;&amp;</span>
-                <span class="n">data</span><span class="p">[</span><span class="n">data</span><span class="o">.</span><span class="nb">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mh">0xd9</span><span class="p">)</span> <span class="p">{</span>
+        <span class="o">//</span> <span class="n">Verify</span> <span class="n">the</span> <span class="n">JPEG</span> <span class="n">type</span> <span class="n">is</span> <span class="n">correct</span><span class="p">,</span> <span class="n">has</span> <span class="n">the</span> <span class="n">correct</span> <span class="n">extension</span> <span class="n">and</span>
+        <span class="o">//</span> <span class="n">the</span> <span class="n">data</span> <span class="n">begins</span> <span class="n">with</span> <span class="n">SOI</span> <span class="o">&amp;</span> <span class="n">ends</span> <span class="n">with</span> <span class="n">EOI</span> <span class="n">markers</span>
+        <span class="k">if</span> <span class="p">(</span><span class="n">allowedTypes</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span class="n">ImageType</span><span class="p">.</span><span class="n">JPEG</span><span class="p">)</span> <span class="o">&amp;&amp;</span>
+            <span class="n">value</span><span class="p">.</span><span class="n">getType</span><span class="p">()</span> <span class="o">==</span> <span class="n">ImageType</span><span class="p">.</span><span class="n">JPEG</span> <span class="o">&amp;&amp;</span>
+            <span class="p">(</span><span class="n">fileName</span><span class="p">.</span><span class="n">endsWith</span><span class="p">(</span>&quot;<span class="p">.</span><span class="n">jpg</span>&quot;<span class="p">)</span> <span class="o">||</span>
+             <span class="n">fileName</span><span class="p">.</span><span class="n">endsWith</span><span class="p">(</span>&quot;<span class="p">.</span><span class="n">jpeg</span>&quot;<span class="p">)))</span> <span class="p">{</span>
+            <span class="k">if</span> <span class="p">(</span><span class="n">data</span><span class="p">.</span><span class="nb">length</span> <span class="o">&gt;</span><span class="p">=</span> 4 <span class="o">&amp;&amp;</span>
+                <span class="n">data</span><span class="p">[</span>0<span class="p">]</span> <span class="o">==</span> 0<span class="n">xff</span> <span class="o">&amp;&amp;</span> <span class="n">data</span><span class="p">[</span>1<span class="p">]</span> <span class="o">==</span> 0<span class="n">xd8</span> <span class="o">&amp;&amp;</span>
+                <span class="n">data</span><span class="p">[</span><span class="n">data</span><span class="p">.</span><span class="nb">length</span> <span class="o">-</span> 2<span class="p">]</span> <span class="o">==</span> 0<span class="n">xff</span> <span class="o">&amp;&amp;</span>
+                <span class="n">data</span><span class="p">[</span><span class="n">data</span><span class="p">.</span><span class="nb">length</span> <span class="o">-</span> 1<span class="p">]</span> <span class="o">==</span> 0<span class="n">xd9</span><span class="p">)</span> <span class="p">{</span>
                 <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
             <span class="p">}</span>
         <span class="p">}</span>
-        <span class="sr">//</span> <span class="n">Unknown</span> <span class="n">file</span> <span class="nb">format</span>
+        <span class="o">//</span> <span class="n">Unknown</span> <span class="n">file</span> <span class="n">format</span>
         <span class="k">return</span> <span class="n">false</span><span class="p">;</span>
     <span class="p">}</span>
 <span class="p">}</span>
@@ -603,16 +614,16 @@ likely due to detachment) you'll be vali
  It can be obtained statically so squirreling away a copy of the JPA entity
 manager is not necessary.  Here is an example of how PersistenceUtil could
 be used in the ImageValidator.</p>
-<div class="codehilite"><pre>    <span class="n">byte</span><span class="o">[]</span> <span class="n">data</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">getData</span><span class="p">();</span>
-    <span class="n">PersistenceUtil</span> <span class="n">putil</span> <span class="o">=</span> <span class="n">Persistence</span><span class="o">.</span><span class="n">getPersistenceUtil</span><span class="p">();</span>
-    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">putil</span><span class="o">.</span><span class="n">isLoaded</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="s">&quot;data&quot;</span><span class="p">))</span> <span class="p">{</span>
-        <span class="sr">//</span> <span class="n">don</span><span class="err">&#39;</span><span class="n">t</span> <span class="n">validate</span> <span class="n">the</span> <span class="n">data</span>
+<div class="codehilite"><pre>    <span class="n">byte</span><span class="p">[]</span> <span class="n">data</span> <span class="p">=</span> <span class="n">value</span><span class="p">.</span><span class="n">getData</span><span class="p">();</span>
+    <span class="n">PersistenceUtil</span> <span class="n">putil</span> <span class="p">=</span> <span class="n">Persistence</span><span class="p">.</span><span class="n">getPersistenceUtil</span><span class="p">();</span>
+    <span class="k">if</span> <span class="p">(</span>!<span class="n">putil</span><span class="p">.</span><span class="n">isLoaded</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> &quot;<span class="n">data</span>&quot;<span class="p">))</span> <span class="p">{</span>
+        <span class="o">//</span> <span class="n">don</span><span class="o">&#39;</span><span class="n">t</span> <span class="n">validate</span> <span class="n">the</span> <span class="n">data</span>
     <span class="p">}</span>
 </pre></div>
 
 
 <p><a name="BeanValidationPrimer-TheCompleteDomainModel"></a></p>
-<h3 id="the-complete-domain-model">The Complete Domain Model</h3>
+<h3 id="the-complete-domain-model">The Complete Domain Model<a class="headerlink" href="#the-complete-domain-model" title="Permanent link">&para;</a></h3>
 <p>Now that some of the basics of bean validation are covered, let's finish up
 the domain model for our simple application and then get into JPA specifics
 through an example.</p>
@@ -635,14 +646,14 @@ an image a new field and corresponding p
 the Image class:</p>
 <div class="codehilite"><pre>    <span class="n">private</span> <span class="n">Location</span> <span class="n">location</span><span class="p">;</span>
 
-    <span class="nv">@Valid</span>
-    <span class="nv">@Embedded</span>
+    <span class="p">@</span><span class="n">Valid</span>
+    <span class="p">@</span><span class="n">Embedded</span>
     <span class="n">public</span> <span class="n">Location</span> <span class="n">getLocation</span><span class="p">()</span> <span class="p">{</span>

[... 340 lines stripped ...]



Mime
View raw message