UserAgentStringParserImpl.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.parser;

  17. import javax.annotation.Nonnull;

  18. import net.sf.qualitycheck.Check;
  19. import net.sf.uadetector.datastore.DataStore;

  20. /**
  21.  * This parser is an implementation of {@code UserAgentStringParser} interface and can detect user agents. The analysis
  22.  * is based on the read {@code Data} of the given data source.
  23.  *
  24.  * @author André Rouél
  25.  */
  26. public class UserAgentStringParserImpl<T extends DataStore> extends AbstractUserAgentStringParser {

  27.     /**
  28.      * Storage for all detection informations for <i>UASparsers</i> from <a
  29.      * href="http://user-agent-string.info/">http://user-agent-string.info</a>.
  30.      */
  31.     @Nonnull
  32.     private final T store;

  33.     /**
  34.      * Constructs an {@code UserAgentStringParser} using the given UAS data as detection source.
  35.      *
  36.      * @param store
  37.      *            store for UAS data
  38.      * @throws net.sf.qualitycheck.exception.IllegalNullArgumentException
  39.      *             if the given argument is {@code null}
  40.      */
  41.     public UserAgentStringParserImpl(@Nonnull final T store) {
  42.         super();
  43.         Check.notNull(store, "store");

  44.         this.store = store;
  45.     }

  46.     @Nonnull
  47.     @Override
  48.     protected T getDataStore() {
  49.         return store;
  50.     }

  51. }