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

org.dmg.pmml.adapters.NodeAdapter Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version
/*
 * Copyright (c) 2019 Villu Ruusmann
 */
package org.dmg.pmml.adapters;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import org.dmg.pmml.tree.ComplexNode;
import org.dmg.pmml.tree.DefaultNodeTransformer;
import org.dmg.pmml.tree.Node;
import org.dmg.pmml.tree.NodeTransformer;

public class NodeAdapter extends XmlAdapter {

	@Override
	public Node unmarshal(ComplexNode value){
		NodeTransformer nodeTransformer = NodeAdapter.NODE_TRANSFORMER_PROVIDER.get();

		return nodeTransformer.fromComplexNode(value);
	}

	@Override
	public ComplexNode marshal(Node node){
		NodeTransformer nodeTransformer = NodeAdapter.NODE_TRANSFORMER_PROVIDER.get();

		return nodeTransformer.toComplexNode(node);
	}

	public static final ThreadLocal NODE_TRANSFORMER_PROVIDER = new ThreadLocal(){

		@Override
		protected NodeTransformer initialValue(){
			return DefaultNodeTransformer.INSTANCE;
		}
	};
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy