fable.adt
Class FableCensor

java.lang.Object
  extended by fable.adt.FableCensor

public class FableCensor
extends java.lang.Object

FableCensor is the class that contains data about the password, as well as banned URLs and banned Keywords!

Author:
Christopher Moh
Specification Fields

Constructor Summary
FableCensor(java.lang.String hash)
          Create a new FableCensor
 
Method Summary
 boolean addBannedKeyword(java.lang.String bannedKeyword)
          Adds a bannedKeyword to the list of banned Keywords
 boolean addBannedURL(java.lang.String bannedURL)
          Adds a bannedURL to the list of banned URLs
 void changePassword(java.lang.String newPassword)
          Changes the password
 java.util.Collection<java.lang.String> getBannedKeywords()
           
 java.util.Collection<java.lang.String> getBannedURLs()
           
 java.lang.String getHash()
          Returns the hashed password
static java.lang.String hash(java.lang.String password)
          Returns the hash of a particular password
 boolean isOkArticleContent(Article a)
          Checks if the content of an article (summary/html/title/author) is ok for the censor
 boolean isOkURL(java.lang.String url)
          Checks if the URL is acceptable according to the censor
 boolean okPassword(java.lang.String password)
          Checks if the password matches!
 boolean removeBannedKeyword(java.lang.String bannedKeyword)
          Remove a banned keyword from the set of bannedKeywords
 boolean removeBannedURL(java.lang.String bannedURL)
          Remove a bannedURL from the set of bannedURLs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FableCensor

public FableCensor(java.lang.String hash)
Create a new FableCensor

Parameters:
hash - Hashcode of the password. Pass in the hash, NOT the string itself!
Requires:
hash != null
Effects:
creates a new FableCensor with this.password = hash
Modifies:
this
Method Detail

hash

public static java.lang.String hash(java.lang.String password)
Returns the hash of a particular password

Parameters:
password -
Returns:
hashed password
Requires:
password != null

getHash

public java.lang.String getHash()
Returns the hashed password

Returns:
this.password

okPassword

public boolean okPassword(java.lang.String password)
Checks if the password matches!

Parameters:
password - Password to check for
Returns:
true if the password is ok, false otherwise
Requires:
password != null

changePassword

public void changePassword(java.lang.String newPassword)
Changes the password

Parameters:
newPassword - The new password
Requires:
newPassword != null
Effects:
Changes this.password to the hash of newPassword
Modifies:
this.password

addBannedURL

public boolean addBannedURL(java.lang.String bannedURL)
Adds a bannedURL to the list of banned URLs

Parameters:
bannedURL - bannedURL
Returns:
true if the URL was added, false otherwise
Requires:
bannedURL != null
Effects:
adds bannedURL to the set this.bannedURLs
Modifies:
this.bannedURLs

addBannedKeyword

public boolean addBannedKeyword(java.lang.String bannedKeyword)
Adds a bannedKeyword to the list of banned Keywords

Parameters:
bannedKeyword - bannedKeyword
Returns:
true if the Keyword was added, false otherwise
Requires:
bannedKeyword != null
Effects:
adds bannedKeyword to the set this.bannedKeywords
Modifies:
this.bannedKeywords

removeBannedURL

public boolean removeBannedURL(java.lang.String bannedURL)
Remove a bannedURL from the set of bannedURLs

Parameters:
bannedURL -
Returns:
true if the bannedURL could be removed
Requires:
bannedURL != null
Effects:
removes bannedURL from the set this.bannedURLs
Modifies:
this.bannedURLs

removeBannedKeyword

public boolean removeBannedKeyword(java.lang.String bannedKeyword)
Remove a banned keyword from the set of bannedKeywords

Parameters:
bannedKeyword -
Returns:
true if the bannedKeyword could be removed
Effects:
removes bannedKeyword from the set this.bannedKeywords
Modifies:
this.bannedKeywords

getBannedURLs

public java.util.Collection<java.lang.String> getBannedURLs()
Returns:
A collection of the banned URLs

getBannedKeywords

public java.util.Collection<java.lang.String> getBannedKeywords()
Returns:
A collection of the banned Keywords

isOkURL

public boolean isOkURL(java.lang.String url)
Checks if the URL is acceptable according to the censor

Parameters:
url - URL to check
Returns:
true if the url is acceptable, false otherwise
Requires:
url != null

isOkArticleContent

public boolean isOkArticleContent(Article a)
Checks if the content of an article (summary/html/title/author) is ok for the censor

Parameters:
a - Article to check
Returns:
true if article is ok, false otherwise
Requires:
a != null