author | David Powell <david.e.powell@oracle.com> |
Thu, 11 Aug 2011 15:41:42 -0700 | |
changeset 764 | ebb25c1dac73 |
parent 681 | e3ebf98ba2fd |
permissions | -rw-r--r-- |
681
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
1 |
/* |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
2 |
* CDDL HEADER START |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
3 |
* |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
4 |
* The contents of this file are subject to the terms of the |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
6 |
* You may not use this file except in compliance with the License. |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
7 |
* |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
9 |
* or http://www.opensolaris.org/os/licensing. |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
10 |
* See the License for the specific language governing permissions |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
11 |
* and limitations under the License. |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
12 |
* |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
18 |
* |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
19 |
* CDDL HEADER END |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
20 |
*/ |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
21 |
|
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
22 |
/* |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
23 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
24 |
*/ |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
25 |
|
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
26 |
package org.opensolaris.os.rad; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
27 |
|
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
28 |
import javax.management.openmbean.OpenDataException; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
29 |
import javax.management.openmbean.OpenType; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
30 |
import javax.management.openmbean.SimpleType; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
31 |
import org.opensolaris.os.adr.Type.EnumType; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
32 |
import org.opensolaris.os.adr.Type.EnumValue; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
33 |
|
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
34 |
/** |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
35 |
* The default EnumMapper. Maps enumeration values to strings. |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
36 |
*/ |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
37 |
public class PlainEnumMapper extends EnumMapper { |
764
ebb25c1dac73
18812 Support building with alternate java implementations
David Powell <david.e.powell@oracle.com>
parents:
681
diff
changeset
|
38 |
public OpenType<?> toOpenType(EnumType type) { |
681
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
39 |
return SimpleType.STRING; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
40 |
} |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
41 |
|
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
42 |
public Object fromWire(EnumType type, EnumValue value) |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
43 |
throws OpenDataException { |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
44 |
|
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
45 |
return value.getName(); |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
46 |
} |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
47 |
|
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
48 |
public String toWire(EnumType type, Object data) { |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
49 |
return (String)data; |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
50 |
} |
e3ebf98ba2fd
18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents:
diff
changeset
|
51 |
} |