cami.jmootcher
Class JMootcher

java.lang.Object
  extended by cami.jmootcher.JMootcher
All Implemented Interfaces:
JMootcherConstants

public class JMootcher
extends java.lang.Object
implements JMootcherConstants

An inner class, representating a freesound-sample

Version:
0.7
Author:
Camillo Bruni

Field Summary
static java.lang.String JMOOTCHER_VERSION
           
 
Fields inherited from interface cami.jmootcher.JMootcherConstants
AIFF, AUDIOSAMPLE_DATE_FORMAT, BUFFER_SIZE, CACHE_ROOT_DIR, ENCODING, FILE_URL, FLAC, HOME_URL, LOGIN_REDIRECT_URL, LOGIN_URL, LOGOUT_URL, MP3, OGG, PREVIEW_CACHE_DIRNAME, SAMPLE_CACHE_DIRNAME, VALID_LOGIN_TEXT, VALID_XML_LINE_PREFIX, VALID_XML_SECONDLINE, WAV, XML_CACHE_DIRNAME, XML_SEARCH_URL, XML_SIMILAR_URL, XML_URL
 
Method Summary
 void checkogin()
           
static JMootcher factory(java.lang.String username, java.lang.String password)
          constructs a single instance of the JMootcher class.
 java.lang.String getCacheDir()
           
 AudioSample[] getDissimilarSamples(int ID)
           
 java.lang.String getFlushedURLConnectionContent(java.net.HttpURLConnection huc)
          Returns the content of an HttpURLConnection-object and flushes the object.
 java.io.InputStream getInputStream(AudioSample sf)
          Returns an InputStream to the complete, full-quality sample.
 java.io.InputStream getInputStream(int ID)
          Returns an InputStream to the complete, full-quality sample.
 java.lang.String getPreviewCacheDir()
           
 AudioSample[] getSampleByBitDepth(int bitDepth)
           
 AudioSample[] getSampleByBitrate(int bitRate)
           
 AudioSample getSampleByID(int ID)
          returns a new AudioSample null if nonexisting
 AudioSample[] getSampleBySampleRate(int sampleRate)
           
 java.lang.String getSampleCacheDir()
           
 AudioSample[] getSampleDuration(float min, float max)
           
 AudioSample[] getSamples(int ID)
          fetches a sample with a given ID
 AudioSample[] getSamples(java.lang.String key)
          fetches samples with given tags / keywords
 AudioSample[] getSamples(java.lang.String[] keys)
          fetches samples with given tags / keywords
 AudioSample[] getSamplesByKeyword(java.lang.String key)
          Returns an Array filled with the samples, mathing the given keyword.
 AudioSample[] getSamplesByKeyword(java.lang.String[] keys)
          Returns an Array filled with the samples, mathing the given keywords.
 AudioSample[] getSimilarSamples(int ID)
           
 java.lang.String getURLConnectionContent(java.net.HttpURLConnection huc)
          returns the content of an HttpURLConnection-object.
 java.lang.String getURLConnectionContent(java.net.HttpURLConnection huc, boolean disconnect)
          Fetches the content of a HttpURLConnection and returns it as a a String
 java.lang.String getXMLCacheDir()
           
 boolean isLoggedIn()
          Returns true if we're logged in.
 void logout()
          Clears the current session...
 void setCacheDir(java.io.File cachedir)
          sets the cache-dir, wehere all files are stored/downloaded
 void setPreviewCacheDirName(java.lang.String dirname)
           
 void setSampleCacheDirName(java.lang.String dirname)
           
 void setXMLCacheDirName(java.lang.String dirname)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JMOOTCHER_VERSION

public static final java.lang.String JMOOTCHER_VERSION
See Also:
Constant Field Values
Method Detail

factory

public static JMootcher factory(java.lang.String username,
                                java.lang.String password)
                         throws java.lang.Exception
constructs a single instance of the JMootcher class. Since all accounts are handled equally, theres no need for using more than one account simultanously.

Throws:
java.lang.Exception

getSamples

public AudioSample[] getSamples(int ID)
fetches a sample with a given ID

Returns:
AudioSample a new AudioSample or null

getSamples

public AudioSample[] getSamples(java.lang.String key)
fetches samples with given tags / keywords

Parameters:
key -
Returns:
AudioSample[] an Array of AudioSamples or null

getSamples

public AudioSample[] getSamples(java.lang.String[] keys)
fetches samples with given tags / keywords

Parameters:
key -
Returns:

getSampleByID

public AudioSample getSampleByID(int ID)
returns a new AudioSample null if nonexisting

Parameters:
ID -
Returns:

getSamplesByKeyword

public AudioSample[] getSamplesByKeyword(java.lang.String key)
Returns an Array filled with the samples, mathing the given keyword. The Array is empty if an error occured while doing the query-stuff.

Parameters:
key - A keyword or name of sample
Returns:

getSamplesByKeyword

public AudioSample[] getSamplesByKeyword(java.lang.String[] keys)
Returns an Array filled with the samples, mathing the given keywords. The Array is empty if an error occured while doing the query-stuff.

Parameters:
keys - An Array of keywords or names of samples
Returns:

getSampleByBitrate

public AudioSample[] getSampleByBitrate(int bitRate)
Parameters:
bitRate - the required bitrate of a sample
Returns:

getSampleByBitDepth

public AudioSample[] getSampleByBitDepth(int bitDepth)
Parameters:
bitDepth - the required bitDepth of a sample
Returns:

getSampleBySampleRate

public AudioSample[] getSampleBySampleRate(int sampleRate)
Parameters:
sampleRate - the required samplerate of a sample
Returns:

getSampleDuration

public AudioSample[] getSampleDuration(float min,
                                       float max)
Parameters:
min - the minimal required duration
max - the maximal required duration
Returns:

getSimilarSamples

public AudioSample[] getSimilarSamples(int ID)
Parameters:
ID -
Returns:

getDissimilarSamples

public AudioSample[] getDissimilarSamples(int ID)
Parameters:
ID -
Returns:

isLoggedIn

public boolean isLoggedIn()
Returns true if we're logged in.


getInputStream

public java.io.InputStream getInputStream(AudioSample sf)
Returns an InputStream to the complete, full-quality sample. This cannot be done unless you have a valid freesound account.

Parameters:
ID - AudioSample
Returns:

getInputStream

public java.io.InputStream getInputStream(int ID)
Returns an InputStream to the complete, full-quality sample. This cannot be done unless you have a valid freesound account.

Parameters:
ID - ID of a freesound-sample
Returns:

getCacheDir

public java.lang.String getCacheDir()
Returns:

setCacheDir

public void setCacheDir(java.io.File cachedir)
sets the cache-dir, wehere all files are stored/downloaded

Parameters:
cachedir -

getXMLCacheDir

public java.lang.String getXMLCacheDir()

setXMLCacheDirName

public void setXMLCacheDirName(java.lang.String dirname)

getSampleCacheDir

public java.lang.String getSampleCacheDir()

setSampleCacheDirName

public void setSampleCacheDirName(java.lang.String dirname)

getPreviewCacheDir

public java.lang.String getPreviewCacheDir()

setPreviewCacheDirName

public void setPreviewCacheDirName(java.lang.String dirname)

checkogin

public void checkogin()

logout

public void logout()
Clears the current session...


getFlushedURLConnectionContent

public java.lang.String getFlushedURLConnectionContent(java.net.HttpURLConnection huc)
Returns the content of an HttpURLConnection-object and flushes the object. This is an alias-method for getURLConnectionContent-method


getURLConnectionContent

public java.lang.String getURLConnectionContent(java.net.HttpURLConnection huc)
returns the content of an HttpURLConnection-object. This is an alias-method for getURLConnectionContent-method


getURLConnectionContent

public java.lang.String getURLConnectionContent(java.net.HttpURLConnection huc,
                                                boolean disconnect)
Fetches the content of a HttpURLConnection and returns it as a a String

Parameters:
huc - a opened HttpURLConnection
disconnect - should the Connection be closed after fetching the content
Returns: