fable.adt
Interface FableContainer

All Known Implementing Classes:
Article, FableComponent, Feed, Folder, PseudoFeed

public interface FableContainer

This interface is designed to be a type that is able to store FableComponent itself. Note that some class implementing this interface may not be a subtype of FableComponent.

Author:
Wonsik Kim

Method Summary
 boolean addChild(FableComponent fc)
          Add c as a child of this (optional operation).
 java.util.List<FableComponent> getChildren()
          Returns a list of children of this.
 boolean removeChild(FableComponent fc)
          Remove c from the children of this.
 

Method Detail

getChildren

java.util.List<FableComponent> getChildren()
Returns a list of children of this. The order is not particularly meaningful.

Returns:
A list of children of this.

addChild

boolean addChild(FableComponent fc)
Add c as a child of this (optional operation). Returns true if c is successfully added as a child of this, otherwise false.

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.

Parameters:
fc - a child to be added.
Returns:
true if c is succesfully added. false otherwise.
Throws:
java.lang.NullPointerException - if fc is null.
Effects:
add c as a child of this if appropriate.
Modifies:
this.children, fc.parent

removeChild

boolean removeChild(FableComponent fc)
Remove c from the children of this. When c is not a children of this, it does nothing and return false. Otherwise, it will return true.

Parameters:
fc - A child to remove from this.
Returns:
true if c is a child of this and successfully removed. false otherwise.
Throws:
java.lang.NullPointerException - if fc is null.
Effects:
remove c from the children of this.
Modifies:
this.children