DataStore.java

  1. /*******************************************************************************
  2.  * Copyright 2012 André Rouél
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  ******************************************************************************/
  16. package net.sf.uadetector.datastore;

  17. import java.net.URL;
  18. import java.nio.charset.Charset;

  19. import javax.annotation.Nonnull;

  20. import net.sf.uadetector.datareader.DataReader;
  21. import net.sf.uadetector.internal.data.Data;

  22. /**
  23.  * Defines an interface to store UAS data where ever you want.
  24.  *
  25.  * @author André Rouél
  26.  */
  27. public interface DataStore {

  28.     /**
  29.      * Default character set to read UAS data
  30.      */
  31.     Charset DEFAULT_CHARSET = Charset.forName("UTF-8");

  32.     /**
  33.      * URL to retrieve the current UAS data as XML
  34.      */
  35.     String DEFAULT_DATA_URL = "http://user-agent-string.info/rpc/get_data.php?key=free&format=xml";

  36.     /**
  37.      * URL to retrieve the current version of the UAS data
  38.      */
  39.     String DEFAULT_VERSION_URL = "http://user-agent-string.info/rpc/get_data.php?key=free&format=ini&ver=y";

  40.     /**
  41.      * Gets the character set in which the <em>UAS data</em> will be read.
  42.      *
  43.      * @return current UAS data
  44.      */
  45.     @Nonnull
  46.     Charset getCharset();

  47.     /**
  48.      * Gets the UAS data which are currently set.
  49.      *
  50.      * @return current UAS data
  51.      */
  52.     @Nonnull
  53.     Data getData();

  54.     /**
  55.      * Gets the data reader to read in UAS data.
  56.      *
  57.      * @return the data reader to read in UAS data
  58.      */
  59.     @Nonnull
  60.     DataReader getDataReader();

  61.     /**
  62.      * Gets the URL from which the UAS data can be read.
  63.      *
  64.      * @return URL to UAS data
  65.      */
  66.     @Nonnull
  67.     URL getDataUrl();

  68.     /**
  69.      * Gets the URL from which version information about the UAS data can be read.
  70.      *
  71.      * @return URL to version information of UAS data
  72.      */
  73.     @Nonnull
  74.     URL getVersionUrl();

  75. }