Example usage for java.util Locale Locale

List of usage examples for java.util Locale Locale

Introduction

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

Prototype

public Locale(String language) 

Source Link

Document

Construct a locale from a language code.

Usage

From source file:jp.terasoluna.fw.beans.jxpath.BeanPropertyPointerExTest.java

/**
 * testGetLength01()/* w w w.j av a 2 s .c om*/
 * <br><br>
 * 
 * ()
 * <br>
 * A
 * <br><br>
 * () super.getLength():1<br>
 *         
 * <br>
 * () -:1<br>
 *         
 * <br>
 * ???
 * <br>
 * 
 * @throws Exception ?????
 */
@Test
public void testGetLength01() throws Exception {
    // ??
    QName qName = new QName("property");
    BeanPropertyPointerEx_JavaBeanStub01 bean = new BeanPropertyPointerEx_JavaBeanStub01();
    Locale locale = new Locale("ja");
    NodePointer nodePointer = NodePointer.newNodePointer(qName, bean, locale);

    JXPathBasicBeanInfo beanInfo = new JXPathBasicBeanInfo(bean.getClass());
    BeanPropertyPointerEx pointer = new BeanPropertyPointerEx(nodePointer, beanInfo);
    pointer.setPropertyName("property");

    // 
    assertEquals(1, pointer.getLength());
}

From source file:org.xwiki.rendering.internal.macro.chart.source.table.TableTimeTableXYBuilderTest.java

@Test
public void testBuildTimeTableXY() throws Exception {
    String content = "| Date | column 2 | column 3 | column 4\n" + "| 2012-01-01 10:30:10 | 12 | 13 | 14 \n"
            + "| 2012-01-01 10:30:20 |  22 | 23 | 24 \n";
    setUpContentExpectation(content);/*from w w w  .j a v  a 2 s  .c  om*/

    getDataSource().buildDataset(content, map("type", "xy_line_and_shape", "dataset", "timetable_xy", "range",
            "A2-D3", "locale", "en_US", "date_format", "yyyy-MM-dd kk:mm:ss", "domain_axis_type", "date"),
            null);

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss", new Locale("en"));

    ChartModel chartModel = getDataSource().getChartModel();

    Assert.assertTrue(chartModel.getDataset() instanceof TimeTableXYDataset);

    Assert.assertTrue(chartModel.getAxis(0) instanceof DateAxis);
    Assert.assertTrue(chartModel.getAxis(1) instanceof ValueAxis);

    TimeTableXYDataset dataset = (TimeTableXYDataset) chartModel.getDataset();

    Assert.assertTrue(dataset.getSeriesCount() == 3);

    Assert.assertTrue(dataset.getSeriesKey(0).equals(" column 2 "));
    Assert.assertTrue(dataset.getSeriesKey(1).equals(" column 3 "));
    Assert.assertTrue(dataset.getSeriesKey(2).equals(" column 4"));

    Assert.assertTrue(dataset.getTimePeriod(0).getStart().equals(new Date(0)));
    Assert.assertTrue(dataset.getTimePeriod(0).getEnd().equals(dateFormat.parse("2012-01-01 10:30:10")));

    Assert.assertTrue(dataset.getTimePeriod(1).getStart().equals(dateFormat.parse("2012-01-01 10:30:10")));
    Assert.assertTrue(dataset.getTimePeriod(1).getEnd().equals(dateFormat.parse("2012-01-01 10:30:20")));
}

From source file:eu.delving.core.util.TestLocalizedFieldNames.java

@Test
public void multiWord() {
    LocalizedFieldNames.Lookup lookup = localizedFieldNames
            .createLookup(Arrays.asList("dcterms.isReferencedBy"));
    final Locale english = new Locale("en");
    String fieldName = lookup.toFieldName("isreferENCedby", english);
    Assert.assertEquals("dcterms_isReferencedBy", fieldName);
}

From source file:org.openmrs.module.hospitalcore.web.controller.ajax.AjaxController.java

/**
 * Concept search autocomplete for form//  ww w  . jav a 2  s .  com
 * 
 * @param name
 * @param model
 * @return
 */
@SuppressWarnings("deprecation")
@RequestMapping(value = "/module/hospitalcore/ajax/autocompleteConceptSearch.htm", method = RequestMethod.GET)
public String autocompleteConceptSearch(@RequestParam(value = "q", required = false) String name, Model model) {
    List<ConceptWord> cws = Context.getConceptService().findConcepts(name, new Locale("en"), false);
    Set<String> conceptNames = new HashSet<String>();
    for (ConceptWord word : cws) {
        String conceptName = word.getConcept().getName().getName();
        conceptNames.add(conceptName);
    }
    List<String> concepts = new ArrayList<String>();
    concepts.addAll(conceptNames);
    Collections.sort(concepts, new Comparator<String>() {

        public int compare(String o1, String o2) {
            return o1.compareToIgnoreCase(o2);
        }
    });
    model.addAttribute("conceptNames", concepts);
    return "/module/hospitalcore/ajax/autocompleteConceptSearch";
}

From source file:io.bibleget.VersionsSelect.java

public VersionsSelect() throws ClassNotFoundException {
    biblegetDB = BibleGetDB.getInstance();
    String bibleVersionsStr = biblegetDB.getMetaData("VERSIONS");
    JsonReader jsonReader = Json.createReader(new StringReader(bibleVersionsStr));
    JsonObject bibleVersionsObj = jsonReader.readObject();
    Set<String> versionsabbrev = bibleVersionsObj.keySet();
    bibleVersions = new BasicEventList<>();
    if (!versionsabbrev.isEmpty()) {
        for (String s : versionsabbrev) {
            String versionStr = bibleVersionsObj.getString(s); //store these in an array
            String[] array;/*from w  w  w  .  ja  v  a  2  s .  co  m*/
            array = versionStr.split("\\|");
            bibleVersions.add(new BibleVersion(s, array[0], array[1],
                    StringUtils.capitalize(new Locale(array[2]).getDisplayLanguage())));
        }
    }

    versionsByLang = new SeparatorList<>(bibleVersions, new VersionComparator(), 1, 1000);

    int listLength = versionsByLang.size();
    enabledFlags = new boolean[listLength];

    ListIterator itr = versionsByLang.listIterator();
    while (itr.hasNext()) {
        int idx = itr.nextIndex();
        Object next = itr.next();
        enabledFlags[idx] = !(next.getClass().getSimpleName().equals("GroupSeparator"));
        if (enabledFlags[idx]) {
            versionCount++;
        } else {
            versionLangs++;
        }
    }

    this.setModel(new DefaultEventListModel<>(versionsByLang));
    this.setCellRenderer(new VersionCellRenderer());
    this.setSelectionModel(new DisabledItemSelectionModel());
}

From source file:com.github.jrh3k5.plugin.maven.l10n.data.AbstractMessagesPropertiesParser.java

/**
 * Determine the supported locale of a messages properties file.
 * /*  w  w w.j a  v a 2  s .co  m*/
 * @param messagesFile
 *            The location of the file whose supported locale is to be determined.
 * @return {@code null} if the locale could not be determined; otherwise, a {@link Locale} representing the supported locale indicated by the given file's name.
 */
protected Locale determineSupportedLocale(File messagesFile) {
    final String filename = messagesFile.getName();
    final int underscorePos = filename.indexOf('_');
    if (underscorePos < 0) {
        return null;
    }

    final int periodPos = filename.indexOf('.');
    final int secondaryUnderscorePos = filename.indexOf('_', underscorePos + 1);
    if (secondaryUnderscorePos < 0) {
        return new Locale(filename.substring(underscorePos + 1, periodPos));
    } else {
        final String language = filename.substring(underscorePos + 1, secondaryUnderscorePos);
        final String country = filename.substring(secondaryUnderscorePos + 1, periodPos);
        return new Locale(language, country);
    }
}

From source file:fi.hsl.parkandride.itest.RequestLogITest.java

@Before
public void init() {
    unknownSource = messageSource.getMessage("reports.requestlog.unknownSource", null, new Locale("fi"));
}

From source file:at.alladin.rmbt.controlServer.ErrorList.java

public void setLanguage(final String lang) {
    labels = ResourceManager.getSysMsgBundle(new Locale(lang));
}

From source file:de.ingrid.portal.interfaces.wms.WMSInterfaceTest.java

public void testGetWMSViewerURL() {
    String myUrl = wmsInterface.getWMSViewerURL("session0815", true, new Locale("de"));
    if (config.getProperty("display_viewer_url").toString().indexOf("?") > 0) {
        assertEquals(config.getProperty("display_viewer_url") + "&PHPSESSID=session0815&lang=de", myUrl);
    } else {//from   w w  w  . java2  s. com
        assertEquals(config.getProperty("display_viewer_url") + "?PHPSESSID=session0815&lang=de", myUrl);
    }
}

From source file:edu.kit.trufflehog.model.configdata.PropertiesDataModelTest.java

/**
 * <p>/*  w  w w.  ja v a2s.  c om*/
 *     Tests whether the english property file can be loaded and whether the test property can be accessed.
 * </p>
 *
 * @throws Exception Passes any errors that occurred during the test on
 */
@Test
@Ignore
public void testEn() throws Exception {
    this.propertiesDataModel = new PropertiesDataModel(new Locale("en"), fileSystem);
    String value = propertiesDataModel.get("test_property");
    assertEquals("this is a test", value);
}