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

org.jclarion.clarion.swing.gui.NetworkQueue Maven / Gradle / Ivy

package org.jclarion.clarion.swing.gui;

import org.jclarion.clarion.ClarionBool;
import org.jclarion.clarion.ClarionNumber;
import org.jclarion.clarion.ClarionObject;
import org.jclarion.clarion.ClarionQueue;
import org.jclarion.clarion.ClarionQueueEvent;
import org.jclarion.clarion.ClarionQueueListener;
import org.jclarion.clarion.ClarionString;

public class NetworkQueue implements ClarionQueueListener,NetworkMetaData
{
	private ClarionQueue queue;
	private boolean modified=true;
	private int colCount=0;
	
	public NetworkQueue(ClarionQueue queue)
	{
		this.queue=queue;
		queue.addListener(this);
		for (int scan=1;scan<=queue.getVariableCount();scan++) {
			ClarionObject o = queue.flatWhat(scan);
			if (o==null) break;
			colCount++;
		}
	}

	@Override
	public void queueModified(ClarionQueueEvent event) 
	{
		modified=true;
	}
	
	public boolean isModified() {
		return modified;
	}

	@Override
	public Object getMetaData() {
		if (!modified) return null;
		
		// encoding is:
		//   1 : colcount
		//   x : current buffer
		//   r : row data
		
		int rec = queue.records();
		
		int size = 1 + colCount*(1+rec);
		Object result[] = new Object[size];
		result[0]=colCount;
		for (int scan=1;scan<=colCount;scan++) {
			result[scan]=queue.flatWhat(scan);
		}
		for (int scan=1;scan<=rec;scan++) {
			ClarionObject co[] = queue.getRecord(scan);
			for (int c=0;cnew_records;scan--) {
			base.get(scan);
			base.delete();
		}
		return base;
	}
	
	public void dispose()
	{
		queue.removeListener(this);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy