@Provides
 @Singleton
 @ImageQuery
 protected Map<String, String> imageQuery(ValueOfConfigurationKeyOrNull config) {
   String amiQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_AMI_QUERY));
   String owners = config.apply(PROPERTY_EC2_AMI_OWNERS);
   if ("".equals(owners)) {
     amiQuery = null;
   } else if (owners != null) {
     StringBuilder query = new StringBuilder();
     if ("*".equals(owners)) query.append("state=available;image-type=machine");
     else query.append("owner-id=").append(owners).append(";state=available;image-type=machine");
     Logger.getAnonymousLogger()
         .warning(
             String.format(
                 "Property %s is deprecated, please use new syntax: %s=%s",
                 PROPERTY_EC2_AMI_OWNERS, PROPERTY_EC2_AMI_QUERY, query.toString()));
     amiQuery = query.toString();
   }
   Builder<String, String> builder = ImmutableMap.<String, String>builder();
   if (amiQuery != null) builder.put(PROPERTY_EC2_AMI_QUERY, amiQuery);
   String ccQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_CC_AMI_QUERY));
   if (ccQuery != null) builder.put(PROPERTY_EC2_CC_AMI_QUERY, ccQuery);
   return builder.build();
 }
예제 #2
0
    public void testBuilderReuse() {
      Builder<String, Integer> builder = new Builder<String, Integer>();
      ImmutableMap<String, Integer> mapOne = builder.put("one", 1).put("two", 2).build();
      ImmutableMap<String, Integer> mapTwo = builder.put("three", 3).put("four", 4).build();

      assertMapEquals(mapOne, "one", 1, "two", 2);
      assertMapEquals(mapTwo, "one", 1, "two", 2, "three", 3, "four", 4);
    }
예제 #3
0
 public void testBuilderPutMutableEntryWithNullKeyFailsAtomically() {
   Builder<String, Integer> builder = new Builder<String, Integer>();
   try {
     builder.put(new SimpleEntry<String, Integer>(null, 1));
     fail();
   } catch (NullPointerException expected) {
   }
   builder.put("foo", 2);
   assertMapEquals(builder.build(), "foo", 2);
 }
예제 #4
0
 public void testBuilder_withImmutableEntryAndNullContents() {
   Builder<String, Integer> builder = new Builder<String, Integer>();
   try {
     builder.put(Maps.immutableEntry("one", (Integer) null));
     fail();
   } catch (NullPointerException expected) {
   }
   try {
     builder.put(Maps.immutableEntry((String) null, 1));
     fail();
   } catch (NullPointerException expected) {
   }
 }
    /** @return The interval info map for the aggregator */
    protected Map<AggregationInterval, AggregationIntervalInfo> getAggregatorIntervalInfo(
        final Class<? extends IPortalEventAggregator<?>> aggregatorType) {
      final AggregatedIntervalConfig aggregatorIntervalConfig =
          this.intervalsForAggregatorHelper.getAggregatorIntervalConfig(aggregatorType);

      Map<AggregationInterval, AggregationIntervalInfo> intervalInfo =
          this.aggregatorReadOnlyIntervalInfo.get(aggregatorType);
      if (intervalInfo == null) {
        final Builder<AggregationInterval, AggregationIntervalInfo> intervalInfoBuilder =
            ImmutableMap.builder();

        for (Map.Entry<AggregationInterval, AggregationIntervalInfo> intervalInfoEntry :
            this.currentIntervalInfo.entrySet()) {
          final AggregationInterval key = intervalInfoEntry.getKey();
          if (aggregatorIntervalConfig.isIncluded(key)) {
            intervalInfoBuilder.put(key, intervalInfoEntry.getValue());
          }
        }

        intervalInfo = intervalInfoBuilder.build();
        aggregatorReadOnlyIntervalInfo.put(aggregatorType, intervalInfo);
      }

      return intervalInfo;
    }
예제 #6
0
 static {
   Builder<Integer, NodeClass> builder = ImmutableMap.builder();
   for (NodeClass e : values()) {
     builder.put(e.getValue(), e);
   }
   VALUES = builder.build();
 }
 static {
   Builder<Integer, NodeAttributesMask> builder = ImmutableMap.builder();
   for (NodeAttributesMask e : values()) {
     builder.put(e.getValue(), e);
   }
   VALUES = builder.build();
 }
예제 #8
0
 static {
   Builder<Integer, BrowseDirection> builder = ImmutableMap.builder();
   for (BrowseDirection e : values()) {
     builder.put(e.getValue(), e);
   }
   VALUES = builder.build();
 }
예제 #9
0
  @Subscribe
  public void buildModList(FMLLoadEvent event) {
    this.modList = loader.getIndexedModList();
    Builder<String, EventBus> eventBus = ImmutableMap.builder();

    for (ModContainer mod : loader.getModList()) {
      EventBus bus = new EventBus(mod.getModId());
      boolean isActive = mod.registerBus(bus, this);
      if (isActive) {
        Level level = Logger.getLogger(mod.getModId()).getLevel();
        FMLLog.log(
            mod.getModId(),
            Level.FINE,
            "Mod Logging channel %s configured at %s level.",
            level == null ? "default" : level);
        FMLLog.log(mod.getModId(), Level.INFO, "Activating mod %s", mod.getModId());
        activeModList.add(mod);
        modStates.put(mod.getModId(), ModState.UNLOADED);
        eventBus.put(mod.getModId(), bus);
      } else {
        FMLLog.log(
            mod.getModId(),
            Level.WARNING,
            "Mod %s has been disabled through configuration",
            mod.getModId());
        modStates.put(mod.getModId(), ModState.UNLOADED);
        modStates.put(mod.getModId(), ModState.DISABLED);
      }
    }

    eventChannels = eventBus.build();
  }
  /* (non-Javadoc)
   * @see org.jasig.portal.portlet.container.properties.BaseRequestPropertiesManager#getRequestProperties(javax.servlet.http.HttpServletRequest, org.jasig.portal.portlet.om.IPortletWindow)
   */
  @Override
  public Map<String, String[]> getRequestProperties(
      HttpServletRequest portletRequest, IPortletWindow portletWindow) {
    if (this.propertyToAttributeMappings.isEmpty() && this.nonNamespacedProperties.isEmpty()) {
      return Collections.emptyMap();
    }

    final HttpServletRequest portalRequest =
        this.portalRequestUtils.getOriginalPortalRequest(portletRequest);
    final String windowIdStr = portletWindow.getPortletWindowId().getStringId();

    final Builder<String, String[]> properties = ImmutableMap.builder();
    for (final Enumeration<String> attributeNames = portalRequest.getAttributeNames();
        attributeNames.hasMoreElements(); ) {
      final String fullAttributeName = attributeNames.nextElement();
      final String propertyName = getPropertyName(windowIdStr, fullAttributeName);
      if (propertyName == null) {
        continue;
      }

      logger.debug(
          "Found portal request attribute {} returning as property {}",
          fullAttributeName,
          propertyName);

      final Object value = portalRequest.getAttribute(fullAttributeName);
      final String[] values = convertValue(value);

      properties.put(propertyName, values);
    }

    return properties.build();
  }
예제 #11
0
 private Map<String, Object> toMap(@SuppressWarnings("rawtypes") Dictionary properties) {
   Builder<String, Object> b = ImmutableMap.builder();
   for (Enumeration<?> e = properties.keys(); e.hasMoreElements(); ) {
     String k = (String) e.nextElement();
     b.put(k, properties.get(k));
   }
   return b.build();
 }
예제 #12
0
 public void testBuilderPutNullValue() {
   Builder<String, Integer> builder = new Builder<String, Integer>();
   try {
     builder.put("one", null);
     fail();
   } catch (NullPointerException expected) {
   }
 }
예제 #13
0
 public static Map<String, String> cleanseAttributes(Attributes in) {
   Builder<String, String> attrs = ImmutableMap.<String, String>builder();
   for (int i = 0; i < in.getLength(); i++) {
     String name = in.getQName(i);
     if (name.indexOf(':') != -1) name = name.substring(name.indexOf(':') + 1);
     attrs.put(name, in.getValue(i));
   }
   return attrs.build();
 }
예제 #14
0
  @Override
  Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasTitle()) {
      builder.put(BOOK_TITLE.BUKKIT, title);
    }

    if (hasAuthor()) {
      builder.put(BOOK_AUTHOR.BUKKIT, author);
    }

    if (hasPages()) {
      builder.put(BOOK_PAGES.BUKKIT, pages);
    }

    return builder;
  }
 private Map<String, ? extends Identified> series(int seriesCount) {
   Builder<String, Series> builder = ImmutableMap.builder();
   for (int j = 0; j < seriesCount; j++) {
     Series series = new Series("uri" + j, "curie", Publisher.BBC);
     builder.put(series.getCanonicalUri(), series);
   }
   ;
   return builder.build();
 }
예제 #16
0
  @Override
  Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasCustomEffects()) {
      builder.put(POTION_EFFECTS.BUKKIT, ImmutableList.copyOf(this.customEffects));
    }

    return builder;
  }
예제 #17
0
  public static <T> ImmutableMap<Integer, T> getColInfoMap(List<T> hiveCols, int startIndx) {
    Builder<Integer, T> bldr = ImmutableMap.<Integer, T>builder();

    int indx = startIndx;
    for (T ci : hiveCols) {
      bldr.put(indx, ci);
      indx++;
    }

    return bldr.build();
  }
예제 #18
0
  public static ImmutableMap<String, Integer> getColNameIndxMap(List<FieldSchema> tableFields) {
    Builder<String, Integer> bldr = ImmutableMap.<String, Integer>builder();

    int indx = 0;
    for (FieldSchema fs : tableFields) {
      bldr.put(fs.getName(), indx);
      indx++;
    }

    return bldr.build();
  }
예제 #19
0
  public static ImmutableMap<Integer, VirtualColumn> getVColsMap(
      List<VirtualColumn> hiveVCols, int startIndx) {
    Builder<Integer, VirtualColumn> bldr = ImmutableMap.<Integer, VirtualColumn>builder();

    int indx = startIndx;
    for (VirtualColumn vc : hiveVCols) {
      bldr.put(indx, vc);
      indx++;
    }

    return bldr.build();
  }
예제 #20
0
  public static ImmutableMap<String, Integer> getRowColNameIndxMap(
      List<RelDataTypeField> rowFields) {
    Builder<String, Integer> bldr = ImmutableMap.<String, Integer>builder();

    int indx = 0;
    for (RelDataTypeField rdt : rowFields) {
      bldr.put(rdt.getName(), indx);
      indx++;
    }

    return bldr.build();
  }
 protected void encodeScript(FacesContext facesContext, UIComponent component) throws IOException {
   JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
   JSFunction messageObject = new JSObject(getJSClassName(), component.getClientId(facesContext));
   Map<String, Object> attributes = component.getAttributes();
   Builder<String, Object> parametersBuilder = ImmutableMap.builder();
   String forId = (String) attributes.get("for");
   RendererUtils rendererUtils = RendererUtils.getInstance();
   if (!Strings.isNullOrEmpty(forId)) {
     UIComponent target = rendererUtils.findComponentFor(component, forId);
     if (null != target) {
       parametersBuilder.put("forComponentId", target.getClientId(facesContext));
     }
   }
   Severity level = getLevel(component);
   if (FacesMessage.SEVERITY_INFO != level) {
     parametersBuilder.put("level", level.getOrdinal());
   }
   if (!rendererUtils.isBooleanAttribute(component, "showSummary")) {
     parametersBuilder.put("showSummary", false);
   }
   if (rendererUtils.isBooleanAttribute(component, "showDetail")) {
     parametersBuilder.put("showDetail", true);
   }
   if (rendererUtils.isBooleanAttribute(component, "tooltip")) {
     parametersBuilder.put("tooltip", true);
   }
   if (isComponentMessages(component)) {
     parametersBuilder.put("isMessages", true);
   }
   messageObject.addParameter(parametersBuilder.build());
   // RendererUtils.getInstance().writeScript(facesContext, component, messageObject);
   javaScriptService.addPageReadyScript(facesContext, messageObject);
 }
