|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.cddb.SimpleCDCollection
public class SimpleCDCollection
Just a very simple reference implementation for a CDCollection based on a bunch of files stored in a directory.
The file storage concept is somewhat similar to the CDDB file storage concept, but without subdirectories for categories. Simply reserve a directory for a class instance, as all files in that directory are considered part of the CD collection.
Conventions for this class: an embedded CDSet export is stored in a file relative to the given base directory and it is named cd.set (see CDSET_LOCATION). All other files in that same directory are user property files named by the discID that is associated with the properties. Property files not associated with a CD in the set are ignored; the content of these property files is standard xmcd format.
This rather simple implementation is designed for smaller collections, everything is held in memory and made persistent on request. For larger, more sophisticated CDCollections supporting queries, consider a different implementation.
CDSet,
Serialized Form| Field Summary | |
|---|---|
String |
CDSET_LOCATION
the filename where the CDSet is stored relative to the base dir |
String |
COL_CATEGORY
the category used for creating records from collection entries |
| Constructor Summary | |
|---|---|
SimpleCDCollection(File baseDirectory)
initializes the collection based on the content found in the given directory |
|
| Method Summary | |
|---|---|
boolean |
addCD(CDID cd)
adds the given cd to the collection and returns true only if the CD was added |
boolean |
contains(CDID cd)
returns true only if the given cd is in this collection |
CDInfo |
getCDInfo(CDID cd)
returns a CDDBEntry object |
Properties |
getCDProperties(CDID cd)
returns all user-properties available for a specific CD (as far as applicable) or null if the CD is not in the collection. |
Set<CDID> |
getCDSet()
returns an unmodifiable view over the set of CDID instances in the collection |
Iterator<CDID> |
iterator()
|
boolean |
removeCD(CDID cd)
removes the given cd to the collection and returns true only if the CD was removed |
CDInfo[] |
searchContent(String pattern)
searches the entire xmcd format content for the exact given pattern. |
void |
setCDInfo(CDID cd,
CDInfo info)
associates the given info with the given cd in this collection; if the given cd is not yet in the collection, it is added. |
void |
setCDInfo(CDID cd,
String xmcdString)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final String CDSET_LOCATION
public final String COL_CATEGORY
| Constructor Detail |
|---|
public SimpleCDCollection(File baseDirectory)
throws IOException
IOException| Method Detail |
|---|
public Iterator<CDID> iterator()
iterator in interface Iterable<CDID>public boolean contains(CDID cd)
CDCollection
contains in interface CDCollectionpublic boolean addCD(CDID cd)
CDCollection
addCD in interface CDCollectionpublic boolean removeCD(CDID cd)
CDCollection
removeCD in interface CDCollectionpublic CDInfo getCDInfo(CDID cd)
getCDInfo in interface CDCollectionCDDBEntry
public void setCDInfo(CDID cd,
CDInfo info)
CDCollection
setCDInfo in interface CDCollection
public void setCDInfo(CDID cd,
String xmcdString)
public Set<CDID> getCDSet()
CDCollection
getCDSet in interface CDCollectionpublic Properties getCDProperties(CDID cd)
CDCollection(For instance, the properties could map keys like year.bought to the value 2002 or the alike.)
Note: An implementing class should specify if the changes in the returned properties are reflected on the actual properties associated with the CD in the collection; otherwise you would assume being given a generated view of the properties that internally are maintained differently.
getCDProperties in interface CDCollectionpublic CDInfo[] searchContent(String pattern)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||