Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1051269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:54:17+00:00 2026-05-16T16:54:17+00:00

I have decided to use Simple XML serialization and was stucked with basic problem.

  • 0

I have decided to use Simple XML serialization and was stucked with basic problem. I am trying to serialize java.util.UUID class instance as final field in this small class:

@Root
public class Identity {
    @Attribute
    private final UUID id;

    public Identity(@Attribute UUID id) {
        this.id = id;
    } 
}

Tutorial shows how to serialize third-party objects by registering converters like this:

Registry registry = new Registry();
registry.bind(UUID.class, UUIDConverter.class);
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);

serializer.write( object, stream );

appropriate converter for UUID is pretty simple:

public class UUIDConverter implements Converter<UUID> {
    @Override
    public UUID read(InputNode node) throws Exception {
       return new UUID.fromString(node.getValue());
    }
    @Override
    public void write(OutputNode node, UUID value) throws Exception {
       node.setValue(value.toString());
    }
}

But this simple code just didn’t work for me, during serialization objects with UUID fields was thrown exception Transform of class java.util.UUID not supported.

I have tried something something similar with custom Matcher (which was not in tutorial) that works for me:

Serializer serializer = new Persister(new MyMatcher());

serializer.write( object, stream );

and Matcher class looks like this:

public static class MyMatcher implements Matcher {
    @Override
    @SuppressWarnings("unchecked")
    public Transform match(Class type) throws Exception {
        if (type.equals(UUID.class))
            return new UUIDTransform();
        return null;
    }
}

public class UUIDTransform implements Transform<UUID> {
    @Override
    public UUID read(String value) throws Exception {
        return UUID.fromString(value);
    }
    @Override
    public String write(UUID value) throws Exception {
        return value.toString();
    }
}

Questions:

  • Is custom Matcher always recommended practice for streaming third-party classes?
  • In which case I can use Converter?
  • Are there any better tutorials/examples for Simple XML out there?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:54:18+00:00Added an answer on May 16, 2026 at 4:54 pm

    I have to answer by myself again 🙂

    Advice from Niall Gallagher, project leader of Simple XML, from support-list:

    “You could use either a Converter or a Transform. I would say
    for a UUID a Transform with a Matcher would be the easiest option.”

    So, I use Transform<T>/Matcher and satisfied with it. This does not alter the fact that the Converter<T> does not work for me 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to use a class I found to fix an eCommerce problem
I have to implement a simple PGP decryption. Have decided to use 'BouncyCastle' as
I have started a new web application and have decided to use jquery as
I have setup subversion 1.6.5 on Fedora. I have decided to use a single
I'm writing a web application (PHP) for my friend and have decided to use
I have some complex types here so I decided to use nifty trick to
I have to use windows to write some shell scripts. I decided to use
I have decided to add some validation to my combobox, what I'm trying to
Since black red tree is a binary search tree I have decided to use
Greetings, everyone. I'm trying to learn some Silverlight basics, and have decided to write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.