예제 #22
0
  public Map<String, String> getSettings(ObmUser user) {
    Builder<String, String> mapBuilder = new Builder<String, String>();

    String domain = user.getDomain().getName();
    String userLogin = user.getLogin();

    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      con = obmHelper.getConnection();

      String q =
          "select userobmpref_option, userobmpref_value from UserObmPref "
              + "where userobmpref_user_id is null "
              + "and userobmpref_option not in "
              + "(select userobmpref_option from UserObmPref where userobmpref_user_id=(select userobm_id from UserObm "
              + "where userobm_login=? "
              + "and userobm_domain_id=(select domain_id from Domain where domain_name=?) "
              + ")) "
              + "union "
              + "select userobmpref_option, userobmpref_value from UserObmPref "
              + "where userobmpref_user_id=(select userobm_id from UserObm "
              + "where userobm_login=? "
              + "and userobm_domain_id=(select domain_id from Domain where domain_name=?) "
              + " )";

      ps = con.prepareStatement(q);
      int idx = 1;
      ps.setString(idx++, userLogin);
      ps.setString(idx++, domain);
      ps.setString(idx++, userLogin);
      ps.setString(idx++, domain);
      rs = ps.executeQuery();
      while (rs.next()) {
        mapBuilder.put(rs.getString(1), rs.getString(2));
      }
    } catch (SQLException se) {
      logger.error("Error fetching preferences for " + user + " at " + domain, se);
    } finally {
      obmHelper.cleanup(con, ps, rs);
    }

    ImmutableMap<String, String> data = mapBuilder.build();

    logger.info("return " + data.size() + " settings for userid: " + user + " at " + domain);
    return data;
  }
  @Override
  protected LrsObject getLrsObject(PortalEvent event) {
    final String targetedLayoutNodeId = ((PortalRenderEvent) event).getTargetedLayoutNodeId();
    final AggregatedTabMapping aggregatedTabMapping =
        aggregatedTabLookupDao.getMappedTabForLayoutId(targetedLayoutNodeId);

    final Builder<String, LocalizedString> definitionBuilder = ImmutableMap.builder();
    definitionBuilder.put(
        "name", new LocalizedString(Locale.US, aggregatedTabMapping.getDisplayString()));

    return new LrsObject(
        buildUrn("tab", aggregatedTabMapping.getFragmentName()),
        getDefaultObjectType(),
        definitionBuilder.build());
  }
 private void saveMigratorSequence(
     SessionImpl session, DependencySequence migratorDependencySequence)
     throws AccessDeniedException, StorageClientException {
   Content runMigrators = session.getContentManager().get(SYSTEM_MIGRATION_CONTENT_ITEM);
   String ts = String.valueOf(System.currentTimeMillis());
   int i = 0;
   if (runMigrators == null) {
     Builder<String, Object> b = ImmutableMap.builder();
     for (PropertyMigrator pm : migratorDependencySequence) {
       b.put(pm.getName(), ts + ";" + i);
     }
     runMigrators = new Content(SYSTEM_MIGRATION_CONTENT_ITEM, b.build());
   } else {
     for (PropertyMigrator pm : migratorDependencySequence) {
       runMigrators.setProperty(pm.getName(), ts + ";" + i);
     }
   }
   session.getContentManager().update(runMigrators);
 }
 @SuppressWarnings("unchecked")
 @Override
 public <R extends HttpRequest> R bindToRequest(R request, Object input) {
   checkNotNull(input, "tags");
   Map<String, String> tagValues;
   if (input instanceof Iterable) {
     Builder<String, String> builder = ImmutableMap.<String, String>builder();
     for (String key : (Iterable<String>) input) {
       builder.put(key, "");
     }
     tagValues = builder.build();
   } else if (input instanceof Map) {
     tagValues = Map.class.cast(input);
   } else {
     throw new IllegalArgumentException(
         "This binder is only valid for Map<String,String> or Iterable<String>");
   }
   return indexMapToFormValuesWithPrefix(request, "Tag", "Key", "Value", tagValues);
 }
예제 #26
0
 @Before
 public void setUp() {
   final Builder<String, SIGAbstractCacheStore> registryBuilder = ImmutableMap.builder();
   registryBuilder.put("Subscribers", new SubscriberDAS(gateway));
   registryBuilder.put("SubscribersAccountsResolver", new SubscribersAccountsResolverDAS(gateway));
   registryBuilder.put("Accounts", new AccountDAS(gateway));
   registryBuilder.put("AccountsSubscribersResolver", new AccountsSubscribersResolverDAS(gateway));
   /* preferences */
   PreferencesDAS preferencesDAS = new PreferencesDAS(gateway);
   registryBuilder.put("Preferences", preferencesDAS);
   registryBuilder.put(
       "SubscribersPreferencesResolver",
       new GenericOneToOneResolverDAS(gateway, preferencesDAS, ImmutableMap.of("guid", "pguid")));
   /**/
   gateway.setRegistry(registryBuilder.build());
 }
예제 #27
0
  @Before
  public void setUp() {

    mockRefDb = mock(RefDatabase.class);

    Builder<String, String> builder = ImmutableMap.builder();
    Map<String, String> allRefs =
        builder //
            .put("refs/heads/master", forString("refs/heads/master").toString()) //
            .put("refs/heads/branch1", forString("refs/heads/branch1").toString()) //
            .put("refs/heads/v1.1", forString("refs/heads/v1.1").toString()) //
            .put("refs/tags/tag1", forString("refs/tags/tag1").toString()) //
            .put("refs/tags/v1.1", forString("refs/tags/v1.1").toString()) //
            .put(
                "refs/remotes/origin/master",
                forString("refs/remotes/origin/master").toString()) //
            .put(
                "refs/remotes/origin/branch1",
                forString("refs/remotes/origin/branch1").toString()) //
            .put("refs/remotes/juan/master", forString("refs/remotes/juan/master").toString()) //
            .put("refs/remotes/juan/v1.1", forString("refs/remotes/juan/v1.1").toString()) //
            .build();

    when(mockRefDb.getAll()).thenReturn(allRefs);
    command = new RefParse();
    for (String name : allRefs.keySet()) {
      when(mockRefDb.getRef(eq(name))).thenReturn(allRefs.get(name));
    }

    CommandLocator mockCommandLocator = mock(CommandLocator.class);
    when(mockCommandLocator.getRefDatabase()).thenReturn(mockRefDb);
    command.setCommandLocator(mockCommandLocator);
    ResolveObjectType mockResolveObjectType = mock(ResolveObjectType.class);
    when(mockCommandLocator.command(eq(ResolveObjectType.class))).thenReturn(mockResolveObjectType);

    when(mockResolveObjectType.setObjectId((ObjectId) anyObject()))
        .thenReturn(mockResolveObjectType);
    when(mockResolveObjectType.call()).thenReturn(TYPE.COMMIT);
  }
  private static Map<QName, MethodHandle> createInvokerMap(
      final Class<? extends NotificationListener> key) {
    final Builder<QName, MethodHandle> ret = ImmutableMap.<QName, MethodHandle>builder();
    for (final Method method : key.getMethods()) {
      if (BindingReflections.isNotificationCallback(method)) {

        final Class<?> notification = method.getParameterTypes()[0];
        final QName name = BindingReflections.findQName(notification);
        MethodHandle handle;
        try {
          handle =
              LOOKUP
                  .unreflect(method)
                  .asType(
                      MethodType.methodType(
                          void.class, NotificationListener.class, DataContainer.class));
          ret.put(name, handle);
        } catch (final IllegalAccessException e) {
          throw new IllegalStateException("Can not access public method.", e);
        }
      }
    }
    return ret.build();
  }
예제 #29
0
 static {
   Builder<String, String> deleteTopicsBuilder = ImmutableMap.builder();
   deleteTopicsBuilder.put(
       Security.ADMIN_AUTHORIZABLES, TOPIC_BASE + "authorizables/" + DELETE_TOPIC);
   deleteTopicsBuilder.put(Security.ADMIN_GROUPS, TOPIC_BASE + "groups/" + DELETE_TOPIC);
   deleteTopicsBuilder.put(Security.ADMIN_USERS, TOPIC_BASE + "users/" + DELETE_TOPIC);
   deleteTopicsBuilder.put(Security.ZONE_ADMIN, TOPIC_BASE + "admin/" + DELETE_TOPIC);
   deleteTopicsBuilder.put(
       Security.ZONE_AUTHORIZABLES, TOPIC_BASE + "authorizables/" + DELETE_TOPIC);
   deleteTopicsBuilder.put(Security.ZONE_CONTENT, TOPIC_BASE + "content/" + DELETE_TOPIC);
   deleteTopics = deleteTopicsBuilder.build();
   Builder<String, String> createTopicsBuilder = ImmutableMap.builder();
   createTopicsBuilder.put(
       Security.ADMIN_AUTHORIZABLES, TOPIC_BASE + "authorizables/" + ADDED_TOPIC);
   createTopicsBuilder.put(Security.ADMIN_GROUPS, TOPIC_BASE + "groups/" + ADDED_TOPIC);
   createTopicsBuilder.put(Security.ADMIN_USERS, TOPIC_BASE + "users/" + ADDED_TOPIC);
   createTopicsBuilder.put(Security.ZONE_ADMIN, TOPIC_BASE + "admin/" + ADDED_TOPIC);
   createTopicsBuilder.put(
       Security.ZONE_AUTHORIZABLES, TOPIC_BASE + "authorizables/" + ADDED_TOPIC);
   createTopicsBuilder.put(Security.ZONE_CONTENT, TOPIC_BASE + "content/" + ADDED_TOPIC);
   createTopics = createTopicsBuilder.build();
   Builder<String, String> updateTopicsBuilder = ImmutableMap.builder();
   updateTopicsBuilder.put(
       Security.ADMIN_AUTHORIZABLES, TOPIC_BASE + "authorizables/" + UPDATED_TOPIC);
   updateTopicsBuilder.put(Security.ADMIN_GROUPS, TOPIC_BASE + "groups/" + UPDATED_TOPIC);
   updateTopicsBuilder.put(Security.ADMIN_USERS, TOPIC_BASE + "users/" + UPDATED_TOPIC);
   updateTopicsBuilder.put(Security.ZONE_ADMIN, TOPIC_BASE + "admin/" + UPDATED_TOPIC);
   updateTopicsBuilder.put(
       Security.ZONE_AUTHORIZABLES, TOPIC_BASE + "authorizables/" + UPDATED_TOPIC);
   updateTopicsBuilder.put(Security.ZONE_CONTENT, TOPIC_BASE + "content/" + UPDATED_TOPIC);
   updateTopics = updateTopicsBuilder.build();
 }
