myDataBases
Class MediaBase

java.lang.Object
  extended by myDataBases.MediaBase

public class MediaBase
extends java.lang.Object

Allows to retrieve the names of the media to sort as well as other characteristics specified in the media.xml file.

The media's names and other characteristics are stored in the '../data/media.xml' file. The aim of this class is to allow other parts of this program to access quickly and simply to these informations.

The structure of the media.xml file must be :

< content >< media >< id >identifier< /id >< name >the name of the file as used by crowdFlower< /name > < characteristic >a first characteristic< /characteristic >< othercharac >another characteristic< /othercharac > < /media > ... < /content >

IMPORTANT: Identifiers must go from zero to $number_of_media without any gap. For instance, [0,2,1,5,4,3] works (the order does not matter), but [0,1,1337,42,5] does NOT.

Author:
Leo Perrin (perrin.leo@gmail.com)

Field Summary
private  java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.String>> content
          The list of the media contained in the file and their characteristics.
 
Constructor Summary
MediaBase(java.lang.String path)
          Creates an instance of MediaBase and sets its attributes.
 
Method Summary
 java.util.List<java.lang.Integer[]> getAllMedia()
          Returns a List of all the identifier of the media considered.
 java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.String>> getContent()
          Returns content, the map of map containing all the information available in the media.xml file.
 java.lang.String getMedia(java.lang.Integer id)
          Returns the name of the media wanted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

content

private java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.String>> content
The list of the media contained in the file and their characteristics.

Constructor Detail

MediaBase

public MediaBase(java.lang.String path)
Creates an instance of MediaBase and sets its attributes.

Generates a hashMap containing all the media and their characteristics, content, by parsing the path xml file. All the information contained in this file will be in the content attribute (as long as it is correctly xml formatted).

Parameters:
path - Path to the file containing the data
Method Detail

getAllMedia

public java.util.List<java.lang.Integer[]> getAllMedia()
Returns a List of all the identifier of the media considered.

Reads the content attribute and adds every < id > it founds in a list.

Returns:
The list of the media.

getContent

public java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.String>> getContent()
Returns content, the map of map containing all the information available in the media.xml file.

Returns:
content

getMedia

public java.lang.String getMedia(java.lang.Integer id)
Returns the name of the media wanted.

Parameters:
id - The identifier of the media wanted.
Returns:
A String, the name of the media whose identifier is id.