Package org.eclipse.compare
Class ZipFileStructureCreator
java.lang.Object
org.eclipse.compare.ZipFileStructureCreator
- All Implemented Interfaces:
IStructureCreator
This implementation of the
IStructureCreator interface
makes the contents of a zip archive available as a
hierarchical structure of IStructureComparators.
It is used when comparing the internal structure of a zip archive.
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new ZipFileStructureCreator.ZipFileStructureCreator(String title) Create a new ZipFileStructureCreator with the given title. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnsfalsesince thisIStructureCreatorcannot rewrite the diff tree in order to fold certain combinations of additions and deletions.booleancanSave()Returnsfalsesince we cannot update a zip archive.getContents(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).getName()Returns a descriptive name which can be used in the UI of theStructureDiffViewer.getStructure(Object input) Creates a tree structure consisting ofIStructureComparators from the given object and returns its root object.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 Details
-
ZipFileStructureCreator
public ZipFileStructureCreator()Create a new ZipFileStructureCreator. -
ZipFileStructureCreator
Create a new ZipFileStructureCreator with the given title. The title is returned by the methodgetName().- Parameters:
title- the title of this structure creator
-
-
Method Details
-
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
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
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
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
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
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
-