예제 #30
0
  public LocaleValueProvider() {
    Builder<String, Object> builder = ImmutableMap.builder();

    AuraLocale al = Aura.getLocalizationAdapter().getAuraLocale();

    Locale userLocale = al.getLocale();
    Locale lang = al.getLanguageLocale();
    Locale dateLocale = al.getDateLocale();

    builder.put(USER_LOCALE_LANGUAGE, userLocale.getLanguage());
    builder.put(USER_LOCALE_COUNTRY, userLocale.getCountry());
    builder.put(LANGUAGE, lang.getLanguage());
    builder.put(COUNTRY, lang.getCountry());
    builder.put(VARIANT, lang.getVariant());
    builder.put(LANGUAGE_LOCALE, lang.toString());

    try {
      builder.put(MONTH_NAME, this.getNameOfMonths(al));
      builder.put(WEEKDAY_NAME, this.getNameOfWeekdays(al));
      builder.put(TODAY_LABEL, this.getLabelForToday());
    } catch (QuickFixException qfe) {
      // Ignore
    }

    builder.put(
        FIRST_DAY_OF_WEEK, Calendar.getInstance(al.getTimeZone(), userLocale).getFirstDayOfWeek());

    // using java DateFormat because the year pattern "MMM d, y" (although valid) isn't understood
    // by moment.js
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, dateLocale);
    DateFormat datetimeFormat =
        DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, dateLocale);
    DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.DEFAULT, dateLocale);
    try {
      SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
      builder.put(DATE_FORMAT, sdf.toPattern());

      SimpleDateFormat sdtf = (SimpleDateFormat) datetimeFormat;
      builder.put(DATETIME_FORMAT, sdtf.toPattern());

      SimpleDateFormat stf = (SimpleDateFormat) timeFormat;
      builder.put(TIME_FORMAT, stf.toPattern());
    } catch (ClassCastException cce) {
      builder.put(DATE_FORMAT, DEFAULT_DATE_FORMAT);
      builder.put(DATETIME_FORMAT, DEFAULT_DATETIME_FORMAT);
      builder.put(TIME_FORMAT, DEFAULT_TIME_FORMAT);
    }

    String timezoneId = al.getTimeZone().getID();
    String availableTimezoneId = Aura.getConfigAdapter().getAvailableTimezone(timezoneId);
    builder.put(TIME_ZONE, availableTimezoneId);
    builder.put(TIME_ZONE_FILE_NAME, availableTimezoneId.replace("/", "-"));

    builder.put(IS_EASTERN_NAME_STYLE, al.isEasternNameStyle());

    // DecimalFormat is expected
    DecimalFormat df = (DecimalFormat) DecimalFormat.getNumberInstance(al.getNumberLocale());

    // Patterns are not localized; the "." means "locale decimal" not "dot"
    builder.put(NUMBER_FORMAT, df.toPattern());
    DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
    builder.put(DECIMAL, dfs.getDecimalSeparator());
    builder.put(GROUPING, dfs.getGroupingSeparator());
    builder.put(ZERO_DIGIT, dfs.getZeroDigit());

    df = (DecimalFormat) DecimalFormat.getPercentInstance(al.getNumberLocale());

    // Don't localize the patterns
    builder.put(PERCENT_FORMAT, df.toPattern());

    df = (DecimalFormat) DecimalFormat.getCurrencyInstance(al.getCurrencyLocale());

    // Don't localize the patterns
    builder.put(CURRENCY_FORMAT, df.toPattern());
    DecimalFormatSymbols cdfs = df.getDecimalFormatSymbols();
    Currency cur = cdfs.getCurrency();
    builder.put(CURRENCY_CODE, cur != null ? cur.getCurrencyCode() : "");
    builder.put(CURRENCY, cdfs.getCurrencySymbol());

    data = builder.build();
  }