org.eclipse.emf.codegen.merge.java
Class JMerger

java.lang.Object
  extended by org.eclipse.emf.codegen.merge.java.JMerger

public class JMerger
extends java.lang.Object

This implements the method run(java.lang.Object), which is called just like main during headless workbench invocation.


Nested Class Summary
 class JMerger.PullTargetVisitor
           
 class JMerger.PushSourceVisitor
           
 
Field Summary
protected  JControlModel controlModel
           
static boolean DEBUG
           
static java.lang.String DEFAULT_FACADE_HELPER_CLASS
           
protected  boolean fixInterfaceBrace
           
protected static java.util.regex.Pattern interfaceBracePattern
           
protected  boolean isBlocked
           
protected static java.lang.Object[] NO_ARGUMENTS
           
protected  boolean noAbstractTypeConversion
           
protected  java.util.Map<JNode,java.util.List<JNode>> orderedSourceChildrenMap
           
protected  JCompilationUnit sourceCompilationUnit
           
protected  JPatternDictionary sourcePatternDictionary
           
protected  java.util.Map<JNode,JNode> sourceToTargetMap
           
protected  boolean targetCompilationChanged
           
protected  JCompilationUnit targetCompilationUnit
           
protected  boolean targetCompilationUnitExists
           
protected  JPatternDictionary targetPatternDictionary
           
protected  java.util.Map<JNode,JNode> targetToSourceMap
           
 
Constructor Summary
JMerger()
          This creates an empty instances, an when used as a runnable.
JMerger(JControlModel controlModel)
           
 
Method Summary
protected  void applyPullRules(JNode sourceNode, JNode targetNode)
           
protected  void applySortRules(JNode sourceNode)
           
protected  boolean applySweepRules(JNode targetNode)
           
protected  boolean areCompatible(JNode sourceNode, JNode targetNode)
          Checks if two nodes are compatible and can be merged.
protected  JNode convertTarget(JAbstractType targetAbstractType, java.lang.Class<? extends JAbstractType> sourceClass)
          Converts the target abstract type to be compatible with the given source node class
 JCompilationUnit createCompilationUnitForContents(java.lang.String contents)
           
 JCompilationUnit createCompilationUnitForInputStream(java.io.InputStream inputStream)
           
 JCompilationUnit createCompilationUnitForInputStream(java.io.InputStream inputStream, java.lang.String encoding)
           
 JCompilationUnit createCompilationUnitForURI(java.lang.String uri)
          Creates a JCompilationUnit from a URI.
 JCompilationUnit createCompilationUnitForURI(java.lang.String uri, java.lang.String encoding)
          Creates a JCompilationUnit from a URI.
protected  FacadeVisitor createPullTargetVisitor()
           
protected  FacadeVisitor createPushSourceVisitor()
           
 java.lang.String execute(Monitor monitor, java.lang.String[] arguments)
          Utility for headless operations.
 JControlModel getControlModel()
           
 JCompilationUnit getSourceCompilationUnit()
           
 java.lang.String getSourceCompilationUnitContents()
           
 JPatternDictionary getSourcePatternDictionary()
           
 JCompilationUnit getTargetCompilationUnit()
           
 java.lang.String getTargetCompilationUnitContents()
           
 JPatternDictionary getTargetPatternDictionary()
           
protected  JNode insertClone(JNode sourceNode)
           
 boolean isFixInterfaceBrace()
           
protected  boolean isPushMarkedUp(JNode node)
          Checks if the node is marked up for pushing.
protected  void map(JNode sourceNode, JNode targetNode)
          Maps the specified source and target nodes.
protected  void mapChildren(JNode sourceNode, JNode targetNode)
           
 void merge()
           
protected  void pullTargetCompilationUnit()
           
protected  void pushSourceCompilationUnit()
           
 void remerge()
           
 void reset()
          Resets this JMerger.
 java.lang.Object run(java.lang.Object object)
          This is called with the command line arguments of a headless workbench invocation.
 void setFixInterfaceBrace(boolean fixInterfaceBrace)
           
 void setSourceCompilationUnit(JCompilationUnit sourceCompilationUnit)
           
 void setSourcePatternDictionary(JPatternDictionary sourcePatternDictionary)
           
 void setTargetCompilationUnit(JCompilationUnit targetCompilationUnit)
           
 void setTargetPatternDictionary(JPatternDictionary targetPatternDictionary)
           
protected  void sortTargetCompilationUnit()
           
protected  void sweepTargetCompilationUnit()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values

DEFAULT_FACADE_HELPER_CLASS

public static final java.lang.String DEFAULT_FACADE_HELPER_CLASS

NO_ARGUMENTS

protected static final java.lang.Object[] NO_ARGUMENTS

interfaceBracePattern

protected static java.util.regex.Pattern interfaceBracePattern

controlModel

protected JControlModel controlModel

sourceCompilationUnit

protected JCompilationUnit sourceCompilationUnit

targetCompilationUnit

protected JCompilationUnit targetCompilationUnit

sourcePatternDictionary

protected JPatternDictionary sourcePatternDictionary

targetPatternDictionary

protected JPatternDictionary targetPatternDictionary

sourceToTargetMap

