本文整理汇总了Java中com.google.template.soy.data.SoyMapData类的典型用法代码示例。如果您正苦于以下问题:Java SoyMapData类的具体用法?Java SoyMapData怎么用?Java SoyMapData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SoyMapData类属于com.google.template.soy.data包,在下文中一共展示了SoyMapData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serve
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
void serve(final Webpath webpath) throws IOException {
response.setContentType(MediaType.HTML_UTF_8);
response.setPayload(
TOFU.newRenderer(ListingSoyInfo.LISTING)
.setData(
new SoyMapData(
ListingSoyInfo.ListingSoyTemplateInfo.LABEL,
config.get().getLabel(),
ListingSoyInfo.ListingSoyTemplateInfo.PATHS,
new SoyListData(
FluentIterable.from(webpaths)
.filter(
new Predicate<Webpath>() {
@Override
public boolean apply(Webpath path) {
return path.startsWith(webpath);
}
})
.transform(Functions.toStringFunction()))))
.render()
.getBytes(StandardCharsets.UTF_8));
}
示例2: initMutatingEppToolCommand
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
protected void initMutatingEppToolCommand() {
checkArgumentNotNull(registrant, "Registrant must be specified");
checkArgument(!admins.isEmpty(), "At least one admin must be specified");
checkArgument(!techs.isEmpty(), "At least one tech must be specified");
if (isNullOrEmpty(password)) {
password = passwordGenerator.createString(PASSWORD_LENGTH);
}
for (String domain : domains) {
setSoyTemplate(DomainCreateSoyInfo.getInstance(), DomainCreateSoyInfo.DOMAINCREATE);
addSoyRecord(
clientId,
new SoyMapData(
"domain", domain,
"period", period == null ? null : period.toString(),
"nameservers", nameservers,
"registrant", registrant,
"admins", admins,
"techs", techs,
"password", password));
}
}
示例3: initMutatingEppToolCommand
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
protected void initMutatingEppToolCommand() {
setSoyTemplate(HostCreateSoyInfo.getInstance(), HostCreateSoyInfo.HOSTCREATE);
ImmutableList.Builder<String> ipv4Addresses = new ImmutableList.Builder<>();
ImmutableList.Builder<String> ipv6Addresses = new ImmutableList.Builder<>();
for (String address : nullToEmpty(addresses)) {
InetAddress inetAddress = InetAddresses.forString(address);
if (inetAddress instanceof Inet4Address) {
ipv4Addresses.add(inetAddress.getHostAddress());
} else if (inetAddress instanceof Inet6Address) {
ipv6Addresses.add(inetAddress.getHostAddress());
} else {
throw new IllegalArgumentException(
String.format("IP address in unknown format: %s", address));
}
}
addSoyRecord(
clientId,
new SoyMapData(
"hostname", hostName,
"ipv4addresses", ipv4Addresses.build(),
"ipv6addresses", ipv6Addresses.build()));
}
示例4: initMutatingEppToolCommand
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
protected void initMutatingEppToolCommand() {
checkArgument(superuser, "This command must be run as a superuser.");
findTldForNameOrThrow(InternetDomainName.from(domainName)); // Check that the tld exists.
if (isNullOrEmpty(password)) {
password = createToken(ANCHOR_TENANT, passwordGenerator);
}
Money cost = null;
if (fee) {
cost = getDomainCreateCost(domainName, DateTime.now(UTC), DEFAULT_ANCHOR_TENANT_PERIOD_YEARS);
}
setSoyTemplate(CreateAnchorTenantSoyInfo.getInstance(),
CreateAnchorTenantSoyInfo.CREATEANCHORTENANT);
addSoyRecord(clientId, new SoyMapData(
"domainName", domainName,
"contactId", contact,
"reason", reason,
"password", password,
"period", DEFAULT_ANCHOR_TENANT_PERIOD_YEARS,
"feeCurrency", cost != null ? cost.getCurrencyUnit().toString() : null,
"fee", cost != null ? cost.getAmount().toString() : null));
}
示例5: initMutatingEppToolCommand
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
protected void initMutatingEppToolCommand() {
checkArgument(
requestedByRegistrar || !isNullOrEmpty(reason),
"A reason must be provided when a change is not requested by a registrar.");
Set<String> valuesToApply = getStatusValuesSet(locksToApply);
Set<String> valuesToRemove = getStatusValuesSet(locksToRemove);
checkArgument(
intersection(valuesToApply, valuesToRemove).isEmpty(),
"Add and remove actions overlap");
checkArgument(
!union(valuesToApply, valuesToRemove).isEmpty(),
"Add and remove actions are both empty");
setSoyTemplate(
UpdateServerLocksSoyInfo.getInstance(), UpdateServerLocksSoyInfo.UPDATESERVERLOCKS);
addSoyRecord(clientId, new SoyMapData(
"domainName", domainName,
"locksToApply", valuesToApply,
"locksToRemove", valuesToRemove,
"reason", reason,
"requestedByRegistrar", requestedByRegistrar));
}
示例6: initMutatingEppToolCommand
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
protected void initMutatingEppToolCommand() {
if (isNullOrEmpty(password)) {
password = passwordGenerator.createString(PASSWORD_LENGTH);
}
checkArgument(street == null || street.size() <= 3,
"Addresses must contain at most 3 street lines.");
setSoyTemplate(ContactCreateSoyInfo.getInstance(), ContactCreateSoyInfo.CONTACTCREATE);
addSoyRecord(clientId, new SoyMapData(
"id", id,
"name", name,
"org", org,
"street", street,
"city", city,
"state", state,
"zip", zip,
"cc", cc,
"phone", phone,
"fax", fax,
"email", email,
"password", password));
}
示例7: getTemplateData
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
static SoyMapData getTemplateData(String canonicalURL, String cdnPath, String faviconPath)
throws URISyntaxException {
String canonicalPath = computeCanonicalPath(canonicalURL);
String staticPath = "";
if (cdnPath != null) {
staticPath = cdnPath;
} else if (canonicalPath != null) {
staticPath = canonicalPath;
}
// The resource path must be typed as safe for use in a script src.
// TODO(wyatta): Upgrade this to use an appropriate safe URL type.
SanitizedContent sanitizedStaticPath =
UnsafeSanitizedContentOrdainer.ordainAsSafe(
staticPath, SanitizedContent.ContentKind.TRUSTED_RESOURCE_URI);
return new SoyMapData(
"canonicalPath", canonicalPath,
"staticResourcePath", sanitizedStaticPath,
"faviconPath", faviconPath);
}
示例8: setupRenderer
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
protected void setupRenderer(final SoyTofu.Renderer renderer, final RenderRequest renderRequest, final Optional<SoyMapData> model) {
if (model.isPresent()) {
logger.debug("renderer - model is available.");
renderer.setData(model.get());
}
final Optional<SoyMapData> globalModel = renderRequest.getGlobalRuntimeModel();
if (globalModel.isPresent()) {
logger.debug("renderer - global runtime model is available.");
renderer.setIjData(globalModel.get());
}
final Optional<SoyMsgBundle> soyMsgBundleOpt = renderRequest.getSoyMsgBundle();
if (soyMsgBundleOpt.isPresent()) {
logger.debug("renderer - soyMsgBundle is available.");
renderer.setMsgBundle(soyMsgBundleOpt.get());
if (!soyViewConf.globalHotReloadMode()) {
if (renderRequest.getCompiledTemplates().isPresent()) {
renderRequest.getCompiledTemplates().get().addToCache(soyMsgBundleOpt.get(), null);
}
}
}
if (soyViewConf.globalHotReloadMode()) {
renderer.setDontAddToCache(true);
}
}
示例9: getDataForRequest
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
@Nullable
public SoyMapData getDataForRequest(Request baseRequest) throws IOException {
String path = baseRequest.getPathInfo();
Matcher matcher = TraceDataHandler.ID_PATTERN.matcher(path);
if (!matcher.matches()) {
return null;
}
SoyMapData templateData = new SoyMapData();
String id = matcher.group(1);
templateData.put("traceId", id);
// Read the args to `buck` out of the Chrome Trace.
TraceAttributes traceAttributes = tracesHelper.getTraceAttributesFor(id);
templateData.put("dateTime", traceAttributes.getFormattedDateTime());
if (traceAttributes.getCommand().isPresent()) {
templateData.put("command", traceAttributes.getCommand().get());
}
return templateData;
}
示例10: resolveData
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
public void resolveData(final HttpServletRequest request, final HttpServletResponse response, final Map<String, ? extends Object> model, final SoyMapData root) {
final RequestContext requestContext = new RequestContext(request, response, servletContext, (Map<String, Object>) model);
if (requestContext.getContextPath() != null) {
root.put(prefix + "contextPath", requestContext.getContextPath());
}
if (requestContext.getPathToServlet() != null) {
root.put(prefix + "pathToServlet", requestContext.getPathToServlet());
}
if (requestContext.getQueryString() != null) {
root.put(prefix + "queryString", requestContext.getQueryString());
}
if (requestContext.getRequestUri() != null) {
root.put(prefix + "requestUri", requestContext.getRequestUri());
}
if (requestContext.getLocale() != null) {
root.put(prefix + "locale", requestContext.getLocale().toString());
}
}
示例11: resolveData
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
public void resolveData(final HttpServletRequest request, final HttpServletResponse response, final Map<String, ? extends Object> model, SoyMapData root) {
if (servletContext.getContextPath() != null) {
root.put(prefix + "contextPath", servletContext.getContextPath());
}
root.put(prefix + "minorVersion", servletContext.getMinorVersion());
root.put(prefix + "majorVersion", servletContext.getMajorVersion());
if (servletContext.getServletContextName() != null) {
root.put(prefix + "servletContextName", servletContext.getServletContextName());
}
if (servletContext.getServerInfo() != null) {
root.put(prefix + "serverInfo", servletContext.getServerInfo());
}
for (final Enumeration<String> e = servletContext.getInitParameterNames(); e.hasMoreElements();) {
final String paramName = e.nextElement();
final String paramValue = servletContext.getInitParameter(paramName);
if (paramValue != null) {
root.put(prefix + "parameter." + paramName, paramValue);
}
}
}
示例12: render
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
public void render(final RenderRequest renderRequest) throws Exception {
if (!renderRequest.getCompiledTemplates().isPresent()) {
logger.warn("compiled templates are not present, nothing to render!");
return;
}
final SoyTofu compiledTemplates = renderRequest.getCompiledTemplates().get();
final String templateName = renderRequest.getTemplateName();
final SoyTofu.Renderer renderer = compiledTemplates.newRenderer(templateName);
final Optional<SoyMapData> soyModel = toSoyDataConverter.toSoyMap(renderRequest.getModel());
setupRenderer(renderer, renderRequest, soyModel);
writeResponse(renderer, renderRequest);
}
示例13: setupRenderer
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
protected void setupRenderer(final SoyTofu.Renderer renderer, final RenderRequest renderRequest, final Optional<SoyMapData> model) throws Exception {
if (model.isPresent()) {
renderer.setData(model.get());
}
final Optional<SoyMapData> globalModel = renderRequest.getGlobalRuntimeModel();
if (globalModel.isPresent()) {
renderer.setIjData(globalModel.get());
}
final Optional<SoyMsgBundle> soyMsgBundleOptional = renderRequest.getSoyMsgBundle();
if (soyMsgBundleOptional.isPresent()) {
renderer.setMsgBundle(soyMsgBundleOptional.get());
if (isHotReloadModeOff()) {
if (renderRequest.getCompiledTemplates().isPresent()) {
renderRequest.getCompiledTemplates().get().addToCache(soyMsgBundleOptional.get(), null);
}
}
}
if (isHotReloadMode()) {
renderer.setDontAddToCache(true);
}
}
示例14: testBindCookies
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Test
public void testBindCookies() throws Exception {
final SoyMapData soyMapData = new SoyMapData();
final HttpServletRequest request = mock(HttpServletRequest.class);
final HttpServletResponse response = mock(HttpServletResponse.class);
final Enumeration e = mock(Enumeration.class);
when(e.hasMoreElements()).thenReturn(false);
when(request.getParameterNames()).thenReturn(e);
when(request.getHeaderNames()).thenReturn(e);
when(request.getCookies()).thenReturn(new Cookie[]{new Cookie("name1", "value1"), new Cookie("name2", "value2")});
cookieResolver.resolveData(request, response, null, soyMapData);
Assert.assertEquals("should not be value1", "value1", soyMapData.get("_request.cookie.name1.value").stringValue());
Assert.assertEquals("should not be value2", "value2", soyMapData.get("_request.cookie.name2.value").stringValue());
Assert.assertEquals("should not be name1", "name1", soyMapData.get("_request.cookie.name1.name").stringValue());
Assert.assertEquals("should not be name2", "name2", soyMapData.get("_request.cookie.name2.name").stringValue());
}
示例15: initMutatingEppToolCommand
import com.google.template.soy.data.SoyMapData; //导入依赖的package包/类
@Override
protected void initMutatingEppToolCommand() {
setSoyTemplate(DeleteDomainSoyInfo.getInstance(), DeleteDomainSoyInfo.DELETEDOMAIN);
addSoyRecord(clientId, new SoyMapData(
"domainName", domainName,
"reason", reason,
"requestedByRegistrar", requestedByRegistrar));
}