本文整理汇总了Java中freemarker.core.ParseException类的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseException类属于freemarker.core包,在下文中一共展示了ParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessageWithCauses
import freemarker.core.ParseException; //导入依赖的package包/类
/**
* The error message (and sometimes also the class), and then the same with the cause exception, and so on. Doesn't
* contain the stack trace or other location information.
*/
public static String getMessageWithCauses(final Throwable exc) {
StringBuilder sb = new StringBuilder();
Throwable curExc = exc;
while (curExc != null) {
if (curExc != exc) {
sb.append("\n\nCaused by:\n");
}
String msg = curExc.getMessage();
if (msg == null || !(curExc instanceof TemplateException || curExc instanceof ParseException)) {
sb.append(curExc.getClass().getName()).append(": ");
}
sb.append(msg);
curExc = curExc.getCause();
}
return sb.toString();
}
示例2: initializeConfiguration
import freemarker.core.ParseException; //导入依赖的package包/类
/**
* Configures freemarker for usage.
* @return
* @throws URISyntaxException
* @throws TemplateNotFoundException
* @throws MalformedTemplateNameException
* @throws ParseException
* @throws IOException
* @throws TemplateException
*/
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
cfg.setClassForTemplateLoading(DwFeatureModelSVGGenerator.class, "templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Bundle bundle = Platform.getBundle("de.darwinspl.feature.graphical.editor");
URL fileURL = bundle.getEntry("templates/");
File file = new File(FileLocator.resolve(fileURL).toURI());
cfg.setDirectoryForTemplateLoading(file);
Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();
customNumberFormats.put("hex", DwHexTemplateNumberFormatFactory.INSTANCE);
cfg.setCustomNumberFormats(customNumberFormats);
return cfg;
}
示例3: initializeConfiguration
import freemarker.core.ParseException; //导入依赖的package包/类
private Configuration initializeConfiguration() throws URISyntaxException, TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
Configuration cfg = new Configuration(Configuration.VERSION_2_3_23);
cfg.setClassForTemplateLoading(DwFeatureModelOverviewGenerator.class, "templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
customDateFormats.put("simple", DwSimpleTemplateDateFormatFactory.INSTANCE);
cfg.setCustomDateFormats(customDateFormats);
cfg.setDateTimeFormat("@simle");
Bundle bundle = Platform.getBundle("eu.hyvar.feature.graphical.editor");
URL fileURL = bundle.getEntry("templates/");
File file = new File(FileLocator.resolve(fileURL).toURI());
cfg.setDirectoryForTemplateLoading(file);
return cfg;
}
示例4: processFreemarkerParseError
import freemarker.core.ParseException; //导入依赖的package包/类
/**
* Handle Freemarker parsing errors.
*/
@ExceptionHandler(ParseException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public ErrorListDto processFreemarkerParseError(ParseException ex) {
//Build ErrorDto
String invalidValue = "(" + ex.getLineNumber()
+ "," + ex.getColumnNumber() + "): " + ex.getEditorMessage();
ErrorDto errorDto = new ErrorDto(ex.getTemplateName(),
"global.error.server-error.freemarker.parsing-error", invalidValue, null);
//Build ErrorListDto
ErrorListDto errorListDto = new ErrorListDto();
errorListDto.add(errorDto);
return errorListDto;
}
示例5: sendMainPage
import freemarker.core.ParseException; //导入依赖的package包/类
/**
* Sends the main HTML page of the WebUI.
*
* @param response
* @throws TemplateNotFoundException
* @throws MalformedTemplateNameException
* @throws ParseException
* @throws IOException
* @throws ServletException
*/
private void sendMainPage(HttpServletResponse response) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, ServletException
{
HashMap<String, Object> model = new HashMap<String, Object>();
model.put("version", Main.VERSION);
model.put("system", PlatformData.computerName);
model.put("actionButtons", this.determineWebUIButtons());
model.put("webcamKey", NMOConfiguration.INSTANCE.integrations.webUI.webcamSecurityKey);
model.put("camTotal", WebcamCapture.webcams.length);
model.put("message", NMOConfiguration.INSTANCE.integrations.webUI.message);
model.put("username", NMOConfiguration.INSTANCE.integrations.webUI.username);
String[] cc = new String[WebcamCapture.webcams.length];
for (int i = 0; i < WebcamCapture.webcams.length; i++)
{
cc[i] = WebcamCapture.webcams[i].cc;
}
model.put("webcams", cc);
for (Integration integration : Main.integrations)
{
model.put("integration_" + integration.id, integration.isEnabled());
}
try
{
WebTemplate.renderTemplate("nmo.ftl", response, model);
}
catch (TemplateException e)
{
throw new ServletException(e);
}
}
示例6: testTemplateWithSyntaxError
import freemarker.core.ParseException; //导入依赖的package包/类
@Test
public void testTemplateWithSyntaxError() {
FreeMarkerServiceResponse serviceResponse = getService().calculateTemplateOutput(
"test ${xx", Collections.<String, Object>emptyMap(), null, null, null);
assertThat(serviceResponse.isSuccesful(), is(false));
assertThat(serviceResponse.getFailureReason(), instanceOf(ParseException.class));
}
示例7: getTemplate
import freemarker.core.ParseException; //导入依赖的package包/类
public Template getTemplate(String templatePath)
throws IOException, TemplateNotFoundException, MalformedTemplateNameException, ParseException {
@SuppressWarnings("deprecation")
Configuration cfg = new Configuration();
if (templatePath.startsWith("classpath:")) {
cfg.setClassForTemplateLoading(FindClass.class, ".." + Constants.FILE_SEP);
templatePath = templatePath.replace("classpath:", "");
} else {
cfg.setDirectoryForTemplateLoading(new File(templatePath));
}
Template template = cfg.getTemplate(templatePath);
return template;
}
示例8: sendEmailMessage
import freemarker.core.ParseException; //导入依赖的package包/类
public void sendEmailMessage(final EmailTarget emailTarget, final ExtensionProperties hubConfiguredProperties)
throws MessagingException, TemplateNotFoundException, MalformedTemplateNameException, ParseException,
IOException, TemplateException {
final String emailAddress = StringUtils.trimToEmpty(emailTarget.getEmailAddress());
final String templateName = StringUtils.trimToEmpty(emailTarget.getTemplateName());
final Map<String, Object> model = emailTarget.getModel();
if (StringUtils.isBlank(emailAddress) || StringUtils.isBlank(templateName)) {
// we've got nothing to do...might as well get out of here...
return;
}
ExtensionProperties properties = localProperties;
// use the hub global configuration as default and let the local
// properties file value override the values from
// the Hub
if (hubConfiguredProperties != null) {
properties = new ExtensionProperties(localProperties.getAppProperties(), hubConfiguredProperties.getAppProperties());
}
final Session session = createMailSession(properties);
final Map<String, String> contentIdsToFilePaths = new HashMap<>();
populateModelWithAdditionalProperties(properties, model, templateName, contentIdsToFilePaths);
final String html = getResolvedTemplate(model, templateName);
final MimeMultipartBuilder mimeMultipartBuilder = new MimeMultipartBuilder();
mimeMultipartBuilder.addHtmlContent(html);
mimeMultipartBuilder.addTextContent(Jsoup.parse(html).text());
mimeMultipartBuilder.addEmbeddedImages(contentIdsToFilePaths);
final MimeMultipart mimeMultipart = mimeMultipartBuilder.build();
final String resolvedSubjectLine = getResolvedSubjectLine(model);
final Message message = createMessage(emailAddress, resolvedSubjectLine, session, mimeMultipart, properties);
javaMailWrapper.sendMessage(properties, session, message);
}
示例9: getResolvedTemplate
import freemarker.core.ParseException; //导入依赖的package包/类
private String getResolvedTemplate(final Map<String, Object> model, final String templateName)
throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException,
TemplateException {
final StringWriter stringWriter = new StringWriter();
final Template template = configuration.getTemplate(templateName);
template.process(model, stringWriter);
return stringWriter.toString();
}
示例10: process
import freemarker.core.ParseException; //导入依赖的package包/类
public void process(EntityMeta meta) throws TemplateNotFoundException, MalformedTemplateNameException,
ParseException, IOException, TemplateException, URISyntaxException {
init();
URL context = ClassLoader.getSystemResource("");
URL tpls = ClassLoader.getSystemResource(tmplPath);
File tmplDir = new File(tpls.toURI());
if (tmplDir.exists() && tmplDir.isDirectory()) {
File[] fiels = tmplDir.listFiles();
if (fiels != null && fiels.length > 0) {
for (File file : fiels) {
String name = file.getName();
Template template = cfg.getTemplate(name);
Writer writer = null;
if ("entity.ftlh".equals(name)) {
writer = writeJavaFile(context, meta);
} else if ("mybatis.ftlh".equals(name)) {
writer = writerBatiesFile(context, meta);
}
if (writer != null) {
try {
template.process(meta, writer);
} finally {
writer.close();
}
}
}
}
}
}
示例11: generateBuilderClasses
import freemarker.core.ParseException; //导入依赖的package包/类
private void generateBuilderClasses(Configuration cfg, APISpec apiSpec) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException,
IOException, TemplateException {
/* Get the template (uses cache internally) */
Template temp = cfg.getTemplate("builderTemplate.ftl");
Writer out = new OutputStreamWriter(System.out);
temp.process(apiSpec, out);
}
示例12: generateApiClass
import freemarker.core.ParseException; //导入依赖的package包/类
private void generateApiClass(Configuration cfg, APISpec apiSpec) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException,
IOException, TemplateException {
Template temp = cfg.getTemplate("apiTemplate.ftl");
Writer out = new OutputStreamWriter(System.out);
temp.process(apiSpec, out);
}
示例13: run
import freemarker.core.ParseException; //导入依赖的package包/类
@Override
public void run (Result result, SchedulerEvent event) {
try {
FTLParserResult sjResult = (FTLParserResult) result;
List<ParseException> syntaxErrors = sjResult.getErrors();
Document document = result.getSnapshot ().getSource ().getDocument (false);
List<ErrorDescription> errors = new ArrayList<ErrorDescription> ();
for (ParseException syntaxError : syntaxErrors) {
int start = NbDocument.findLineOffset ((StyledDocument) document, syntaxError.lineNumber - 1) + syntaxError.columnNumber - 1;
int end = NbDocument.findLineOffset ((StyledDocument) document, syntaxError.endLineNumber - 1) + syntaxError.endColumnNumber;
ErrorDescription errorDescription = ErrorDescriptionFactory.createErrorDescription(
Severity.ERROR,
syntaxError.getMessage (),
document,
document.createPosition(start),
document.createPosition(end)
);
errors.add (errorDescription);
}
HintsController.setErrors (document, "freemarker", errors);
} catch (BadLocationException ex1) {
Exceptions.printStackTrace (ex1);
//} catch (org.netbeans.modules.parsing.spi.ParseException ex1) {
// Exceptions.printStackTrace (ex1);
}
}
开发者ID:rostanek,项目名称:freemarker-support-for-netbeans,代码行数:28,代码来源:FTLSyntaxErrorHighlightingTask.java
示例14: Jtempx
import freemarker.core.ParseException; //导入依赖的package包/类
public Jtempx(String tempName) throws IOException {
try {
t = cfg.getTemplate(tempName, encoding);
} catch (IOException e) {
isnull = true;
if (e instanceof ParseException) {
t = cfg.getTemplate("500." + suffix, encoding);
this.appendData("message", e.getMessage());
} else {
t = cfg.getTemplate("404." + suffix, encoding);
this.appendData("message", e.getMessage());
};
e.printStackTrace();
}
}
示例15: JmailTemp
import freemarker.core.ParseException; //导入依赖的package包/类
public JmailTemp(String tempName) throws IOException {
try {
t = cfg.getTemplate(tempName, encoding);
} catch (IOException e) {
isnull = true;
if (e instanceof ParseException) {
t = cfg.getTemplate("500." + suffix, encoding);
this.appendInfo("message", e.getMessage());
} else {
t = cfg.getTemplate("404." + suffix, encoding);
this.appendInfo("message", e.getMessage());
};
e.printStackTrace();
}
}