1 22 package org.snmp4j.agent.mo.jmx.types; 23 24 import javax.management.openmbean.CompositeDataSupport ; 25 import javax.management.*; 26 27 public class CombinedBitsType extends TypedAttribute { 28 29 private TypedAttribute[] proxyAttribute; 30 31 public CombinedBitsType(TypedAttribute[] proxyAttribute) { 32 super(proxyAttribute[0].getName(), proxyAttribute[0].getType()); 33 this.proxyAttribute = proxyAttribute; 34 } 35 36 public Object transformFromNative(Object nativeValue, ObjectName objectName) { 37 byte[] bits = null; 38 for (TypedAttribute a : proxyAttribute) { 39 Object n = ((CompositeDataSupport )nativeValue).get(a.getName()); 40 n = a.transformFromNative(n, null); 41 byte[] bytes = (byte[])n; 42 if (bits == null) { 43 bits = bytes; 44 } 45 else if (bits.length < bytes.length) { 46 for (int i=0; i<bits.length; i++) { 47 bytes[i] |= bits[i]; 48 } 49 bits = bytes; 50 } 51 else { 52 for (int i=0; i<bytes.length; i++) { 53 bits[i] |= bytes[i]; 54 } 55 } 56 } 57 return bits; 58 } 59 60 public Object transformToNative(Object transformedValue, 61 Object oldNativeValue, ObjectName objectName) { 62 throw new UnsupportedOperationException (); 63 } 64 65 66 } 67 | Popular Tags |