aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/library/LibraryItem.java
diff options
context:
space:
mode:
authorMatt Windsor <mbw500@student.cs.york.ac.uk>2011-02-20 01:30:54 +0000
committerMatt Windsor <mbw500@student.cs.york.ac.uk>2011-02-20 01:30:54 +0000
commitc8cb46d18ce2506e7da226b08c6521795b6e6173 (patch)
tree15a0cbc679cfb99d4f0ccd73a7c288838dac2b99 /src/uk/org/ury/library/LibraryItem.java
parenta0030a5314fe29960b82bc38a96728ee222a3be5 (diff)
Search now works; database and library viewer now separated by LibraryUtils static class (staticness will probably change later). LibraryItem now uses a hash-map to store semi-arbitrary data on tracks.
Diffstat (limited to 'src/uk/org/ury/library/LibraryItem.java')
-rw-r--r--src/uk/org/ury/library/LibraryItem.java482
1 files changed, 63 insertions, 419 deletions
diff --git a/src/uk/org/ury/library/LibraryItem.java b/src/uk/org/ury/library/LibraryItem.java
index 0e44be5..593d1a5 100644
--- a/src/uk/org/ury/library/LibraryItem.java
+++ b/src/uk/org/ury/library/LibraryItem.java
@@ -3,6 +3,10 @@
*/
package uk.org.ury.library;
+
+import java.util.Map;
+
+
/**
* An item in the URY library.
*
@@ -11,436 +15,76 @@ package uk.org.ury.library;
public class LibraryItem
{
- private String title;
- private String artist;
- private String label;
- private String status;
- private String medium;
- private String format;
- private String dateReleased;
- private String dateAdded;
- private String dateEdited;
- private String shelfLetter;
- private String shelfNumber;
- private String addForename;
- private String addSurname;
- private String editForename;
- private String editSurname;
- private String cdID;
- private int addMemberID;
- private int editMemberID;
-
- public
- LibraryItem ()
- {
- }
-
-
- /**
- * @return the title
- */
-
- public String
- getTitle ()
- {
- return title;
- }
-
-
- /**
- * @param title the title to set
- */
-
- public void
- setTitle (String title)
- {
- this.title = title;
- }
-
-
- /**
- * @return the artist
- */
-
- public String
- getArtist ()
- {
- return artist;
- }
-
-
- /**
- * @param artist the artist to set
- */
-
- public void
- setArtist (String artist)
- {
- this.artist = artist;
- }
-
-
- /**
- * @return the label
- */
-
- public String
- getLabel ()
- {
- return label;
- }
-
-
- /**
- * @param label the label to set
- */
-
- public void
- setLabel (String label)
- {
- this.label = label;
- }
-
-
- /**
- * @return the status
- */
-
- public String
- getStatus ()
- {
- return status;
- }
-
-
- /**
- * @param status the status to set
- */
-
- public void
- setStatus (String status)
- {
- this.status = status;
- }
-
-
- /**
- * @return the medium
- */
-
- public String
- getMedium ()
- {
- return medium;
- }
-
-
- /**
- * @param medium the medium to set
- */
-
- public void
- setMedium (String medium)
- {
- this.medium = medium;
- }
-
-
- /**
- * @return the format
- */
-
- public String
- getFormat ()
- {
- return format;
- }
-
-
- /**
- * @param format the format to set
- */
-
- public void
- setFormat (String format)
- {
- this.format = format;
- }
-
-
- /**
- * @return the dateReleased
- */
-
- public String
- getDateReleased ()
- {
- return dateReleased;
- }
-
-
- /**
- * @param dateReleased the dateReleased to set
- */
-
- public void
- setDateReleased (String dateReleased)
- {
- this.dateReleased = dateReleased;
- }
-
-
- /**
- * @return the dateAdded
- */
-
- public String
- getDateAdded ()
- {
- return dateAdded;
- }
-
-
- /**
- * @param dateAdded the dateAdded to set
- */
-
- public void
- setDateAdded (String dateAdded)
- {
- this.dateAdded = dateAdded;
- }
-
-
- /**
- * @return the dateEdited
- */
-
- public String
- getDateEdited ()
- {
- return dateEdited;
- }
-
-
- /**
- * @param dateEdited the dateEdited to set
- */
-
- public void
- setDateEdited (String dateEdited)
- {
- this.dateEdited = dateEdited;
- }
-
-
- /**
- * @return the shelfLetter
- */
-
-
- public String
- getShelfLetter ()
- {
- return shelfLetter;
- }
-
-
- /**
- * @param shelfLetter the shelfLetter to set
- */
-
- public void
- setShelfLetter (String shelfLetter)
- {
- this.shelfLetter = shelfLetter;
- }
-
-
- /**
- * @return the shelfNumber
- */
-
- public String
- getShelfNumber ()
- {
- return shelfNumber;
- }
-
-
- /**
- * @param shelfNumber the shelfNumber to set
- */
-
- public void
- setShelfNumber (String shelfNumber)
- {
- this.shelfNumber = shelfNumber;
- }
-
-
- /**
- * @return the addForename
- */
-
- public String
- getAddForename ()
- {
- return addForename;
- }
-
-
- /**
- * @param addForename the addForename to set
- */
-
- public void
- setAddForename (String addForename)
- {
- this.addForename = addForename;
- }
-
-
- /**
- * @return the addSurname
- */
-
- public String
- getAddSurname ()
- {
- return addSurname;
- }
-
-
- /**
- * @param addSurname the addSurname to set
- */
-
- public void
- setAddSurname (String addSurname)
- {
- this.addSurname = addSurname;
- }
-
-
- /**
- * @return the editForename
- */
-
- public String
- getEditForename ()
- {
- return editForename;
- }
-
-
- /**
- * @param editForename the editForename to set
- */
-
- public void
- setEditForename (String editForename)
- {
- this.editForename = editForename;
- }
-
-
- /**
- * @return the editSurname
- */
-
- public String
- getEditSurname ()
- {
- return editSurname;
- }
-
-
- /**
- * @param editSurname the editSurname to set
- */
-
- public void
- setEditSurname (String editSurname)
- {
- this.editSurname = editSurname;
- }
-
-
- /**
- * @return the cdID
- */
-
- public String
- getCdID ()
- {
- return cdID;
- }
-
-
- /**
- * @param cdID the cdID to set
- */
-
- public void
- setCdID (String cdID)
- {
- this.cdID = cdID;
- }
-
-
- /**
- * @return the addMemberID
- */
-
- public int
- getAddMemberID ()
- {
- return addMemberID;
- }
-
-
- /**
- * @param addMemberID the addMemberID to set
- */
-
- public void
- setAddMemberID (int addMemberID)
- {
- this.addMemberID = addMemberID;
- }
-
-
/**
- * @return the editMemberID
+ * The parameters that are stored in the LibraryItem.
+ *
+ * @author Matt Windsor
+ */
+
+ public enum LibraryProperty
+ {
+ // Constant SQL identifier
+ TITLE ("title"),
+ ARTIST ("artist"),
+ LABEL ("label"),
+ STATUS ("status"),
+ MEDIUM ("medium"),
+ FORMAT ("format"),
+ DATE_RELEASED ("datereleased"),
+ DATE_ADDED ("dateadded"),
+ DATE_EDITED ("dateedited"),
+ SHELF_LETTER ("shelfletter"),
+ SHELF_NUMBER ("shelfnumber"),
+ CD_ID ("cdid"),
+ ADD_MEMBER_ID ("memberid_add"),
+ EDIT_MEMBER_ID ("memberid_lastedit"),
+ ADD_FORENAME ("fnameadd"),
+ ADD_SURNAME ("snameadd"),
+ EDIT_FORENAME ("fnameedit"),
+ EDIT_SURNAME ("snameedit");
+
+
+ public final String sql;
+
+ private
+ LibraryProperty (String sql)
+ {
+ this.sql = sql;
+ }
+ };
+
+
+ private Map<LibraryProperty, String> properties;
+
+
+ /**
+ * Construct a new library item from an existing list of
+ * properties.
+ *
+ * @param properties The map of properties that the new item will
+ * inherit.
*/
- public int
- getEditMemberID ()
- {
- return editMemberID;
- }
-
-
- /**
- * @param editMemberID the editMemberID to set
- */
-
- public void
- setEditMemberID (int editMemberID)
+ public
+ LibraryItem (Map<LibraryProperty, String> properties)
{
- this.editMemberID = editMemberID;
+ this.properties = properties;
}
/**
- * @return a human-readable string representation of the item.
+ * Query this item for a property.
+ *
+ * @param property The property to query.
+ * @return The property, if it exists, or "Unknown" otherwise.
*/
- @Override
public String
- toString ()
+ get (LibraryProperty property)
{
- return getArtist () + " - " + getTitle () + " (" + getShelfLetter () + getShelfNumber () + ")";
+ if (properties.containsKey (property))
+ return properties.get (property);
+ else
+ return "Unknown";
}
}