prefixes.push (prefix); if (ff.is_list) { listFormats.push (listFormat); listFormat = new ListFormat(); listFormat.name = prefix + fieldname; listFormat.type = ff.datatype; listFormat.hasObjects = ff.is_subobject; listFormat.object = object; object.addListField (listFormat.name); objects.push (object); object = null; prefix = ""; } else if (ff.is_subobject) { prefix = prefix + fieldname + "."; } else { object.addField (prefix + fieldname, ff.datatype, atts.getValue ("value"), ff.is_key, false); if (ff.is_key && (object instanceof Task)) { if (doingDeleted) removeTask (((Task) object).getKey()); else if (doingChanged) replaceTask ((Task) object); else if (doingNew) addTask ((Task) object); } if (ff.is_key && (object instanceof Resource)) { if (doingDeleted) removeResource (((Resource) object).getKey()); else if (doingChanged) replaceResource ((Resource) object); else if (doingNew) addResource ((Resource) object); } if (predefined != null) predefined.addField (fieldname, ff.datatype, atts.getValue ("value"), false, false); } } catch (NullPointerException npe) { throw new RuntimeException ("ERROR : SchedulingData.startElement - No object format for type " + objectType); }
prefixes.push (prefix); if (ff.is_list) { listFormats.push (listFormat); listFormat = new ListFormat(); listFormat.name = prefix + fieldname; listFormat.type = ff.datatype; listFormat.hasObjects = ff.is_subobject; listFormat.object = object; object.addListField (listFormat.name); objects.push (object); object = null; prefix = ""; } else if (ff.is_subobject) { prefix = prefix + fieldname + "."; } else { object.addField (prefix + fieldname, ff.datatype, atts.getValue ("value"), ff.is_key, false); if (ff.is_key && (object instanceof Task)) { if (doingDeleted) removeTask (((Task) object).getKey()); else if (doingChanged) replaceTask ((Task) object); else if (doingNew) addTask ((Task) object); } if (ff.is_key && (object instanceof Resource)) { if (doingDeleted) removeResource (((Resource) object).getKey()); else if (doingChanged) replaceResource ((Resource) object); else if (doingNew) addResource ((Resource) object); } if (predefined != null) predefined.addField (fieldname, ff.datatype, atts.getValue ("value"), false, false); } } catch (NullPointerException npe) { npe.printStackTrace (); throw new RuntimeException ("ERROR : SchedulingData.startElement - No object format for type " + objectType); }
    public void startElement (String uri, String local,                              String name, Attributes atts) {      if (name.equals ("FIELD")) {        fieldname = atts.getValue ("name");		Map fieldsForObject = (Map) formats.get (objectType);		try {		  FieldFormat ff = (FieldFormat) fieldsForObject.get (fieldname);		  if (ff == null) {			if (throwExceptionOnMissingField) {			  throw new RuntimeException ("Undefined field named " +										  fieldname + " for object type " +										  objectType);			}			else {			  if (debug)				System.out.println ("SchedulingData.startElement - NOTE : " +									"found undefined field " + fieldname +									" for object type " + objectType +									". Ignoring.");			  prefixes.push (prefix);			  return;			}		  }		  prefixes.push (prefix);		  if (ff.is_list) {			listFormats.push (listFormat);			listFormat = new ListFormat();			listFormat.name = prefix + fieldname;			listFormat.type = ff.datatype;			listFormat.hasObjects = ff.is_subobject;			listFormat.object = object;			object.addListField (listFormat.name);			objects.push (object);			object = null;			prefix = "";		  }		  else if (ff.is_subobject) {			prefix = prefix + fieldname + ".";		  }		  else {			object.addField (prefix + fieldname, ff.datatype,							 atts.getValue ("value"), ff.is_key, false);			if (ff.is_key && (object instanceof Task)) {			  if (doingDeleted)				removeTask (((Task) object).getKey());			  else if (doingChanged)				replaceTask ((Task) object);			  else if (doingNew)				addTask ((Task) object);			}			if (ff.is_key && (object instanceof Resource)) {			  if (doingDeleted)				removeResource (((Resource) object).getKey());			  else if (doingChanged)				replaceResource ((Resource) object);			  else if (doingNew)				addResource ((Resource) object);			}			if (predefined != null)			  predefined.addField (fieldname, ff.datatype,								   atts.getValue ("value"), false, false);		  }		} catch (NullPointerException npe) {		  throw new RuntimeException ("ERROR : SchedulingData.startElement - No object format for type " +									  objectType);		}      }      else if (name.equals ("OBJECT")) {        objectTypes.push (objectType);        objectType = atts.getValue ("type");        if ((object != null) && predefinedTypes.contains (objectType)) {          predefined = new SchObject (timeOps);          object.addField (((String) prefixes.peek()) + fieldname,                           objectType, predefined, false, false);        }        objects.push (object);        if (objectType.equals (taskObject))          object = new Task (timeOps);        else if (objectType.equals (resourceObject))          object = new Resource (timeOps);        else if (object == null) {          object = new SchObject (timeOps);          if (listFormat != null) {            listFormat.object.addField (listFormat.name, listFormat.type,                                        object, false, true);          }        }        if (globalName != null) {          if (doingDeleted || doingChanged)            removeGlobal (globalName);          if (doingNew || doingChanged)            addGlobal (globalName, objectType, object);          globalName = null;        }      }      else if (name.equals ("VALUE")) {        if (listFormat != null) {          if (! listFormat.hasObjects) {            listFormat.object.addField (listFormat.name, listFormat.type,                                        atts.getValue ("value"), false, true);          }        }        else if (debug)          System.out.println ("SchedulingData.startElement - expecting " +                              "listFormat to be set when hit VALUE tag.");      }      else if (name.equals ("FIELDFORMAT")) {        FieldFormat ff = new FieldFormat          (atts.getValue ("datatype"),           atts.getValue ("is_key").equals ("true"),           atts.getValue ("is_subobject").equals ("true"),           atts.getValue ("is_list").equals ("true"));        if (ff.datatype.startsWith ("string"))          ff.datatype = "string";        currentFormat.put (atts.getValue ("name"), ff);      }      else if (name.equals ("OBJECTFORMAT")) {        currentFormat = new HashMap();        formats.put (atts.getValue ("name"), currentFormat);        if ((taskObject == null) &&            atts.getValue ("is_task").equals ("true"))          taskObject = atts.getValue ("name");        if ((resourceObject == null) &&            atts.getValue ("is_resource").equals ("true"))          resourceObject = atts.getValue ("name");      }      else if (name.equals ("GLOBAL")) {        globalName = atts.getValue ("name");      }      else if (name.equals ("WINDOW")) {        startTime = timeOps.stringToTime (atts.getValue ("starttime"));        if (atts.getValue ("endtime") != null)          endTime = timeOps.stringToTime (atts.getValue ("endtime"));      }      else if (name.equals ("NEWOBJECTS")) {        doingNew = true;      }      else if (name.equals ("CHANGEDOBJECTS")) {        doingChanged = true;      }      else if (name.equals ("DELETEDOBJECTS")) {        doingDeleted = true;      }      else if (name.equals ("CLEARDATABASE")) {        Task[] tasks = getTasks();        for (int i = 0; i < tasks.length; i++)          removeTask (tasks[i].getKey());        Resource[] resources = getResources();        for (int i = 0; i < resources.length; i++)          removeResource (resources[i].getKey());        globals.clear();        globalTypes.clear();      }      else if (name.equals ("FREEZE")) {        freezeTask (atts.getValue ("task"), atts.getValue ("resource"),                    atts.getValue ("start"), atts.getValue ("end"));      }      else if (name.equals ("UNFREEZE")) {        unfreezeTask (atts.getValue ("task"));      }      else if (name.equals ("FREEZEALL")) {        Task[] tasks = getTasks();        for (int i = 0; i < tasks.length; i++)          freezeTask (tasks[i].getKey(), null, null, null);      }      else if (name.equals ("UNFREEZEALL")) {        Task[] tasks = getTasks();        for (int i = 0; i < tasks.length; i++)          unfreezeTask (tasks[i].getKey());      }    }