net.sf.uadetector.datastore
Class AbstractDataStore

java.lang.Object
  extended by net.sf.uadetector.datastore.AbstractDataStore
All Implemented Interfaces:
DataStore
Direct Known Subclasses:
SimpleXmlDataStore

public abstract class AbstractDataStore
extends java.lang.Object
implements DataStore

The abstract implementation to store UAS data only in the heap space.

A store must always have an usable instance of Data. It is recommended to initialize it with the supplied UAS file in the uadetector-resources module.

Author:
André Rouél

Field Summary
 
Fields inherited from interface net.sf.uadetector.datastore.DataStore
DEFAULT_CHARSET, DEFAULT_DATA_URL, DEFAULT_VERSION_URL
 
Constructor Summary
protected AbstractDataStore(Data data, DataReader reader, java.net.URL dataUrl, java.net.URL versionUrl, java.nio.charset.Charset charset)
          Constructs an new instance of AbstractDataStore.
protected AbstractDataStore(DataReader reader, java.lang.String dataUrl, java.lang.String versionUrl, java.nio.charset.Charset charset)
          Constructs an AbstractDataStore by reading the given dataUrl as UAS data.
protected AbstractDataStore(DataReader reader, java.net.URL dataUrl, java.net.URL versionUrl, java.nio.charset.Charset charset)
          Constructs an AbstractDataStore by reading the given dataUrl as UAS data.
 
Method Summary
 java.nio.charset.Charset getCharset()
          Gets the character set in which the UAS data will be read.
 Data getData()
          Gets the UAS data which are currently set.
 DataReader getDataReader()
          Gets the data reader to read in UAS data.
 java.net.URL getDataUrl()
          Gets the URL from which the UAS data can be read.
 java.net.URL getVersionUrl()
          Gets the URL from which version information about the UAS data can be read.
protected static Data readData(DataReader reader, java.net.URL url, java.nio.charset.Charset charset)
          This method reads the given URL by using an DataReader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDataStore

protected AbstractDataStore(@Nonnull
                            Data data,
                            @Nonnull
                            DataReader reader,
                            @Nonnull
                            java.net.URL dataUrl,
                            @Nonnull
                            java.net.URL versionUrl,
                            @Nonnull
                            java.nio.charset.Charset charset)
Constructs an new instance of AbstractDataStore.

Parameters:
data - first UAS data which will be available in the store
reader - data reader to read the given dataUrl
dataUrl - URL to UAS data
versionUrl - URL to version information about the given UAS data
charset - the character set in which the data should be read
Throws:
net.sf.qualitycheck.exception.IllegalNullArgumentException - if one of the given arguments is null

AbstractDataStore

protected AbstractDataStore(DataReader reader,
                            java.lang.String dataUrl,
                            java.lang.String versionUrl,
                            java.nio.charset.Charset charset)
Constructs an AbstractDataStore by reading the given dataUrl as UAS data.

Parameters:
reader - data reader to read the given dataUrl
dataUrl - URL to UAS data
versionUrl - URL to version information about the given UAS data
charset - the character set in which the data should be read
Throws:
net.sf.qualitycheck.exception.IllegalNullArgumentException - if one of the given arguments is null
net.sf.qualitycheck.exception.IllegalNullArgumentException - if the given strings are not valid URLs

AbstractDataStore

protected AbstractDataStore(DataReader reader,
                            java.net.URL dataUrl,
                            java.net.URL versionUrl,
                            java.nio.charset.Charset charset)
Constructs an AbstractDataStore by reading the given dataUrl as UAS data.

Parameters:
reader - data reader to read the given dataUrl
dataUrl - URL to UAS data
versionUrl - URL to version information about the given UAS data
charset - the character set in which the data should be read
Throws:
net.sf.qualitycheck.exception.IllegalNullArgumentException - if the given argument is null
net.sf.qualitycheck.exception.IllegalStateOfArgumentException - if the created instance of Data is empty
Method Detail

readData

protected static final Data readData(@Nonnull
                                     DataReader reader,
                                     @Nonnull
                                     java.net.URL url,
                                     @Nonnull
                                     java.nio.charset.Charset charset)
This method reads the given URL by using an DataReader. The new created instance of Data will be returned.

Parameters:
reader - data reader to read the given dataUrl
url - URL to UAS data
charset - the character set in which the data should be read
Returns:
an instance of Data or Data.EMPTY if an error occurred, but never null
Throws:
net.sf.qualitycheck.exception.IllegalNullArgumentException - if the given argument is null

getCharset

public java.nio.charset.Charset getCharset()
Description copied from interface: DataStore
Gets the character set in which the UAS data will be read.

Specified by:
getCharset in interface DataStore
Returns:
current UAS data

getData

public Data getData()
Description copied from interface: DataStore
Gets the UAS data which are currently set.

Specified by:
getData in interface DataStore
Returns:
current UAS data

getDataReader

public DataReader getDataReader()
Description copied from interface: DataStore
Gets the data reader to read in UAS data.

Specified by:
getDataReader in interface DataStore
Returns:
the data reader to read in UAS data

getDataUrl

public java.net.URL getDataUrl()
Description copied from interface: DataStore
Gets the URL from which the UAS data can be read.

Specified by:
getDataUrl in interface DataStore
Returns:
URL to UAS data

getVersionUrl

public java.net.URL getVersionUrl()
Description copied from interface: DataStore
Gets the URL from which version information about the UAS data can be read.

Specified by:
getVersionUrl in interface DataStore
Returns:
URL to version information of UAS data


Copyright © 2011-2014. All Rights Reserved.