001/*
002 * ModeShape (http://www.modeshape.org)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *       http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.modeshape.schematic.internal.schema;
017
018import org.modeshape.schematic.annotation.NotThreadSafe;
019import org.modeshape.schematic.document.JsonSchema;
020import org.modeshape.schematic.document.Path;
021
022/**
023 * An interface for recording problems.
024 * 
025 * @author Randall Hauch <rhauch@redhat.com> (C) 2011 Red Hat Inc.
026 */
027@NotThreadSafe
028public interface Problems {
029
030    /**
031     * Record a successful validation.
032     */
033    void recordSuccess();
034
035    /**
036     * Record an error at the given path in a document.
037     * 
038     * @param path the path; may not be null
039     * @param message the message describing the error; may not be null
040     */
041    void recordError( Path path,
042                      String message );
043
044    /**
045     * Record an error at the given path in a document.
046     * 
047     * @param path the path; may not be null
048     * @param message the message describing the error; may not be null
049     * @param exception the exception that occurred and that is considered the cause
050     */
051    void recordError( Path path,
052                      String message,
053                      Throwable exception );
054
055    /**
056     * Record a warning at the given path in a document.
057     * 
058     * @param path the path; may not be null
059     * @param message the message describing the warning; may not be null
060     */
061    void recordWarning( Path path,
062                        String message );
063
064    /**
065     * Record a field value was encountered whose type was not the expected type but could be converted to the expected type.
066     * 
067     * @param path the path; may not be null
068     * @param message the message describing the warning; may not be null
069     * @param actualType the actual type of the field value; may not be null
070     * @param actualValue the actual field value
071     * @param requiredType the expected type; may not be null
072     * @param convertedValue the converted value
073     */
074    void recordTypeMismatch( Path path,
075                             String message,
076                             JsonSchema.Type actualType,
077                             Object actualValue,
078                             JsonSchema.Type requiredType,
079                             Object convertedValue );
080
081}