|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.h20.course.tp4.NameDirectory
public final class NameDirectory
This class implements a list of names, which consists of a set of names (Entry), plus a set of labels. We use labels to group related names. Typical labels are, say, "work", "friends", "university", etc. This class is a SINGLETON. There are advantages to using a static Singleton, such as you can refer to them without casting getApplication() to an application-specific class, or going to the trouble of hanging an interface on all your Application subclasses so that your various modules can refer to that interface instead. But, the life cycle of a static is not well under your control; so to abide by the life-cycle model, the application class should initiate and tear down these static objects in the onCreate() and onTerminate() methods of the Application Class.
| Method Summary | |
|---|---|
static void |
add(java.lang.String name,
java.lang.String number)
This method adds a new entry to the phone list. |
static boolean |
addLabel(java.lang.String name,
java.lang.String label)
Adds a new label to the directory of names. |
static void |
delete(java.lang.String name)
This method deletes an entry from the list. |
static java.util.List<Entry> |
getEntries()
Return an array with all the entries stored in this directory. |
static java.util.List<java.lang.String> |
getLabels()
This method returns the list of all the labels in the data-set. |
static java.util.List<java.lang.String> |
getLabels(java.lang.String name)
This method returns the list of labels that mark a given entry. |
static void |
removeLabel(java.lang.String name,
java.lang.String label)
This method removes the label from a given name. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.util.List<java.lang.String> getLabels()
public static java.util.List<java.lang.String> getLabels(java.lang.String name)
name - the identifier of the target entry.
public static void add(java.lang.String name,
java.lang.String number)
name - the owner of the telephone.number - the number that will be bound to the name.public static void delete(java.lang.String name)
name - the name that identifies the entry that will be deleted.
public static boolean addLabel(java.lang.String name,
java.lang.String label)
throws NameNotFoundException
name - the name of the entry that will be labeled.label - the new label that will be created.
NameNotFoundException - in case the name was not present in the directory.
public static void removeLabel(java.lang.String name,
java.lang.String label)
throws NameNotFoundException,
LabelNotFoundException
name - The target namelabel - The label to be removed
NameNotFoundException - If the name is not present.
LabelNotFoundException - If the label does not exist.public static java.util.List<Entry> getEntries()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||