All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpmml.model.visitors.MarkupInspector Maven / Gradle / Ivy

There is a newer version: 1.6.6
Show newest version
/*
 * Copyright (c) 2015 Villu Ruusmann
 */
package org.jpmml.model.visitors;

import java.util.ArrayList;
import java.util.List;

import org.dmg.pmml.Visitable;
import org.jpmml.model.MarkupException;

/**
 * 

* This class provides a skeletal implementation of class model inspectors. *

* *

* Unlike evaluation, which takes place in "dynamic mode", the inspection takes place in "static mode". * The inspector performs the full traversal of the specified class model object. * Every problematic PMML element or attribute is reported in the form of an appropriate {@link MarkupException} instance. * The class model object can be considered safe and sound if the {@link #getExceptions() list of exceptions} stays empty. *

* * Typical usage: *
 * static
 * public <E extends MarkupException> void inspect(MarkupInspector<E> inspector){
 *   Visitable visitable = ...;
 *
 *   try {
 *     inspector.applyTo(visitable);
 *   } catch(MarkupException me){
 *     List<E> exceptions = inspector.getException();
 *   }
 * }
 * 
*/ abstract public class MarkupInspector extends AbstractVisitor { private List exceptions = new ArrayList<>(); /** * @throws E The first element of the {@link #getExceptions() list of Exceptions} if this list is not empty. */ @Override public void applyTo(Visitable visitable){ super.applyTo(visitable); List exceptions = getExceptions(); if(!exceptions.isEmpty()){ throw exceptions.get(0); } } protected void report(E exception){ this.exceptions.add(exception); } public List getExceptions(){ return this.exceptions; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy