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

org.semanticweb.yars.nx.parser.Callback Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
package org.semanticweb.yars.nx.parser;

import java.util.concurrent.atomic.AtomicInteger;

import org.semanticweb.yars.nx.Node;

public abstract class Callback {

	protected AtomicInteger _openDocuments = new AtomicInteger(0);

	public void startDocument() {
		startDocumentInternal();

		_openDocuments.incrementAndGet();
	}

	public void endDocument() {
		endDocumentInternal();

		int i = _openDocuments.decrementAndGet();
		if (i<0)
			throw new IllegalStateException("I don't have a document to end.");
	}

	public void processStatement(Node[] nx) {
		if (_openDocuments.get()<1)
			throw new IllegalStateException("I don't have a document to write to.");
		else
			processStatementInternal(nx);
	}

	abstract protected void startDocumentInternal();

	abstract protected void endDocumentInternal();

	abstract protected void processStatementInternal(Node[] nx);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy