|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfable.adt.FableComponent
public abstract class FableComponent
This class is a basic type that all components in the ADT will extend. This type supports common behavior among Article, Feed, and Folder. Also, this type enables basic tree structure operations.
Constructor Summary | |
---|---|
protected |
FableComponent()
Constructs a new FableComponent object. |
protected |
FableComponent(java.util.Date date)
Contstructs a new FableComponent with provided UID and date. |
Method Summary | |
---|---|
abstract void |
accept(FableVisitor v)
Accept the visitor v to visit this. |
abstract void |
acceptRecursive(FableVisitor v)
Accept the visitor v to visit this, and recurse on children of this. |
boolean |
activate()
Activates it to the GUI |
boolean |
addChild(FableComponent fc)
Add c as a child of this (optional operation). |
void |
addStructuralChangeListener(StructuralChangeListener scl)
Add a listener for structural change of ADT to this. |
java.util.List<FableComponent> |
getChildren()
Returns a list of children of this. |
java.util.Date |
getDate()
Returns the creation date of this. |
java.util.List<FableComponent> |
getDescendants()
Returns a list of descendants of this. |
FableComponent |
getParent()
Returns the parent of this. |
int |
getPosition()
Returns a position of this FableComponent in its parent's list of children. |
java.lang.String |
getTitle()
Returns the title of this. |
boolean |
isAncestorOf(FableComponent fc)
Checks if this component is an Ancestor of a given component |
abstract boolean |
isSimilarTo(FableComponent fc)
Returns true if this and fc is similar. |
boolean |
moveDown()
Increase an index of this in the parent's list of children. |
boolean |
moveUp()
Decrease an index of this in the parent's list of children. |
void |
removeAllListeners()
Removes all the listeners associated with this FableComponent. |
boolean |
removeChild(FableComponent fc)
Remove c from the children of this. |
void |
removeStructuralChangeListener(StructuralChangeListener scl)
Remove a listener for structural change of ADT from this. |
boolean |
setParent(FableComponent fc)
Set the parent of this as provided FableComponent (optional operation). |
void |
setPosition(int index)
Set its position in the parent's list of children as index. |
void |
setTitle(java.lang.String t)
Set the title of this to the string t. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected FableComponent()
protected FableComponent(java.util.Date date)
java.lang.NullPointerException
- if date is null.Method Detail |
---|
public boolean activate()
public abstract boolean isSimilarTo(FableComponent fc)
fc
- FableComponent object to compare.
public final java.util.List<FableComponent> getChildren()
FableContainer
getChildren
in interface FableContainer
public final java.util.List<FableComponent> getDescendants()
public final java.util.Date getDate()
public final java.lang.String getTitle()
public final FableComponent getParent()
public final int getPosition()
public void setTitle(java.lang.String t)
t
- a string to be the title of this.
java.lang.UnsupportedOperationException
- if setTitle method is not supported
by this. (e.g. Article)
java.lang.NullPointerException
- if t is null.public final void setPosition(int index)
When provided with negative index or index equal to or greater than the number of children of the parent, it will throw IndexOutOfBoundException.
index
-
java.lang.IllegalArgumentException
- if index less than 0 or index equals to
or greater than number of children of the parent.public final boolean setParent(FableComponent fc)
Also, when this is one of the ancestors of fc, it will return false and the structure of tree won't change.
fc
- a FableComponent to be a new parent of this.
public final boolean isAncestorOf(FableComponent fc)
fc
- FableComponent to check if this particular component is ancestor ofpublic boolean addChild(FableComponent fc)
FableContainer
FableContainers inheriting this method can impose their own restrictions. For example, Feed may accept only Article as a child. This restrictions should be clearly documented in the specification.
One extreme example of restriction is Article, which bounces any FableComponents.
addChild
in interface FableContainer
fc
- a child to be added.
public final void addStructuralChangeListener(StructuralChangeListener scl)
scl
- a listener to be added to this.
java.lang.NullPointerException
- if scl is null.public final boolean removeChild(FableComponent fc)
FableContainer
removeChild
in interface FableContainer
fc
- A child to remove from this.
public final void removeStructuralChangeListener(StructuralChangeListener scl)
scl
- a listener to be removed from this.
java.lang.NullPointerException
- if scl is null.public void removeAllListeners()
public abstract void accept(FableVisitor v)
v
- the visitor to visit this.
java.lang.NullPointerException
- if v is null.public abstract void acceptRecursive(FableVisitor v)
v
- the visitor to visit this and decendants of this.
java.lang.NullPointerException
- if v is null.public final boolean moveUp()
Returns true if it successfully decreased index of this. It returns false otherwise (e.g. index is equal to or less than 0).
public final boolean moveDown()
Returns true if it successfully increased index of this. It returns false otherwise (e.g. index is equal to or greater than number of children of the parent - 1).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |