Skip to content

Commit 618ef8f

Browse files
committed
Put identical methods together
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1333741 13f79535-47bb-0310-9956-ffa450edef68
1 parent e4d7385 commit 618ef8f

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/main/java/org/apache/commons/codec/binary/BaseNCodec.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ public Object encode(Object obj) throws EncoderException {
293293

294294
/**
295295
* Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet.
296+
* Uses UTF8 encoding.
296297
*
297298
* @param pArray
298299
* a byte array containing binary data
@@ -302,6 +303,17 @@ public String encodeToString(byte[] pArray) {
302303
return StringUtils.newStringUtf8(encode(pArray));
303304
}
304305

306+
/**
307+
* Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet.
308+
* Uses UTF8 encoding.
309+
*
310+
* @param pArray a byte array containing binary data
311+
* @return String containing only character data in the appropriate alphabet.
312+
*/
313+
public String encodeAsString(byte[] pArray){
314+
return StringUtils.newStringUtf8(encode(pArray));
315+
}
316+
305317
/**
306318
* Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of the
307319
* Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String.
@@ -374,17 +386,6 @@ public byte[] encode(byte[] pArray) {
374386
return buf;
375387
}
376388

377-
/**
378-
* Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet.
379-
* Uses UTF8 encoding.
380-
*
381-
* @param pArray a byte array containing binary data
382-
* @return String containing only character data in the appropriate alphabet.
383-
*/
384-
public String encodeAsString(byte[] pArray){
385-
return StringUtils.newStringUtf8(encode(pArray));
386-
}
387-
388389
abstract void encode(byte[] pArray, int i, int length, Context context); // package protected for access from I/O streams
389390

390391
abstract void decode(byte[] pArray, int i, int length, Context context); // package protected for access from I/O streams

0 commit comments

Comments
 (0)