28
28
package org .jruby .ext .openssl ;
29
29
30
30
import java .io .IOException ;
31
+
31
32
import org .jruby .Ruby ;
32
33
import org .jruby .RubyClass ;
33
34
import org .jruby .RubyModule ;
38
39
import org .jruby .runtime .Block ;
39
40
import org .jruby .runtime .ThreadContext ;
40
41
import org .jruby .runtime .builtin .IRubyObject ;
41
- import org .jruby .util .ByteList ;
42
42
43
43
/**
44
44
* @author <a href="mailto:[email protected] ">Ola Bini</a>
45
45
*/
46
46
public class Utils {
47
+
47
48
private Utils () {}
48
49
50
+ /**
51
+ * @deprecated no longer used
52
+ */
49
53
@ Deprecated
50
54
public static String toHex (byte [] val ) {
51
55
final StringBuilder out = new StringBuilder ();
@@ -59,6 +63,9 @@ public static String toHex(byte[] val) {
59
63
return out .toString ();
60
64
}
61
65
66
+ /**
67
+ * @deprecated no longer used
68
+ */
62
69
@ Deprecated
63
70
public static String toHex (byte [] val , char sep ) {
64
71
final StringBuilder out = new StringBuilder ();
@@ -76,64 +83,24 @@ public static String toHex(byte[] val, char sep) {
76
83
return out .toString ().toUpperCase ();
77
84
}
78
85
79
- static ByteList hexBytes (final byte [] data ) {
80
- return hexBytes (data , 0 );
81
- }
82
-
83
- static ByteList hexBytes (final byte [] data , final int off ) {
84
- final int len = data .length - off ;
85
- return hexBytes (data , off , len , new ByteList ( len * 3 ));
86
- }
87
-
88
- static ByteList hexBytes (final byte [] data , final ByteList out ) {
89
- return hexBytes (data , 0 , data .length , out );
90
- }
91
-
92
- @ SuppressWarnings ("deprecation" )
93
- static ByteList hexBytes (final ByteList data , final ByteList out ) {
94
- return hexBytes (data .bytes , data .begin , data .realSize , out );
95
- }
96
-
97
- private static final char [] digits = {
98
- '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' ,
99
- '8' , '9' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F'
100
- };
101
-
102
- private static ByteList hexBytes (final byte [] data , final int off , final int len , final ByteList out ) {
103
- boolean notFist = false ;
104
- out .ensure ( len * 3 - 1 );
105
- for ( int i = off ; i < (off + len ); i ++ ) {
106
- if ( notFist ) out .append (':' );
107
- final byte b = data [i ];
108
- out .append ( digits [ (b >> 4 ) & 0xF ] );
109
- out .append ( digits [ b & 0xF ] );
110
- notFist = true ;
111
- }
112
- return out ;
113
- }
114
-
86
+ /**
87
+ * @deprecated no longer used, please avoid
88
+ */
115
89
@ Deprecated
116
90
public static void checkKind (Ruby rt , IRubyObject obj , String path ) {
117
91
if (((RubyObject ) obj ).kind_of_p (rt .getCurrentContext (), rt .getClassFromPath (path )).isFalse ()) {
118
92
throw rt .newTypeError (String .format ("wrong argument (%s)! (Expected kind of %s)" , obj .getMetaClass ().getName (), path ));
119
93
}
120
94
}
121
95
96
+ /**
97
+ * @deprecated no longer used, please avoid
98
+ */
122
99
@ Deprecated
123
100
public static RubyClass getClassFromPath (Ruby rt , String path ) {
124
101
return (RubyClass ) rt .getClassFromPath (path );
125
102
}
126
103
127
- @ Deprecated
128
- public static RaiseException newError (Ruby rt , String path , String message ) {
129
- return new RaiseException (rt , getClassFromPath (rt , path ), message , true );
130
- }
131
-
132
- @ Deprecated
133
- public static RaiseException newError (Ruby rt , String path , String message , boolean nativeException ) {
134
- return new RaiseException (rt , getClassFromPath (rt , path ), message , nativeException );
135
- }
136
-
137
104
static RaiseException newIOError (Ruby runtime , IOException e ) {
138
105
return new RaiseException (runtime , runtime .getIOError (), e .getMessage (), true );
139
106
}
@@ -154,6 +121,16 @@ static RaiseException newError(Ruby runtime, RubyClass errorClass, String msg) {
154
121
return new RaiseException (runtime , errorClass , msg , true );
155
122
}
156
123
124
+ @ Deprecated
125
+ public static RaiseException newError (Ruby rt , String path , String message ) {
126
+ return new RaiseException (rt , (RubyClass ) rt .getClassFromPath (path ), message , true );
127
+ }
128
+
129
+ @ Deprecated
130
+ public static RaiseException newError (Ruby rt , String path , String message , boolean nativeException ) {
131
+ return new RaiseException (rt , (RubyClass ) rt .getClassFromPath (path ), message , nativeException );
132
+ }
133
+
157
134
@ Deprecated
158
135
public static IRubyObject newRubyInstance (Ruby rt , String path ) {
159
136
return rt .getClassFromPath (path ).callMethod (rt .getCurrentContext (), "new" );
@@ -169,16 +146,19 @@ public static IRubyObject newRubyInstance(Ruby rt, String path, IRubyObject... a
169
146
return rt .getClassFromPath (path ).callMethod (rt .getCurrentContext (), "new" , args );
170
147
}
171
148
149
+ @ Deprecated
172
150
static IRubyObject newRubyInstance (final ThreadContext context , final String path ) {
173
151
final RubyModule klass = context .runtime .getClassFromPath (path );
174
152
return klass .callMethod (context , "new" );
175
153
}
176
154
155
+ @ Deprecated
177
156
static IRubyObject newRubyInstance (final ThreadContext context , final String path , IRubyObject arg ) {
178
157
final RubyModule klass = context .runtime .getClassFromPath (path );
179
158
return klass .callMethod (context , "new" , arg );
180
159
}
181
160
161
+ @ Deprecated
182
162
static IRubyObject newRubyInstance (final ThreadContext context , final String path , IRubyObject ... args ) {
183
163
final RubyModule klass = context .runtime .getClassFromPath (path );
184
164
return klass .callMethod (context , "new" , args );
0 commit comments