|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object social105.SocialDB
A support class for ICS 105 projects on social networking. This provides basic support for building network structures relating people to each other, as well as supporting arbitrary properties that can be associated with people. It's basically a wrapper for a simple storage service.
To use this, start off by using SocialDB.getInstance() to get an instance of the SocialDB object. Next, identify yourself to the database using the login() method. This will keep your changes separate from other peoples. Probably, you should have one login per group, but you can use as many as you like. You can then use the other methods to record and lookup values in the database.
Constructor Summary | |
SocialDB()
Constructor. |
Method Summary | |
void |
addFriend(java.lang.String person,
java.lang.String friend)
Add a new friend for a person. |
java.lang.String |
getAttributeValue(java.lang.String person,
java.lang.String attribute)
Look up the value of an attribute for a particular person. |
static SocialDB |
getDB()
Return a static instance of SocialDB, which encapsulates a connection to the database. |
java.util.List |
listAttributesOf(java.lang.String person)
List all the attributes for a person. |
java.util.List |
listFriendsOf(java.lang.String person)
Return a list of all the registered friends of a given person. |
java.util.List |
listPeople()
Return a list of all the people known to the database. |
java.util.List |
listPeopleWithAttribute(java.lang.String attribute)
Return a list of all the people who have a particular attribute defined, regardless of that attribute's value. |
java.util.List |
listPeopleWithAttributeValue(java.lang.String attribute,
java.lang.String value)
Return a list of all the people who have a particular attribute with a particular value. |
void |
login(java.lang.String newGroupName)
Login to the database. |
void |
removeAttribute(java.lang.String person,
java.lang.String attribute)
Remove an attribute from a person. |
void |
removeFriend(java.lang.String person,
java.lang.String friend)
Remove a friend from a person. |
void |
setAttribute(java.lang.String person,
java.lang.String attribute,
java.lang.String value)
Set an attribute and value for a person. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SocialDB()
Method Detail |
public static SocialDB getDB()
public void login(java.lang.String newGroupName)
This doesn't actually provide any access control; it only gives a name to associate with future actions, so as to partition one developer's or group's activities from others.
public java.util.List listPeople()
public java.util.List listPeopleWithAttribute(java.lang.String attribute)
attribute
- String the name of an attribute to search on
public java.util.List listPeopleWithAttributeValue(java.lang.String attribute, java.lang.String value)
attribute
- String the name of an attribute to search onvalue
- String the value of the attribute to search on
public java.util.List listFriendsOf(java.lang.String person)
public void addFriend(java.lang.String person, java.lang.String friend)
person
- String the person who has a friendpublic void removeFriend(java.lang.String person, java.lang.String friend)
public java.util.List listAttributesOf(java.lang.String person)
person
- String the person on whom attributes are defined
public java.lang.String getAttributeValue(java.lang.String person, java.lang.String attribute)
person
- String the person for whom this attribute is definedattribute
- String the name of the attribute
public void setAttribute(java.lang.String person, java.lang.String attribute, java.lang.String value)
person
- String the person on whom the attribute is to be definedattribute
- String the name of the attributevalue
- String the value of the attributepublic void removeAttribute(java.lang.String person, java.lang.String attribute)
person
- String the person on whom the attribute is definedattribute
- String the name of the attribute
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |