Example usage for java.util Locale ROOT

List of usage examples for java.util Locale ROOT

Introduction

In this page you can find the example usage for java.util Locale ROOT.

Prototype

Locale ROOT

To view the source code for java.util Locale ROOT.

Click Source Link

Document

Useful constant for the root locale.

Usage

From source file:ch.cyberduck.core.importer.S3BrowserBookmarkCollection.java

@Override
protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException {
    try {//from w  w  w.  j a va2s. co m
        final BufferedReader in = new BufferedReader(
                new InputStreamReader(file.getInputStream(), Charset.forName("UTF-8")));
        try {
            Host current = null;
            String line;
            while ((line = in.readLine()) != null) {
                if (line.startsWith("[account_")) {
                    current = new Host(protocols.forType(Protocol.Type.s3));
                } else if (StringUtils.isBlank(line)) {
                    this.add(current);
                    current = null;
                } else {
                    if (null == current) {
                        log.warn("Failed to detect start of bookmark");
                        continue;
                    }
                    Scanner scanner = new Scanner(line);
                    scanner.useDelimiter(" = ");
                    if (!scanner.hasNext()) {
                        log.warn("Missing key in line:" + line);
                        continue;
                    }
                    String name = scanner.next().toLowerCase(Locale.ROOT);
                    if (!scanner.hasNext()) {
                        log.warn("Missing value in line:" + line);
                        continue;
                    }
                    String value = scanner.next();
                    if ("name".equals(name)) {
                        current.setNickname(value);
                    } else if ("comment".equals(name)) {
                        current.setComment(value);
                    } else if ("access_key".equals(name)) {
                        current.getCredentials().setUsername(value);
                    } else if ("secret_key".equals(name)) {
                        current.getCredentials().setPassword(value);
                    }
                }
            }
        } finally {
            IOUtils.closeQuietly(in);
        }
    } catch (IOException e) {
        throw new AccessDeniedException(e.getMessage(), e);
    }
}

From source file:cn.tata.t2s.ssm.util.AcmeCorpPhysicalNamingStrategy.java

private LinkedList<String> splitAndReplace(String name) {
    LinkedList<String> result = new LinkedList<>();
    for (String part : StringUtils.splitByCharacterTypeCamelCase(name)) {
        if (part == null || part.trim().isEmpty()) {
            // skip null and space
            continue;
        }// ww  w .j av  a 2  s . c o  m
        part = applyAbbreviationReplacement(part);
        result.add(part.toLowerCase(Locale.ROOT));
    }
    return result;
}

From source file:br.ufrj.ppgi.jemf.mobile.bean.Mission.java

/**
 * Set the status as String value.//from   ww  w . j ava 2 s. c o m
 * @param status
 */
public void setStatusString(String status) {
    setStatus(EnumServiceStatus.valueOf(status.toUpperCase(Locale.ROOT)));
}

From source file:org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer.java

public void configure(DefaultHttpClient httpClient, SolrParams config) {
    super.configure(httpClient, config);

    if (System.getProperty(LOGIN_CONFIG_PROP) != null) {
        String configValue = System.getProperty(LOGIN_CONFIG_PROP);

        if (configValue != null) {
            logger.info("Setting up SPNego auth with config: " + configValue);
            final String useSubjectCredsProp = "javax.security.auth.useSubjectCredsOnly";
            String useSubjectCredsVal = System.getProperty(useSubjectCredsProp);

            // "javax.security.auth.useSubjectCredsOnly" should be false so that the underlying
            // authentication mechanism can load the credentials from the JAAS configuration.
            if (useSubjectCredsVal == null) {
                System.setProperty(useSubjectCredsProp, "false");
            } else if (!useSubjectCredsVal.toLowerCase(Locale.ROOT).equals("false")) {
                // Don't overwrite the prop value if it's already been written to something else,
                // but log because it is likely the Credentials won't be loaded correctly.
                logger.warn("System Property: " + useSubjectCredsProp + " set to: " + useSubjectCredsVal
                        + " not false.  SPNego authentication may not be successful.");
            }/*from   w  w w .  j av  a  2  s.  c om*/

            javax.security.auth.login.Configuration.setConfiguration(jaasConfig);
            //Enable only SPNEGO authentication scheme.
            AuthSchemeRegistry registry = new AuthSchemeRegistry();
            registry.register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory(true, false));
            httpClient.setAuthSchemes(registry);
            // Get the credentials from the JAAS configuration rather than here
            Credentials useJaasCreds = new Credentials() {
                public String getPassword() {
                    return null;
                }

                public Principal getUserPrincipal() {
                    return null;
                }
            };

            SolrPortAwareCookieSpecFactory cookieFactory = new SolrPortAwareCookieSpecFactory();
            httpClient.getCookieSpecs().register(cookieFactory.POLICY_NAME, cookieFactory);
            httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, cookieFactory.POLICY_NAME);

            httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, useJaasCreds);

            httpClient.addRequestInterceptor(bufferedEntityInterceptor);
        } else {
            httpClient.getCredentialsProvider().clear();
        }
    }
}

From source file:com.grayfox.server.dao.RecommendationDaoTest.java

@Test
@Transactional/*from  www.  j  av a  2 s  . c om*/
public void testFetchNearestByRating() {
    loadMockDataForFetchNearestByRating();

    Category c = new Category();
    c.setFoursquareId("1");
    c.setIconUrl("url");
    c.setName("CAT_1");

    Poi p1 = new Poi();
    p1.setFoursquareId("1");
    p1.setFoursquareRating(9.2);
    p1.setLocation(Location.parse("19.044,-98.197753"));
    p1.setName("POI_1");
    p1.setCategories(new HashSet<>(Arrays.asList(c)));

    Recommendation r1 = new Recommendation();
    r1.setPoi(p1);
    r1.setType(Recommendation.Type.GLOBAL);
    r1.setReason(Messages.get("recommendation.global.reason"));

    List<Recommendation> expectedRecommendations = Arrays.asList(r1);
    List<Recommendation> actualRecommendations = recommendationDao
            .findNearestWithHighRating(Location.parse("19.043635,-98.197947"), 100, Locale.ROOT);

    assertThat(actualRecommendations).isNotNull().isNotEmpty().doesNotContainNull()
            .hasSameSizeAs(expectedRecommendations).containsExactlyElementsOf(expectedRecommendations);
}

From source file:ch.cyberduck.core.importer.FlashFxpBookmarkCollection.java

@Override
protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException {
    try {/*  www .  j a  v a  2  s.c  o m*/
        final BufferedReader in = new BufferedReader(
                new InputStreamReader(file.getInputStream(), Charset.forName("UTF-8")));
        try {
            Host current = null;
            String line;
            while ((line = in.readLine()) != null) {
                if (line.startsWith("[")) {
                    current = new Host(protocols.forScheme(Scheme.ftp));
                    current.getCredentials()
                            .setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name"));
                    Pattern pattern = Pattern.compile("\\[(.*)\\]");
                    Matcher matcher = pattern.matcher(line);
                    if (matcher.matches()) {
                        current.setNickname(matcher.group(1));
                    }
                } else if (StringUtils.isBlank(line)) {
                    this.add(current);
                    current = null;
                } else {
                    if (null == current) {
                        log.warn("Failed to detect start of bookmark");
                        continue;
                    }
                    Scanner scanner = new Scanner(line);
                    scanner.useDelimiter("=");
                    if (!scanner.hasNext()) {
                        log.warn("Missing key in line:" + line);
                        continue;
                    }
                    String name = scanner.next().toLowerCase(Locale.ROOT);
                    if (!scanner.hasNext()) {
                        log.warn("Missing value in line:" + line);
                        continue;
                    }
                    String value = scanner.next();
                    if ("ip".equals(name)) {
                        current.setHostname(StringUtils.substringBefore(value, "\u0001"));
                    } else if ("port".equals(name)) {
                        try {
                            current.setPort(Integer.parseInt(value));
                        } catch (NumberFormatException e) {
                            log.warn("Invalid Port:" + e.getMessage());
                        }
                    } else if ("path".equals(name)) {
                        current.setDefaultPath(value);
                    } else if ("notes".equals(name)) {
                        current.setComment(value);
                    } else if ("user".equals(name)) {
                        current.getCredentials().setUsername(value);
                    }
                }
            }
        } finally {
            IOUtils.closeQuietly(in);
        }
    } catch (IOException e) {
        throw new AccessDeniedException(e.getMessage(), e);
    }
}

From source file:com.actinarium.kinetic.pipeline.CodeGenerator.java

/**
 * Generates Java code for a table lookup interpolator based on provided values
 *
 * @param packageName package name to write into the template
 * @param className   class name to write into the template
 * @param sourceName  title of the measurement the values were taken from
 * @param values      an array of float values that must be recorded at equal intervals
 * @return generated drop-in Java code//  w  ww.  j av  a 2  s  .  co  m
 */
public static String generateInterpolatorCode(String packageName, String className, String sourceName,
        float[] values) {
    NumberFormat format = DecimalFormat.getNumberInstance(Locale.ROOT);
    format.setMinimumFractionDigits(4);
    format.setMaximumFractionDigits(4);
    StringBuilder valuesBuilder = new StringBuilder(CHARS_PER_LINE * (values.length / VALUES_PER_ROW + 1));

    // Append all values but the last one
    final int lengthMinusOne = values.length - 1;
    for (int i = 0; i < lengthMinusOne; /* incremented in loop body */) {
        if (values[i] > 0) {
            // Append space before positive numbers to align with those having minus sign
            valuesBuilder.append(' ');
        }
        valuesBuilder.append(format.format(values[i])).append('f').append(',');
        if (++i % VALUES_PER_ROW == 0) {
            valuesBuilder.append("\n            ");
        } else {
            valuesBuilder.append(' ');
        }
    }
    // Append last value
    valuesBuilder.append(format.format(values[lengthMinusOne])).append('f');

    // and generate Java code out of the given template
    return String.format(TABLE_LOOKUP_TEMPLATE, packageName, className, sourceName, valuesBuilder.toString());
}

From source file:com.puppycrawl.tools.checkstyle.checks.FileSetCheckLifecycleTest.java

@Test
public void testProcessCallsFinishBeforeCallingDestroy() throws Exception {

    DefaultConfiguration dc = new DefaultConfiguration("configuration");
    DefaultConfiguration twConf = createCheckConfig(TreeWalker.class);
    dc.addAttribute("charset", "UTF-8");
    dc.addChild(twConf);/*from w w w  . j a va  2 s .  c  o  m*/
    twConf.addChild(new DefaultConfiguration(FileContentsHolder.class.getName()));
    twConf.addChild(new DefaultConfiguration(AvoidStarImportCheck.class.getName()));

    final Checker checker = new Checker();
    final Locale locale = Locale.ROOT;
    checker.setLocaleCountry(locale.getCountry());
    checker.setLocaleLanguage(locale.getLanguage());
    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
    checker.configure(dc);
    checker.addListener(new BriefLogger(stream));

    checker.addFileSetCheck(new TestFileSetCheck());

    final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;

    verify(checker, getPath("InputIllegalTokens.java"), expected);

    assertTrue("FileContent should be available during finishProcessing() call",
            TestFileSetCheck.isFileContentAvailable());
}

From source file:fi.muikku.plugins.googlecalendar.model.GoogleCalendarEvent.java

public GoogleCalendarEvent(Event event, String calendarId) {
    this(event.getId(), calendarId, event.getSummary(), event.getDescription(),
            CalendarEventStatus.valueOf(event.getStatus().toUpperCase(Locale.ROOT)), null,
            new GoogleCalendarEventUser(event.getOrganizer().getDisplayName(), event.getOrganizer().getEmail()),
            new GoogleCalendarEventTemporalField(Convert.toDate(event.getStart()),
                    getJavaTimeZone(event.getStart().getTimeZone())),
            new GoogleCalendarEventTemporalField(Convert.toDate(event.getEnd()),
                    getJavaTimeZone(event.getEnd().getTimeZone())),
            new Date(event.getCreated().getValue()), new Date(event.getUpdated().getValue()),
            new HashMap<String, String>(), null, null, event.getHtmlLink(),
            new DefaultCalendarEventLocation(event.getLocation(), event.getHangoutLink(), null, null),
            event.getStart().getDate() != null);

    if (event.getRecurrence() != null) {
        for (String rec : event.getRecurrence()) {
            System.err.println(rec);
        }// w w w.  ja va2 s . c  o m
    }
}

From source file:fitnesse.wiki.WikiPageProperty.java

public static DateFormat getTimeFormat() {
    DateFormat format = timeFormat.get();
    if (format == null) {
        format = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ROOT);
        timeFormat.set(format);// w w w.  j  a  va 2  s. c om
    }
    return format;
}