Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jmx/snmp/SnmpOpaque.java
38924 views
1
/*
2
* Copyright (c) 1997, 2007, 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
/**
32
* Is used to represent an SNMP value.
33
* The <CODE>Opaque</CODE> type is defined in RFC 1155.
34
*
35
* <p><b>This API is a Sun Microsystems internal API and is subject
36
* to change without notice.</b></p>
37
*/
38
39
public class SnmpOpaque extends SnmpString {
40
private static final long serialVersionUID = 380952213936036664L;
41
42
// CONSTRUCTORS
43
//-------------
44
/**
45
* Constructs a new <CODE>SnmpOpaque</CODE> from the specified bytes array.
46
* @param v The bytes composing the opaque value.
47
*/
48
public SnmpOpaque(byte[] v) {
49
super(v) ;
50
}
51
52
/**
53
* Constructs a new <CODE>SnmpOpaque</CODE> with the specified <CODE>Bytes</CODE> array.
54
* @param v The <CODE>Bytes</CODE> composing the opaque value.
55
*/
56
public SnmpOpaque(Byte[] v) {
57
super(v) ;
58
}
59
60
/**
61
* Constructs a new <CODE>SnmpOpaque</CODE> from the specified <CODE>String</CODE> value.
62
* @param v The initialization value.
63
*/
64
public SnmpOpaque(String v) {
65
super(v) ;
66
}
67
68
// PUBLIC METHODS
69
//---------------
70
/**
71
* Converts the opaque to its <CODE>String</CODE> form, that is, a string of
72
* bytes expressed in hexadecimal form.
73
* @return The <CODE>String</CODE> representation of the value.
74
*/
75
public String toString() {
76
StringBuffer result = new StringBuffer() ;
77
for (int i = 0 ; i < value.length ; i++) {
78
byte b = value[i] ;
79
int n = (b >= 0) ? b : b + 256 ;
80
result.append(Character.forDigit(n / 16, 16)) ;
81
result.append(Character.forDigit(n % 16, 16)) ;
82
}
83
return result.toString() ;
84
}
85
86
/**
87
* Returns a textual description of the type object.
88
* @return ASN.1 textual description.
89
*/
90
final public String getTypeName() {
91
return name ;
92
}
93
94
// VARIABLES
95
//----------
96
/**
97
* Name of the type.
98
*/
99
final static String name = "Opaque" ;
100
}
101
102