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.support.renderingcontrol.lastchange;
17  
18  import org.fourthline.cling.model.ModelUtil;
19  import org.fourthline.cling.support.lastchange.EventedValue;
20  import org.fourthline.cling.support.lastchange.LastChangeParser;
21  
22  import javax.xml.transform.Source;
23  import javax.xml.transform.stream.StreamSource;
24  import java.util.Set;
25  
26  /**
27   * @author Christian Bauer
28   */
29  public class RenderingControlLastChangeParser extends LastChangeParser {
30  
31      public static final String NAMESPACE_URI = "urn:schemas-upnp-org:metadata-1-0/RCS/";
32      public static final String SCHEMA_RESOURCE = "org/fourthline/cling/support/renderingcontrol/metadata-1.0-rcs.xsd";
33  
34      @Override
35      protected String getNamespace() {
36          return NAMESPACE_URI;
37      }
38  
39      @Override
40      protected Source[] getSchemaSources() {
41          // TODO: Android 2.2 has a broken SchemaFactory, we can't validate
42          // http://code.google.com/p/android/issues/detail?id=9491&q=schemafactory&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
43          if (!ModelUtil.ANDROID_RUNTIME) {
44              return new Source[]{new StreamSource(
45                      Thread.currentThread().getContextClassLoader().getResourceAsStream(SCHEMA_RESOURCE)
46              )};
47          }
48          return null;
49      }
50  
51      @Override
52      protected Set<Class<? extends EventedValue>> getEventedVariables() {
53          return RenderingControlVariable.ALL;
54      }
55  }