/** * Creates a page and sets up the velocity engine to render */ public Page(final HttpServletRequest request, final HttpServletResponse response, final VelocityEngine engine, final String template) { this.request = Utils.nonNull(request); this.response = Utils.nonNull(response); this.engine = Utils.nonNull(engine); this.template = Utils.nonNull(template); this.context = new VelocityContext(); this.context.put("esc", new EscapeTool()); this.context.put("session", request.getSession(true)); this.context.put("context", request.getContextPath()); }
/** * Its need to override base class method to be able to change its locale property outside the * class hierarchy * * @see org.apache.velocity.tools.generic.ResourceTool#setLocale(Locale locale) */ @Override public void setLocale(Locale locale) { super.setLocale(locale); }
public static VelocityContext prepareContext(long userId, Event event, Position position) { User user = Context.getPermissionsManager().getUser(userId); Device device = Context.getIdentityManager().getById(event.getDeviceId()); VelocityContext velocityContext = new VelocityContext(); velocityContext.put("user", user); velocityContext.put("device", device); velocityContext.put("event", event); if (position != null) { velocityContext.put("position", position); velocityContext.put("speedUnit", ReportUtils.getSpeedUnit(userId)); velocityContext.put("distanceUnit", ReportUtils.getDistanceUnit(userId)); velocityContext.put("volumeUnit", ReportUtils.getVolumeUnit(userId)); } if (event.getGeofenceId() != 0) { velocityContext.put("geofence", Context.getGeofenceManager().getById(event.getGeofenceId())); } if (event.getMaintenanceId() != 0) { velocityContext.put("maintenance", Context.getMaintenancesManager().getById(event.getMaintenanceId())); } String driverUniqueId = event.getString(Position.KEY_DRIVER_UNIQUE_ID); if (driverUniqueId != null) { velocityContext.put("driver", Context.getDriversManager().getDriverByUniqueId(driverUniqueId)); } velocityContext.put("webUrl", Context.getVelocityEngine().getProperty("web.url")); velocityContext.put("dateTool", new DateTool()); velocityContext.put("numberTool", new NumberTool()); velocityContext.put("timezone", ReportUtils.getTimezone(userId)); velocityContext.put("locale", Locale.getDefault()); return velocityContext; }
/** * Directs this instance to completely exclude * any elements equal to the specified Object. * @param compare value to exclude * @return This same {@link ManagedIterator} instance */ public ManagedIterator exclude(Object compare) { return condition(new ActionCondition(Action.EXCLUDE, new Equals(compare))); }
protected void configure(ValueParser parser) { String[] bundles = parser.getStrings(BUNDLES_KEY); if (bundles != null) { this.bundles = bundles; } super.configure(parser); }
/** * @see org.apache.velocity.tools.generic.ResourceTool#get(java.lang.Object, java.lang.String[], * java.lang.Object) */ @Override public Object get(Object code, String[] resourceNamePrefixes, Object locale) { Object msg = super.get(code, resourceNamePrefixes, locale); //if code's translation is blank, use the english equivalent if (msg == null || StringUtils.isBlank(msg.toString())) { msg = super.get(code, resourceNamePrefixes, Locale.ENGLISH.toString()); } return msg; } }
/** * Inspected object deprecation status * @return deprecation status */ public boolean isDeprecated() { return ClassTool.isDeprecated(getElement()); }
/** * Does the actual configuration. This is protected, so * subclasses may share the same ValueParser and call configure * at any time, while preventing templates from doing so when * configure(Map) is locked. */ protected void configure(ValueParser values) { Locale locale = values.getLocale(ToolContext.LOCALE_KEY); if (locale != null) { setLocale(locale); } }
/** * Gets an instance of the velocity context * * Add the utility instances that are commonly used in many templates. * * @return the instance */ public static VelocityContext getInstance() { final VelocityContext context = new VelocityContext(); context.put("esc", new EscapeTool()); final WebUtils utils = new WebUtils(); context.put("utils", utils); return context; } }
public static org.jxls.common.Context initializeContext(long userId) { org.jxls.common.Context jxlsContext = PoiTransformer.createInitialContext(); jxlsContext.putVar("distanceUnit", getDistanceUnit(userId)); jxlsContext.putVar("speedUnit", getSpeedUnit(userId)); jxlsContext.putVar("volumeUnit", getVolumeUnit(userId)); jxlsContext.putVar("webUrl", Context.getVelocityEngine().getProperty("web.url")); jxlsContext.putVar("dateTool", new DateTool()); jxlsContext.putVar("numberTool", new NumberTool()); jxlsContext.putVar("timezone", getTimezone(userId)); jxlsContext.putVar("locale", Locale.getDefault()); jxlsContext.putVar("bracketsRegex", "[\\{\\}\"]"); return jxlsContext; }
/** * Directs this instance to stop iterating immediately prior to * any element equal to the specified Object. * @param compare value to stop at * @return This same {@link ManagedIterator} instance */ public ManagedIterator stop(Object compare) { return condition(new ActionCondition(Action.STOP, new Equals(compare))); }
ctx.put("valueSet", theValueSetTm); ctx.put("packageBase", thePackageBase); ctx.put("esc", new EscapeTool());
ctx.put("version", configuration.getVersion()); ctx.put("package_suffix", configuration.getPackageSuffix()); ctx.put("esc", new EscapeTool());
ctx.put("version", myVersion.replace(".", "")); ctx.put("versionEnumName", determineVersionEnum().name()); ctx.put("esc", new EscapeTool()); ctx.put("isRi", determineVersionEnum().isRi()); ctx.put("package_suffix", packageSuffix);
ctx.put("version", version); ctx.put("package_suffix", packageSuffix); ctx.put("esc", new EscapeTool()); if (BaseStructureSpreadsheetParser.determineVersionEnum(version).isRi()) { ctx.put("resourcePackage", "org.hl7.fhir." + version + ".model");
ctx.put("searchParamsWithoutComposite", (theResource.getSearchParametersWithoutComposite())); ctx.put("includes", (theResource.getIncludes())); ctx.put("esc", new EscapeTool()); ctx.put("isRi", determineVersionEnum().isRi());