Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jmx/snmp/SnmpOpaque.java
38924 views
/*1* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/242526package com.sun.jmx.snmp;27282930/**31* Is used to represent an SNMP value.32* The <CODE>Opaque</CODE> type is defined in RFC 1155.33*34* <p><b>This API is a Sun Microsystems internal API and is subject35* to change without notice.</b></p>36*/3738public class SnmpOpaque extends SnmpString {39private static final long serialVersionUID = 380952213936036664L;4041// CONSTRUCTORS42//-------------43/**44* Constructs a new <CODE>SnmpOpaque</CODE> from the specified bytes array.45* @param v The bytes composing the opaque value.46*/47public SnmpOpaque(byte[] v) {48super(v) ;49}5051/**52* Constructs a new <CODE>SnmpOpaque</CODE> with the specified <CODE>Bytes</CODE> array.53* @param v The <CODE>Bytes</CODE> composing the opaque value.54*/55public SnmpOpaque(Byte[] v) {56super(v) ;57}5859/**60* Constructs a new <CODE>SnmpOpaque</CODE> from the specified <CODE>String</CODE> value.61* @param v The initialization value.62*/63public SnmpOpaque(String v) {64super(v) ;65}6667// PUBLIC METHODS68//---------------69/**70* Converts the opaque to its <CODE>String</CODE> form, that is, a string of71* bytes expressed in hexadecimal form.72* @return The <CODE>String</CODE> representation of the value.73*/74public String toString() {75StringBuffer result = new StringBuffer() ;76for (int i = 0 ; i < value.length ; i++) {77byte b = value[i] ;78int n = (b >= 0) ? b : b + 256 ;79result.append(Character.forDigit(n / 16, 16)) ;80result.append(Character.forDigit(n % 16, 16)) ;81}82return result.toString() ;83}8485/**86* Returns a textual description of the type object.87* @return ASN.1 textual description.88*/89final public String getTypeName() {90return name ;91}9293// VARIABLES94//----------95/**96* Name of the type.97*/98final static String name = "Opaque" ;99}100101102