/*******************************************************************************
 * Copyright (c) 1998, 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the 
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
 * which accompanies this distribution. 
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at 
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 ******************************************************************************/  
package org.eclipse.persistence.testing.jaxb.xmlmarshaller;

import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.ValidationEvent;

public class CustomErrorValidationEventHandler implements ValidationEventHandler {
  public boolean handleEvent(ValidationEvent event) {

		if(event.getSeverity() != ValidationEvent.ERROR)
		{
			return false;
		}
		
    Exception ex = (Exception)event.getLinkedException();
    String message = ex.getMessage();
    System.out.println("Handling Event: " + message);
    if(message.indexOf("Invalid ") != -1) {
      System.out.println("Recoverable Error, Ignoring...");
      return true;
    }
    return false;
  }
}


@@ -208,17 +208,16 @@
 nder the
- 
 %0D%0A * ter
@@ -293,17 +293,16 @@
 e v. 1.0
- 
 %0D%0A * whi
@@ -334,17 +334,16 @@
 ibution.
- 
 %0D%0A * The
@@ -480,17 +480,16 @@
 lable at
- 
 %0D%0A * htt
@@ -706,18 +706,16 @@
 *******/
-  
 %0D%0Apackag
@@ -944,16 +944,59 @@
 dler %7B%0D%0A
+%0D%0A    private int errorCount = 0;%0D%0A    %0D%0A  
   public
@@ -1046,14 +1046,19 @@
  %7B%0D%0A
-%0D%0A%09%09
+        
 if
+ 
 (eve
@@ -1103,18 +1103,24 @@
 ROR)
-%0D%0A%09%09%7B%0D%0A%09%09%09
+ %7B%0D%0A            
 retu
@@ -1134,209 +1134,80 @@
 e;%0D%0A
-%09%09
+        
 %7D%0D%0A
-%09%09
 %0D%0A    
-Exception ex = (Exception)event.getLinkedException();%0D%0A    String message = ex.getMessage();%0D%0A    System.out.println(%22Handling Event: %22 + message);%0D%0A    if(message.indexOf(%22Invalid %22) !
+    errorCount++;%0D%0A        %0D%0A        if (errorCount =
 = 
--
 1) %7B
@@ -1218,63 +1218,8 @@
     
-System.out.println(%22Recoverable Error, Ignoring...%22);%0D%0A
     
@@ -1238,19 +1238,37 @@
 e;%0D%0A    
-%7D%0D%0A
+    %7D%0D%0A        %0D%0A    
     retu
@@ -1284,12 +1284,16 @@
 %0D%0A  
-%7D%0D%0A%7D%0D%0A
+  %7D%0D%0A    
 %0D%0A
+%7D

Fix for bug 286807, reviewed by bdoughan.