forked from allegro/json-avro-converter
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support era and string numbers (#17)
* Support Era and string Numbers * Update Readme * Modify exception formatting * Added infinity support for double type * Merge date and datetime formatters into one * Added onValidStringNumber * Support base56 decode * Added test to verify Infinity and NaN is not supported for avro int type
- Loading branch information
Showing
8 changed files
with
308 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
converter/src/main/java/tech/allegro/schema/json2avro/converter/util/StringUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tech.allegro.schema.json2avro.converter.util; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
|
||
public class StringUtil { | ||
|
||
public static boolean isBase64(String value) { | ||
return value != null && value.matches("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$"); | ||
} | ||
|
||
public static String decodeBase64(String string) { | ||
if (isBase64(string)) { | ||
byte[] decoded = Base64.getDecoder().decode(string); | ||
return new String(decoded, StandardCharsets.UTF_8); | ||
} | ||
return string; | ||
} | ||
} |
Oops, something went wrong.