org.exolab.castor.xml
Class ValidationContext

java.lang.Object
  extended by org.exolab.castor.xml.ValidationContext

public class ValidationContext
extends java.lang.Object

A class which can be used to hold validation information, used by the TypeValidator interface.

Version:
$Revision$ $Date: 2004-10-06 02:10:17 -0600 (Wed, 06 Oct 2004) $
Author:
Keith Visco

Constructor Summary
ValidationContext()
          Creates a new ValidationContext.
 
Method Summary
 void addID(java.lang.String id)
          Adds current ID (as seen during (un)marshalling) to the ID cache.
protected  void addValidated(java.lang.Object object)
          Adds the specified object to the cache of already validated objects.
 boolean checkIdRef(java.lang.String id)
          Checks an ID Reference, returning true if the provided ID is known.
 void cleanup()
          Life-cycle method for proper 'shutdown operations'.
 Configuration getConfiguration()
          Returns the Configuration to use during validation.
 XMLClassDescriptorResolver getResolver()
          Returns the ClassDescriptorResolver to use during validation.
 java.util.Set getUnresolvedIdRefs()
          Returns the Set of unresolved ID references.
 boolean isFailFast()
          Returns true if the validation process should fail upon first error encountered, otherwise the validation processs will attempt to validate as much as possible (even after the first error is encountered) and collect as many errors before either returning (no errors) or throwing a validationException containing the list of errors.
protected  boolean isValidated(java.lang.Object object)
          Checks whether an object has already been validated.
protected  void removeValidated(java.lang.Object object)
          Removes the specified object from the cache of already validated objects.
 void setConfiguration(Configuration config)
          Sets the Configuration used during validation.
 void setFailFast(boolean failFast)
          Sets the fail-fast flag.
 void setResolver(XMLClassDescriptorResolver resolver)
          Sets the ClassDescriptorResolver to use during validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationContext

public ValidationContext()
Creates a new ValidationContext.

Method Detail

getConfiguration

public Configuration getConfiguration()
Returns the Configuration to use during validation.

Returns:
the Configuration to use. Will never be null.

getResolver

public XMLClassDescriptorResolver getResolver()
Returns the ClassDescriptorResolver to use during validation.

Returns:
the ClassDescriptorResolver to use. May be null.

isFailFast

public boolean isFailFast()
Returns true if the validation process should fail upon first error encountered, otherwise the validation processs will attempt to validate as much as possible (even after the first error is encountered) and collect as many errors before either returning (no errors) or throwing a validationException containing the list of errors.

NOTE: DISABLING OF FAIL-FAST IS NOT YET ENABLED.

Returns:
true if fail-fast processing is enabled.

setConfiguration

public void setConfiguration(Configuration config)
Sets the Configuration used during validation.

Parameters:
config - the Configuration to use

setFailFast

public void setFailFast(boolean failFast)
Sets the fail-fast flag. Fail-fast is enabled by default. When fail-fast is enabled (default or by setting the flag to true) the validation process will throw an exception upon the first error encountered. When fail-fast is disabled (by setting the flag to false) the validation processs will attempt to validate even after the first error is encountered and collect as many errors before either returning (no errors) or throwing a validationException containing the list of errors.

NOTE: DISABLING FAIL-FAST IS NOT YET ENABLED.

Parameters:
failFast - a boolean that when true enables fail-fast validation, otherwise the validator will attempt to validate as much as it can reporting as many errors as possible before returning.

setResolver

public void setResolver(XMLClassDescriptorResolver resolver)
Sets the ClassDescriptorResolver to use during validation.

Parameters:
resolver - the ClassDescriptorResolver to use.

isValidated

protected boolean isValidated(java.lang.Object object)
Checks whether an object has already been validated.

Parameters:
object - The object for which the check should be performed
Returns:
True if the object specified has already been validated.

addValidated

protected void addValidated(java.lang.Object object)
Adds the specified object to the cache of already validated objects.

Parameters:
object - Object about to be validated.

removeValidated

protected void removeValidated(java.lang.Object object)
Removes the specified object from the cache of already validated objects.

Parameters:
object - The object to be removed from the cache.

addID

public void addID(java.lang.String id)
           throws ValidationException
Adds current ID (as seen during (un)marshalling) to the ID cache. If this ID was previously added to the Set of unresolved IDs, then remove it from that Set.

Parameters:
id - The current ID
Throws:
ValidationException - If an ID is used more than once.
See Also:
getUnresolvedIdRefs()

checkIdRef

public boolean checkIdRef(java.lang.String id)
Checks an ID Reference, returning true if the provided ID is known. If the provided ID is not known, it is added to the Set of unresolved ID references. Note that if this ID is later found, it will be removed from this Set.

Parameters:
id - The ID to check.
Returns:
true if the provided ID is known.
See Also:
getUnresolvedIdRefs()

getUnresolvedIdRefs

public java.util.Set getUnresolvedIdRefs()
Returns the Set of unresolved ID references. The Set returns is not modifiable, but is available to be used to list all unresolved references.

Returns:
the Set of unresolved ID references.

cleanup

public void cleanup()
Life-cycle method for proper 'shutdown operations'.



Intalio Inc. (C) 1999-2007. All rights reserved http://www.intalio.com