Package org.codehaus.cargo.module.merge
Class DocumentStreamAdapter
- java.lang.Object
-
- org.codehaus.cargo.module.merge.DocumentStreamAdapter
-
- All Implemented Interfaces:
MergeProcessor
public class DocumentStreamAdapter extends Object implements MergeProcessor
Adapter class to convert streams into documents.
This is needed because the DocumentMerger understands DOM Documents, but items in War files are accessed as streams - therefore use this wrapper to pass streams into the DocumentMerger (or subclass).
-
-
Constructor Summary
Constructors Constructor Description DocumentStreamAdapter(MergeProcessor next)
constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMergeItem(Object mergeItem)
Add an item to be merged.DescriptorIo
getDescriptorIo()
protected org.jdom2.Document
getDocument(InputStream theInput)
Parse the input stream into a document.Object
performMerge()
Perform the merge.void
setDescriptorIo(DescriptorIo descriptorIo)
-
-
-
Constructor Detail
-
DocumentStreamAdapter
public DocumentStreamAdapter(MergeProcessor next)
constructor.- Parameters:
next
- the processor to adapt
-
-
Method Detail
-
addMergeItem
public void addMergeItem(Object mergeItem) throws MergeException
Add an item to be merged.- Specified by:
addMergeItem
in interfaceMergeProcessor
- Parameters:
mergeItem
- in the item to merge.- Throws:
MergeException
- on exceptions
-
performMerge
public Object performMerge() throws MergeException
Perform the merge.- Specified by:
performMerge
in interfaceMergeProcessor
- Returns:
- the merged artifact
- Throws:
MergeException
- if there is a problem
-
getDocument
protected org.jdom2.Document getDocument(InputStream theInput) throws IOException, org.jdom2.JDOMException
Parse the input stream into a document.- Parameters:
theInput
- in the InputStream to read- Returns:
- Document generated from the stream
- Throws:
IOException
- on IO exceptionorg.jdom2.JDOMException
- if there is an XML problem
-
getDescriptorIo
public DescriptorIo getDescriptorIo()
- Returns:
- the descriptorIo
-
setDescriptorIo
public void setDescriptorIo(DescriptorIo descriptorIo)
- Parameters:
descriptorIo
- the descriptorIo to set
-
-