package jas2.jds.module;

import java.io.*;  // describes FilenameFilter interface
import jas2.jds.interfaces.*;
import java.util.*;
import jas2.util.tree.*;
import hepjas.analysis.*;

public abstract class BasicServer implements FilenameFilter, DIM2
{
	private String directory;
	private String fileExtension;
	private String title;
	private Vector dataSetList;

	public BasicServer(String args[], String title, String fileExtension)
	{
		directory = ".";
		this.fileExtension = fileExtension;
		this.title = title;

		if (args.length > 0) this.title = args[0];
		if (args.length > 1) this.directory = args[1];
		if (args.length > 2) this.fileExtension = args[2];
		if (args.length > 3) throw new RuntimeException("Too many arguments passed to server");
	}

	public boolean accept(File dir, String name)
	{
		if (new File(dir,name).isDirectory())
		{
			TreeItem item = new TreeItem();
			item.path = new String[1];
			item.path[0] = name;
			item.flags = item.HAS_SUB_ITEMS;
			dataSetList.addElement(item);
		}
		else if (fileExtension == null || name.endsWith("." + fileExtension))
		{
			TreeItem item = new TreeItem();
			item.path = new String[1];
			item.path[0] = name;
			dataSetList.addElement(item);
		}
		return true;
	}
	public TreeItem[] getDataSets(TreeItem base)
	{
		dataSetList = new Vector();
		File dir = new File(directory);
		for (int i=0; i 

Ads help maintain this website.