001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.validation.routines;
003
004/**
005 * Abstract validator superclass to extend Apache Validator routines.
006 * @since 7489
007 */
008public abstract class AbstractValidator {
009
010    private String errorMessage;
011    private String fix;
012
013    /**
014     * Tests validity of a given value.
015     * @param value Value to test
016     * @return {@code true} if value is valid, {@code false} otherwise
017     */
018    public abstract boolean isValid(String value);
019
020    /**
021     * Replies the error message.
022     * @return the errorMessage
023     */
024    public final String getErrorMessage() {
025        return errorMessage;
026    }
027
028    /**
029     * Sets the error message.
030     * @param errorMessage the errorMessage
031     */
032    protected final void setErrorMessage(String errorMessage) {
033        this.errorMessage = errorMessage;
034    }
035
036    /**
037     * Replies the fixed value, if any.
038     * @return the fixed value or {@code null}
039     */
040    public final String getFix() {
041        return fix;
042    }
043
044    /**
045     * Sets the fixed value.
046     * @param fix the fixed value, if any
047     */
048    protected final void setFix(String fix) {
049        this.fix = fix;
050    }
051}