本文整理汇总了Java中org.apache.velocity.runtime.parser.ParseException类的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseException类属于org.apache.velocity.runtime.parser包,在下文中一共展示了ParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnsetAttributes
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
public static String[] getUnsetAttributes(FileTemplate fileTemplate, PackageTemplateWrapper ptWrapper) {
HashSet<String> defaultAttributeNames = getDefaultAttributeNames(ptWrapper.getProject());
// Add globals vars
for (GlobalVariable variable : ptWrapper.getPackageTemplate().getListGlobalVariable()) {
defaultAttributeNames.add(variable.getName());
}
Properties properties = new Properties();
for (String item : defaultAttributeNames) {
properties.put(item, "fakeValue");
}
//parse
try {
return fileTemplate.getUnsetAttributes(properties, ptWrapper.getProject());
} catch (ParseException e) {
Logger.log("getUnsetAttributes ex: " + e.getMessage());
Logger.printStack(e);
return new String[0];
}
}
示例2: mergeTemplateIntoString
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
public String mergeTemplateIntoString(String templateFilename, Map<String, Object> params)
throws VelocityTemplateParsingException {
try (InputStream is = settingsFacade.getRawConfig(templateFilename)) {
StringReader reader = new StringReader(IOUtils.toString(is));
SimpleNode node = rs.parse(reader, templateFilename);
Template template = new Template();
template.setRuntimeServices(rs);
template.setData(node);
template.initDocument();
StringWriter writer = new StringWriter();
template.merge(new VelocityContext(params), writer);
return writer.toString();
} catch (ParseException|IOException e) {
throw new VelocityTemplateParsingException("Couldn't merge template into string", e);
}
}
示例3: initTemplate
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
private void initTemplate(@NonNull final String verifyExpression) throws ParseException {
// Init pattern ...
final RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
final StringReader reader = new StringReader(verifyExpression);
SimpleNode node = runtimeServices.parse(reader, this.getDocumentation().getId());
final Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
this.template = template;
// Parse expression looking for variable ...
final Pattern pattern = Pattern.compile(VELOCITY_VARIABLE);
final Matcher matcher = pattern.matcher(verifyExpression);
while (matcher.find()) {
final String key = matcher.group(1);
final ClassProperty property = ClassProperty.to(key);
this.templateProperties.add(property);
}
}
示例4: getAllFileTemplatesVariables
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
public Set<String> getAllFileTemplatesVariables() {
Set<String> result = new TreeSet<String>();
List<FileTemplate> allTemplates = new ArrayList<FileTemplate>();
FileTemplateManager fileTemplateManager = FileTemplateManager.getInstance();
FileTemplate[] templates = fileTemplateManager.getAllTemplates();
FileTemplate[] patterns = fileTemplateManager.getAllPatterns();
FileTemplate[] codeTemplates = fileTemplateManager.getAllCodeTemplates();
FileTemplate[] j2eeTemplates = fileTemplateManager.getAllJ2eeTemplates();
allTemplates.addAll(Arrays.asList(templates));
allTemplates.addAll(Arrays.asList(codeTemplates));
allTemplates.addAll(Arrays.asList(j2eeTemplates));
allTemplates.addAll(Arrays.asList(patterns));
for (FileTemplate template : allTemplates) {
try {
String[] variables = FileTemplateUtil.calculateAttributes(template.getText(), new Properties(), true, myProject);
result.addAll(Arrays.asList(variables));
} catch (ParseException e) {
logger.warn("Parsing exception", e);
}
}
return result;
}
示例5: updateTemplateAttributes
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
private void updateTemplateAttributes() {
FileTemplate template = (FileTemplate) ((Trinity) this.myKindComboBox.getSelectedItem()).getThird();
if (template.equals(this.myCurrentTemplate)) {
return;
}
this.myCurrentTemplate = template;
this.myTemplateAttributes.getPanel().removeAll();
this.myTemplateAttributesFields.clear();
String[] attrs = new String[0];
try {
attrs = template.getUnsetAttributes(this.getProperties(this.getDirectory()), this.myProject);
} catch (ParseException e1) {
e1.printStackTrace();
}
List<String> ignoredAttributes = Arrays.asList("PROJECT_NAME", "FILE_NAME", "NAME", "USER", "DATE", "TIME", "YEAR", "MONTH", "DAY", "HOUR", "MINUTE", "PRODUCT_NAME", "MONTH_NAME_SHORT", "MONTH_NAME_FULL", "NAME", "NAMESPACE", "CLASS_NAME", "STATIC", "TYPE_HINT", "PARAM_DOC", "THROWS_DOC", "DS", "CARET");
for (String attribute : attrs) {
if (ignoredAttributes.contains(attribute)) {
continue;
}
EditorTextField field = new EditorTextField();
this.myTemplateAttributesFields.put(attribute, field);
this.myTemplateAttributes.addLabeledComponent(attribute.concat(":"), field);
}
this.myTemplateAttributes.getPanel().revalidate();
this.myTemplateAttributes.getPanel().repaint();
}
示例6: create
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
public static Template create(String source, String templateName) throws ParseException {
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(source);
SimpleNode node = runtimeServices.parse(reader, templateName);
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
return template;
}
示例7: init
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
@Override
public void init(AlarmDeduplicationProcessorConfiguration configuration) {
this.configuration = configuration;
try {
this.alarmIdTemplate = VelocityUtils.create(configuration.getAlarmIdTemplate(), "Alarm Id Template");
this.alarmBodyTemplate = VelocityUtils.create(configuration.getAlarmBodyTemplate(), "Alarm Body Template");
} catch (ParseException e) {
log.error("Failed to create templates based on provided configuration!", e);
throw new RuntimeException("Failed to create templates based on provided configuration!", e);
}
}
示例8: init
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
@Override
public void init(SendMailActionConfiguration configuration) {
this.configuration = configuration;
try {
fromTemplate = toTemplate(configuration.getFromTemplate(), "From Template");
toTemplate = toTemplate(configuration.getToTemplate(), "To Template");
ccTemplate = toTemplate(configuration.getCcTemplate(), "Cc Template");
bccTemplate = toTemplate(configuration.getBccTemplate(), "Bcc Template");
subjectTemplate = toTemplate(configuration.getSubjectTemplate(), "Subject Template");
bodyTemplate = toTemplate(configuration.getBodyTemplate(), "Body Template");
} catch (ParseException e) {
log.error("Failed to create templates based on provided configuration!", e);
throw new RuntimeException("Failed to create templates based on provided configuration!", e);
}
}
示例9: toTemplate
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
private Optional<Template> toTemplate(String source, String name) throws ParseException {
if (!StringUtils.isEmpty(source)) {
return Optional.of(VelocityUtils.create(source, name));
} else {
return Optional.empty();
}
}
示例10: init
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
@Override
public void init(T configuration) {
this.configuration = configuration;
try {
this.template = VelocityUtils.create(configuration.getTemplate(), "Template");
} catch (ParseException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例11: create
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
public static Template create(String source, String templateName) throws ParseException {
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(source);
SimpleNode node = runtimeServices.parse(reader, templateName);
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
return template;
}
示例12: init
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
@Override
public void init(AlarmDeduplicationProcessorConfiguration configuration) {
this.configuration = configuration;
try {
this.alarmIdTemplate = VelocityUtils.create(configuration.getAlarmIdTemplate(), "Alarm Id Template");
this.alarmBodyTemplate = VelocityUtils.create(configuration.getAlarmBodyTemplate(), "Alarm Body Template");
} catch (ParseException e) {
log.error("Failed to create templates based on provided configuration!", e);
throw new RuntimeException("Failed to create templates based on provided configuration!", e);
}
}
示例13: init
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
@Override
public void init(ServerSideRpcCallActionConfiguration configuration) {
this.configuration = configuration;
try {
deviceIdTemplate = toTemplate(configuration.getDeviceIdTemplate(), "Device Id Template");
fromDeviceRelationTemplate = toTemplate(configuration.getFromDeviceRelationTemplate(), "From Device Relation Template");
toDeviceRelationTemplate = toTemplate(configuration.getToDeviceRelationTemplate(), "To Device Relation Template");
rpcCallMethodTemplate = toTemplate(configuration.getRpcCallMethodTemplate(), "RPC Call Method Template");
rpcCallBodyTemplate = toTemplate(configuration.getRpcCallBodyTemplate(), "RPC Call Body Template");
} catch (ParseException e) {
log.error("Failed to create templates based on provided configuration!", e);
throw new RuntimeException("Failed to create templates based on provided configuration!", e);
}
}
示例14: toTemplate
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
private Optional<Template> toTemplate(String source, String name) throws ParseException {
if (!StringUtils.isEmpty(source)) {
return Optional.of(VelocityUtils.create(source, name));
} else {
return Optional.empty();
}
}
示例15: init
import org.apache.velocity.runtime.parser.ParseException; //导入依赖的package包/类
@Override
public void init(SendMailActionConfiguration configuration) {
this.configuration = configuration;
try {
fromTemplate = toTemplate(configuration.getFromTemplate(), "From Template");
toTemplate = toTemplate(configuration.getToTemplate(), "To Template");
ccTemplate = toTemplate(configuration.getCcTemplate(), "Cc Template");
bccTemplate = toTemplate(configuration.getBccTemplate(), "Bcc Template");
subjectTemplate = toTemplate(configuration.getSubjectTemplate(), "Subject Template");
bodyTemplate = toTemplate(configuration.getBodyTemplate(), "Body Template");
} catch (ParseException e) {
log.error("Failed to create templates based on provided configuration!", e);
throw new RuntimeException("Failed to create templates based on provided configuration!", e);
}
}