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


Java ParseException类代码示例

本文整理汇总了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];
    }
}
 
开发者ID:CeH9,项目名称:PackageTemplates,代码行数:23,代码来源:AttributesHelper.java

示例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);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:19,代码来源:VelocityTemplateParser.java

示例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);
        }

    }
 
开发者ID:mulesoft-labs,项目名称:connector-certification-tools,代码行数:26,代码来源:DirectoryStructureRule.java

示例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;
}
 
开发者ID:vkravets,项目名称:FileTemplatesVariable,代码行数:24,代码来源:PerProjectTemplateManager.java

示例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();
}
 
开发者ID:aurimasniekis,项目名称:idea-php-class-templates,代码行数:35,代码来源:PhpNewTemplateClassDialog.java

示例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;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:11,代码来源:VelocityUtils.java

示例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);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:12,代码来源:AlarmDeduplicationProcessor.java

示例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);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:16,代码来源:SendMailAction.java

示例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();
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:8,代码来源:SendMailAction.java

示例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);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:10,代码来源:AbstractTemplatePluginAction.java

示例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;
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:11,代码来源:VelocityUtils.java

示例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);
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:12,代码来源:AlarmDeduplicationProcessor.java

示例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);
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:15,代码来源:ServerSideRpcCallAction.java

示例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();
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:8,代码来源:ServerSideRpcCallAction.java

示例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);
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:16,代码来源:SendMailAction.java


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