Commit 7b78b7f9 authored by Lukas Jungmann's avatar Lukas Jungmann
Browse files

#188: Remove deprecated jakarta.xml.bind.Validator

Signed-off-by: default avatarLukas Jungmann <lukas.jungmann@oracle.com>
parent f2897d74
/* /*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -51,10 +51,6 @@ public class JAXBContextServiceProviderNPETest { ...@@ -51,10 +51,6 @@ public class JAXBContextServiceProviderNPETest {
return null; return null;
} }
@Override
public Validator createValidator() throws JAXBException {
return null;
}
} }
@Test @Test
......
/* /*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -14,7 +14,6 @@ import jakarta.xml.bind.JAXBContext; ...@@ -14,7 +14,6 @@ import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.Validator;
import java.util.Map; import java.util.Map;
/** /**
...@@ -43,10 +42,5 @@ public class Valid { ...@@ -43,10 +42,5 @@ public class Valid {
public Marshaller createMarshaller() throws JAXBException { public Marshaller createMarshaller() throws JAXBException {
return null; return null;
} }
@Override
public Validator createValidator() throws JAXBException {
return null;
}
} }
} }
/* /*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -14,7 +14,6 @@ import jakarta.xml.bind.JAXBContext; ...@@ -14,7 +14,6 @@ import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.Validator;
import java.util.Map; import java.util.Map;
/** /**
...@@ -44,10 +43,5 @@ public class Valid2 { ...@@ -44,10 +43,5 @@ public class Valid2 {
public Marshaller createMarshaller() throws JAXBException { public Marshaller createMarshaller() throws JAXBException {
return null; return null;
} }
@Override
public Validator createValidator() throws JAXBException {
return null;
}
} }
} }
/* /*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -14,7 +14,6 @@ import jakarta.xml.bind.JAXBContext; ...@@ -14,7 +14,6 @@ import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.Validator;
import java.util.Map; import java.util.Map;
/** /**
...@@ -44,10 +43,5 @@ public class Valid3 { ...@@ -44,10 +43,5 @@ public class Valid3 {
public Marshaller createMarshaller() throws JAXBException { public Marshaller createMarshaller() throws JAXBException {
return null; return null;
} }
@Override
public Validator createValidator() throws JAXBException {
return null;
}
} }
} }
/* /*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -15,7 +15,6 @@ import jakarta.xml.bind.JAXBContextFactory; ...@@ -15,7 +15,6 @@ import jakarta.xml.bind.JAXBContextFactory;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.Validator;
import java.util.Map; import java.util.Map;
/** /**
...@@ -43,11 +42,6 @@ public class Valid implements JAXBContextFactory { ...@@ -43,11 +42,6 @@ public class Valid implements JAXBContextFactory {
public Marshaller createMarshaller() throws JAXBException { public Marshaller createMarshaller() throws JAXBException {
return null; return null;
} }
@Override
public Validator createValidator() throws JAXBException {
return null;
}
} }
} }
/* /*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -15,7 +15,6 @@ import jakarta.xml.bind.JAXBContextFactory; ...@@ -15,7 +15,6 @@ import jakarta.xml.bind.JAXBContextFactory;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.Validator;
import java.util.Map; import java.util.Map;
/** /**
...@@ -43,11 +42,6 @@ public class Valid2 implements JAXBContextFactory { ...@@ -43,11 +42,6 @@ public class Valid2 implements JAXBContextFactory {
public Marshaller createMarshaller() throws JAXBException { public Marshaller createMarshaller() throws JAXBException {
return null; return null;
} }
@Override
public Validator createValidator() throws JAXBException {
return null;
}
} }
} }
/* /*
* Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -15,7 +15,6 @@ import jakarta.xml.bind.JAXBContextFactory; ...@@ -15,7 +15,6 @@ import jakarta.xml.bind.JAXBContextFactory;
import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller; import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.Validator;
import java.util.Map; import java.util.Map;
/** /**
...@@ -44,10 +43,6 @@ public class Valid3 implements JAXBContextFactory { ...@@ -44,10 +43,6 @@ public class Valid3 implements JAXBContextFactory {
return null; return null;
} }
@Override
public Validator createValidator() throws JAXBException {
return null;
}
} }
} }
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -159,14 +159,8 @@ import java.util.Properties; ...@@ -159,14 +159,8 @@ import java.util.Properties;
* *
* <h3>Validation</h3> * <h3>Validation</h3>
* <p> * <p>
* Validation has been changed significantly since JAXB 1.0. The {@link Validator}
* class has been deprecated and made optional. This means that you are advised
* not to use this class and, in fact, it may not even be available depending on
* your Jakarta XML Binding provider. JAXB 1.0 client applications that rely on {@code Validator}
* will still work properly when deployed with the JAXB 1.0 runtime system.
*
* In Jakarta XML Binding, the {@link Unmarshaller} has included convenience methods that expose * In Jakarta XML Binding, the {@link Unmarshaller} has included convenience methods that expose
* the JAXP 1.3 {@link javax.xml.validation} framework. Please refer to the * the JAXP {@link javax.xml.validation} framework. Please refer to the
* {@link Unmarshaller#setSchema(javax.xml.validation.Schema)} API for more * {@link Unmarshaller#setSchema(javax.xml.validation.Schema)} API for more
* information. * information.
* *
...@@ -715,22 +709,6 @@ public abstract class JAXBContext { ...@@ -715,22 +709,6 @@ public abstract class JAXBContext {
public abstract Marshaller createMarshaller() throws JAXBException; public abstract Marshaller createMarshaller() throws JAXBException;
/**
* {@link Validator} has been made optional and deprecated in Jakarta XML Binding. Please
* refer to the javadoc for {@link Validator} for more detail.
* <p>
* Create a {@code Validator} object that can be used to validate a
* java content tree against its source schema.
*
* @return a {@code Validator} object
*
* @throws JAXBException if an error was encountered while creating the
* {@code Validator} object
* @deprecated since JAXB2.0
*/
@Deprecated
public abstract Validator createValidator() throws JAXBException;
/** /**
* Creates a {@code Binder} object that can be used for * Creates a {@code Binder} object that can be used for
* associative/in-place unmarshalling/marshalling. * associative/in-place unmarshalling/marshalling.
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -294,7 +294,6 @@ import java.io.File; ...@@ -294,7 +294,6 @@ import java.io.File;
* *
* @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see JAXBContext * @see JAXBContext
* @see Validator
* @see Unmarshaller * @see Unmarshaller
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
...@@ -701,7 +700,7 @@ public interface Marshaller { ...@@ -701,7 +700,7 @@ public interface Marshaller {
AttachmentMarshaller getAttachmentMarshaller(); AttachmentMarshaller getAttachmentMarshaller();
/** /**
* Specify the JAXP 1.3 {@link javax.xml.validation.Schema Schema} * Specify the JAXP {@link javax.xml.validation.Schema Schema}
* object that should be used to validate subsequent marshal operations * object that should be used to validate subsequent marshal operations
* against. Passing null into this method will disable validation. * against. Passing null into this method will disable validation.
* *
...@@ -720,7 +719,7 @@ public interface Marshaller { ...@@ -720,7 +719,7 @@ public interface Marshaller {
public void setSchema( Schema schema ); public void setSchema( Schema schema );
/** /**
* Get the JAXP 1.3 {@link javax.xml.validation.Schema Schema} object * Get the JAXP {@link javax.xml.validation.Schema Schema} object
* being used to perform marshal-time validation. If there is no * being used to perform marshal-time validation. If there is no
* Schema set on the marshaller, then this method will return null * Schema set on the marshaller, then this method will return null
* indicating that marshal-time validation will not be performed. * indicating that marshal-time validation will not be performed.
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -15,7 +15,6 @@ package jakarta.xml.bind; ...@@ -15,7 +15,6 @@ package jakarta.xml.bind;
* *
* *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see Validator
* @see ValidationEventHandler * @see ValidationEventHandler
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
......
/* /*
* Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -18,7 +18,6 @@ package jakarta.xml.bind; ...@@ -18,7 +18,6 @@ package jakarta.xml.bind;
* *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see JAXBContext * @see JAXBContext
* @see Validator
* @see Unmarshaller * @see Unmarshaller
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -311,10 +311,10 @@ import java.io.Reader; ...@@ -311,10 +311,10 @@ import java.io.Reader;
* <b>Validation and Well-Formedness</b><br> * <b>Validation and Well-Formedness</b><br>
* <blockquote> * <blockquote>
* <p> * <p>
* A client application can enable or disable JAXP 1.3 validation * A client application can enable or disable JAXP validation
* mechanism via the {@code setSchema(javax.xml.validation.Schema)} API. * mechanism via the {@code setSchema(javax.xml.validation.Schema)} API.
* Sophisticated clients can specify their own validating SAX 2.0 compliant * Sophisticated clients can specify their own validating SAX 2.0 compliant
* parser and bypass the JAXP 1.3 validation mechanism using the * parser and bypass the JAXP validation mechanism using the
* {@link #unmarshal(javax.xml.transform.Source) unmarshal(Source)} API. * {@link #unmarshal(javax.xml.transform.Source) unmarshal(Source)} API.
* *
* <p> * <p>
...@@ -384,7 +384,6 @@ import java.io.Reader; ...@@ -384,7 +384,6 @@ import java.io.Reader;
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see JAXBContext * @see JAXBContext
* @see Marshaller * @see Marshaller
* @see Validator
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
public interface Unmarshaller { public interface Unmarshaller {
...@@ -803,58 +802,6 @@ public interface Unmarshaller { ...@@ -803,58 +802,6 @@ public interface Unmarshaller {
*/ */
public UnmarshallerHandler getUnmarshallerHandler(); public UnmarshallerHandler getUnmarshallerHandler();
/**
* Specifies whether or not the default validation mechanism of the
* {@code Unmarshaller} should validate during unmarshal operations.
* By default, the {@code Unmarshaller} does not validate.
* <p>
* This method may only be invoked before or after calling one of the
* unmarshal methods.
* <p>
* This method only controls the Jakarta XML Binding Provider's default unmarshal-time
* validation mechanism - it has no impact on clients that specify their
* own validating SAX 2.0 compliant parser. Clients that specify their
* own unmarshal-time validation mechanism may wish to turn off the Jakarta XML Binding
* Provider's default validation mechanism via this API to avoid "double
* validation".
* <p>
* This method is deprecated as of Jakarta XML Binding - please use the new
* {@link #setSchema(javax.xml.validation.Schema)} API.
*
* @param validating true if the Unmarshaller should validate during
* unmarshal, false otherwise
* @throws JAXBException if an error occurred while enabling or disabling
* validation at unmarshal time
* @throws UnsupportedOperationException could be thrown if this method is
* invoked on an Unmarshaller created from a JAXBContext referencing
* Jakarta XML Binding mapped classes
* @deprecated since JAXB2.0, please see {@link #setSchema(javax.xml.validation.Schema)}
*/
public void setValidating( boolean validating )
throws JAXBException;
/**
* Indicates whether or not the {@code Unmarshaller} is configured to
* validate during unmarshal operations.
* <p>
* This API returns the state of the Jakarta XML Binding Provider's default unmarshal-time
* validation mechanism.
* <p>
* This method is deprecated as of Jakarta XML Binding - please use the new
* {@link #getSchema()} API.
*
* @return true if the Unmarshaller is configured to validate during
* unmarshal operations, false otherwise
* @throws JAXBException if an error occurs while retrieving the validating
* flag
* @throws UnsupportedOperationException could be thrown if this method is
* invoked on an Unmarshaller created from a JAXBContext referencing
* Jakarta XML Binding mapped classes
* @deprecated since JAXB2.0, please see {@link #getSchema()}
*/
public boolean isValidating()
throws JAXBException;
/** /**
* Allow an application to register a {@code ValidationEventHandler}. * Allow an application to register a {@code ValidationEventHandler}.
* <p> * <p>
...@@ -929,12 +876,9 @@ public interface Unmarshaller { ...@@ -929,12 +876,9 @@ public interface Unmarshaller {
public Object getProperty( String name ) throws PropertyException; public Object getProperty( String name ) throws PropertyException;
/** /**
* Specify the JAXP 1.3 {@link javax.xml.validation.Schema Schema} * Specify the JAXP {@link javax.xml.validation.Schema Schema}
* object that should be used to validate subsequent unmarshal operations * object that should be used to validate subsequent unmarshal operations
* against. Passing null into this method will disable validation. * against. Passing null into this method will disable validation.
* <p>
* This method replaces the deprecated {@link #setValidating(boolean) setValidating(boolean)}
* API.
* *
* <p> * <p>
* Initially this property is set to {@code null}. * Initially this property is set to {@code null}.
...@@ -948,18 +892,10 @@ public interface Unmarshaller { ...@@ -948,18 +892,10 @@ public interface Unmarshaller {
public void setSchema( javax.xml.validation.Schema schema ); public void setSchema( javax.xml.validation.Schema schema );
/** /**
* Get the JAXP 1.3 {@link javax.xml.validation.Schema Schema} object * Get the JAXP {@link javax.xml.validation.Schema Schema} object
* being used to perform unmarshal-time validation. If there is no * being used to perform unmarshal-time validation. If there is no
* Schema set on the unmarshaller, then this method will return null * Schema set on the unmarshaller, then this method will return null
* indicating that unmarshal-time validation will not be performed. * indicating that unmarshal-time validation will not be performed.
* <p>
* This method provides replacement functionality for the deprecated
* {@link #isValidating()} API as well as access to the Schema object.
* To determine if the Unmarshaller has validation enabled, simply
* test the return type for null:
* <pre>{@code
* boolean isValidating = u.getSchema()!=null;
* }</pre>
* *
* @return the Schema object being used to perform unmarshal-time * @return the Schema object being used to perform unmarshal-time
* validation or null if not present * validation or null if not present
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -17,7 +17,6 @@ package jakarta.xml.bind; ...@@ -17,7 +17,6 @@ package jakarta.xml.bind;
* Java content tree back to XML data. * Java content tree back to XML data.
* *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see Validator
* @see ValidationEventHandler * @see ValidationEventHandler
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -16,8 +16,7 @@ package jakarta.xml.bind; ...@@ -16,8 +16,7 @@ package jakarta.xml.bind;
* <p> * <p>
* If an application needs to implement customized event handling, it must * If an application needs to implement customized event handling, it must
* implement this interface and then register it with either the * implement this interface and then register it with either the
* {@link Unmarshaller#setEventHandler(ValidationEventHandler) Unmarshaller}, * {@link Unmarshaller#setEventHandler(ValidationEventHandler) Unmarshaller}, or
* the {@link Validator#setEventHandler(ValidationEventHandler) Validator}, or
* the {@link Marshaller#setEventHandler(ValidationEventHandler) Marshaller}. * the {@link Marshaller#setEventHandler(ValidationEventHandler) Marshaller}.
* The Jakarta XML Binding Provider will then report validation errors and warnings encountered * The Jakarta XML Binding Provider will then report validation errors and warnings encountered
* during the unmarshal, marshal, and validate operations to these event * during the unmarshal, marshal, and validate operations to these event
...@@ -41,14 +40,19 @@ package jakarta.xml.bind; ...@@ -41,14 +40,19 @@ package jakarta.xml.bind;
* <p> * <p>
* <b>Default Event Handler</b> * <b>Default Event Handler</b>
* <blockquote> * <blockquote>
* See: <a href="Validator.html#defaulthandler">Validator javadocs</a> * If the client application does not set an event handler on their
* {@code Unmarshaller}, or {@code Marshaller} prior to
* calling the validate, unmarshal, or marshal methods, then a default event
* handler will receive notification of any errors or warnings encountered.
* The default event handler will cause the current operation to halt after
* encountering the first error or fatal error (but will attempt to continue
* after receiving warnings).
* </blockquote> * </blockquote>
* *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li>
* <li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li> * <li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li>
* <li>Joe Fialli, Sun Microsystems, Inc.</li></ul> * <li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see Unmarshaller * @see Unmarshaller
* @see Validator
* @see Marshaller * @see Marshaller
* @see ValidationEvent * @see ValidationEvent
* @see jakarta.xml.bind.util.ValidationEventCollector * @see jakarta.xml.bind.util.ValidationEventCollector
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -25,7 +25,6 @@ package jakarta.xml.bind; ...@@ -25,7 +25,6 @@ package jakarta.xml.bind;
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li>
* <li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li> * <li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li>
* <li>Joe Fialli, Sun Microsystems, Inc.</li></ul> * <li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see Validator
* @see ValidationEvent * @see ValidationEvent
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -22,7 +22,6 @@ package jakarta.xml.bind; ...@@ -22,7 +22,6 @@ package jakarta.xml.bind;
* *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul>
* @see JAXBException * @see JAXBException
* @see Validator
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
public class ValidationException extends JAXBException { public class ValidationException extends JAXBException {
......
/*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package jakarta.xml.bind;
/**
* As of Jakarta XML Binding, this class is deprecated and optional.
* <p>
* The {@code Validator} class is responsible for controlling the validation
* of content trees during runtime.
*
* <p>
* <a id="validationtypes"></a>
* <b>Three Forms of Validation</b><br>
* <blockquote>
* <dl>
* <dt><b>Unmarshal-Time Validation</b></dt>
* <dd>This form of validation enables a client application to receive
* information about validation errors and warnings detected while
* unmarshalling XML data into a Java content tree and is completely
* orthogonal to the other types of validation. To enable or disable
* it, see the javadoc for
* {@link Unmarshaller#setValidating(boolean) Unmarshaller.setValidating}.
* All JAXB 1.0 Providers are required to support this operation.
* </dd>
*
* <dt><b>On-Demand Validation</b></dt>
* <dd> This form of validation enables a client application to receive
* information about validation errors and warnings detected in the
* Java content tree. At any point, client applications can call
* the {@link Validator#validate(Object) Validator.validate} method
* on the Java content tree (or any sub-tree of it). All JAXB 1.0
* Providers are required to support this operation.
* </dd>
*
* <dt><b>Fail-Fast Validation</b></dt>
* <dd> This form of validation enables a client application to receive
* immediate feedback about modifications to the Java content tree
* that violate type constraints on Java Properties as defined in
* the specification. Jakarta XML Binding Providers are not required support
* this type of validation. Of the Jakarta XML Binding Providers that do support
* this type of validation, some may require you to decide at schema
* compile time whether or not a client application will be allowed
* to request fail-fast validation at runtime.
* </dd>
* </dl>
* </blockquote>
*
* <p>
* The {@code Validator} class is responsible for managing On-Demand Validation.
* The {@code Unmarshaller} class is responsible for managing Unmarshal-Time
* Validation during the unmarshal operations. Although there is no formal
* method of enabling validation during the marshal operations, the
* {@code Marshaller} may detect errors, which will be reported to the
* {@code ValidationEventHandler} registered on it.
*
* <p>
* <a id="defaulthandler"></a>
* <b>Using the Default EventHandler</b><br>
* <blockquote>
* If the client application does not set an event handler on their
* {@code Validator}, {@code Unmarshaller}, or {@code Marshaller} prior to
* calling the validate, unmarshal, or marshal methods, then a default event
* handler will receive notification of any errors or warnings encountered.
* The default event handler will cause the current operation to halt after
* encountering the first error or fatal error (but will attempt to continue
* after receiving warnings).
* </blockquote>
*
* <p>
* <a id="handlingevents"></a>
* <b>Handling Validation Events</b><br>
* <blockquote>
* There are three ways to handle events encountered during the unmarshal,
* validate, and marshal operations:
* <dl>
* <dt>Use the default event handler</dt>
* <dd>The default event handler will be used if you do not specify one
* via the {@code setEventHandler} API's on {@code Validator},
* {@code Unmarshaller}, or {@code Marshaller}.
* </dd>
*
* <dt>Implement and register a custom event handler</dt>
* <dd>Client applications that require sophisticated event processing
* can implement the {@code ValidationEventHandler} interface and
* register it with the {@code Unmarshaller} and/or
* {@code Validator}.
* </dd>
*
* <dt>Use the {@link jakarta.xml.bind.util.ValidationEventCollector ValidationEventCollector}
* utility</dt>
* <dd>For convenience, a specialized event handler is provided that
* simply collects any {@code ValidationEvent} objects created
* during the unmarshal, validate, and marshal operations and
* returns them to the client application as a
* {@code java.util.Collection}.
* </dd>
* </dl>
* </blockquote>
*
* <p>
* <b>Validation and Well-Formedness</b><br>
* <blockquote>
* <p>
* Validation events are handled differently depending on how the client
* application is configured to process them as described in the previous
* section. However, there are certain cases where a Jakarta XML Binding Provider indicates
* that it is no longer able to reliably detect and report errors. In these
* cases, the Jakarta XML Binding Provider will set the severity of the ValidationEvent to
* FATAL_ERROR to indicate that the unmarshal, validate, or marshal operations
* should be terminated. The default event handler and
* {@code ValidationEventCollector} utility class must terminate processing
* after being notified of a fatal error. Client applications that supply their
* own {@code ValidationEventHandler} should also terminate processing after
* being notified of a fatal error. If not, unexpected behaviour may occur.
* </blockquote>
*
* <p>
* <a id="supportedProps"></a>
* <b>Supported Properties</b><br>
* <blockquote>
* <p>
* There currently are not any properties required to be supported by all
* Jakarta XML Binding Providers on Validator. However, some providers may support
* their own set of provider specific properties.
* </blockquote>
*
*
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see JAXBContext
* @see Unmarshaller
* @see ValidationEventHandler
* @see ValidationEvent
* @see jakarta.xml.bind.util.ValidationEventCollector
* @since 1.6, JAXB 1.0
* @deprecated since JAXB 2.0
*/
public interface Validator {
/**
* Allow an application to register a validation event handler.
* <p>
* The validation event handler will be called by the Jakarta XML Binding Provider if any
* validation errors are encountered during calls to
* {@link #validate(Object) validate}. If the client application does not
* register a validation event handler before invoking the validate method,
* then validation events will be handled by the default event handler which
* will terminate the validate operation after the first error or fatal error
* is encountered.
* <p>
* Calling this method with a null parameter will cause the Validator
* to revert back to the default default event handler.
*
* @param handler the validation event handler
* @throws JAXBException if an error was encountered while setting the
* event handler
* @deprecated since JAXB2.0
*/
public void setEventHandler( ValidationEventHandler handler )
throws JAXBException;
/**
* Return the current event handler or the default event handler if one
* hasn't been set.
*
* @return the current ValidationEventHandler or the default event handler
* if it hasn't been set
* @throws JAXBException if an error was encountered while getting the
* current event handler
* @deprecated since JAXB2.0
*/
public ValidationEventHandler getEventHandler()
throws JAXBException;
/**
* Validate the Java content tree starting at {@code subrootObj}.
* <p>
* Client applications can use this method to validate Java content trees
* on-demand at runtime. This method can be used to validate any arbitrary
* subtree of the Java content tree. Global constraint checking <b>will not
* </b> be performed as part of this operation (i.e. ID/IDREF constraints).
*
* @param subrootObj the obj to begin validation at
* @throws JAXBException if any unexpected problem occurs during validation
* @throws ValidationException
* If the {@link ValidationEventHandler ValidationEventHandler}
* returns false from its {@code handleEvent} method or the
* {@code Validator} is unable to validate the content tree rooted
* at {@code subrootObj}
* @throws IllegalArgumentException
* If the subrootObj parameter is null
* @return true if the subtree rooted at {@code subrootObj} is valid, false
* otherwise
* @deprecated since JAXB2.0
*/
public boolean validate( Object subrootObj ) throws JAXBException;
/**
* Validate the Java content tree rooted at {@code rootObj}.
* <p>
* Client applications can use this method to validate Java content trees
* on-demand at runtime. This method is used to validate an entire Java
* content tree. Global constraint checking <b>will</b> be performed as
* part of this operation (i.e. ID/IDREF constraints).
*
* @param rootObj the root obj to begin validation at
* @throws JAXBException if any unexpected problem occurs during validation
* @throws ValidationException
* If the {@link ValidationEventHandler ValidationEventHandler}
* returns false from its {@code handleEvent} method or the
* {@code Validator} is unable to validate the content tree rooted
* at {@code rootObj}
* @throws IllegalArgumentException
* If the rootObj parameter is null
* @return true if the tree rooted at {@code rootObj} is valid, false
* otherwise
* @deprecated since JAXB2.0
*/
public boolean validateRoot( Object rootObj ) throws JAXBException;
/**
* Set the particular property in the underlying implementation of
* {@code Validator}. This method can only be used to set one of
* the standard Jakarta XML Binding defined properties above or a provider specific
* property. Attempting to set an undefined property will result in
* a PropertyException being thrown. See <a href="#supportedProps">
* Supported Properties</a>.
*
* @param name the name of the property to be set. This value can either
* be specified using one of the constant fields or a user
* supplied string.
* @param value the value of the property to be set
*
* @throws PropertyException when there is an error processing the given
* property or value
* @throws IllegalArgumentException
* If the name parameter is null
* @deprecated since JAXB2.0
*/
public void setProperty( String name, Object value )
throws PropertyException;
/**
* Get the particular property in the underlying implementation of
* {@code Validator}. This method can only be used to get one of
* the standard Jakarta XML Binding defined properties above or a provider specific
* property. Attempting to get an undefined property will result in
* a PropertyException being thrown. See <a href="#supportedProps">
* Supported Properties</a>.
*
* @param name the name of the property to retrieve
* @return the value of the requested property
*
* @throws PropertyException
* when there is an error retrieving the given property or value
* property name
* @throws IllegalArgumentException
* If the name parameter is null
* @deprecated since JAXB2.0
*/
public Object getProperty( String name ) throws PropertyException;
}
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -59,9 +59,6 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller ...@@ -59,9 +59,6 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller
private ValidationEventHandler eventHandler = private ValidationEventHandler eventHandler =
new DefaultValidationEventHandler(); new DefaultValidationEventHandler();
/** whether or not the unmarshaller will validate */
protected boolean validating = false;
/** /**
* XMLReader that will be used to parse a document. * XMLReader that will be used to parse a document.
*/ */
...@@ -200,22 +197,6 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller ...@@ -200,22 +197,6 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller
} }
/**
* Indicates whether or not the Unmarshaller is configured to validate
* during unmarshal operations.
* <p>
* <i><b>Note:</b> I named this method isValidating() to stay in-line
* with JAXP, as opposed to naming it getValidating(). </i>
*
* @return true if the Unmarshaller is configured to validate during
* unmarshal operations, false otherwise
* @throws JAXBException if an error occurs while retrieving the validating
* flag
*/
public boolean isValidating() throws JAXBException {
return validating;
}
/** /**
* Allow an application to register a validation event handler. * Allow an application to register a validation event handler.
* <p> * <p>
...@@ -240,22 +221,6 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller ...@@ -240,22 +221,6 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller
} }
} }
/**
* Specifies whether or not the Unmarshaller should validate during
* unmarshal operations. By default, the {@code Unmarshaller} does
* not validate.
* <p>
* This method may only be invoked before or after calling one of the
* unmarshal methods.
*
* @param validating true if the Unmarshaller should validate during
* unmarshal, false otherwise
* @throws JAXBException if an error occurred while enabling or disabling
* validation at unmarshal time
*/
public void setValidating(boolean validating) throws JAXBException {
this.validating = validating;
}
/** /**
* Return the current event handler or the default event handler if one * Return the current event handler or the default event handler if one
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -35,7 +35,6 @@ import java.net.URL; ...@@ -35,7 +35,6 @@ import java.net.URL;
* *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul>
* @see jakarta.xml.bind.Unmarshaller * @see jakarta.xml.bind.Unmarshaller
* @see jakarta.xml.bind.Validator
* @see jakarta.xml.bind.ValidationEventHandler * @see jakarta.xml.bind.ValidationEventHandler
* @since 1.6, JAXB 1.0 * @since 1.6, JAXB 1.0
*/ */
......
/* /*
* Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
* *
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at * terms of the Eclipse Distribution License v. 1.0, which is available at
...@@ -22,7 +22,6 @@ import jakarta.xml.bind.ValidationEventLocator; ...@@ -22,7 +22,6 @@ import jakarta.xml.bind.ValidationEventLocator;
* *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul> * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li></ul>
* @see jakarta.xml.bind.NotIdentifiableEvent * @see jakarta.xml.bind.NotIdentifiableEvent
* @see jakarta.xml.bind.Validator
* @see jakarta.xml.bind.ValidationEventHandler * @see jakarta.xml.bind.ValidationEventHandler
* @see jakarta.xml.bind.ValidationEvent * @see jakarta.xml.bind.ValidationEvent
* @see jakarta.xml.bind.ValidationEventLocator * @see jakarta.xml.bind.ValidationEventLocator
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment