All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.truelicense.xml.LicenseXmlCodec Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy