Goodbye, AOL

After 7 exciting years at AOL, I’m moving on, leaving behind some awesome people and great products. As part of my spring cleaning, I’ve decided to clean up justinsc.com. That means putting up a blog. Now, I’m a terrible blogger. I can’t write well, and I don’t have that much to say. So, this is going to mostly be a repository of interesting code snippets that I come up with.

I’ve solved so many interesting problems after finding a blog post with a solution to a problem. It probably makes more sense to put this on stack overflow, but I wanted to have a place to drop any thoughts too — should I have any 😉

this is a test of really long posts

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur posuere pellentesque faucibus. Pellentesque nec turpis diam, eget dapibus lectus. In hac habitasse platea dictumst. Phasellus nunc leo, convallis id iaculis eget, fermentum id tellus. Phasellus posuere, diam sit amet luctus rhoncus, turpis tellus bibendum orci, vitae molestie massa mi in nulla. Duis imperdiet aliquam eros ac placerat. Fusce at diam odio. Curabitur sed nibh sed orci consequat rhoncus. Pellentesque pellentesque est id dui tristique aliquet. Curabitur at placerat nisi. Maecenas sed lorem sem, vel rhoncus eros. Donec nec dignissim lectus.

Continue reading “this is a test of really long posts”

What’s this blog for?

I’ve tried to blog before, and it never really works for me.  I just don’t have enough interesting things to say.  I do, however, occasionally run into solutions to problems that I want to save somewhere.  Since I find so much help searching Google for others peoples solutions, I figured I should do the same.

So here’s my first try. How do you get XStream to act sanely when it comes to parsing generally unknown xml files? You override the wrapMapper and tell it to not freak out if a parameter isn’t found…


static XStream xstream = new XStream() {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) {
@Override
public boolean shouldSerializeMember(Class definedIn,
String fieldName) {
if (definedIn == Object.class) {
return false;
}
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
};

static {
xstream.alias("xml-read-devices", UdrXmlReadDevices.class);
xstream.alias("xml-write-device", UdrXmlWriteDevice.class);
xstream.alias("xml-confirm-confcode-device", UdrXmlConfirmConfCodeDevice.class);
xstream.addImplicitCollection(UdrXmlReadDevices.class, "device", UdrDevice.class);
xstream.addImplicitCollection(UdrServices.class, "service", UdrService.class);
xstream.useAttributeFor(UdrService.class, "flags");
xstream.useAttributeFor(UdrService.class, "serviceId");
xstream.useAttributeFor(UdrService.class, "type");
xstream.useAttributeFor(UdrXmlConfirmConfCodeDevice.class, "errorCode");
xstream.useAttributeFor(UdrXmlWriteDevice.class, "errorCode");
}