nz.co.senanque.validationengine.ValidationEngine Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of madura-objects Show documentation
Show all versions of madura-objects Show documentation
This is essentially a JAXB/XJC plugin that adds automatic validation to the generated Java classes.
You define business objects in an XSD file, pass it through XJC and the plugin will add the validation code.
It uses information in the XSD to pick up validation, and you can specify extensions to that in the XSD. The resulting
Java classes check for validity when the setter is called and they reject attempts to set invalid values (this is a difference from other validation frameworks). The Java classes also expose a metadata interface to make it easy for UIs to generate, say, lists of options for a select box.
The validation framework handles single field validation but you can inject a rule engine (or several) to handle cross field validation.
But to any Java code the objects still look like ordinary Java beans. The surrounding application is unaware that they are anything different until they throw an exception. This makes it easy to use with frameworks that expect Java beans, and most of them do.
/*******************************************************************************
* Copyright (c)2014 Prometheus Consulting
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package nz.co.senanque.validationengine;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.springframework.context.MessageSource;
import nz.co.senanque.validationengine.metadata.ClassMetadata;
/**
* Validation engines all implement this
*
* @author Roger Parkinson
* @version $Revision: 1.12 $
*/
public interface ValidationEngine
{
boolean clean(ValidationObject object);
void set(ValidationObject object, String name, Object newValue, Object currentValue, ValidationSession validationSession) throws ValidationException;
Map add(ListeningArray object, ValidationObject newValue, ValidationSession validationSession) throws ValidationException;
ClassMetadata getClassMetadata(Class> clazz);
Map bind(ValidationObject object, ValidationSession session, ValidationObject owner);
void removedFrom(ListeningArray> array, ValidationObject o, ValidationSession session);
void unbind(ValidationSession session, ProxyField proxyField, ValidationObject validationObject, Map boundMap);
Map addAll(ListeningArray listeningArray,
List o, ValidationSession validationSession);
ValidationSession createSession();
void close(ValidationSession validationSession);
MessageSource getMessageSource();
ValidationSession createSession(Locale locale);
void unbindAll(ValidationSession session, Map boundMap);
String getStats(ValidationSession session);
String getIdentifier();
long getCurrentTime();
T getPlugin(Class clazz);
void invokeListeners(ValidationObject object, String fieldName,
Object newValue, Object currentValue,
ValidationSession validationSession);
void addListener(ValidationObject object, String name, ValidationSession session, SetterListener listener);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy