当前位置: 首页>>代码示例>>Java>>正文


Java WalkModException类代码示例

本文整理汇总了Java中org.walkmod.exceptions.WalkModException的典型用法代码示例。如果您正苦于以下问题:Java WalkModException类的具体用法?Java WalkModException怎么用?Java WalkModException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WalkModException类属于org.walkmod.exceptions包,在下文中一共展示了WalkModException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
protected void visit(Object element) throws Exception {
    VisitorContext context = new VisitorContext(getChainConfig());
    context.put(ORIGINAL_FILE_KEY, originalFile);
    try {
        visit(element, context);
    } catch (Throwable e) {
        String path = originalFile == null ? null : originalFile.getCanonicalPath();
        WalkModException e1 = new WalkModException("Error visiting a Java source file", e,
                new LocationImpl("File Location", path));
        if (!ignoreErrors) {
            throw e1;
        } else {
            e1.fillInStackTrace();
            e1.printStackTrace();
        }
    }
    addVisitorMessages(context);
}
 
开发者ID:walkmod,项目名称:walkmod-javalang-plugin,代码行数:20,代码来源:DefaultJavaWalker.java

示例2: getSourceNode

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
protected Object getSourceNode(Object targetNode) {
    Object result = null;
    if (targetNode instanceof CompilationUnit) {
        CompilationUnit targetCU = (CompilationUnit) targetNode;
        try {
            File sourceFile = resolveFile(targetCU);
            if (sourceFile.exists()) {

                result = parser.parse(sourceFile);

            } else {
                result = targetNode;
            }
        } catch (Exception e) {
            throw new WalkModException(e);
        }
    }
    return result;
}
 
开发者ID:walkmod,项目名称:walkmod-javalang-plugin,代码行数:21,代码来源:DefaultJavaWalker.java

示例3: initialize

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
public void initialize(VisitorContext context, Object rootNode) {
	if (queryEngine == null) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("language", "groovy");
		List<String> includes = new LinkedList<String>();			
		includes.add("query.alias.groovy");
		parameters.put("includes", includes);
		
		Object bean = context.getBean(
				"org.walkmod.query.ScriptingQueryEngine", parameters);
		if (bean != null) {
			if (bean instanceof QueryEngine) {
				queryEngine = (QueryEngine) bean;
			}

		} else {
			throw new WalkModException("Query Engine not found");
		}
	}
	
	Map<String, Object> params = new HashMap<String, Object>();
	params.put("node", rootNode);
	queryEngine.initialize(context, params);
}
 
开发者ID:walkmod,项目名称:walkmod-javalang-plugin,代码行数:25,代码来源:VisitorSupport.java

示例4: formatFile

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
private String formatFile(String code, VisitorContext ctx) {
   TextEdit te = null;
   if (formatter == null) {
      log.debug("starting Eclipse formatter");
      Map<String, String> options = getFormattingOptions(ctx);
      formatter = ToolFactory.createCodeFormatter(options);
      if (formatter != null) {
         log.debug("Eclipse formatter [ok]");
      }
   }
   if (formatter != null) {
      te = formatter.format(CodeFormatter.K_COMPILATION_UNIT, code, 0, code.length(), 0, String.valueOf('\n'));
      if (te == null) {
         log.warn("The source cannot be formatted with the selected configuration. Applying a default formatting");
         return code;

      }
      IDocument doc = new org.eclipse.jface.text.Document(code);
      try {
         te.apply(doc);
      } catch (Exception e) {
         throw new WalkModException(e);
      }
      String formattedCode = doc.get();
      if (formattedCode == null || "".equals(formattedCode)) {
         return code;
      }
      return formattedCode;
   } else {
      throw new WalkModException("Eclipse formatter cannot be initialized");
   }
}
 
开发者ID:walkmod,项目名称:walkmod-java-formatter-plugin,代码行数:33,代码来源:EclipseWriter.java

示例5: initialize

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
public void initialize(VisitorContext context, Object node) {
	if (engine == null) {
		ScriptEngineManager factory = new ScriptEngineManager(context.getClassLoader());
		engine = factory.getEngineByName(language);
		if (engine instanceof GroovyScriptEngineImpl) {
			((GroovyScriptEngineImpl) engine).setClassLoader(new GroovyClassLoader(context.getClassLoader(),
					new CompilerConfiguration()));
		}
	}

	if (queryEngine == null) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("language", "groovy");
		List<String> includes = new LinkedList<String>();
		includes.add("query.alias.groovy");
		parameters.put("includes", includes);

		Object bean = context.getBean("org.walkmod.query.ScriptingQueryEngine", parameters);
		if (bean != null) {
			if (bean instanceof QueryEngine) {
				queryEngine = (QueryEngine) bean;
			}

		} else {
			throw new WalkModException("Query Engine not found");
		}
	}

	Map<String, Object> params = new HashMap<String, Object>();
	params.put("node", node);
	queryEngine.initialize(context, params);
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:33,代码来源:ScriptProcessor.java

示例6: resolve

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
public Object resolve(Object context, String query) {
	if (context == null) {
		context = rootNode;
	}
	bindings.put("node", context);
	bindings.put("root", rootNode);
	bindings.put("context", this.context);
	try {
		if (query == null) {
			return null;
		}
		if (includes != null) {
			for (String include : includes) {
				URI uri = this.context.getResource(include);
				if (uri != null) {
					String aux = includeExpression(uri.getPath()) + "\n";
					query = aux + query;
				}
			}
		}
		return engine.eval(query, bindings);
	} catch (ScriptException e) {
		log.error("The query: [" + query + "] has an error");
		throw new WalkModException(e);
	}
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:28,代码来源:ScriptingQueryEngine.java

示例7: execute

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
public void execute() throws Exception {
   Iterator<?> it = getResource().iterator();
   while (it.hasNext()) {
      Object current = it.next();
      try {
         walk(current);
      } catch (WalkModException e) {
         log.error(e.getMessage());
      }
   }
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:13,代码来源:AbstractWalker.java

示例8: setup

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
/**
 * Setup this instance transformer and result objects.
 */
private void setup() {
	try {
		TransformerHandler handler = this.factory.newTransformerHandler();
		nextHandler = handler;
		if (this.parentNode != null) {
			this.result = new DOMResult(this.parentNode);
		} else {
			this.result = new DOMResult();
		}
		handler.setResult(this.result);
	} catch (javax.xml.transform.TransformerException local) {
		throw new WalkModException("Fatal-Error: Unable to get transformer handler", local);
	}
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:18,代码来源:DomHelper.java

示例9: invoke

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
public void invoke() throws WalkModException {
	ChainWalkerAdapter wa = chainAdapter.getWalkerAdapter();
	ChainWalkerInvocation wi = new DefaultChainWalkerInvocation();
	wi.init(wa);
	wi.invoke();
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:8,代码来源:DefaultChainInvocation.java

示例10: invoke

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
public void invoke() throws WalkModException {
	ChainWalker walker = walkerAdapter.getWalker();
	if (walker != null) {
		try {
			walker.execute();
		} catch (Exception e) {
			throw new WalkModException("An exeception has been produced during the " + walkerAdapter.getName()
					+ " transformation", e);
		}
	}
	LOG.debug("The transformation [" + walkerAdapter.getName() + "] has been executed");
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:14,代码来源:DefaultChainWalkerInvocation.java

示例11: recoverOriginalCU

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
protected CompilationUnit recoverOriginalCU(VisitorContext vc) {
    try {
        return parser.parse(originalFile, encoding);
    } catch (Exception e) {
        throw new WalkModException("Exception writing results of " + originalFile.getPath(), e);
    }
}
 
开发者ID:walkmod,项目名称:walkmod-javalang-plugin,代码行数:8,代码来源:DefaultJavaWalker.java

示例12: visit

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
public synchronized void visit(Object node, VisitorContext context) throws Exception {
	if (rootLabel == null) {
		setRootLabel("cu");
	}
	if (propertiesFile == null) {
		setProperties("template.properties");
	}
	context.put(getRootLabel(), node);
	if (templateEngine == null) {
		Object bean = context.getBean("org.walkmod.templates.groovy.GroovyTemplateEngine", null);
		if (bean != null && bean instanceof TemplateEngine) {
			templateEngine = (TemplateEngine) bean;
			log.info("Applying [groovy] as a default template engine");
		} else {
			throw new WalkModException("Template engine not found");
		}
	}

	templateEngine.initialize(context, node);

	if (templateFiles != null && templates != null && templateFiles.size() == templates.size()) {

		for (File template : templateFiles) {

			String templateResult = templateEngine.applyTemplate(template, propertiesFile);
			Object producedNode = null;
			currentTemplate = template;

			if (parser != null) {
				try {
					producedNode = parser.parse(templateResult, true);
				} catch (ParseException e) {
					log.warn("Error parsing the template " + template.getAbsolutePath() + ". Dumping contents..");

					doPlainOutput(templateResult, context);
				}

			} else {
				doPlainOutput(templateResult, context);
			}
			if (producedNode != null) {
				log.debug("Template successfuly parsed");
				context.addResultNode(producedNode);
			}
		}
	} else {
		if (!missingTemplates.isEmpty()) {
			for (String missing : missingTemplates) {
				log.error("The template " + missing + " is missing");
			}
		}
		throw new WalkModException("There are missing or unexitent templates.");
	}

}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:56,代码来源:DefaultTemplateVisitor.java

示例13: execute

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
public void execute() throws WalkModException {
	wi.invoke();
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:5,代码来源:DefaultChainWalkerAdapter.java

示例14: execute

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
public void execute() throws WalkModException {
	ai.invoke();
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:5,代码来源:DefaultChainAdapter.java

示例15: prepare

import org.walkmod.exceptions.WalkModException; //导入依赖的package包/类
@Override
public void prepare() {

	Collection<ProviderConfig> providers = config.getProviderConfigurations();

	if (providers != null) {
		for (ProviderConfig pc : providers) {
			Object aux = config.getBean(pc.getType(), pc.getParameters());
			if (aux instanceof ConfigurationProvider) {
				ConfigurationProvider cp = ((ConfigurationProvider) aux);
				cp.init(config);
				cp.load();

			}
		}
	}

	Collection<MergePolicyConfig> mergePolicies = config.getMergePolicies();
	if (mergePolicies != null) {
		Map<String, MergeEngine> mergeEngines = new HashMap<String, MergeEngine>();
		config.setMergeEngines(mergeEngines);
		for (MergePolicyConfig mpc : mergePolicies) {
			MergeEngine me = new MergeEngine();
			mergeEngines.put(mpc.getName(), me);
			String dopTypeLabel = mpc.getDefaultObjectPolicy();
			Object dop = null;
			Object top = null;
			if (dopTypeLabel != null) {
				dop = config.getBean(dopTypeLabel, null);
			}
			if (dop != null && dop instanceof MergePolicy<?>) {
				me.setDefaultObjectMergePolicy((MergePolicy) dop);
			}
			String topTypeLabel = mpc.getDefaultTypePolicy();
			if (topTypeLabel != null) {
				top = config.getBean(topTypeLabel, null);
			}
			if ((top != null) && top instanceof MergePolicy<?>) {
				me.setDefaultTypeMergePolicy((MergePolicy) top);
			}
			Map<String, String> policyEntries = mpc.getPolicyEntries();
			Class<?> oType = null;
			Object pType = null;
			Map<Class<?>, MergePolicy> resolvedEntries = new HashMap<Class<?>, MergePolicy>();
			if (policyEntries != null && !policyEntries.isEmpty()) {
				for (Map.Entry<String, String> entry : policyEntries.entrySet()) {
					try {
						oType = config.getClassLoader().loadClass(entry.getKey());
					} catch (ClassNotFoundException e) {
						throw new WalkModException("Invalid policy entry for " + entry.getKey());
					}
					pType = config.getBean(entry.getValue(), null);
					if (pType instanceof MergePolicy) {
						resolvedEntries.put(oType, (MergePolicy) pType);
					}
				}
			}
			me.setPolicyConfiguration(resolvedEntries);
		}
	}
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:62,代码来源:DefaultConfigurationAdapter.java


注:本文中的org.walkmod.exceptions.WalkModException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。