mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 01:29:38 +02:00
Make StringEncoder generic
This commit is contained in:
parent
e91a8336f6
commit
7374caefef
7 changed files with 22 additions and 22 deletions
|
@ -34,7 +34,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
*/
|
||||
public class Base32 {
|
||||
|
||||
private static final StringEncoder base32Stringencoder = new StringEncoder() {
|
||||
private static final StringEncoder<String> base32Stringencoder = new StringEncoder<String>() {
|
||||
|
||||
@Override
|
||||
public String encode(String string) {
|
||||
|
@ -49,7 +49,7 @@ public class Base32 {
|
|||
};
|
||||
private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ2345678";
|
||||
|
||||
public static StringEncoder getStringEncoder() {
|
||||
public static StringEncoder<String> getStringEncoder() {
|
||||
return base32Stringencoder;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2015 Florian Schmaus
|
||||
* Copyright © 2014-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,14 +20,14 @@ import org.jivesoftware.smack.util.Objects;
|
|||
|
||||
|
||||
public class Base64UrlSafeEncoder {
|
||||
private static StringEncoder base64UrlSafeEncoder;
|
||||
private static StringEncoder<String> base64UrlSafeEncoder;
|
||||
|
||||
public static void setEncoder(StringEncoder encoder) {
|
||||
public static void setEncoder(StringEncoder<String> encoder) {
|
||||
Objects.requireNonNull(encoder, "encoder must no be null");
|
||||
base64UrlSafeEncoder = encoder;
|
||||
}
|
||||
|
||||
public static StringEncoder getStringEncoder() {
|
||||
public static StringEncoder<String> getStringEncoder() {
|
||||
return base64UrlSafeEncoder;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2013-2014 Florian Schmaus
|
||||
* Copyright 2013-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,20 +21,20 @@ package org.jivesoftware.smack.util.stringencoder;
|
|||
*
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
public interface StringEncoder {
|
||||
public interface StringEncoder<O> {
|
||||
/**
|
||||
* Encodes an string to another representation.
|
||||
* Encodes an object to another representation.
|
||||
*
|
||||
* @param string
|
||||
* @param object the object to encode.
|
||||
* @return the encoded String
|
||||
*/
|
||||
String encode(String string);
|
||||
String encode(O object);
|
||||
|
||||
/**
|
||||
* Decodes an string back to it's initial representation.
|
||||
* Decodes a string back to it's initial representation.
|
||||
*
|
||||
* @param string
|
||||
* @return the decoded String
|
||||
* @param string the string to decode.
|
||||
* @return the decoded object
|
||||
*/
|
||||
String decode(String string);
|
||||
O decode(String string);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue