Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* *********************************************************************
   * This Source Code Form is subject to the terms of the Mozilla Public
   * License, v. 2.0.
   * 
   * If a copy of the MPL was not distributed with this file, You can obtain
   * one at http://mozilla.org/MPL/2.0/.
   * 
   * This Source Code Form is "Incompatible With Secondary Licenses", as
   * defined by the Mozilla Public License, v. 2.0.
  * ********************************************************************* */
 package fiftyone.mobile.detection.matchers;
 
Abstract class created to handle requests for User Agents.

Author(s):
51Degrees.mobi
Version:
2.2.8.9
 
 public abstract class Request {

    
The handler the User Agent has been assigned to.
 
     private final Handler _handler;
    
The amount of devices left to be tested.
 
     protected final LinkedBlockingQueue<BaseDeviceInfo_queue;
    
The User Agent being processed.
 
     protected final String _userAgent;

    

Returns:
The User Agent being processed.
 
     public String getUserAgent() {
         return ;
     }

    

Returns:
The handler the User Agent has been assigned to.
 
     public Handler getHandler() {
         return ;
     }

    

Returns:
The amount of devices left to be tested.
 
     public int getCount() {
         return .size();
     }

    
Constructs a new instance of Request.

Parameters:
userAgent User Agent to be tested.
handler Handler that is currently assigned to the User Agent.
 
     public Request(final String userAgentfinal Handler handler) {
          = userAgent;
          = createQueue(handler);
          = handler;
     }

    

Returns:
The next device to be tested.
 
     public BaseDeviceInfo next() {
         return .poll();
     }

    
Takes a handler and returns a queue containing the User Agent Strings.

Parameters:
handler Handler containing devices.
Returns:
A queue of devices.
 
     private static LinkedBlockingQueue<BaseDeviceInfocreateQueue(final Handler handler) {
         final LinkedBlockingQueue<BaseDeviceInfoqueue = 
                 new LinkedBlockingQueue<BaseDeviceInfo>();
 
         synchronized (handler.getDevices()) {
             for (int device : handler.getDevices().keySet()) {
                 queue.addAll(handler.getDevices().get(device));
             }
         }
        return queue;
    }
New to GrepCode? Check out our FAQ X