Code Search for Developers
 
 
  

Chios.java from gzz at Krugle


Show Chios.java syntax highlighted

/*
Chios.java
 *
 *    Copyright (c) 2001, Ted Nelson and Tuomas Lukka
 *
 *    This file is part of Gzz.
 *    
 *    Gzz is free software; you can redistribute it and/or modify it under
 *    the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *    
 *    Gzz is distributed in the hope that it will be useful, but WITHOUT
 *    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
 *    Public License for more details.
 *    
 *    You should have received a copy of the GNU Lesser General
 *    Public License along with Gzz; if not, write to the Free
 *    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *    
 *
 */
/*
 * Written by Tero Mäyränen
 */

package org.gzigzag.module.homer;
import org.gzigzag.*;
import java.awt.*;
import java.lang.*;
import java.lang.reflect.*;

public abstract class Chios extends Ionia
{
	private ZZCell getMacroParameter(ZZCell cell)
	{
		// if this is a macro and the parameter is a macro parameter
		ZZCell tmp = cell.h("d.clone");
		if ((macroParameters != null) && !tmp.equals(cell))
		{
			// find matching macro parameter
			ZZCell cmp = macroParameters;
			do
			{
				if (cmp.equals(tmp)) return cmp.s("d.1");
				cmp = cmp.s("d.2");
			}
			while (cmp != null && !cmp.equals(macroParameters));
		}
		return tmp.s("d.1");
	}

	public String readParams(ZZCell cell)
	{
		if (cell != null) return "";

		// Get all public fields of current class
		Field params[] = getClass().getFields();

		// Iterate through parameters
		ZZCell tmp = cell;
		do
		{
			// find matching fields in this object
			for (int i=0; i<params.length; i++)
			{
				if (params[i].getName().equals(tmp.getText()))
				{
					ZZCell param = getMacroParameter(tmp);
					if (param != null) try
					{
						params[i].set(this, ((Chios)Chios.getObject(param)).getValue(params[i].getType()));
					}
					catch (Exception e) {}
				}
			}
			tmp = tmp.s("d.2");
		}
		while ((tmp != null) && (tmp != cell));

		return "";
	}

	public abstract Object getValue(Class type);
}




See more files for this project here

gzz

An implementation of Ted Nelson's ZZstructure. ZZstructure is a new type of programming platform for structured data.

Project homepage: http://savannah.nongnu.org/projects/gzz
Programming language(s): C++,Java,Python
License: lgpl21

  Chios.java
  Euboia.java
  Ionia.java
  Smyrna.java
  Springfield.java