package kakibeans; import java.util.*; import java.sql.*; import kotkabeans.*; /** *

Title: StudyPlanGroup

*

Description: Class for groups in study plan structure. Group can have * other StudyPlanElements as its children. *

*

Copyright: Copyright (c) Kuikka-team GPL 2004

*

Company: University of Jyväskylä

*

Created: 19.4.2004

* @author Sami Kosonen * @version 1.0 */ public class StudyPlanGroup extends StudyPlanElement { // Attributes //attributes in database private float minCredits = 0; private int minCount = 0; private String courseMask = ""; //other attributes private Vector children = new Vector(); private boolean open = false; public StudyPlanGroup() { setAbility(StudyPlanElement.NOT_PLANNED_GROUP); } // Set-methods /** * Defines ability of this element. * These abilities are: * PLANNED_GROUP, NOT_PLANNED_GROUP. * @param abilityType the type of ability defined in this class */ protected void setAbility( int abilityType ) { switch (abilityType) { case (PLANNED_GROUP): setAbility(plannedGroup); break; case (NOT_PLANNED_GROUP): setAbility(notPlannedGroup); break; } } public void setMinCredits( float minCredits ) { if (minCredits < 0) return; this.minCredits = minCredits; } public void setMinCount( int minCount ) { if (minCount < 0) return; this.minCount = minCount; } public void setCourseMask( String courseMask ) { this.courseMask = courseMask; } /** * Defines if this node is open or not. * @param open true = open, false = closed */ public void setOpen( boolean open ) { this.open = open; } /** * Defines if element is included in plan or not. * Sets also ability if necessary. * @param planned if null, element is not included in plan. * If initialized, element is included in plan. */ public void setPlanned(PlannedElement planned) { super.setPlanned(planned); if (getPlanned() == null) { setAbility(StudyPlanElement.NOT_PLANNED_GROUP); } else { setAbility(StudyPlanElement.PLANNED_GROUP); } } // Get-methods public float getMinCredits() { return minCredits; } public int getMinCount() { return minCount; } public String getCourseMask() { return courseMask; } public boolean getOpen() { return open; } public Vector getChildren() { return children; } // Other methods /** * Adds one child under this group. * @param element new child */ public void add(StudyPlanElement element) { if (element == null) return; element.setParent(this); children.add(element); } /** * Removes one child from this group. * @param element child to be removed */ public void remove(StudyPlanElement element) { if (element == null) return; children.remove(element); } /** * @return iterator for children */ public Iterator iterator() { return children.iterator(); } }