org.exolab.castor.builder.conflictresolution

Class WarningViaDialogClassNameCRStrategy

Implemented Interfaces:
ClassNameCRStrategy

public final class WarningViaDialogClassNameCRStrategy
extends BaseClassNameCRStrategy
implements ClassNameCRStrategy

An implementation of ClassNameCRStrategy that reports any conflict notifications to a console dialog, asking the user whether to stop code generation (as the conflict is not acceptable), or whether to proceed by overwriting an already existing class.
Author:
Werner Guttmann
Since:
1.1

Field Summary

static String
NAME
Name of this strategy.

Constructor Summary

WarningViaDialogClassNameCRStrategy()
Creates an instance of this name conflict resolution strategy, that will use the specified ConsoleDialog instance to emit warnings to the user and ask about an approach to deal with them.

Method Summary

SGStateInfo
dealWithClassNameConflict(SGStateInfo state, ClassInfo newClassInfo, JClass conflict)
Handle a class name conflict between newClassInfo and conflict.
boolean
dealWithFileOverwrite(String filename)
Presents the user with a console dialog, asking for confirmation whether an existing file should be overwritten (or not).
protected ConsoleDialog
getConsoleDialog()
Returns the ConsoleDialog instance in use.
String
getName()
Returns the name of the strategy.
void
setConsoleDialog(ConsoleDialog dialog)
Sets the console dialog to use with this strategy.

Methods inherited from class org.exolab.castor.builder.conflictresolution.BaseClassNameCRStrategy

getSingleClassGenerator, setSingleClassGenerator

Field Details

NAME

public static final String NAME
Name of this strategy.

Constructor Details

WarningViaDialogClassNameCRStrategy

public WarningViaDialogClassNameCRStrategy()
Creates an instance of this name conflict resolution strategy, that will use the specified ConsoleDialog instance to emit warnings to the user and ask about an approach to deal with them.

Method Details

dealWithClassNameConflict

public SGStateInfo dealWithClassNameConflict(SGStateInfo state,
                                             ClassInfo newClassInfo,
                                             JClass conflict)
Handle a class name conflict between newClassInfo and conflict.
Specified by:
dealWithClassNameConflict in interface ClassNameCRStrategy
Parameters:
state - SourceGeneration state
newClassInfo - ClassInfo for the new class
conflict - JClass for the existing class
Returns:
the provided source generator state, as modified by the strategy

dealWithFileOverwrite

public boolean dealWithFileOverwrite(String filename)
Presents the user with a console dialog, asking for confirmation whether an existing file should be overwritten (or not).
Specified by:
dealWithFileOverwrite in interface ClassNameCRStrategy
Parameters:
filename - the filename to potentially overwrite.
Returns:
whether or not the file should be overwritten.

getConsoleDialog

protected ConsoleDialog getConsoleDialog()
Returns the ConsoleDialog instance in use.
Returns:
the ConsoleDialog used for output/feedback gathering.

getName

public String getName()
Returns the name of the strategy.
Specified by:
getName in interface ClassNameCRStrategy
Returns:
the name of the strategy.

setConsoleDialog

public void setConsoleDialog(ConsoleDialog dialog)
Sets the console dialog to use with this strategy.
Specified by:
setConsoleDialog in interface ClassNameCRStrategy
Parameters:
dialog - the console dialog to use with this strategy.
See Also:
setConsoleDialog(org.exolab.castor.util.dialog.ConsoleDialog)

Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com