SimpleXmlDataStore.java

  1. /*******************************************************************************
  2.  * Copyright 2013 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 net.sf.uadetector.datareader.DataReader;
  19. import net.sf.uadetector.datareader.XmlDataReader;

  20. /**
  21.  * This is the simplest implementation of a {@link DataStore}. It initialize the store by reading the <em>UAS data</em>
  22.  * via the passed URL and store it only in the Java heap space.
  23.  *
  24.  * <p>
  25.  * The given resource must have a valid XML format with UTF-8 charset that validates against specified schema under <a
  26.  * href="http://user-agent-string.info/rpc/uasxmldata.dtd">http://user-agent-string.info/rpc/uasxmldata.dtd</a>.
  27.  *
  28.  * @author André Rouél
  29.  */
  30. public final class SimpleXmlDataStore extends AbstractDataStore implements DataStore {

  31.     /**
  32.      * The default data reader to read in <em>UAS data</em> in XML format
  33.      */
  34.     private static final DataReader DEFAULT_DATA_READER = new XmlDataReader();

  35.     /**
  36.      * Constructs an {@code SimpleXmlDataStore} by reading <em>UAS data</em> by the specified default URL
  37.      * {@link DataStore#DEFAULT_DATA_URL} (in XML format).
  38.      *
  39.      * @param dataUrl
  40.      *            URL to <em>UAS data</em>
  41.      * @param versionUrl
  42.      *            URL to version information about the given <em>UAS data</em>
  43.      */
  44.     public SimpleXmlDataStore(final URL dataUrl, final URL versionUrl) {
  45.         super(DEFAULT_DATA_READER, dataUrl, versionUrl, DEFAULT_CHARSET);
  46.     }

  47. }