1 /* 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 27 package com.sun.jmx.snmp; 28 29 30 31 import java.io.Serializable; 32 33 /** 34 * Is an abstract representation of an SNMP Value. 35 * All classes provided for dealing with SNMP types should derive from this 36 * class. 37 * 38 * <p><b>This API is a Sun Microsystems internal API and is subject 39 * to change without notice.</b></p> 40 */ 41 @SuppressWarnings("serial") // JDK implementation class 42 public abstract class SnmpValue implements Cloneable, Serializable, SnmpDataTypeEnums { 43 44 /** 45 * Returns a <CODE>String</CODE> form containing ASN.1 tagging information. 46 * @return The <CODE>String</CODE> form. 47 */ 48 public String toAsn1String() { 49 return "[" + getTypeName() + "] " + toString(); 50 } 51 52 /** 53 * Returns the value encoded as an OID. 54 * The method is particularly useful when dealing with indexed table made of 55 * several SNMP variables. 56 * @return The value encoded as an OID. 57 */ 58 public abstract SnmpOid toOid() ; 59 60 /** 61 * Returns a textual description of the object. 62 * @return ASN.1 textual description. 63 */ 64 public abstract String getTypeName() ; 65 66 /** 67 * Same as clone, but you cannot perform cloning using this object because 68 * clone is protected. This method should call <CODE>clone()</CODE>. 69 * @return The <CODE>SnmpValue</CODE> clone. 70 */ 71 public abstract SnmpValue duplicate() ; 72 73 /** 74 * This method returns <CODE>false</CODE> by default and is redefined 75 * in the {@link com.sun.jmx.snmp.SnmpNull} class. 76 */ 77 public boolean isNoSuchObjectValue() { 78 return false; 79 } 80 81 /** 82 * This method returns <CODE>false</CODE> by default and is redefined 83 * in the {@link com.sun.jmx.snmp.SnmpNull} class. 84 */ 85 public boolean isNoSuchInstanceValue() { 86 return false; 87 } 88 89 /** 90 * This method returns <CODE>false</CODE> by default and is redefined 91 * in the {@link com.sun.jmx.snmp.SnmpNull} class. 92 */ 93 public boolean isEndOfMibViewValue() { 94 return false; 95 } 96 }