com.helger.ebinterface.builder.EbInterfaceWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ph-ebinterface Show documentation
Show all versions of ph-ebinterface Show documentation
ebInterface wrapper library to easily read and write ebInterface documents
/**
* Copyright (C) 2014-2020 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* 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 com.helger.ebinterface.builder;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;
import com.helger.ebinterface.EbInterface302NamespaceContext;
import com.helger.ebinterface.EbInterface30NamespaceContext;
import com.helger.ebinterface.EbInterface40NamespaceContext;
import com.helger.ebinterface.EbInterface41NamespaceContext;
import com.helger.ebinterface.EbInterface42NamespaceContext;
import com.helger.ebinterface.EbInterface43NamespaceContext;
import com.helger.ebinterface.EbInterface50NamespaceContext;
import com.helger.ebinterface.EbInterface60NamespaceContext;
import com.helger.ebinterface.v30.Ebi30InvoiceType;
import com.helger.ebinterface.v302.Ebi302InvoiceType;
import com.helger.ebinterface.v40.Ebi40InvoiceType;
import com.helger.ebinterface.v41.Ebi41InvoiceType;
import com.helger.ebinterface.v42.Ebi42InvoiceType;
import com.helger.ebinterface.v43.Ebi43InvoiceType;
import com.helger.ebinterface.v50.Ebi50InvoiceType;
import com.helger.ebinterface.v60.Ebi60InvoiceType;
import com.helger.jaxb.builder.JAXBWriterBuilder;
import com.helger.xml.namespace.MapBasedNamespaceContext;
/**
* A writer builder for ebInterface documents.
*
* @author Philip Helger
* @param
* The ebInterface implementation class to be written
*/
@NotThreadSafe
public class EbInterfaceWriter extends JAXBWriterBuilder >
{
public EbInterfaceWriter (@Nonnull final EEbInterfaceDocumentType eDocType)
{
super (eDocType);
// Create a default namespace context for the passed document type
final MapBasedNamespaceContext aNSContext = new MapBasedNamespaceContext ();
aNSContext.setMapping ("eb", m_aDocType.getNamespaceURI ());
setNamespaceContext (aNSContext);
}
public EbInterfaceWriter (@Nonnull final Class aClass)
{
this (EbInterfaceDocumentTypes.getDocumentTypeOfImplementationClass (aClass));
}
/**
* Create a new writer builder.
*
* @param aClass
* The UBL class to be written. May not be null
.
* @return The new writer builder. Never null
.
* @param
* The ebInterface document implementation type
*/
@Nonnull
public static EbInterfaceWriter create (@Nonnull final Class aClass)
{
return new EbInterfaceWriter <> (aClass);
}
/**
* Create a writer builder for Ebi30InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface30 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi30InvoiceType.class);
ret.setNamespaceContext (EbInterface30NamespaceContext.getInstance ());
return ret;
}
/**
* Create a writer builder for Ebi302InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface302 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi302InvoiceType.class);
ret.setNamespaceContext (EbInterface302NamespaceContext.getInstance ());
return ret;
}
/**
* Create a writer builder for Ebi40InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface40 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi40InvoiceType.class);
ret.setNamespaceContext (EbInterface40NamespaceContext.getInstance ());
return ret;
}
/**
* Create a writer builder for Ebi41InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface41 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi41InvoiceType.class);
ret.setNamespaceContext (EbInterface41NamespaceContext.getInstance ());
return ret;
}
/**
* Create a writer builder for Ebi42InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface42 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi42InvoiceType.class);
ret.setNamespaceContext (EbInterface42NamespaceContext.getInstance ());
return ret;
}
/**
* Create a writer builder for Ebi43InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface43 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi43InvoiceType.class);
ret.setNamespaceContext (EbInterface43NamespaceContext.getInstance ());
return ret;
}
/**
* Create a writer builder for Ebi50InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface50 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi50InvoiceType.class);
ret.setNamespaceContext (EbInterface50NamespaceContext.getInstance ());
return ret;
}
/**
* Create a writer builder for Ebi60InvoiceType.
*
* @return The builder and never null
*/
@Nonnull
public static EbInterfaceWriter ebInterface60 ()
{
final EbInterfaceWriter ret = EbInterfaceWriter.create (Ebi60InvoiceType.class);
ret.setNamespaceContext (EbInterface60NamespaceContext.getInstance ());
return ret;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy