1 22 23 package org.snmp4j.agent.mo.jmx.types; 24 25 import java.io.*; 26 27 import org.snmp4j.smi.Variable; 28 import javax.management.*; 29 30 39 public class TypedAttribute 40 implements Serializable, SMITransformType, TransformType 41 { 42 43 private String name; 44 private Class type; 45 46 public TypedAttribute(String name, String type) throws ClassNotFoundException { 47 this.name = name; 48 this.type = Class.forName(type); 49 } 50 51 public TypedAttribute(String name, Class type) { 52 this.name = name; 53 this.type = type; 54 } 55 56 public String getName() { 57 return name; 58 } 59 60 public Class getType() { 61 return type; 62 } 63 64 public void transformObject2SMI(Object object, Variable value) { 65 SMIVariant colVariant = new SMIVariant(value); 66 colVariant.setValue(object); 67 } 68 69 public Object transformSMI2Object(Variable value) { 70 SMIVariant smiVariant = new SMIVariant(value); 71 return smiVariant.getValue(type); 72 } 73 74 public Object transformFromNative(Object nativeValue, ObjectName objectName) { 75 return nativeValue; 76 } 77 78 public Object transformToNative(Object transformedValue, 79 Object oldNativeValue, ObjectName objectName) { 80 return transformedValue; 81 } 82 83 public boolean isNativeValueAlwaysNeeded() { 84 return false; 85 } 86 87 } 88 | Popular Tags |