Szablon musi być pojedynczym plikiem. Jego przetwarzanie polega na jednorazowym
wywołaniu metody {@link #processVelocityFile(ITemplateSourceEntry, VelocityContext,
String)} w celu utworzenia pojedynczego zasobu.
481718
protected void processVelocityResource(ITemplateSource source, VelocityContext context, String target) throws Exception {
		if(!source.isFile()) {
			throw new RuntimeException("Zasób "
					+ source.getTemplate() + "/"+ source.getResource()
					+ " nie jest plikiem"
			);
		}
		processVelocityFile(source.getEntry(source.getResource()), context, target);
	}
317720
private void processFiles() throws CompilationFailedException, IOException, URISyntaxException {
        GroovyShell groovy = new GroovyShell(conf);
        setupContextClassLoader(groovy);

        Script s = groovy.parse(getScriptSource(isScriptFile, script));

        if (args.isEmpty()) {
            try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
                PrintWriter writer = new PrintWriter(System.out);
                processReader(s, reader, writer);
                writer.flush();
            }
        } else {
            Iterator i = args.iterator();
            while (i.hasNext()) {
                String filename = (String) i.next();
                //TODO: These are the arguments for -p and -i.  Why are we searching using Groovy script extensions?
                // Where is this documented?
                File file = huntForTheScriptFile(filename);
                processFile(s, file);
            }
        }
    }
1289234
public void processDynamicFile(Map<String, Object> context, TemplatePack templatePack, Template template) throws Exception {
        try {
            if (!(template.getName().indexOf(".vm.") >= 0 || template.getName().endsWith(".vm"))) {
                throw new IllegalStateException("not a velocity template!: " + template.getName());
            }

            String evaluatedTemplate = null;

            try {
                evaluatedTemplate = velocityGenerator.evaluate(context, templatePack, template);
            } catch (StopFileReachedException e) {
                return;
            }

            if (currentFullFilename.endsWith(".donotgenerate")) {
                return;
            }
            if (isBlank(currentFullFilename)) {
                log.error("In " + templatePack.getName() + ":" + template.getName() + "  target filename is missing");
                return;
            }
            if (!config.getCelerio().getConfiguration().hasFilename(templatePack.getName(), currentFullFilename)) {
                packDebug(templatePack, "SKIPPING:" + currentFullFilename);
                return;
            }

            if (currentEnableDynamicImport) {
                if (ImportsContext.getCurrentImportsHolder().hasImports()) {
                    evaluatedTemplate = evaluatedTemplate.replace(DYNA_IMPORTS_TAG, "\n" + ImportsContext.getCurrentImportsHolder().toJavaImportString());
                } else {
                    evaluatedTemplate = evaluatedTemplate.replace(DYNA_IMPORTS_TAG, "");
                }
            }

            if (currentFullFilename.endsWith(".java")) {
                evaluatedTemplate = eclipseCodeFormatter.format(evaluatedTemplate);
            } else if (currentFullFilename.endsWith(".xml") || currentFullFilename.endsWith(".xhtml")) {
                evaluatedTemplate = xmlCodeFormatter.format(evaluatedTemplate);
            }

            // generated content is in the string writer
            if (log.isDebugEnabled()) {
                packDebug(templatePack, "processing template " + template.getName() + " (" + currentFullFilename + ")");
            }
            try {
                contentWriter.processFile(outputResult, templatePack, template, evaluatedTemplate.getBytes("UTF-8"), currentFullFilename);
            } catch (Exception e) {
                log.error("In " + templatePack.getName() + ":" + template.getName() + " template, got exception " + e.getMessage(), e);
            }

        } finally {
            clearDynamicFileContext();
        }
    }
1356365
public void processSource (CloudTrailSource source) {
        boolean filterSourceOut = false;
        boolean downloadLogSuccess = true;
        boolean processSourceSuccess = false;

        ProgressStatus processSourceStatus = new ProgressStatus(ProgressState.processSource, new BasicProcessSourceInfo(source, processSourceSuccess));
        final Object processSourceReportObject = progressReporter.reportStart(processSourceStatus);

        // Start to process the source
        try {
            // Apply source filter first. If source filtered out then delete source immediately and return.
            if (!sourceFilter.filterSource(source)) {
                logger.debug("AWSCloudTrailSource " + source + " has been filtered out.");
                processSourceSuccess = true;
                filterSourceOut = true;

            } else {
                int nLogFilesToProcess = ((SQSBasedSource)source).getLogs().size();

                for (CloudTrailLog ctLog : ((SQSBasedSource)source).getLogs()) {
                    //start to process the log
                    boolean processLogSuccess = false;
                    ProgressStatus processLogStatus = new ProgressStatus(ProgressState.processLog, new BasicProcessLogInfo(source, ctLog, processLogSuccess));
                    final Object processLogReportObject = progressReporter.reportStart(processLogStatus);

                    try {
                        byte[] s3ObjectBytes = s3Manager.downloadLog(ctLog, source);
                        if (s3ObjectBytes == null) {
                            downloadLogSuccess = false;
                            continue; //Failure downloading log file. Skip it.
                        }

                        try (GZIPInputStream gzippedInputStream = new GZIPInputStream(new ByteArrayInputStream(s3ObjectBytes));
                            EventSerializer serializer = getEventSerializer(gzippedInputStream, ctLog)) {

                            emitEvents(serializer);

                            //decrement this value upon successfully processed a log
                            nLogFilesToProcess --;
                            processLogSuccess = true;

                        } catch (IllegalArgumentException | IOException e) {
                            LibraryUtils.handleException(exceptionHandler, processLogStatus, e, "Failed to parse log file.");
                        }

                    } finally {
                        //end to process the log
                        LibraryUtils.endToProcess(progressReporter, processLogSuccess, processLogStatus, processLogReportObject);
                    }
                }

                if (nLogFilesToProcess == 0) {
                    processSourceSuccess = true;
                }
            }

        } catch (CallbackException ex) {
            exceptionHandler.handleException(ex);

        } finally {
            cleanupMessage(filterSourceOut, downloadLogSuccess, processSourceSuccess, source);
            // end to process the source
            LibraryUtils.endToProcess(progressReporter, processSourceSuccess, processSourceStatus, processSourceReportObject);
        }
    }
175499
public static void toFile(VelocityEngine ve, String templateFileName, VelocityContext context, String destPath) {
		toFile(ve.getTemplate(templateFileName), context, destPath);
	}
756133
protected void processVelocityResource(ITemplateSource source, Map<String, Object> params, String target) throws Exception {

		for(ITemplateSourceEntry entry : source.listEntries()) {
			//System.out.println("Wykryto zasób: " + entry.getName());

			if(entry.isFile()) {
//				System.out.println("Element " + entry.getTemplate() + "/" + source.getResource() +
//						"/"+ entry.getName() + " jest plikiem");
				processVelocityFile(entry, source.getResource(), params, target);
			}
		}
	}
510480
private void createFrameset(File outputDirectory) throws Exception
    {
        VelocityContext context = createContext();
        generateFile(new File(outputDirectory, INDEX_FILE),
                     INDEX_FILE + TEMPLATE_EXTENSION,
                     context);
    }
639583
private static InputStream render(final String folder,
        final InputStream template,
        final Map<String, Object> params) throws IOException {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final Writer writer = new Utf8OutputStreamContent(baos);
        final VelocityEngine engine = new VelocityEngine();
        engine.setProperty(
            "file.resource.loader.path",
            folder
        );
        engine.evaluate(
            new VelocityContext(params),
            writer,
            "",
            new Utf8InputStreamContent(template)
        );
        writer.close();
        return new ByteArrayInputStream(baos.toByteArray());
    }
1005837
public static void toWriter(VelocityEngine ve, String templateFileName, VelocityContext context, Writer writer) {
		final Template template = ve.getTemplate(templateFileName);
		merge(template, context, writer);
	}
1204608
@Override
	public void processItemDocument(ItemDocument itemDocument) {
		this.countItems++;

		// Do some printing for demonstration/debugging.
		// Only print at most 50 items (or it would get too slow).
		if (this.countItems < 10) {
			System.out.println(itemDocument);
		} else if (this.countItems == 10) {
			System.out.println("*** I won't print any further items.\n"
					+ "*** We will never finish if we print all the items.\n"
					+ "*** Maybe remove this debug output altogether.");
		}
	}
105023
protected void processIndexTemplate(
            final Configuration cfg,
            final List<DocWorkUnit> workUnitList,
            final List<Map<String, String>> groupMaps
   ) throws IOException {
        // Get or create a template and merge in the data
        final Template template = cfg.getTemplate(getIndexTemplateName());

        final File indexFile = new File(getDestinationDir(),
                            getIndexBaseFileName() + '.' + getIndexFileExtension()
        );

        try (final FileOutputStream fileOutStream = new FileOutputStream(indexFile);
             final OutputStreamWriter outWriter = new OutputStreamWriter(fileOutStream)) {
            template.process(groupIndexMap(workUnitList, groupMaps), outWriter);
        } catch (TemplateException e) {
            throw new DocException("Freemarker Template Exception during documentation index creation", e);
        }
    }
442774
public void writeTemplateSpreadsheetDownloadFile(List<TemplateTokenInfo> tokenNames,
                                                     TemplateVariablesSet variablesSet,
                                                     String filePath) throws TemplateException {

        prepareWriter(filePath);
        writeDownloadSpreadsheetHeader(tokenNames);

        for (int i = 1; i < variablesSet.getEntryCount() + 1; i++) {
            TemplateVariables entryVariables = variablesSet.getEntryValues(i);
            writeSpreadsheetVariableRow(tokenNames, i, entryVariables);
        }

        flushAndCloseWriter();
    }
708352
@Override
    public void process(Object event) throws Exception {
        int secOffset = TimeUtils.secOffset();
        if (secOffset < UPLOAD_TIME_OFFSET_SEC) {
            JStormUtils.sleepMs((UPLOAD_TIME_OFFSET_SEC - secOffset) * 1000);
        } else if (secOffset == UPLOAD_TIME_OFFSET_SEC) {
            // do nothing
        } else {
            JStormUtils.sleepMs((60 - secOffset + UPLOAD_TIME_OFFSET_SEC) * 1000);
        }
        if (topologyMetricContext.getUploadedWorkerNum() > 0) {
            metricLogger.info("force upload metrics.");
            mergeAndUploadMetrics();
        }
    }
709833
public static void toWriter(String templateFileName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) {
		final VelocityContext context = new VelocityContext();
		parseRequest(context, request);
		parseSession(context, request.getSession(false));

		Writer writer = null;
		try {
			writer = response.getWriter();
			toWriter(templateFileName, context, writer);
		} catch (Exception e) {
			throw new UtilException(e, "Write Velocity content template by [{}] to response error!", templateFileName);
		} finally {
			IoUtil.close(writer);
		}
	}
1325379
@Override
	public void process(String xmlString, ITempelEntryProcessor entryProcessor) throws Exception {
		process(new ByteArrayInputStream(xmlString.getBytes()), entryProcessor);
	}
1110322
public VelocityContext buildVelocityContext(Object bean) {
		VelocityContext context_ = new VelocityContext();
		ClassUtil.ClassInfo beanInfo = ClassUtil.getClassInfo(bean.getClass());
		String name = null;
		DateFormateMeta dataformat = null;

//		String charset = null;
		Object value = null;
//		Class type = null;

//		Method writeMethod = null;

		List<ClassUtil.PropertieDescription> attributes = beanInfo.getPropertyDescriptors();
		for (int i = 0; attributes != null && i < attributes.size(); i++) {
			ClassUtil.PropertieDescription property = attributes.get(i);
			ColumnWraper column = property.getColumn();
			if (column != null && (column.ignoreCUDbind() || column.ignorebind()))
				continue;

//			type = property.getPropertyType();


			try {
				if (property.canread()) {
					try {
						value = property.getValue(bean);
					} catch (InvocationTargetException e1) {
						log.error("Failed to get attribute[" + beanInfo.getClazz().getName() + "." + property.getName() + "] value:", e1.getTargetException());
					} catch (Exception e1) {
						log.error("Failed to get attribute[" + beanInfo.getClazz().getName() + "." + property.getName() + "] value:", e1);
					}

					name = property.getName();

					if (column != null) {
						ColumnEditorInf editor = column.editor();
						if (editor == null || editor instanceof ColumnToFieldEditor) {

							dataformat = column.getDateFormateMeta();

//							charset = column.charset();


						} else {
							Object cv = editor.toColumnValue(column, value);
							if (cv == null)
								throw new ElasticSearchException("转换属性[" + beanInfo.getClazz().getName() + "." + property.getName() + "]值失败：值为null时，转换器必须返回ColumnType类型的对象,用来指示表字段对应的java类型。");

							if (!(cv instanceof ColumnType)) {
								value = cv;
//								type = value.getClass();

							} else {
//								type = ((ColumnType) cv).getType();
							}
						}

					}
					/**
					 * since 5.0.6.0,去掉vm模板解析时变量的转义，因此在模板中的使用$aaa模式变量的情况时，需要注意转义的问题，如果存在转义问题，请使用#[]模式变量
					 * 	 日期也不做格式化转换，使用$aaa模式变量的情况下需要注意日期格式问题，如果存在日期，则需要使用#[]模式变量，这样bboss会根据bean属性配置的格式，或者变量中指定的格式
					 * 	 对日期进行格式化，如果不指定格式采用默认的格式和时区进行处理
					 */
					/**
					if (value == null) {
						context_.put(name, null);
					} else if (value instanceof Date) {
//						if(dataformat != null)
							context_.put(name, this.getDate((Date) value, dataformat));
//						else {
////							context_.put(name, ((Date) value).getTime());
//							context_.put(name, ((Date) value));
//						}
					} else if(value instanceof String){//提前转义
						CharEscapeUtil charEscapeUtil = new CharEscapeUtil();
						charEscapeUtil.writeString((String)value,false);
						context_.put(name, charEscapeUtil.toString());
					}
					else {
						context_.put(name, value);
					}
					 */
					context_.put(name, value);
//					params.addSQLParamWithDateFormateMeta(name, value, sqltype, dataformat,charset);

				}
				name = null;
				value = null;
				dataformat = null;

//				charset = null;


			} catch (SecurityException e) {
				throw new ElasticSearchException(e);
			} catch (IllegalArgumentException e) {
				throw new ElasticSearchException(e);
			}
//			catch (InvocationTargetException e) {
//				throw new ElasticSearchException(e.getTargetException());
//			}


			catch (Exception e) {
				throw new ElasticSearchException(e);
			}


		}


		return context_;

	}
1056880
protected void processContent(Content file) {
        // Handle metadata/special cases
        String lowerCaseFileName = file.name.toLowerCase();
        if (lowerCaseFileName.endsWith("pom.properties")) {
            // handle pom properties files
            InputStream is = new ByteArrayInputStream(file.bytes);
            Metadata md = Metadata.fromPomProperties(is);
            putMetadata(file.name, md);
        }

        // This is separate as we may or may not want to fingerprint
        // all files.
        if (RECURSIVE) {
            Artifact record = Processor.process(file.bytes, file.name, true);
            addContent(record, file.name);
        }
    }