<commit_before>/*
 * Copyright (c) 2012 <NAME>, <NAME>
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * <NAME> - initial API and implementation
 */
package prm4j.indexing.treebased.impl;

import prm4j.indexing.AbstractBaseMonitor;
import prm4j.indexing.treebased.MonitorSet;
import prm4j.indexing.treebased.Node;
import prm4j.indexing.treebased.NodeMap;
import prm4j.logic.NodeContext;

public class DefaultNode<A> implements Node<A> {

    private final NodeContext<A> nodeContext;
    private final MonitorSet<A>[] monitorSets;

    private NodeMap<A> nodeMap;
    private AbstractBaseMonitor<A> monitor;

    @SuppressWarnings("unchecked")
    public DefaultNode(NodeContext<A> nodeContext, int monitorSetCount) {
	super();
	this.nodeContext = nodeContext;
	this.monitorSets = new MonitorSet[monitorSetCount];
    }

    @Override
    public NodeContext<A> getNodeContext() {
	return nodeContext;
    }

    @Override
    public AbstractBaseMonitor<A> getMonitor() {
	return monitor;
    }

    @Override
    public void setMonitor(AbstractBaseMonitor<A> monitor) {
	this.monitor = monitor;
    }

    @Override
    public NodeMap<A> getNodeMap() {
	// lazy creation
	if (nodeMap == null) {
	    nodeMap = nodeContext.createNodeMap();
	}
	return nodeMap;
    }

    @Override
    public MonitorSet<A> getMonitorSet(int parameterSetId) {
	// lazy creation
	MonitorSet<A> monitorSet = monitorSets[parameterSetId];
	if (monitorSet == null) {
	    monitorSet = nodeContext.createMonitorSet();
	    monitorSets[parameterSetId] = monitorSet;
	}
	return monitorSet;
    }

    @Override
    public Node<A> next() {
	// TODO Auto-generated method stub
	return null;
    }

}<commit_msg>Implement NodePrototype interface<commit_after>/*
 * Copyright (c) 2012 <NAME>, <NAME>
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * <NAME> - initial API and implementation
 */
package prm4j.indexing.treebased.impl;

import prm4j.indexing.AbstractBaseMonitor;
import prm4j.indexing.treebased.MonitorSet;
import prm4j.indexing.treebased.Node;
import prm4j.indexing.treebased.NodeMap;
import prm4j.logic.NodeContext;
import prm4j.logic.NodePrototype;

public class DefaultNode<A> implements Node<A>, NodePrototype<A> {

    private final NodeContext<A> nodeContext;
    private final MonitorSet<A>[] monitorSets;

    private NodeMap<A> nodeMap;
    private AbstractBaseMonitor<A> monitor;

    @SuppressWarnings("unchecked")
    public DefaultNode(NodeContext<A> nodeContext, int monitorSetCount) {
	super();
	this.nodeContext = nodeContext;
	this.monitorSets = new MonitorSet[monitorSetCount];
    }

    @Override
    public NodeContext<A> getNodeContext() {
	return nodeContext;
    }

    @Override
    public AbstractBaseMonitor<A> getMonitor() {
	return monitor;
    }

    @Override
    public void setMonitor(AbstractBaseMonitor<A> monitor) {
	this.monitor = monitor;
    }

    @Override
    public NodeMap<A> getNodeMap() {
	// lazy creation
	if (nodeMap == null) {
	    nodeMap = nodeContext.createNodeMap();
	}
	return nodeMap;
    }

    @Override
    public MonitorSet<A> getMonitorSet(int parameterSetId) {
	// lazy creation
	MonitorSet<A> monitorSet = monitorSets[parameterSetId];
	if (monitorSet == null) {
	    monitorSet = nodeContext.createMonitorSet();
	    monitorSets[parameterSetId] = monitorSet;
	}
	return monitorSet;
    }

    @Override
    public Node<A> next() {
	// TODO Auto-generated method stub
	return null;
    }

    @Override
    @SuppressWarnings("unchecked")
    public Node<A> clonePrototype() {
	try {
	    return (Node<A>) this.clone();
	} catch (CloneNotSupportedException e) {
	    throw new IllegalStateException(e);
	}
    }

}
{'fraction_non_alphanumeric': 0.10226995362460337, 'fraction_numerical': 0.007078350012204052, 'mean_word_length': 3.9854014598540144, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3520755', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1249, 'n_words': 312}