FileDocCategorySizeDatePackage
SourceMedia.javaAPI DocExample4149Tue Feb 10 12:16:34 GMT 2004com.oreilly.hh

SourceMedia

public class SourceMedia extends Object implements Serializable
This is a typesafe enumeration that identifies the media on which an item in our music database was obtained.

Fields Summary
private final String
name
Stores the external name of this instance, by which it can be retrieved.
private final transient String
description
Stores the human-readable description of this instance, by which it is identified in the user interface.
private static final Map
instancesByName
Keeps track of all instances by name, for efficient lookup.
public static final SourceMedia
CASSETTE
The instance that represents music obtained from cassette tape.
public static final SourceMedia
VINYL
The instance that represents music obtained from vinyl.
public static final SourceMedia
VHS
The instance that represents music obtained from VHS tapes.
public static final SourceMedia
CD
The instance that represents music obtained from a compact disc.
public static final SourceMedia
BROADCAST
The instance that represents music obtained from a broadcast.
public static final SourceMedia
DOWNLOAD
The instance that represents music obtained as an Internet download.
public static final SourceMedia
STREAM
The instance that represents music from a digital audio stream.
Constructors Summary
private SourceMedia(String name, String description)
Constructor is private to prevent instantiation except during class loading.

param
name the external name of the message type.
param
description the human readable description of the message type, by which it is presented in the user interface.


                                                       
         
        this.name = name;
        this.description = description;

        // Record this instance in the collection that tracks the enumeration
        instancesByName.put(name, this);
    
Methods Summary
public static java.util.CollectiongetAllValues()
Obtain the collection of all legal enumeration values.

return
all instances of this typesafe enumeration.


                        
        
        return Collections.unmodifiableCollection(instancesByName.values());
    
public java.lang.StringgetDescription()
Return the description associated with this instance.

return
the human-readable description by which this instance is identified in the user interface.

        return description;
    
public static com.oreilly.hh.SourceMediagetInstanceByName(java.lang.String name)
Look up an instance by name.

param
name the external name of an instance.
return
the corresponding instance.
throws
NoSuchElementException if there is no such instance.

        SourceMedia result = (SourceMedia)instancesByName.get(name);
        if (result == null) {
            throw new NoSuchElementException(name);
        }
        return result;
    
public java.lang.StringgetName()
Return the external name associated with this instance.

return
the name by which this instance is identified in code.

        return name;
    
private java.lang.ObjectreadResolve()
Insure that deserialization preserves the signleton property.

        return getInstanceByName(name);
    
public java.lang.StringtoString()
Return a string representation of this object.

        return description;