Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class Main {
    public static <ValueType, BoundType> ValueType marshall(
            Class<? extends XmlAdapter<ValueType, BoundType>> xmlAdapterClass, BoundType v) {
        try {
            final XmlAdapter<ValueType, BoundType> xmlAdapter = getXmlAdapter(xmlAdapterClass);
            return xmlAdapter.marshal(v);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    public static <ValueType, BoundType> XmlAdapter<ValueType, BoundType> getXmlAdapter(
            Class<? extends XmlAdapter<ValueType, BoundType>> xmlAdapterClass) {
        try {
            final XmlAdapter<ValueType, BoundType> xmlAdapter = xmlAdapterClass.newInstance();
            return xmlAdapter;
        } catch (IllegalAccessException iaex) {
            throw new RuntimeException(iaex);
        } catch (InstantiationException iex) {
            throw new RuntimeException(iex);
        }
    }
}