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

org.apache.juddi.jaxb.PrintUDDI Maven / Gradle / Ivy

There is a newer version: 3.3.10
Show newest version
/*
 * Copyright 2001-2009 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.juddi.jaxb;

import java.io.StringWriter;
import javax.xml.bind.JAXB;


/**
 * This is for printing UDDI v3 objects from the spec.

* @author Kurt T Stam * @author Alex O'Ree * @see javax.xml.bind.JAXB * @param */ public class PrintUDDI { /* static JAXBContext jaxbContext = null; private Marshaller getUDDIMarshaller() throws JAXBException { if (jaxbContext==null) { jaxbContext=JAXBContext.newInstance("org.uddi.api_v3"); } Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); return marshaller; } */ /** * Prints a UDDI entity. * @param UDDIEntity * @return Marshalled XML as a string * @throws IllegalArgumentException */ public String print(T UDDIEntity) { if (UDDIEntity==null) throw new IllegalArgumentException(); StringWriter sw = new StringWriter(); JAXB.marshal(UDDIEntity, sw); return sw.toString(); /*String xml = ""; @SuppressWarnings("unchecked") Class type = (Class) UDDIEntity.getClass(); try { StringWriter writer = new StringWriter(); JAXBElement element = new JAXBElement(new QName("",UDDIEntity.getClass().getName()),type,UDDIEntity); getUDDIMarshaller().marshal(element,writer); xml=writer.toString(); } catch (JAXBException je) { } return xml;*/ } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy