net.shibboleth.metadata.dom
Class ElementFormattingStage

java.lang.Object
  extended by net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
      extended by net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
          extended by net.shibboleth.metadata.pipeline.BaseStage<DomElementItem>
              extended by net.shibboleth.metadata.dom.ElementFormattingStage
All Implemented Interfaces:
Stage<DomElementItem>, net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.IdentifiableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent

public class ElementFormattingStage
extends BaseStage<DomElementItem>

A stage that formats a collection of DOM Elements.

Note, this stage uses Xalan so Xalan must be included on the classpath. However, Xalan does not have to be the system default TransformerFactory implementation.


Field Summary
private  List<String> cdataSectionElements
          List of elements whose content should be wrapped in CDATA sections.
private  boolean indented
          Whether to indent elements.
private  int indentSize
          Number of spaces used to indent elements.
private  String lineSeparator
          Line separator character to use.
private  TransformerFactory transformerFactory
          The factory used to create the Transformer used to format the elements.
 
Constructor Summary
ElementFormattingStage()
           
 
Method Summary
protected  void doExecute(Collection<DomElementItem> itemCollection)
          Performs the stage processing on the given Item collection.
protected  void doInitialize()
          
 List<String> getCdataSectionElements()
          Gets the list of elements whose content should be wrapped in CDATA sections.
 int getIndentSize()
          Gets the number of spaces to use when indenting elements.
 String getLineSeparator()
          Gets the line separator character to use.
protected  Transformer getTransformer()
          Builds the Transformer that will be used to format the element.
 boolean isIndented()
          Gets whether to indent elements.
 void setCdataSectionElements(List<String> elements)
          Sets the list of elements whose content should be wrapped in CDATA sections.
 void setIndented(boolean indentElements)
          Sets whether to indent elements.
 void setIndentSize(int size)
          Sets the number of spaces to use when indenting elements.
 void setLineSeparator(String separator)
          Sets the line separator character to use.
 
Methods inherited from class net.shibboleth.metadata.pipeline.BaseStage
execute, setId
 
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
getId
 
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.DestructableComponent
destroy, isDestroyed
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiableComponent
getId
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
 

Field Detail

lineSeparator

private String lineSeparator
Line separator character to use. Default value: \n


indented

private boolean indented
Whether to indent elements. Default value: true


indentSize

private int indentSize
Number of spaces used to indent elements. Default value: 4


cdataSectionElements

private List<String> cdataSectionElements
List of elements whose content should be wrapped in CDATA sections. Elements are specified either by their local name, if they are not in a namespace, or via the form '{' + namespace URI + '}' + local name if they are in a namespace.


transformerFactory

private TransformerFactory transformerFactory
The factory used to create the Transformer used to format the elements.

Constructor Detail

ElementFormattingStage

public ElementFormattingStage()
Method Detail

getLineSeparator

@Nonnull
public String getLineSeparator()
Gets the line separator character to use.

Returns:
line separator character to use

setLineSeparator

public void setLineSeparator(@Nullable
                             String separator)
Sets the line separator character to use.

Parameters:
separator - line separator character to use

isIndented

public boolean isIndented()
Gets whether to indent elements.

Returns:
whether to indent elements

setIndented

public void setIndented(boolean indentElements)
Sets whether to indent elements.

Parameters:
indentElements - whether to indent elements

getIndentSize

public int getIndentSize()
Gets the number of spaces to use when indenting elements.

Returns:
number of spaces to use when indenting elements

setIndentSize

public void setIndentSize(int size)
Sets the number of spaces to use when indenting elements.

Parameters:
size - number of spaces to use when indenting elements, must be 0 or greater

getCdataSectionElements

@Nonnull
@NonnullElements
@Unmodifiable
public List<String> getCdataSectionElements()
Gets the list of elements whose content should be wrapped in CDATA sections.

Elements are specified either by their local name, if they are not in a namespace, or via the form '{' + namespace URI + '}' + local name if they are in a namespace.

Returns:
list of elements whose content should be wrapped in CDATA sections

setCdataSectionElements

public void setCdataSectionElements(@Nullable@NullableElements
                                    List<String> elements)
Sets the list of elements whose content should be wrapped in CDATA sections.

Parameters:
elements - list of elements whose content should be wrapped in CDATA sections

doExecute

protected void doExecute(Collection<DomElementItem> itemCollection)
                  throws StageProcessingException
Performs the stage processing on the given Item collection.

The stage is guaranteed to be have been initialized and not destroyed when this is invoked.

Specified by:
doExecute in class BaseStage<DomElementItem>
Parameters:
itemCollection - collection to be processed
Throws:
StageProcessingException - thrown if there is an unrecoverable problem when processing the stage

getTransformer

protected Transformer getTransformer()
                              throws StageProcessingException
Builds the Transformer that will be used to format the element.

Returns:
the Transformer that will be used to format the element
Throws:
StageProcessingException - thrown if the configuration of the TransformerFactory has become corrupted since stage initialization

doInitialize

protected void doInitialize()
                     throws net.shibboleth.utilities.java.support.component.ComponentInitializationException

Overrides:
doInitialize in class net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException


Copyright © 1999-2012. All Rights Reserved.