The CZoo.java file contains completed method stubs for a user-defined interface named IZoo, as well as the Netscape Application Server-defined ITemplateData interface.
//
// This file is initially generated by KIDL - Edit as
// necessary to complete
//
package zoo.cZoo;
import com.kivasoft.*;
import com.kivasoft.types.*;
import com.kivasoft.util.*;
import zoo.*;
import java.util.*;
public class CZoo
implements zoo.IZoo, com.kivasoft.ITemplateData
{
public zoo.cZoo.CZooMgr m_Module;
protected String mName = null;
protected Vector mAnimalList = null;
protected Enumeration mAnimalEnumeration = null;
protected IAnimal mCurrentAnimal = null;
public CZoo(zoo.cZoo.CZooMgr module, String name)
{
m_Module=module;
mName = name;
mAnimalList = new Vector();
reset();
}
public void finalize()
{
}
public String getName()
{
return mName;
}
public void reset()
{
mAnimalEnumeration = mAnimalList.elements();
if (mAnimalEnumeration.hasMoreElements()) {
mCurrentAnimal = (IAnimal)
mAnimalEnumeration.nextElement();
}
}
// Method bodies for interface: IZoo
public zoo.IElephant addElephant(
java.lang.String name,
int id,
double trunkSize)
{
IElephant elephant = new CElephant(m_Module, name, id,
trunkSize);
mAnimalList.addElement(elephant);
return elephant;
}
public zoo.IPanda addPanda(
java.lang.String name,
int id,
int type)
{
IPanda panda = new CPanda(m_Module, name, id, type);
mAnimalList.addElement(panda);
return panda;
}
public zoo.IFrog addFrog(
java.lang.String name,
int id,
java.lang.String color)
{
IFrog frog = new CFrog(m_Module, name, id, color);
mAnimalList.addElement(frog);
return frog;
}
// Method bodies for interface: ITemplateData
public boolean isEmpty(
java.lang.String group)
{
// ignore group parameter, not using it
return !mAnimalEnumeration.hasMoreElements();
}
public int moveNext(
java.lang.String group)
{
// ignore group parameter, not using it
int retVal = -1;
if (mAnimalEnumeration.hasMoreElements()) {
mCurrentAnimal = (IAnimal)
mAnimalEnumeration.nextElement();
retVal = 0;
}
return retVal;
}
public com.kivasoft.IBuffer getValue(
java.lang.String szExpr)
{
String outString = "Error animal";
System.out.println("getValueString: " + szExpr);
if (mCurrentAnimal != null && szExpr != null) {
if (szExpr.equals("AnimalName")) {
outString = mCurrentAnimal.getName();
} else if (szExpr.equals("AnimalType")) {
if (mCurrentAnimal instanceof IElephant) {
outString = "Elephant";
} else if (mCurrentAnimal instanceof IPanda) {
outString = "Panda";
} else if (mCurrentAnimal instanceof IFrog) {
outString = "Frog";
}
} else if (szExpr.equals("AnimalId")) {
outString = mCurrentAnimal.getId() + "";
} else if (szExpr.equals("AnimalData")) {
if (mCurrentAnimal instanceof IElephant) {
IElephant elephant = (IElephant)
mCurrentAnimal;
outString = elephant.getTrunkSize() + "feet";
} else if (mCurrentAnimal instanceof IPanda) {
IPanda panda = (IPanda) mCurrentAnimal;
int type = panda.getType();
if (type == 0) {
outString = "Giant Panda";
} else {
outString = "Red Panda";
}
} else if (mCurrentAnimal instanceof IFrog) {
IFrog frog = (IFrog) mCurrentAnimal;
outString = frog.getColor();
}
} else if (szExpr.equals("ZooName")) {
outString = getName();
}
}
IBuffer buffer = GX.CreateBufferFromString(outString);
return buffer;
}
// We're not making use of this callback
public int setHint(
java.lang.String group,
int flags,
int max,
com.kivasoft.IValList pVal)
{
return 0;
}
}