public void remove() { if (prevEvent != null) { prevEvent.setNextEvent(nextEvent); } if (nextEvent != null) { nextEvent.setPrevEvent(prevEvent); } }
public void addEvent(String eventNameX, DateTime endTimeX) { /* * Three Conditions * First Event == null - No Events - firstEvent = New Path * First Event.getNext() == null - One Event - firstEvent.getNext().setNext(New Event) * First Event.getNext() != null - > Two Events - find last and assign */ if (firstEvent == null) { eventNode newEvent = new eventNode(eventNameX, endTimeX); firstEvent = newEvent; M.debug("New Event Created, assigned to firstEvent"); } else if (firstEvent.getNextEvent() == null) { eventNode newEvent = new eventNode(eventNameX, endTimeX); firstEvent.setNextEvent(newEvent); //firstEvent.next = newPath newEvent.setPrevEvent(firstEvent); M.debug("New Event Created, registered as second Event created"); } else { ES = firstEvent; while (ES.getNextEvent() != null) { //Find last path ES = ES.getNextEvent(); } eventNode newPath = new eventNode(eventNameX, endTimeX); ES.setNextEvent(newPath); //lastPath.next = newPath newPath.setPrevEvent(ES); //newPath.last = lastPath M.debug("Event created, Unkown Event possiton, Prev/Next Event values assigned accordingly"); } }
public void removeEvent(eventNode remove) { /* * The getters for pathNodes are not build to not return null, meaning if you try and call a method like * remove.getNext().setNext(null) but remove.getNext() is null it will hard error */ if (remove == firstEvent) //If the path to remove is the first path, you simple need to re-assign first path. { if (remove.getNextEvent() == null) //Program will error out w/o these error checks { firstEvent = null; } else { firstEvent = remove.getNextEvent(); firstEvent.setPrevEvent(null); } } else if (remove == firstEvent.getNextEvent()) /* * This is a simi-redundent case * This could be handled with the else statment * however I like handling this case seperatly I don't know why * Anyt thing I mess with anything to do with firstEvent, I like to call it Directly */ { if (remove.getNextEvent() == null) { firstEvent.setNextEvent(null); remove.setPrevEvent(null); //This is a redudent clean up that I like to do, it is not necissary } else { firstEvent.setNextEvent(remove.getNextEvent()); remove.getNextEvent().setPrevEvent(firstEvent); remove.setNextEvent(null); remove.setPrevEvent(null); } } else { if (remove.getNextEvent() == null) { remove.getPrevEvent().setNextEvent(null); remove.setNextEvent(null); } else { remove.getPrevEvent().setNextEvent(remove.getNextEvent()); remove.getNextEvent().setPrevEvent(remove.getPrevEvent()); remove.setNextEvent(null); remove.setPrevEvent(null); } } }