protected java.util.Map<JNode,JNode> sourceToTargetMap

targetToSourceMap

protected java.util.Map<JNode,JNode> targetToSourceMap

orderedSourceChildrenMap

protected java.util.Map<JNode,java.util.List<JNode>> orderedSourceChildrenMap

fixInterfaceBrace

protected boolean fixInterfaceBrace

isBlocked

protected boolean isBlocked

targetCompilationUnitExists

protected boolean targetCompilationUnitExists

targetCompilationChanged

protected boolean targetCompilationChanged

noAbstractTypeConversion

protected boolean noAbstractTypeConversion
Constructor Detail

JMerger

public JMerger()
This creates an empty instances, an when used as a runnable.


JMerger

public JMerger(JControlModel controlModel)
Method Detail

reset

public void reset()
Resets this JMerger. After calling this method, it is necessary to set the source and target compilation unit to reuse this instance.


merge

public void merge()

remerge

public void remerge()

createCompilationUnitForInputStream

public JCompilationUnit createCompilationUnitForInputStream(java.io.InputStream inputStream)

createCompilationUnitForInputStream

public JCompilationUnit createCompilationUnitForInputStream(java.io.InputStream inputStream,
                                                            java.lang.String encoding)

createCompilationUnitForURI

public JCompilationUnit createCompilationUnitForURI(java.lang.String uri)
Creates a JCompilationUnit from a URI.


createCompilationUnitForURI

public JCompilationUnit createCompilationUnitForURI(java.lang.String uri,
                                                    java.lang.String encoding)
Creates a JCompilationUnit from a URI.


createCompilationUnitForContents

public JCompilationUnit createCompilationUnitForContents(java.lang.String contents)

getControlModel

public JControlModel getControlModel()

getSourceCompilationUnit

public JCompilationUnit getSourceCompilationUnit()

setSourceCompilationUnit

public void setSourceCompilationUnit(JCompilationUnit sourceCompilationUnit)

getSourceCompilationUnitContents

public java.lang.String getSourceCompilationUnitContents()

getTargetCompilationUnit

public JCompilationUnit getTargetCompilationUnit()

setTargetCompilationUnit

public void setTargetCompilationUnit(JCompilationUnit targetCompilationUnit)

getTargetCompilationUnitContents

public java.lang.String getTargetCompilationUnitContents()

getSourcePatternDictionary

public JPatternDictionary getSourcePatternDictionary()

setSourcePatternDictionary

public void setSourcePatternDictionary(JPatternDictionary sourcePatternDictionary)

getTargetPatternDictionary

public JPatternDictionary getTargetPatternDictionary()

setTargetPatternDictionary

public void setTargetPatternDictionary(JPatternDictionary targetPatternDictionary)

isFixInterfaceBrace

public boolean isFixInterfaceBrace()

setFixInterfaceBrace

public void setFixInterfaceBrace(boolean fixInterfaceBrace)

pullTargetCompilationUnit

protected void pullTargetCompilationUnit()

createPullTargetVisitor

protected FacadeVisitor createPullTargetVisitor()

pushSourceCompilationUnit

protected void pushSourceCompilationUnit()

createPushSourceVisitor

protected FacadeVisitor createPushSourceVisitor()

sortTargetCompilationUnit

protected void sortTargetCompilationUnit()

sweepTargetCompilationUnit

protected void sweepTargetCompilationUnit()

applyPullRules

protected void applyPullRules(JNode sourceNode,
                              JNode targetNode)

applySortRules

protected void applySortRules(JNode sourceNode)

applySweepRules

protected boolean applySweepRules(JNode targetNode)

areCompatible

protected boolean areCompatible(JNode sourceNode,
                                JNode targetNode)
Checks if two nodes are compatible and can be merged.

This method must always return false if target node can have children that can not be added to source node.

Parameters:
sourceNode -
targetNode -
Returns:
true if nodes can be merged, false otherwise

convertTarget

protected JNode convertTarget(JAbstractType targetAbstractType,
                              java.lang.Class<? extends JAbstractType> sourceClass)
Converts the target abstract type to be compatible with the given source node class

Parameters:
targetAbstractType -
sourceClass - the class to which to convert the node.
Returns:
null when conversion not possible, converted node otherwise

insertClone

protected JNode insertClone(JNode sourceNode)

isPushMarkedUp

protected boolean isPushMarkedUp(JNode node)
Checks if the node is marked up for pushing.

Node is considered marked up by default if there are no push rules for this node class.

The first push rule that matches the node makes the node marked up, and no further checking is performed.

If the push rule does not match the node, but the push rule is defined for the same node class, then the node will not be marked up, unless any of the following push rules will match the node.

Parameters:
node -
Returns:
true if node should be pushed, false otherwise

map

protected void map(JNode sourceNode,
                   JNode targetNode)
Maps the specified source and target nodes.

Parameters:
sourceNode -
targetNode -

mapChildren

protected void mapChildren(JNode sourceNode,
                           JNode targetNode)

run

public java.lang.Object run(java.lang.Object object)
This is called with the command line arguments of a headless workbench invocation.


execute

public java.lang.String execute(Monitor monitor,
                                java.lang.String[] arguments)
Utility for headless operations.

Returns:
the merged content.

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.