net.java.truelicense.xml.LicenseXmlCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truelicense-xml Show documentation
Show all versions of truelicense-xml Show documentation
Provides Utilities for XML.
The newest version!
/*
* Copyright (C) 2005-2013 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package net.java.truelicense.xml;
import java.beans.*;
import java.io.OutputStream;
import javax.annotation.concurrent.Immutable;
import javax.security.auth.x500.X500Principal;
import net.java.truelicense.core.License;
/**
* A custom XML codec for use with {@link License}s and {@link XmlRepository}s.
* It will add a custom persistence delegate for use with {@link X500Principal}s
* to each new {@link XMLEncoder}.
*
* @author Christian Schlichtherle
*/
@Immutable
public class LicenseXmlCodec extends XmlCodec {
private static final PersistenceDelegate pd4xp =
new DefaultPersistenceDelegate(new String[]{ "name" }); // NOI18N
@Override
protected XMLEncoder encoder(final OutputStream out) {
final XMLEncoder enc = super.encoder(out);
enc.setPersistenceDelegate(X500Principal.class, pd4xp);
return enc;
}
}