@Override public InputStream getResourceStream(String source) throws ResourceNotFoundException { if (logger.isDebugEnabled()) { logger.debug("Looking for Velocity resource with name [" + source + "]"); } for (String resourceLoaderPath : this.resourceLoaderPaths) { org.springframework.core.io.Resource resource = this.resourceLoader.getResource(resourceLoaderPath + source); try { return resource.getInputStream(); } catch (IOException ex) { if (logger.isDebugEnabled()) { logger.debug("Could not find Velocity resource: " + resource); } } } throw new ResourceNotFoundException( "Could not find resource [" + source + "] in Spring resource loader path"); }
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { String value = (String) node.jjtGetChild(0).value(context); String character = (String) node.jjtGetChild(1).value(context); int len = value.length(); StringBuilder sb = new StringBuilder(len); sb.append(value.charAt(0)); for (int i = 1; i < len; i++) { char c = value.charAt(i); if (Character.isUpperCase(c)) { sb.append(character).append(Character.toLowerCase(c)); } else { sb.append(c); } } writer.write(sb.toString()); return true; }
public void outputCode(String codePath, String templatePath) throws IOException { VelocityContext context = new VelocityContext(); context.put("cModule", cModule); Template template = null; try { template = Velocity.getTemplate(templatePath, TEMPLATE_ENCODING); } catch (ResourceNotFoundException e) { throw e; } File file = new File(codePath); logger.info("Generating {} ({})", file.getName(), templatePath); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), OUTPUT_ENCODING))); template.merge(context, pw); pw.close(); }
@Override public boolean render(RenderHandler handler) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException { String src = handler.getStringParameter(0); String base = handler.getRequest().getContextPath(); // 判断是否启用图片域名 if (Global.getImageDomain()) { base = Global.getImageHost(); } StringBuffer buf = new StringBuffer(); buf.append(base); buf.append(src); handler.write(buf.toString()); return true; }
@Override public boolean render(RenderHandler handler) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException { ServletRequest request = handler.getRequest(); // request 获取参数 String ord = ServletRequestUtils.getStringParameter(request, "ord", Consts.order.NEWEST); int pn = ServletRequestUtils.getIntParameter(request, "pn", 1); // 标签中获取参数 int groupId = handler.getIntParameter(0); String alias = handler.getStringParameter(1); Paging paging = wrapPaing(pn); Paging result = postPlanet.paging(paging, groupId, ord); handler.put(alias, result); handler.doRender(); postRender(handler.getContext()); return true; }
public boolean render(InternalContextAdapter ctx, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { // get the bean ValueStack stack = (ValueStack) ctx.get("stack"); HttpServletRequest req = (HttpServletRequest) stack.getContext().get(ServletActionContext.HTTP_REQUEST); HttpServletResponse res = (HttpServletResponse) stack.getContext().get(ServletActionContext.HTTP_RESPONSE); Component bean = getBean(stack, req, res); Container container = (Container) stack.getContext().get(ActionContext.CONTAINER); container.inject(bean); // get the parameters Map params = createPropertyMap(ctx, node); bean.copyParams(params); //bean.addAllParameters(params); bean.start(writer); if (getType() == BLOCK) { Node body = node.jjtGetChild(node.jjtGetNumChildren() - 1); body.render(ctx, writer); } bean.end(writer, ""); return true; }
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { int argsNum = node.jjtGetNumChildren(); for(int step = 0 ; step < argsNum; step++) { SimpleNode simpleNode = (SimpleNode) node.jjtGetChild(step); Object argObject = simpleNode.value(context); //传入参数 if(argObject instanceof String) { System.out.println((String)argObject); writer.write((String)argObject); writer.flush(); } } return true; }
/** * Process the resourceName with {@link #resolveTemplateIdentifiers(String)} and return the * localized message object of the referenced template definition and the locale object. * * @param resourceName * the velocity resource name * @return the message and the locale extract from the resource name * @throws ResourceNotFoundException * in case the resource name is not an identifier for a note template or the note * template does not exist */ private Pair<LocalizedMessage, Locale> resolveTemplate(String resourceName) throws ResourceNotFoundException { String[] templateParts = resolveTemplateIdentifiers(resourceName); NoteTemplateDefinition definition = getNoteTemplateService() .getDefinition(templateParts[0]); if (definition == null) { throw new ResourceNotFoundException("Note template " + templateParts[0] + " does not exist"); } NoteRenderMode mode = null; Locale locale = null; try { locale = LocaleHelper.toLocale(templateParts[1]); if (templateParts[2] != null) { mode = NoteRenderMode.valueOf(templateParts[2]); } } catch (IllegalArgumentException e) { throw new ResourceNotFoundException("Resource name " + resourceName + " cannot be parsed", e); } return new Pair<LocalizedMessage, Locale>(definition.getTemplate(mode), locale); }
/** * Extract templateId, locale string and optionally the render mode from the resourceName. * * @param resourceName * the velocity resource name to process * @return an array with 3 elements where the first is the templateId, the 2nd the locale string * and the 3rd the render mode or null if not contained * @throws ResourceNotFoundException * in case the resource name is not an identifier for a note template */ private String[] resolveTemplateIdentifiers(String resourceName) throws ResourceNotFoundException { if (!resourceName.startsWith(RESOURCE_NAME_PREFIX)) { throw new ResourceNotFoundException("Resource " + resourceName + " not supported by this loader"); } String[] result = new String[3]; int startIdx = RESOURCE_NAME_PREFIX.length(); try { int idx = resourceName.indexOf(RESOURCE_NAME_PARTS_SEPARATOR, startIdx); result[0] = resourceName.substring(startIdx, idx); startIdx = idx + 1; idx = resourceName.indexOf(RESOURCE_NAME_PARTS_SEPARATOR, startIdx); // third part (render mode) is optional if (idx < 0) { result[1] = resourceName.substring(startIdx); } else { result[1] = resourceName.substring(startIdx, idx); result[2] = resourceName.substring(idx + 1); } return result; } catch (IndexOutOfBoundsException e) { throw new ResourceNotFoundException("Resource " + resourceName + " not found"); } }
/** * Return the String representation of the template rendered using Velocity. * * @param context context use to render the template * @param templateFileName file name of the template in the classpath * @throws TemplateRenderException if there is an error with the template */ public static String renderTemplate(String templateFileName, VelocityContext context) throws TemplateRenderException { VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); StringWriter sw = new StringWriter(); try { ve.mergeTemplate(templateFileName, "UTF-8", context, sw); } catch (ResourceNotFoundException | ParseErrorException | MethodInvocationException e) { throw new TemplateRenderException("Error rendering template file: " + templateFileName, e); } return sw.toString(); }
@Override public InputStream getResourceStream(String resourceName) throws ResourceNotFoundException { FileTemplateManager templateManager = ourTemplateManager.get(); if (templateManager == null) templateManager = FileTemplateManager.getDefaultInstance(); final FileTemplate include = templateManager.getPattern(resourceName); if (include == null) { throw new ResourceNotFoundException("Template not found: " + resourceName); } final String text = include.getText(); try { return new ByteArrayInputStream(text.getBytes(FileTemplate.ourEncoding)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
@Override public InputStream getResourceStream(String name) throws ResourceNotFoundException { try { Registry registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION); if (registry == null) { throw new IllegalStateException("No valid registry instance is attached to the current carbon context"); } if (!registry.resourceExists(EMAIL_CONFIG_BASE_LOCATION + "/" + name)) { throw new ResourceNotFoundException("Resource '" + name + "' does not exist"); } org.wso2.carbon.registry.api.Resource resource = registry.get(EMAIL_CONFIG_BASE_LOCATION + "/" + name); resource.setMediaType("text/plain"); return resource.getContentStream(); } catch (RegistryException e) { throw new ResourceNotFoundException("Error occurred while retrieving resource", e); } }
private Set<String> prepareVelocityTemplate(String template) throws PIPException { VelocityContext vctx = new VelocityContext(); EventCartridge vec = new EventCartridge(); VelocityParameterReader reader = new VelocityParameterReader(); vec.addEventHandler(reader); vec.attachToContext(vctx); try { Velocity.evaluate(vctx, new StringWriter(), "LdapResolver", template); } catch (ParseErrorException pex) { throw new PIPException("Velocity template preparation failed", pex); } catch (MethodInvocationException mix) { throw new PIPException("Velocity template preparation failed", mix); } catch (ResourceNotFoundException rnfx) { throw new PIPException("Velocity template preparation failed", rnfx); } if (this.logger.isTraceEnabled()) { this.logger.trace("(" + id + ") " + template + " with parameters " + reader.parameters); } return reader.parameters; }
private String evaluateVelocityTemplate(String template, final Map<String, PIPRequest> templateParameters, final PIPFinder pipFinder) throws PIPException { StringWriter out = new StringWriter(); VelocityContext vctx = new VelocityContext(); EventCartridge vec = new EventCartridge(); VelocityParameterWriter writer = new VelocityParameterWriter(pipFinder, templateParameters); vec.addEventHandler(writer); vec.attachToContext(vctx); try { Velocity.evaluate(vctx, out, "LdapResolver", template); } catch (ParseErrorException pex) { throw new PIPException("Velocity template evaluation failed", pex); } catch (MethodInvocationException mix) { throw new PIPException("Velocity template evaluation failed", mix); } catch (ResourceNotFoundException rnfx) { throw new PIPException("Velocity template evaluation failed", rnfx); } this.logger.warn("(" + id + ") " + " template yields " + out.toString()); return out.toString(); }
/** * Create a template. * * @param language * programming language name of the generated source code. * @param templatePath * template path. * @param defaultTemplate * default template path. */ protected Template createTemplate(String language, String templatePath, String defaultTemplate) { String defaultResourcePath = "resources/" + this.language + "/" + defaultTemplate; if (templatePath == null || templatePath.isEmpty()) { templatePath = defaultResourcePath; } VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "file, classpath"); ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, ""); ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); ve.init(); try { return ve.getTemplate(templatePath); } catch (ResourceNotFoundException ex) { if (templatePath != defaultResourcePath) { return ve.getTemplate(defaultResourcePath); } else { throw ex; } } }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { //render content StringWriter content = new StringWriter(); node.jjtGetChild(0).render(context, content); //compress try { writer.write(htmlCompressor.compress(content.toString())); } catch (Exception e) { writer.write(content.toString()); String msg = "Failed to compress content: "+content.toString(); log.error(msg, e); throw new RuntimeException(msg, e); } return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { //render content StringWriter content = new StringWriter(); node.jjtGetChild(0).render(context, content); //compress try { writer.write(xmlCompressor.compress(content.toString())); } catch (Exception e) { writer.write(content.toString()); String msg = "Failed to compress content: "+content.toString(); log.error(msg, e); throw new RuntimeException(msg, e); } return true; }
public boolean render( InternalContextAdapter context, Writer writer, org.apache.velocity.runtime.parser.node.Node node ) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { String var = node.jjtGetChild( 0 ).getFirstToken().image.substring( 1 ); Node document = ( Node ) node.jjtGetChild( 1 ).value( context ); String xpath = String.valueOf( node.jjtGetChild( 2 ).value( context ) ); XPath xPath = XPathFactory.newInstance().newXPath(); try { Node element = ( Node ) xPath.evaluate( xpath, document, XPathConstants.NODE ); if( element != null ) if( TEXT_NODES.contains( element.getNodeType() ) ) context.put( var, element.getTextContent() ); else context.put( var, element ); else log.warn( "for " + xpath + " nothing found" ); } catch( XPathExpressionException e ) { throw new IOException( "cannot evaluate xpath: " + e.getMessage() ); } return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { if(node.jjtGetNumChildren() != 1){ throw new RuntimeException(getName() + " only and must accept one parameter!") ; } Object param2 = node.jjtGetChild(0).value(context) ; //如果为null,则什么都不输出。 if(param2 != null){ String param = String.valueOf(param2) ; param = StringUtil.replaceStringIgnoreCase(param, "<script", "< script") ; param = StringUtil.replaceStringIgnoreCase(param, "</script", "</ script") ; writer.append(param) ; } return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { Object value = node.jjtGetChild(0).value(context); boolean isEmpty = false ; if(value == null){ isEmpty = true ; }else{ if(value instanceof String){ isEmpty = StringUtil.isEmpty((String) value) ; }else if(value instanceof Collection){ isEmpty = ((Collection) value).isEmpty() ; }else if(value.getClass().isArray()){ isEmpty = Array.getLength(value) > 0 ; } } if (isEmpty) { Node content = node.jjtGetChild(1); content.render(context, writer); } return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { if(node.jjtGetNumChildren() != 2){ throw new RuntimeException(getName() + " accepts 2 parameters. The first is a boolean value indicating whether or not to add this conditon; the second is a List containing your conditions!") ; } Boolean test = (Boolean) node.jjtGetChild(0).value(context) ; if(Boolean.FALSE.equals(test)){ //ignore this condition. return true ; } Collection conditions = (Collection) node.jjtGetChild(1).value(context) ; BoundaryChain chain = (BoundaryChain) context.get(GuzzBoundaryDirective.BOUNDARY_CONTEXT_NAME) ; if(chain == null){ throw new ParseErrorException(getName() + " must be resided inside a guzzBoundary directive.") ; } chain.addLimitConditions(conditions) ; return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { Object value = node.jjtGetChild(0).value(context); boolean isEmpty = false ; if(value == null){ isEmpty = true ; }else{ if(value instanceof String){ isEmpty = StringUtil.isEmpty((String) value) ; }else if(value instanceof Collection){ isEmpty = ((Collection) value).isEmpty() ; }else if(value.getClass().isArray()){ isEmpty = Array.getLength(value) > 0 ; } } if (!isEmpty) { Node content = node.jjtGetChild(1); content.render(context, writer); } return true; }
public CompiledSQL getSqlById(String id, Object tableCondition, Map params) { TemplateData data = this.templates.get(id) ; if (data == null) { throw new ResourceNotFoundException("No Template for id:" + id); } VelocityContext context = new VelocityContext(params) ; StringWriter w = new StringWriter() ; Template template = ve.getTemplate(id); template.merge(context, w) ; String sql = w.toString() ; if(data.mapping != null){ return compiledSQLBuilder.buildCompiledSQL(data.mapping, sql) ; }else{ return this.compiledSQLBuilder.buildCompiledSQL(data.ormName, sql) ; } }
@Override public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { Node bodyNode = getBodyNode(context, node); if (AsynchronousContain.isAsyncConext()) { StringWriter sw = new StringWriter(); bodyNode.render(context, sw); PipelineTask task = (PipelineTask) context .get(PipelineTask.ATTR_KEY); task.addJsCode(sw.toString()); } else { writer.write("<script type=\"text/javascript\">\r\n"); bodyNode.render(context, writer); writer.write("</script>\r\n"); } return true; }
@Test public void createSourceFilesFromCsv() throws ResourceNotFoundException, ParseErrorException, Exception { loadModulesFromCsv(); I18nModuleConverter fooConverter = new I18nModuleConverter( FooI18n.class, serverStore.getLocalizablesForModule(FooI18n.MODULE_NAME)); fooConverter.generateModuleFile(); fooConverter.generateServerModuleProviderFile(); I18nModuleConverter barConverter = new I18nModuleConverter( BarI18n.class, serverStore.getLocalizablesForModule(BarI18n.MODULE_NAME)); barConverter.generateModuleFile(); barConverter.generateServerModuleProviderFile(); }
@Test public void generateModuleFileToConsole() throws ResourceNotFoundException, ParseErrorException, Exception { loadModulesFromCsv(); I18nModuleConverter fooConverter = new I18nModuleConverter( FooI18n.class, serverStore.getLocalizablesForModule(FooI18n.MODULE_NAME)); StringWriter sw = new StringWriter(); fooConverter.generateFileToWriter( sw, I18nModuleConverter.MODULE_VM, fooConverter.getModuleFileCreatorContext()); System.out.println(sw.getBuffer()); }
/** * Renders the template and writes the output to the given file. * * Strips all trailing whitespace before writing to file. */ public void write(File outputFile) throws IOException { StringWriter stringWriter = new StringWriter(); try { engine.mergeTemplate(template, "UTF-8", context, stringWriter); } catch (ResourceNotFoundException|ParseErrorException|MethodInvocationException e) { throw new IOException(e); } stringWriter.close(); String[] lines = stringWriter.toString().split(System.getProperty("line.separator")); try (FileWriter fileWriter = new FileWriter(outputFile)) { for (String line : lines) { // Strip trailing whitespace then append newline before writing to file. fileWriter.write(line.replaceFirst("\\s+$", "") + "\n"); } } }
@Override public InputStream getResourceStream(String name) throws ResourceNotFoundException { InputStream result = null; try { Representation resultRepresentation = getStore().get(name); if (resultRepresentation == null) { resultRepresentation = this.defaultRepresentation; if (resultRepresentation == null) { throw new ResourceNotFoundException( "Could not locate resource '" + name + "'"); } result = resultRepresentation.getStream(); } else { result = resultRepresentation.getStream(); } } catch (IOException ioe) { throw new ResourceNotFoundException(ioe); } return result; }
/** * Constructor based on a Velocity 'encoded' representation. * * @param templateRepresentation * The representation to 'decode'. * @param dataModel * The Velocity template's data model. * @param mediaType * The representation's media type. * @throws IOException * @throws ParseErrorException * @throws ResourceNotFoundException */ public TemplateRepresentation(Representation templateRepresentation, Map<String, Object> dataModel, MediaType mediaType) throws ResourceNotFoundException, ParseErrorException, IOException { super(mediaType); setDataModel(dataModel); this.engine = null; this.template = new Template(); this.template .setEncoding((templateRepresentation.getCharacterSet() == null) ? Charset .defaultCharset().name() : templateRepresentation.getCharacterSet().getName()); if (templateRepresentation.getModificationDate() != null) { this.template.setLastModified(templateRepresentation .getModificationDate().getTime()); } this.template.setName("org.restlet.resource.representation"); this.template.setRuntimeServices(RuntimeSingleton.getRuntimeServices()); this.template.setResourceLoader(new RepresentationResourceLoader( templateRepresentation)); this.template.process(); this.templateName = null; }
/** * Constructor based on a Velocity 'encoded' representation. * * @param templateRepresentation * The representation to 'decode'. * @param mediaType * The representation's media type. * @throws IOException * @throws ParseErrorException * @throws ResourceNotFoundException */ public TemplateRepresentation(Representation templateRepresentation, MediaType mediaType) throws ResourceNotFoundException, ParseErrorException, IOException { super(mediaType); this.engine = null; this.template = new Template(); this.template .setEncoding((templateRepresentation.getCharacterSet() == null) ? Charset .defaultCharset().name() : templateRepresentation.getCharacterSet().getName()); this.template.setLastModified((templateRepresentation .getModificationDate() == null) ? new Date().getTime() : templateRepresentation.getModificationDate().getTime()); this.template.setName("org.restlet.resource.representation"); this.template.setRuntimeServices(RuntimeSingleton.getRuntimeServices()); this.template.setResourceLoader(new RepresentationResourceLoader( templateRepresentation)); this.template.process(); this.templateName = null; }
/** * 根据模板名字和编码完成Velocity模板对象的创建工作 * * @param templateName * @param encoding * @return * @throws ResourceNotFoundException * @throws ParseErrorException * @throws MethodInvocationException * @throws Exception */ protected Template getTemplate(String templateName, String encoding) throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception { String name = parseTemplateName(templateName); if (FrameworkEngine.getWebConfig().isDebug()) return RuntimeSingleton.getTemplate(name, encoding);// 若为Debug状态,则每次都重新载入模板 String templatePath = (String) Velocity .getProperty("file.resource.loader.path"); java.io.File f = new java.io.File(new java.io.File(templatePath), name); Template template = (Template) templateCache.get(name);// 先从Cache中读取模板文件 // 这里得进一步完善,当用户已经更改模板文件后,需要能够自动加载,同时增加Cache数量的限制 if (template == null || (f.exists() && f.lastModified() > template.getLastModified())) synchronized (templateCache) { { logger.info(I18n.getLocaleMessage("core.web.template.file.reloads") + name); template = RuntimeSingleton.getTemplate(name, encoding);// name templateCache.put(name, template); } } return template; }
protected Language readTemplateLanguage(final String templateName) { if (StringUtils.isEmpty(templateName)) { throw new ResourceNotFoundException("DataSourceResourceLoader: Template name was empty or null"); } Matcher matcher = SOURCE_NAME_PATTERN.matcher(templateName); String languageStr = null; if (matcher.matches()) { languageStr = matcher.group("language"); } else { throw new ResourceNotFoundException("Template name not valid. Pattern: templateId(/lang)?"); } Language language = null; if (StringUtils.isNotBlank(languageStr)) { language = Language.valueOf(languageStr); if (language == null) { throw new ResourceNotFoundException("Language not supported"); } } return language; }
@Override public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException { InputStream result = null; if (name == null || name.length() == 0) { throw new ResourceNotFoundException ("No template name provided"); } URL url = getResource(name); if (url != null) { try { result = url.openStream(); } catch (Exception e) { _logger.error("Error opening stream", e); throw new ResourceNotFoundException(e.getMessage()); } } else { throw new ResourceNotFoundException("Resource '" + name + "' count not be found"); } return result; }
/** * {@inheritDoc} */ @Override public synchronized InputStream getResourceStream(String name) throws ResourceNotFoundException { if ((name == null) || (name.length() == 0)) { throw new ResourceNotFoundException("No template name provided"); } if (name.charAt(0) == '/') { name = name.substring(1); } try { return DefaultBundleAccessor.getInstance().loadResourceAsStream(name); } catch (final Exception e) { throw new ResourceNotFoundException(e); } }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { //setting default params String moneyValue = null; //reading params if (node.jjtGetChild(0) != null) { moneyValue = node.jjtGetChild(0).value(context) == null ? null : String.valueOf(node.jjtGetChild(0).value(context)); } //truncate and write result to writer writer.write(moneyUAH(moneyValue)); return true; }
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { //setting default params String ukrValue = null; //reading params if (node.jjtGetChild(0) != null) { ukrValue = node.jjtGetChild(0).value(context) == null ? null : String.valueOf(node.jjtGetChild(0).value(context)); } if (ukrValue == null) { return false; } //truncate and write result to writer writer.write(UkrainianToLatin.generateLat(ukrValue)); return true; }