Package org.eclipse.compare
Class ZipFileStructureCreator
- java.lang.Object
-
- org.eclipse.compare.ZipFileStructureCreator
-
- All Implemented Interfaces:
IStructureCreator
public class ZipFileStructureCreator extends Object implements IStructureCreator
This implementation of theIStructureCreatorinterface makes the contents of a zip archive available as a hierarchical structure ofIStructureComparators.It is used when comparing the internal structure of a zip archive.
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description ZipFileStructureCreator()Create a new ZipFileStructureCreator.ZipFileStructureCreator(String title)Create a new ZipFileStructureCreator with the given title.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRewriteTree()Returnsfalsesince thisIStructureCreatorcannot rewrite the diff tree in order to fold certain combinations of additions and deletions.booleancanSave()Returnsfalsesince we cannot update a zip archive.StringgetContents(Object o, boolean ignoreWhitespace)Returns the contents of the given node as a string for the purpose of performing a content comparison only (that is the string will not be visible in the UI).StringgetName()Returns a descriptive name which can be used in the UI of theStructureDiffViewer.IStructureComparatorgetStructure(Object input)Creates a tree structure consisting ofIStructureComparators from the given object and returns its root object.IStructureComparatorlocate(Object path, Object source)Creates the single node specified by path from the given input object.voidrewriteTree(Differencer differencer, IDiffContainer root)Empty implementation since thisIStructureCreatorcannot rewrite the diff tree in order to fold certain combinations of additions and deletions.voidsave(IStructureComparator structure, Object input)Called whenever a copy operation has been performed on a tree node.
-
-
-
Constructor Detail
-
ZipFileStructureCreator
public ZipFileStructureCreator()
Create a new ZipFileStructureCreator.
-
ZipFileStructureCreator
public ZipFileStructureCreator(String title)
Create a new ZipFileStructureCreator with the given title. The title is returned by the methodgetName().- Parameters:
title- the title of this structure creator
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:IStructureCreatorReturns a descriptive name which can be used in the UI of theStructureDiffViewer.- Specified by:
getNamein interfaceIStructureCreator- Returns:
- a descriptive name for this
IStructureCreator
-
getStructure
public IStructureComparator getStructure(Object input)
Description copied from interface:IStructureCreatorCreates a tree structure consisting ofIStructureComparators from the given object and returns its root object. Implementing this method typically involves parsing the input object. In case of an error (e.g. a parsing error) the valuenullis returned.- Specified by:
getStructurein interfaceIStructureCreator- Parameters:
input- the object from which to create the tree ofIStructureComparator- Returns:
- the root node of the structure or
nullin case of error
-
getContents
public String getContents(Object o, boolean ignoreWhitespace)
Description copied from interface:IStructureCreatorReturns the contents of the given node as a string for the purpose of performing a content comparison only (that is the string will not be visible in the UI). IfignoreWhitespaceistrueall character sequences considered whitespace should be removed from the returned string.- Specified by:
getContentsin interfaceIStructureCreator- Parameters:
o- the node for which to return a string representationignoreWhitespace- iftruethe returned string should not contain whitespace- Returns:
- the string contents of the given node
-
canSave
public boolean canSave()
Returnsfalsesince we cannot update a zip archive.- Returns:
false
-
save
public void save(IStructureComparator structure, Object input)
Called whenever a copy operation has been performed on a tree node. This implementation throws anAssertionFailedExceptionsince we cannot update a zip archive.- Specified by:
savein interfaceIStructureCreator- Parameters:
structure- the node for which to save the new contentinput- the object from which the structure tree was created ingetStructure
-
locate
public IStructureComparator locate(Object path, Object source)
Description copied from interface:IStructureCreatorCreates the single node specified by path from the given input object. In case of an error (e.g. a parsing error) the valuenullis returned. This method is similar togetStructurebut in contrast togetStructureonly a single node without any children must be returned. This method is used in theReplaceWithEditionDialogto locate a sub element (e.g. a method) within an input object (e.g. a file containing source code).One (not optimized) approach to implement this method is calling
getStructure(input)to build the full tree, and then finding that node within the tree that is specified bypath.The syntax of
pathis not specified, because it is treated by the compare subsystem as an opaque entity and is not further interpreted. Clients using this functionality will pass a value ofpathto theselectEditionmethod ofReplaceWithEditionDialogand will receive this value unchanged as an argument tolocate.- Specified by:
locatein interfaceIStructureCreator- Parameters:
path- specifies a sub object within the input objectsource- the object from which to create theIStructureComparator- Returns:
- the single node specified by
pathornull
-
canRewriteTree
public boolean canRewriteTree()
Returnsfalsesince thisIStructureCreatorcannot rewrite the diff tree in order to fold certain combinations of additions and deletions.Note: this method is for internal use only. Clients should not call this method.
- Returns:
false
-
rewriteTree
public void rewriteTree(Differencer differencer, IDiffContainer root)
Empty implementation since thisIStructureCreatorcannot rewrite the diff tree in order to fold certain combinations of additions and deletions.Note: this method is for internal use only. Clients should not call this method.
- Parameters:
differencer- the differencer used to rewriteroot- the root to rewrite
-
-