Skip to content

add parseHex and parseUuid spel functions to return byte arrays #171

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeremyplichta
Copy link
Collaborator

Added new spel functions parseHex and parseUuid

To complete before merge:

  • test locally with local redis instance
  • add unit/integration tests

@jeremyplichta jeremyplichta requested a review from jruaux March 20, 2025 03:53
@jruaux
Copy link
Collaborator

jruaux commented Mar 20, 2025

Could we use jakarta.xml.bind.DataTypeConverter.parseHexBinary(String hex) for the hex parser?

Also we could probably simplify parseUuid with java.nio.ByteBuffer:

	public static String parseUuid(String uuid) {
		if (uuid == null) {
			return null;
		}
		UUID uuidObj = UUID.fromString(uuid);
		ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
		bb.putLong(uuidObj.getMostSignificantBits());
		bb.putLong(uuidObj.getLeastSignificantBits());
		return new String(bb.array());
	}

@jeremyplichta
Copy link
Collaborator Author

Could we use jakarta.xml.bind.DataTypeConverter.parseHexBinary(String hex) for the hex parser?

Also we could probably simplify parseUuid with java.nio.ByteBuffer:

	public static String parseUuid(String uuid) {
		if (uuid == null) {
			return null;
		}
		UUID uuidObj = UUID.fromString(uuid);
		ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
		bb.putLong(uuidObj.getMostSignificantBits());
		bb.putLong(uuidObj.getLeastSignificantBits());
		return new String(bb.array());
	}

Thanks, those are good suggestions. I will make those when I have a chance as well as implement some tests for this to make sure that we are not having any character encode issues going from byte to string. I'll ping you on here for another review when I'm ready. Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants