Skip to content

Commit 17bd887

Browse files
committed
deprecate unused Utils static helpers
1 parent 90e629a commit 17bd887

File tree

1 file changed

+27
-47
lines changed

1 file changed

+27
-47
lines changed

src/main/java/org/jruby/ext/openssl/Utils.java

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
package org.jruby.ext.openssl;
2929

3030
import java.io.IOException;
31+
3132
import org.jruby.Ruby;
3233
import org.jruby.RubyClass;
3334
import org.jruby.RubyModule;
@@ -38,14 +39,17 @@
3839
import org.jruby.runtime.Block;
3940
import org.jruby.runtime.ThreadContext;
4041
import org.jruby.runtime.builtin.IRubyObject;
41-
import org.jruby.util.ByteList;
4242

4343
/**
4444
* @author <a href="mailto:[email protected]">Ola Bini</a>
4545
*/
4646
public class Utils {
47+
4748
private Utils() {}
4849

50+
/**
51+
* @deprecated no longer used
52+
*/
4953
@Deprecated
5054
public static String toHex(byte[] val) {
5155
final StringBuilder out = new StringBuilder();
@@ -59,6 +63,9 @@ public static String toHex(byte[] val) {
5963
return out.toString();
6064
}
6165

66+
/**
67+
* @deprecated no longer used
68+
*/
6269
@Deprecated
6370
public static String toHex(byte[] val, char sep) {
6471
final StringBuilder out = new StringBuilder();
@@ -76,64 +83,24 @@ public static String toHex(byte[] val, char sep) {
7683
return out.toString().toUpperCase();
7784
}
7885

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+
*/
11589
@Deprecated
11690
public static void checkKind(Ruby rt, IRubyObject obj, String path) {
11791
if (((RubyObject) obj).kind_of_p(rt.getCurrentContext(), rt.getClassFromPath(path)).isFalse()) {
11892
throw rt.newTypeError(String.format("wrong argument (%s)! (Expected kind of %s)", obj.getMetaClass().getName(), path));
11993
}
12094
}
12195

96+
/**
97+
* @deprecated no longer used, please avoid
98+
*/
12299
@Deprecated
123100
public static RubyClass getClassFromPath(Ruby rt, String path) {
124101
return (RubyClass) rt.getClassFromPath(path);
125102
}
126103

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-
137104
static RaiseException newIOError(Ruby runtime, IOException e) {
138105
return new RaiseException(runtime, runtime.getIOError(), e.getMessage(), true);
139106
}
@@ -154,6 +121,16 @@ static RaiseException newError(Ruby runtime, RubyClass errorClass, String msg) {
154121
return new RaiseException(runtime, errorClass, msg, true);
155122
}
156123

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+
157134
@Deprecated
158135
public static IRubyObject newRubyInstance(Ruby rt, String path) {
159136
return rt.getClassFromPath(path).callMethod(rt.getCurrentContext(), "new");
@@ -169,16 +146,19 @@ public static IRubyObject newRubyInstance(Ruby rt, String path, IRubyObject... a
169146
return rt.getClassFromPath(path).callMethod(rt.getCurrentContext(), "new", args);
170147
}
171148

149+
@Deprecated
172150
static IRubyObject newRubyInstance(final ThreadContext context, final String path) {
173151
final RubyModule klass = context.runtime.getClassFromPath(path);
174152
return klass.callMethod(context, "new");
175153
}
176154

155+
@Deprecated
177156
static IRubyObject newRubyInstance(final ThreadContext context, final String path, IRubyObject arg) {
178157
final RubyModule klass = context.runtime.getClassFromPath(path);
179158
return klass.callMethod(context, "new", arg);
180159
}
181160

161+
@Deprecated
182162
static IRubyObject newRubyInstance(final ThreadContext context, final String path, IRubyObject... args) {
183163
final RubyModule klass = context.runtime.getClassFromPath(path);
184164
return klass.callMethod(context, "new", args);

0 commit comments

Comments
 (0)