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 9200193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:42:39+00:00 2026-06-17T22:42:39+00:00

The only documentation on XStream converters that I can find is on these two

  • 0

The only documentation on XStream converters that I can find is on these two pages:

  • Tutorial
  • List of all shipped converters

When XStream is parsing XML input, it uses a ConverterLookup (and by default, a DefaultConverterLookup) to lookup which converter to use by class. I’d like to configure my XStream mapper to use my own custom ConverterLookup, but only see a getConverterLookup() method, not a respective setter.

I have an instance where XStream is encountering a Date value in the XML, and returning using the respective DateConverter. I want it to use a different converter, which (I believe) means I need to set/register my own Converter impl. Just can’t figure out how to do this. Thanks in advance.

  • 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-06-17T22:42:40+00:00Added an answer on June 17, 2026 at 10:42 pm

    First of all your question is in fact two unrelated questions, I’ll try my best to answer them both.

    Converters

    To your second question regarding date conversion. Which in my mind seems to be the reason why you are here.

    The basic way of adding your own converter is rather simple, the method registerConverter should give your a clue. If you are wondering how to implement a Converter I suggest you take a look at one of the many converters already provided by XStream. On an extra note I feel like I must mention the priority of converters.

    The converters can be registered with an explicit priority. By
    default they are registered with XStream.PRIORITY_NORMAL. Converters
    of same priority will be used in the reverse sequence they have been
    registered. The default converter, i.e. the converter which will be
    used if no other registered converter is suitable, can be registered
    with priority XStream.PRIORITY_VERY_LOW. XStream uses by default the
    ReflectionConverter as the fallback converter.

    In other terms, given two converters accepting the same classes, the one who was added last will be used.

    ConverterLookup

    To answer how you can use your ConverterLookup there are two ways which may yield the same results, personally I would go for alternative 2.

    1) Overriding getConverterLookup

        XStream xs = new XStream(){
            @Override
            public ConverterLookup getConverterLookup() {
                return new ConverterLookup() {
    
                    public Converter lookupConverterForType(Class type) {
                        //Do your magic here
                    }
                };
            }
        };
    

    2) Using a Mapper

    In this case I would keep the DefaultMapper and instead implement MapperWrapper‘s for my new mappings. (Have a look at buildMapper inside of XStream.java to see some of the defaults) Initialize like this:

        ClassLoader classLoader = new ClassLoaderReference(new CompositeClassLoader());
        Mapper mapper = new DefaultMapper(classLoader);
        mapper = new MyOwnMapperWrapper(mapper);
        XStream xs = new XStream(null, mapper, new XppDriver());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The only documentation I can find (on MSDN or otherwise) is that a call
The PHP documentation states that php://input can only be read once. In my application
Dozer's documentation states that you should only have one instance of DozerBeanMapper running in
The documentation of jQuery.animate states that The only required parameter is a map of
The documentation ( http://developer.android.com/guide/topics/manifest/manifest-element.html#uid ) only states I can't use raw strings and the
reading the documentation for java org.w3c.dom.ls it seems as a Element only can be
I can't find any information of where cakeError() is defined as member-function. The documentation
I've had a good look through a load of MS documentation only to find
Does it do anything at all or it is only for documentation. If it
I am running an application which was deployed on JBoss. There is only documentation

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.