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

com.phloc.commons.xml.serialize.IXMLWriterSettings Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
/**
 * Copyright (C) 2006-2015 phloc systems
 * http://www.phloc.com
 * office[at]phloc[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.phloc.commons.xml.serialize;

import java.nio.charset.Charset;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.namespace.NamespaceContext;

import com.phloc.commons.annotations.Nonempty;
import com.phloc.commons.xml.EXMLIncorrectCharacterHandling;
import com.phloc.commons.xml.EXMLVersion;

/**
 * Interface for the settings to be used for serializing XML nodes.
 * 
 * @author Philip Helger
 */
public interface IXMLWriterSettings
{
  /**
   * @return Create XML or HTML? Default is XML.
   */
  @Nonnull
  EXMLSerializeFormat getFormat ();

  /**
   * @return The XML version to use. Default is 1.0
   */
  @Nonnull
  EXMLVersion getXMLVersion ();

  /**
   * @return Write document type? Default is true.
   */
  @Nonnull
  EXMLSerializeDocType getSerializeDocType ();

  /**
   * @return Write comments? Default is true.
   */
  @Nonnull
  EXMLSerializeComments getSerializeComments ();

  /**
   * @return Indent code? Default is indent and aligned.
   */
  @Nonnull
  EXMLSerializeIndent getIndent ();

  /**
   * @return The incorrect character handling to be used. May not be
   *         null.
   */
  @Nonnull
  EXMLIncorrectCharacterHandling getIncorrectCharacterHandling ();

  /**
   * @return The charset name to use. May never be null.
   */
  @Nonnull
  String getCharset ();

  /**
   * @return The charset to use. May never be null.
   */
  @Nonnull
  Charset getCharsetObj ();

  /**
   * @return The namespace context to be used. May be null to
   *         dynamically create the namespace prefixes.
   */
  @Nullable
  NamespaceContext getNamespaceContext ();

  /**
   * @return true if attribute values should be enclosed in double
   *         quotes, false if single quotes should be used.
   */
  boolean isUseDoubleQuotesForAttributes ();

  /**
   * Determine if a self closed element (an element having no children) should
   * be emitted with a space at the end (<br />) or not (
   * <br/>)
   * 
   * @return true if a space should be emitted, false
   *         if no space should be emitted.
   */
  boolean isSpaceOnSelfClosedElement ();

  /**
   * @return The newline string to be used. By default it is the platform
   *         specific newline string. Never null nor empty.
   */
  @Nonnull
  @Nonempty
  String getNewlineString ();

  /**
   * @return The string to be used for indentation. By default it is 2 spaces.
   */
  @Nonnull
  @Nonempty
  String getIndentationString ();

  /**
   * Determine if namespaces should be emitted or not.
   * 
   * @return true if namespaces should be emitted,
   *         false if all created elements should reside in the
   *         default namespace.
   */
  boolean isEmitNamespaces ();

  /**
   * Check if the flag for putting all namespace prefixes specified in the
   * namespace context should be put in the root document. This setting only has
   * an effect if a namespace context is defined and if it implements the
   * {@link com.phloc.commons.xml.namespace.IIterableNamespaceContext}
   * interface!
   * 
   * @return true if it is enabled, false if not.
   */
  boolean isPutNamespaceContextPrefixesInRoot ();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy