01: /*
02: *
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.jsr135;
28:
29: import com.sun.cdc.config.PropertyProvider;
30:
31: /**
32: * This class provides values for the following dynamic properties:
33: * <ul>
34: * <li>supports.mixing</li>
35: * </ul>
36: */
37: public class DynamicProperties implements PropertyProvider {
38:
39: /** The only instance of this class. */
40: private static DynamicProperties instance = null;
41:
42: /**
43: * Does not let anyone instantiate this class.
44: */
45: private DynamicProperties() {
46: }
47:
48: /**
49: * Returns one and only instance of this class.
50: * This method does not need to be synchronized because it will be called
51: * only sequentially during isolate initialization.
52: *
53: * @return <code>DynamicProperties</code> instance
54: */
55: public static DynamicProperties getInstance() {
56: if (instance == null) {
57: instance = new DynamicProperties();
58: }
59: return instance;
60: }
61:
62: /**
63: * Returns current value for the dynamic property corresponding to the
64: * given key. This method is called upon retrieval of any of the properties
65: * supported by this class.
66: *
67: * @param key key for the property being retrieved.
68: * @param fromCache indicates whether property value should be taken from
69: * internal cache. It can be ignored if properties caching is not
70: * supported by underlying implementation.
71: * @return current property value
72: */
73: public String getValue(String key, boolean fromCache) {
74: if ("supports.mixing".equals(key)) {
75: return nSupportsMixing(fromCache);
76: }
77: return null;
78: }
79:
80: /**
81: * Returns TRUE if audio mixing is supported.
82: *
83: * @param fromCache indicates whether property value should be taken from
84: * internal cache. It can be ignored if properties caching is not
85: * supported by underlying implementation.
86: * @return TRUE if audio mixing is supported.
87: */
88: private static native String nSupportsMixing(boolean fromCache);
89:
90: /**
91: * Tells underlying implementation to cache values of all the properties
92: * corresponding to this particular class. This call can be ignored if
93: * property caching is not supported.
94: *
95: * @return <code>true</code> on success, <code>false</code> otherwise
96: */
97: public native boolean cacheProperties();
98:
99: }
|