Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

oracle.jdeveloper.compare
Class CompareMethod

java.lang.Object
  extended by oracle.jdeveloper.compare.CompareMethod

public abstract class CompareMethod
extends java.lang.Object

Base class for a compare/merge method as registered through the CompareManager. The function of a CompareMethod is to recognize an invocation context, associate it with a CompareType, and specify any required fallback behavior if the compare (or merge) algorithm fails to complete. Fallback might happen, for example, if an XML file contains a corruption or is over the maximum comparable size.

Since:
11.1.1.0.0

Constructor Summary
CompareMethod()
           
 
Method Summary
abstract  boolean canCompare(CompareContributor left, CompareContributor right, StreamType streamType)
          Asks whether the given contributors, from the current context, can be compared.
 boolean canFallBack(CompareFailedException cfe)
          Asks whether the fallback behavior should go ahead when the algorithm has failed with the given exception.
 boolean canMerge(CompareContributor left, CompareContributor right, CompareContributor ancestor)
          Asks whether the given contributors, from the current context, can be merged.
protected  oracle.jdevimpl.compare.CompareOptions getCompareOptions()
          Gets the CompareOptions instance from IDE preferences.
abstract  CompareType getCompareType()
          Gets the CompareType associated with this CompareMethod
 CompareType[] getFallbackCompareTypes()
          Gets the fallback compare types whose algorithms can be invoked if this CompareMethod fails.
protected  StreamType getStreamType(CompareContributor contributor)
          Scans the stream for the given CompareContributor to yield information about the type of the represented file.
protected  TextBuffer getTextBuffer(CompareContributor contributor)
          Gets the text buffer for the given CompareContributor.
 void processOptions()
          Process any options from the environment, prior to invoking the compare/merge algorithm.
 boolean recognizeContent(java.net.URL url)
           
protected  java.lang.String scanForXMLNamespaceURI(TextBuffer textBuffer, java.lang.String name)
          Scans the given buffer for an XML root element's namespace URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompareMethod

public CompareMethod()
Method Detail

recognizeContent

public boolean recognizeContent(java.net.URL url)

canCompare

public abstract boolean canCompare(CompareContributor left,
                                   CompareContributor right,
                                   StreamType streamType)
Asks whether the given contributors, from the current context, can be compared.

Note that this method is performance-critical and must do a minumum of work to recognize the context, E.g. by scanning files rather than parsing them in their entirety.

Parameters:
left - the left-hand side contributor.
right - the right-hand side contributor.
streamType - the StreamType, if available. (null-capable)
Returns:
a verdict on whether the algorithm for the associated CompareType can compare the given contributors.

canMerge

public boolean canMerge(CompareContributor left,
                        CompareContributor right,
                        CompareContributor ancestor)
Asks whether the given contributors, from the current context, can be merged.

Note that this method is performance-critical and must do a minumum of work to recognize the context, E.g. by scanning files rather than parsing them in their entirety.

Parameters:
left - the left-hand side contributor.
right - the right-hand side contributor.
ancestor - the common ancestor contributor.
Returns:
a verdict on whether the algorithm for the associated CompareType can merge the given contributors.

getCompareType

public abstract CompareType getCompareType()
Gets the CompareType associated with this CompareMethod

Returns:
the associated CompareType.

processOptions

public void processOptions()
Process any options from the environment, prior to invoking the compare/merge algorithm.


canFallBack

public boolean canFallBack(CompareFailedException cfe)
Asks whether the fallback behavior should go ahead when the algorithm has failed with the given exception. In the case of severe exceptions, it may be better to veto the fallback mechanism and abandon the compare/merge operation altogether. By default, returns true.

Parameters:
cfe - the failure.
Returns:
a verdict on whether fallback should occur.

getFallbackCompareTypes

public CompareType[] getFallbackCompareTypes()
Gets the fallback compare types whose algorithms can be invoked if this CompareMethod fails. In practice, only one returned CompareType will be chosen for fallback; this will be the first type with a registered algorithm. Returning multiple types gives the framework an alternative for when an algorithm is not available because, for example, its product extension is not loaded.

Returns:
an array of fallback types.

getStreamType

protected final StreamType getStreamType(CompareContributor contributor)
Scans the stream for the given CompareContributor to yield information about the type of the represented file.

Parameters:
contributor - the CompareContributor.
Returns:
the contributor's StreamType.

getTextBuffer

protected final TextBuffer getTextBuffer(CompareContributor contributor)
Gets the text buffer for the given CompareContributor. This will not be accessible for certain contributor types (E.g. those representing directories).

Parameters:
contributor - the CompareContributor.
Returns:
the contributor's TextBuffer. (null-capable)

scanForXMLNamespaceURI

protected final java.lang.String scanForXMLNamespaceURI(TextBuffer textBuffer,
                                                        java.lang.String name)
Scans the given buffer for an XML root element's namespace URI.

Parameters:
textBuffer - the TextBuffer to scan.
name - the namespace name, or null for the default namespace.
Returns:
the value for the namespace URI, if any, with no leading/trailing parentheses.

getCompareOptions

protected final oracle.jdevimpl.compare.CompareOptions getCompareOptions()
Gets the CompareOptions instance from IDE preferences.

Returns:
the IDE's CompareOptions.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

Copyright © 1997, 2010, Oracle. All rights reserved.