Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/tuneology/irremote/IRRemote.java


1   /*
2     IRRemote.java
3   
4     Copyright (C) 2002 Fran Taylor
5   
6     This library is free software; you can redistribute it and/or modify
7     it under the terms of the GNU Lesser General Public License as
8     published by the Free Software Foundation; either version 2.1 of the
9     License, or (at your option) any later version.
10  
11    This library 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.  See the GNU
14    Lesser General Public License for more details.
15  
16    You should have received a copy of the GNU Lesser General Public
17    License along with this library; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19    
20    $Id: IRRemote.java,v 1.3 2002/11/06 09:25:04 xnarf Exp $
21  
22  */
23  
24  package com.tuneology.irremote;
25  
26  import java.lang.reflect.*;
27  
28  /**
29   * This class is the interface for listing and instantiating IR components.
30   *
31   * @version $Id: IRRemote.java,v 1.3 2002/11/06 09:25:04 xnarf Exp $
32   * 
33   * @author Fran Taylor
34   */
35  public class IRRemote {
36      private IRRemote() { }
37      /**
38       * Creates a new instance of a Remote Control device. 
39       *
40       * @param cl The class of the new device.
41       * @param arg The string argument to pass to the constructor.
42       * @throws NoSuchMethodException 
43       * @throws InstantiationException
44       * @throws IllegalAccessException
45       * @throws InvocationTargetException
46       */
47      public static IRComponent newIRComponent(Class cl, String arg) 
48    throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
49    Class[] parms = new Class[1];
50    parms[0] = String.class;
51    Object[] args = new Object[1];
52    args[0] = arg;
53    return (IRComponent) cl.getConstructor(parms).newInstance(args);
54      }
55      /**
56       * Returns an array of all the supported remote control types.
57       * @return an array of remote control types.
58       */
59      public static Class[] getComponentTypes() {
60          if (isLinux) {
61              Class[] retval = new Class[1];
62              retval[0] = LircComponent.class;
63              return retval;
64          } else {
65              return null;
66          }            
67      }
68      /**
69       *
70       */
71      public static String getVersions() {
72          if (isLinux)
73              return version + "\n" + LircClient.getIrwVersion();
74          else
75              return null;
76      }
77      private static final String version = "java-irremote 0.1a1 - Copyright (C) 2002 Fran Taylor";
78      private static String osName;
79      private static boolean isLinux;
80      static {
81          osName = System.getProperty("os.name");
82    isLinux = (osName.indexOf("inux") != -1);
83      }
84  }
85  
86  /*
87     Local Variables:
88     mode:java
89     indent-tabs-mode:nil 
90     c-basic-offset:4 
91     c-indent-level:4 
92     c-continued-statement-offset:4 
93     c-brace-offset:-4 
94     c-brace-imaginary-offset:-4 
95     c-argdecl-indent:0
96     c-label-offset:0
97     End:
98  */