org.exolab.castor.xml

Class 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(String id)
Adds current ID (as seen during (un)marshalling) to the ID cache.
protected void
addValidated(Object object)
Adds the specified object to the cache of already validated objects.
boolean
checkIdRef(String id)
Checks an ID Reference, returning true if the provided ID is known.
void
cleanup()
Life-cycle method for proper 'shutdown operations'.
XMLClassDescriptorResolver
getClassDescriptorResolver()
Returns the ClassDescriptorResolver to use during validation.
InternalContext
getInternalContext()
To get the AbstractInternalContext to use.
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(Object object)
Checks whether an object has already been validated.
protected void
removeValidated(Object object)
Removes the specified object from the cache of already validated objects.
void
setFailFast(boolean failFast)
Sets the fail-fast flag.
void
setInternalContext(InternalContext internalContext)
To set which AbstractInternalContext should be used.

Constructor Details

ValidationContext

public ValidationContext()
Creates a new ValidationContext.

Method Details

addID

public void addID(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.

addValidated

protected void addValidated(Object object)
Adds the specified object to the cache of already validated objects.
Parameters:
object - Object about to be validated.

checkIdRef

public boolean checkIdRef(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.

cleanup

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

getClassDescriptorResolver

public XMLClassDescriptorResolver getClassDescriptorResolver()
Returns the ClassDescriptorResolver to use during validation.
Returns:
the ClassDescriptorResolver to use. May be null.

getInternalContext

public InternalContext getInternalContext()
To get the AbstractInternalContext to use.
Returns:
the AbstractInternalContext?to use

getUnresolvedIdRefs

public 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.

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.

isValidated

protected boolean isValidated(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.

removeValidated

protected void removeValidated(Object object)
Removes the specified object from the cache of already validated objects.
Parameters:
object - The object to be removed from the cache.

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.

setInternalContext

public void setInternalContext(InternalContext internalContext)
To set which AbstractInternalContext should be used.
Parameters:
internalContext - the AbstractInternalContext to use

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