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

com.helger.asic.jaxb.AsicWriter Maven / Gradle / Ivy

/**
 * Copyright (C) 2015-2017 difi (www.difi.no)
 * Copyright (C) 2018-2021 Philip Helger (www.helger.com)
 * philip[at]helger[dot]com
 *
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0.
 * If a copy of the MPL was not distributed
 * with this file, You can obtain one at
 * https://mozilla.org/MPL/2.0/
 */
package com.helger.asic.jaxb;

import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;

import com.helger.asic.OasisManifest;
import com.helger.asic.jaxb.cades.ASiCManifestType;
import com.helger.asic.jaxb.opendocument.manifest.Manifest;
import com.helger.jaxb.builder.JAXBWriterBuilder;
import com.helger.xml.namespace.MapBasedNamespaceContext;

/**
 * A writer builder for Asic documents.
 *
 * @author Philip Helger
 * @param 
 *        The Asic implementation class to be read
 */
@NotThreadSafe
public class AsicWriter  extends JAXBWriterBuilder >
{
  public AsicWriter (@Nonnull final EAsicDocumentType eDocType)
  {
    super (eDocType);
  }

  /**
   * Create a writer builder for ASiCManifestType.
   *
   * @return The builder and never null
   */
  @Nonnull
  public static AsicWriter  asicManifest ()
  {
    final AsicWriter  ret = new AsicWriter <> (EAsicDocumentType.ASIC_MANIFEST);
    ret.setFormattedOutput (true);
    return ret;
  }

  /**
   * Create a writer builder for Manifest.
   *
   * @return The builder and never null
   */
  @Nonnull
  public static AsicWriter  oasisManifest ()
  {
    final AsicWriter  ret = new AsicWriter <> (EAsicDocumentType.OASIS_MANIFEST);
    final MapBasedNamespaceContext aCtx = new MapBasedNamespaceContext ();
    // Not default namespace because attribute form is qualified!
    aCtx.addMapping ("manifest", OasisManifest.NAMESPACE_URI);
    ret.setNamespaceContext (aCtx);
    ret.setFormattedOutput (true);
    return ret;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy