001    package org.gwtbootstrap3.client.ui.form.error;
002    
003    /*
004     * #%L
005     * GwtBootstrap3
006     * %%
007     * Copyright (C) 2015 GwtBootstrap3
008     * %%
009     * Licensed under the Apache License, Version 2.0 (the "License");
010     * you may not use this file except in compliance with the License.
011     * You may obtain a copy of the License at
012     * 
013     *      http://www.apache.org/licenses/LICENSE-2.0
014     * 
015     * Unless required by applicable law or agreed to in writing, software
016     * distributed under the License is distributed on an "AS IS" BASIS,
017     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018     * See the License for the specific language governing permissions and
019     * limitations under the License.
020     * #L%
021     */
022    
023    import com.google.gwt.editor.client.Editor;
024    import com.google.gwt.editor.client.EditorError;
025    
026    /**
027     * Basic {@link EditorError} implementation.
028     */
029    public class BasicEditorError implements EditorError {
030    
031        protected boolean consumed = false;
032    
033        protected Editor<?> editor = null;
034    
035        protected String message = null;
036    
037        protected Object value = null;
038    
039        /**
040         * Create an new error.
041         *
042         * @param editor the editor
043         * @param value the value
044         * @param message the message
045         */
046        public BasicEditorError(Editor<?> editor, Object value, String message) {
047            this.editor = editor;
048            this.value = value;
049            this.message = message;
050        }
051    
052        /** {@inheritDoc} */
053        @Override
054        public String getAbsolutePath() {
055            return null;
056        }
057    
058        /** {@inheritDoc} */
059        @Override
060        public Editor<?> getEditor() {
061            return editor;
062        }
063    
064        /** {@inheritDoc} */
065        @Override
066        public String getMessage() {
067            // TODO We may need to format the message using MessageFormat.
068            return message;
069        }
070    
071        /** {@inheritDoc} */
072        @Override
073        public String getPath() {
074            return null;
075        }
076    
077        /** {@inheritDoc} */
078        @Override
079        public Object getUserData() {
080            return null;
081        }
082    
083        /** {@inheritDoc} */
084        @Override
085        public Object getValue() {
086            return value;
087        }
088    
089        /** {@inheritDoc} */
090        @Override
091        public boolean isConsumed() {
092            return consumed;
093        }
094    
095        /** {@inheritDoc} */
096        @Override
097        public void setConsumed(boolean consumed) {
098            this.consumed = consumed;
099        }
100    
101    }