📄 strategyfactory.java
字号:
/**
* Copyright (c) 2002, Siddhartha P. Chandurkar siddhartha@visioncodified.com
* All rights reserved.
* Licensed under the Academic Free License version 1.1
* See the file LICENSE.TXT for details.
* LICENSE.txt is located in the directory <install-directory>\Jenerator
* of your Jenertaor Installation.
*
*/
package com.jenerator.transformer;
//<Imports>
//Java imports
import com.jenerator.util.ArgumentParser;
import java.util.Vector;
//</Imports>
/**
* StrategyFactory
* It is a factory class which instantiates the different Strategies based on the information
* obtained from the ArgumentParser
* It is based on the Factory pattern
* @author Siddhartha P. Chandurkar
* @version 0.9.0
*
*/
public class StrategyFactory {
//CONSTRUCTORS
/**
* Default Constructor
*/
public StrategyFactory() {
}
/**
* getStrategies
* A Factory method which takes the ArgumentParser as an argument. It asks which options are
* selected for code generation, it then instantiates the respective strategies and fills them in the
* strats vectore which it returns.
* @param argParser An ArgumentParser
*/
public Vector getStrategies(ArgumentParser argParser) throws StrategyNotFoundException {
Vector strats = new Vector();
if (argParser.isDesc() == true)
strats.addElement(new JenDescStrategy());
if (argParser.isRemote() == true)
strats.addElement(new RemoteStrategy());
if (argParser.isHome() == true)
strats.addElement(new HomeStrategy());
if (argParser.isBean() == true) {
strats.addElement(new BeanStrategy());
strats.addElement(new ValueObjectStrategy());
strats.addElement(new PrimKeyStrategy());
strats.addElement(new ExceptionStrategy());
}
if (argParser.isLocal() == true)
strats.addElement(new LocalStrategy());
if (argParser.isDD() == true)
strats.addElement(new DDStrategy());
if (argParser.isJUNIT() == true)
strats.addElement(new JUnitStrategy());
if (argParser.isANT() == true)
strats.addElement(new AntStrategy());
if (argParser.isPATTERN() == true)
strats.addElement(new PatternStrategy());
if (argParser.isSERVLET() == true)
strats.addElement(new ViewStrategy());
if (argParser.isJDO() == true)
strats.addElement(new JDOStrategy());
if (argParser.isUNIT_TESTS() == true)
strats.addElement(new UnitTestStrategy());
if (strats.size() == 0)
throw new StrategyNotFoundException();
return strats;
}//getStrategies
}//StrategyFactory
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -