diff options
Diffstat (limited to 'src/uk/org/ury/library/item')
-rw-r--r-- | src/uk/org/ury/library/item/LibraryItem.java | 26 | ||||
-rw-r--r-- | src/uk/org/ury/library/item/LibraryItemProperty.java | 62 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/uk/org/ury/library/item/LibraryItem.java b/src/uk/org/ury/library/item/LibraryItem.java new file mode 100644 index 0000000..d2a790b --- /dev/null +++ b/src/uk/org/ury/library/item/LibraryItem.java @@ -0,0 +1,26 @@ +/** + * + */ +package uk.org.ury.library.item; + + +import java.util.Map; + +import uk.org.ury.database.DatabaseItem; + + +/** + * An item in the URY library. + * + * @author Matt Windsor + */ + +public class LibraryItem extends DatabaseItem<LibraryItemProperty, + String> +{ + public + LibraryItem (Map<LibraryItemProperty, String> properties) + { + super (properties); + } +}
\ No newline at end of file diff --git a/src/uk/org/ury/library/item/LibraryItemProperty.java b/src/uk/org/ury/library/item/LibraryItemProperty.java new file mode 100644 index 0000000..44f5f22 --- /dev/null +++ b/src/uk/org/ury/library/item/LibraryItemProperty.java @@ -0,0 +1,62 @@ +package uk.org.ury.library.item; + +/** + * The parameters that are stored in the LibraryItem. + * + * @author Matt Windsor + */ + +public enum LibraryItemProperty + { + // Constant SQL identifier + TITLE ("title"), + ALBUM ("album"), + 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"), + IS_DIGITISED ("digitised"), + IS_CLEAN ("clean"); + + + public final String sql; + + + private + LibraryItemProperty (String sql) + { + this.sql = sql; + } + + + /** + * Retrieve a LibraryItemProperty given its SQL identifier. + * + * @param string The SQL identifier. + * @return The first property to match. + * + * @throws IllegalArgumentException if no matches were + * found. + */ + + public static LibraryItemProperty + getFromSQL (String string) + { + // TODO: Better exception? + + for (LibraryItemProperty prop : values ()) + { + if (prop.sql.equals (string)) + return prop; + } + + throw new IllegalArgumentException ("Nonexistent property SQL."); + } + };
\ No newline at end of file |