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 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
Method Summary
|
boolean
|
canRewriteTree
()
Returns false since this IStructureCreator
cannot rewrite the diff tree in order to fold certain combinations of
additions and deletions. |
boolean
|
canSave
()
Returns false since we cannot update a zip archive. |
String
|
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). |
String
|
getName
()
Returns a descriptive name which can be used in the UI of the StructureDiffViewer . |
IStructureComparator
|
getStructure
(
Object input)
Creates a tree structure consisting of IStructureComparator s
from the given object and returns its root object. |
IStructureComparator
|
locate
(
Object path,
Object source)
Creates the single node specified by path from the given input object. |
void
|
rewriteTree
(
Differencer differencer,
IDiffContainer root)
Empty implementation since this IStructureCreator
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. |
Methods inherited from class java.lang.
Object
|
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
|
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 method
getName()
.
-
Parameters:
-
title
- the title of this structure creator
getName
public
String getName()
-
Description copied from interface:
IStructureCreator
- Returns a descriptive name which can be used in the UI of the
StructureDiffViewer
.
-
-
Specified by:
-
getName
in interface
IStructureCreator
-
-
Returns:
- a descriptive name for this
IStructureCreator
getStructure
public
IStructureComparator getStructure(
Object input)
-
Description copied from interface:
IStructureCreator
- Creates a tree structure consisting of
IStructureComparator
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 value null
is returned.
-
-
Specified by:
-
getStructure
in interface
IStructureCreator
-
-
Parameters:
-
input
- the object from which to create the tree of IStructureComparator
-
Returns:
- the root node of the structure or
null
in case of error
getContents
public
String getContents(
Object o,
boolean ignoreWhitespace)
-
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).
If
ignoreWhitespace
is true
all character sequences considered
whitespace should be removed from the returned string.
-
-
Specified by:
-
getContents
in interface
IStructureCreator
-
-
Parameters:
-
o
- the node for which to return a string representation -
ignoreWhitespace
- if true
the returned string should not contain whitespace
-
Returns:
- the string contents of the given node
canSave
public boolean canSave()
- Returns
false
since 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 an
AssertionFailedException
since we cannot update a zip archive.
-
-
Specified by:
-
save
in interface
IStructureCreator
-
-
Parameters:
-
structure
- the node for which to save the new content -
input
- the object from which the structure tree was created in getStructure
locate
public
IStructureComparator locate(
Object path,
Object source)
-
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 value
null
is returned.
This method is similar to getStructure
but in
contrast to getStructure
only a single node without any children must be returned.
This method is used in the ReplaceWithEditionDialog
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
by path
.
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 of path
to the selectEdition
method of ReplaceWithEditionDialog
and will receive this value unchanged
as an argument to locate
.
-
-
Specified by:
-
locate
in interface
IStructureCreator
-
-
Parameters:
-
path
- specifies a sub object within the input object -
source
- the object from which to create the IStructureComparator
-
Returns:
- the single node specified by
path
or null
canRewriteTree
public boolean canRewriteTree()
- Returns
false
since this IStructureCreator
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
public void rewriteTree(
Differencer differencer,
IDiffContainer root)
- Empty implementation since this
IStructureCreator
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
- -
root
-
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.