View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.model.message.discovery;
17  
18  import org.fourthline.cling.model.message.IncomingDatagramMessage;
19  import org.fourthline.cling.model.message.UpnpRequest;
20  import org.fourthline.cling.model.message.header.MANHeader;
21  import org.fourthline.cling.model.message.header.MXHeader;
22  import org.fourthline.cling.model.message.header.UpnpHeader;
23  import org.fourthline.cling.model.types.NotificationSubtype;
24  
25  /**
26   * @author Christian Bauer
27   */
28  public class IncomingSearchRequest extends IncomingDatagramMessage<UpnpRequest> {
29  
30      public IncomingSearchRequest(IncomingDatagramMessage<UpnpRequest> source) {
31          super(source);
32      }
33  
34      public UpnpHeader getSearchTarget() {
35          return getHeaders().getFirstHeader(UpnpHeader.Type.ST);
36      }
37  
38      public Integer getMX() {
39          MXHeader header = getHeaders().getFirstHeader(UpnpHeader.Type.MX, MXHeader.class);
40          if (header != null) {
41              return header.getValue();
42          }
43          return null;
44      }
45  
46      /**
47       * @return <code>true</code> if this message has a MAN with
48       *         value {@link org.fourthline.cling.model.types.NotificationSubtype#DISCOVER}.
49       */
50      public boolean isMANSSDPDiscover() {
51          MANHeader header = getHeaders().getFirstHeader(UpnpHeader.Type.MAN, MANHeader.class);
52          return header != null && header.getValue().equals(NotificationSubtype.DISCOVER.getHeaderString());
53      }
54  
55  }