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 IStructureComparator
s.
It is used when comparing the internal structure of a zip archive.
- Since:
- 2.0
-
Constructor Summary
ConstructorDescriptionCreate a new ZipFileStructureCreator.ZipFileStructureCreator
(String title) Create a new ZipFileStructureCreator with the given title. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnsfalse
since thisIStructureCreator
cannot rewrite the diff tree in order to fold certain combinations of additions and deletions.boolean
canSave()
Returnsfalse
since 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 ofIStructureComparator
s from the given object and returns its root object.Creates the single node specified by path from the given input object.void
rewriteTree
(Differencer differencer, IDiffContainer root) Empty implementation since thisIStructureCreator
cannot rewrite the diff tree in order to fold certain combinations of additions and deletions.void
save
(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:IStructureCreator
Returns a descriptive name which can be used in the UI of theStructureDiffViewer
.- Specified by:
getName
in interfaceIStructureCreator
- Returns:
- a descriptive name for this
IStructureCreator
-
getStructure
Description copied from interface:IStructureCreator
Creates a tree structure consisting ofIStructureComparator
s 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 valuenull
is returned.- Specified by:
getStructure
in interfaceIStructureCreator
- Parameters:
input
- the object from which to create the tree ofIStructureComparator
- Returns:
- the root node of the structure or
null
in case of error
-
getContents
Description copied from interface:IStructureCreator
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). IfignoreWhitespace
istrue
all character sequences considered whitespace should be removed from the returned string.- Specified by:
getContents
in interfaceIStructureCreator
- Parameters:
o
- the node for which to return a string representationignoreWhitespace
- iftrue
the returned string should not contain whitespace- Returns:
- the string contents of the given node
-
canSave
public boolean canSave()Returnsfalse
since we cannot update a zip archive.- Returns:
false
-
save
Called whenever a copy operation has been performed on a tree node. This implementation throws anAssertionFailedException
since we cannot update a zip archive.- Specified by:
save
in 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:IStructureCreator
Creates the single node specified by path from the given input object. In case of an error (e.g. a parsing error) the valuenull
is returned. This method is similar togetStructure
but in contrast togetStructure
only a single node without any children must be returned. This method is used in theReplaceWithEditionDialog
to 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
path
is 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 ofpath
to theselectEdition
method ofReplaceWithEditionDialog
and will receive this value unchanged as an argument tolocate
.- Specified by:
locate
in interfaceIStructureCreator
- Parameters:
path
- specifies a sub object within the input objectsource
- the object from which to create theIStructureComparator
- Returns:
- the single node specified by
path
ornull
-
canRewriteTree
public boolean canRewriteTree()Returnsfalse
since thisIStructureCreator
cannot 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 thisIStructureCreator
cannot 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
-