Top Description Fields Constructors Methods
net.synedra.validatorfx

public Class Validator

extends Object
Class Inheritance
Imports
java.util.Arrays, .HashSet, .LinkedHashMap, .Map, .Set, javafx.beans.binding.Bindings, .StringBinding, javafx.beans.property.ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, javafx.beans.value.ChangeListener

A Validator collects several checks and sums up their ValidationResults.
Author
[email protected]

Field Summary

Modifier and TypeField and Description
private Map<Check, ChangeListener<ValidationResult>>
private ReadOnlyBooleanWrapper
private ReadOnlyBooleanWrapper
private ReadOnlyObjectWrapper<ValidationResult>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(Check
The check to add.
check
)

Add another check to the checker.

public void
clear()

Clear all validations (i.e. remove decorations an clear validations result.

public boolean
public ReadOnlyBooleanProperty
containsErrorsProperty()

A read-only boolean property indicating whether any of the checks of this validator emitted an error.

public boolean
public ReadOnlyBooleanProperty
containsWarningsProperty()

A read-only boolean property indicating whether any of the checks of this validator emitted a warning.

public Check

Returns:

A check object whose dependsOn, decorates, etc. methods can be called
createCheck
()

Create a check that lives within this checker's domain.

public StringBinding
createStringBinding()

Create a string property that depends on the validation result.

public StringBinding
createStringBinding(String
The string to prefix each validation message with
prefix
,
String
The string to separate consecutive validation messages with
separator
,
Severity...
The severities to consider; If none is given, only Severity.ERROR will be considered
severities
)

Create a string property that depends on the validation result.

public void
explicit()

Set all checks (that are currently added to the validator) to explicit mode.

public ValidationResult

Returns:

validation result
getValidationResult
()

Retrieves current validation result

public void
immediate()

Set all checks (that are currently added to the validator) to immediate mode.

public void
immediateClear()

Set all checks (that are currently added to the validator) to immediate clear mode.

private void
public void
remove(Check
The check to remove from this validator.
check
)

Removes a check from this validator.

public boolean

Returns:

true if no errors were found, false otherwise
validate
()

Run all checks (decorating nodes if appropriate)

public ReadOnlyObjectProperty<ValidationResult>

Returns:

The Validation result property.
validationResultProperty
()

Can be used to track validation result changes

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checksback to summary
private Map<Check, ChangeListener<ValidationResult>> checks
containsErrorsPropertyback to summary
private ReadOnlyBooleanWrapper containsErrorsProperty
containsWarningsPropertyback to summary
private ReadOnlyBooleanWrapper containsWarningsProperty
validationResultPropertyback to summary
private ReadOnlyObjectWrapper<ValidationResult> validationResultProperty

Constructor Detail

Validatorback to summary
public Validator()

Method Detail

addback to summary
public void add(Check check)

Add another check to the checker. Changes in the check's validationResultProperty will be reflected in the checker.

Parameters
check:Check

The check to add.

clearback to summary
public void clear()

Clear all validations (i.e. remove decorations an clear validations result.

containsErrorsback to summary
public boolean containsErrors()
containsErrorsPropertyback to summary
public ReadOnlyBooleanProperty containsErrorsProperty()

A read-only boolean property indicating whether any of the checks of this validator emitted an error.

containsWarningsback to summary
public boolean containsWarnings()
containsWarningsPropertyback to summary
public ReadOnlyBooleanProperty containsWarningsProperty()

A read-only boolean property indicating whether any of the checks of this validator emitted a warning.

createCheckback to summary
public Check createCheck()

Create a check that lives within this checker's domain.

Returns:Check

A check object whose dependsOn, decorates, etc. methods can be called

createStringBindingback to summary
public StringBinding createStringBinding()

Create a string property that depends on the validation result. Each error message will be displayed on a separate line prefixed with a bullet.

createStringBindingback to summary
public StringBinding createStringBinding(String prefix, String separator, Severity... severities)

Create a string property that depends on the validation result.

Parameters
prefix:String

The string to prefix each validation message with

separator:String

The string to separate consecutive validation messages with

severities:Severity[]

The severities to consider; If none is given, only Severity.ERROR will be considered

explicitback to summary
public void explicit()

Set all checks (that are currently added to the validator) to explicit mode.

getValidationResultback to summary
public ValidationResult getValidationResult()

Retrieves current validation result

Returns:ValidationResult

validation result

immediateback to summary
public void immediate()

Set all checks (that are currently added to the validator) to immediate mode.

immediateClearback to summary
public void immediateClear()

Set all checks (that are currently added to the validator) to immediate clear mode.

refreshPropertiesback to summary
private void refreshProperties()
removeback to summary
public void remove(Check check)

Removes a check from this validator.

Parameters
check:Check

The check to remove from this validator.

validateback to summary
public boolean validate()

Run all checks (decorating nodes if appropriate)

Returns:boolean

true if no errors were found, false otherwise

validationResultPropertyback to summary
public ReadOnlyObjectProperty<ValidationResult> validationResultProperty()

Can be used to track validation result changes

Returns:ReadOnlyObjectProperty<ValidationResult>

The Validation result property.