Example usage for java.util Locale GERMAN

List of usage examples for java.util Locale GERMAN

Introduction

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

Prototype

Locale GERMAN

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

Click Source Link

Document

Useful constant for language.

Usage

From source file:org.languagetool.rules.de.GermanSpellerRule.java

@Nullable
private static MorfologikMultiSpeller getSpeller(Language language, UserConfig userConfig,
        String languageVariantPlainTextDict) {
    if (!language.getShortCode().equals(Locale.GERMAN.getLanguage())) {
        throw new IllegalArgumentException("Language is not a variant of German: " + language);
    }/*w  w  w  .  jav a  2s.c  o  m*/
    try {
        String morfoFile = "/de/hunspell/de_" + language.getCountries()[0] + ".dict";
        if (JLanguageTool.getDataBroker().resourceExists(morfoFile)) {
            // spell data will not exist in LibreOffice/OpenOffice context
            List<String> paths = Arrays.asList("/de/hunspell/spelling.txt");
            StringBuilder concatPaths = new StringBuilder();
            List<InputStream> streams = new ArrayList<>();
            for (String path : paths) {
                concatPaths.append(path).append(";");
                streams.add(JLanguageTool.getDataBroker().getFromResourceDirAsStream(path));
            }
            try (BufferedReader br = new BufferedReader(
                    new InputStreamReader(new SequenceInputStream(Collections.enumeration(streams)), UTF_8))) {
                BufferedReader variantReader = null;
                if (languageVariantPlainTextDict != null && !languageVariantPlainTextDict.isEmpty()) {
                    InputStream variantStream = JLanguageTool.getDataBroker()
                            .getFromResourceDirAsStream(languageVariantPlainTextDict);
                    variantReader = new ExpandingReader(
                            new BufferedReader(new InputStreamReader(variantStream, UTF_8)));
                }
                return new MorfologikMultiSpeller(morfoFile, new ExpandingReader(br), concatPaths.toString(),
                        variantReader, languageVariantPlainTextDict,
                        userConfig != null ? userConfig.getAcceptedWords() : Collections.emptyList(),
                        MAX_EDIT_DISTANCE);
            }
        } else {
            return null;
        }
    } catch (IOException e) {
        throw new RuntimeException("Could not set up morfologik spell checker", e);
    }
}

From source file:de.geeksfactory.opacclient.apis.Bibliotheca.java

public static AccountData parse_account(Account acc, Document doc, JSONObject data) throws JSONException {
    JSONObject copymap = data.getJSONObject("accounttable");

    List<LentItem> media = new ArrayList<>();

    if (doc.select(".kontozeile_center table").size() == 0) {
        return null;
    }/*from  w  w w.  j a  v a2 s .  co  m*/

    Elements exemplartrs = doc.select(".kontozeile_center table").get(0).select("tr.tabKonto");

    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN);

    for (int i = 0; i < exemplartrs.size(); i++) {
        Element tr = exemplartrs.get(i);
        LentItem item = new LentItem();

        Iterator<?> keys = copymap.keys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            int index;
            try {
                index = copymap.has(key) ? copymap.getInt(key) : -1;
            } catch (JSONException e1) {
                index = -1;
            }
            if (index >= 0) {
                if (key.equals("prolongurl")) {
                    if (tr.child(index).children().size() > 0) {
                        item.setProlongData(tr.child(index).child(0).attr("href"));
                        item.setRenewable(tr.child(index).child(0).attr("href").contains("vermsg"));
                    }
                } else if (key.equals("returndate")) {
                    try {
                        item.setDeadline(fmt.parseLocalDate(tr.child(index).text()));
                    } catch (IllegalArgumentException e1) {
                        e1.printStackTrace();
                    }
                } else {
                    item.set(key, tr.child(index).text());
                }
            }
        }

        media.add(item);
    }
    assert (doc.select(".kontozeile_center table").get(0).select("tr").size() > 0);
    assert (exemplartrs.size() == media.size());

    copymap = data.getJSONObject("reservationtable");

    List<ReservedItem> reservations = new ArrayList<>();
    exemplartrs = doc.select(".kontozeile_center table").get(1).select("tr.tabKonto");
    for (int i = 0; i < exemplartrs.size(); i++) {
        Element tr = exemplartrs.get(i);
        ReservedItem item = new ReservedItem();

        Iterator<?> keys = copymap.keys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            int index;
            try {
                index = copymap.has(key) ? copymap.getInt(key) : -1;
            } catch (JSONException e1) {
                index = -1;
            }
            if (index >= 0) {
                if (key.equals("cancelurl")) {
                    if (tr.child(index).children().size() > 0) {
                        item.setCancelData(tr.child(index).child(0).attr("href"));
                    }
                } else if (key.equals("availability")) {
                    try {
                        item.setReadyDate(fmt.parseLocalDate(tr.child(index).text()));
                    } catch (IllegalArgumentException e1) {
                        item.setStatus(tr.child(index).text());
                    }
                } else if (key.equals("expirationdate")) {
                    try {
                        item.setExpirationDate(fmt.parseLocalDate(tr.child(index).text()));
                    } catch (IllegalArgumentException e1) {
                        item.setStatus(tr.child(index).text());
                    }
                } else {
                    item.set(key, tr.child(index).text());
                }
            }
        }

        reservations.add(item);
    }
    assert (doc.select(".kontozeile_center table").get(1).select("tr").size() > 0);
    assert (exemplartrs.size() == reservations.size());

    AccountData res = new AccountData(acc.getId());

    for (Element row : doc.select(".kontozeile_center, div[align=center]")) {
        String text = row.text().trim();
        if (text.matches(".*Ausstehende Geb.+hren:[^0-9]+([0-9.,]+)[^0-9A-Z]*(|EUR|CHF|Fr.).*")) {
            text = text.replaceAll(
                    ".*Ausstehende Geb.+hren:[^0-9]+([0-9.," + "]+)[^0-9A-Z]*(|EUR|CHF|Fr.).*", "$1 $2");
            res.setPendingFees(text);
        }
        if (text.matches("Ihr Ausweis ist g.ltig bis:.*")) {
            text = text.replaceAll("Ihr Ausweis ist g.ltig bis:[^A-Za-z0-9]+", "");
            res.setValidUntil(text);
        } else if (text.matches("Ausweis g.ltig bis:.*")) {
            text = text.replaceAll("Ausweis g.ltig bis:[^A-Za-z0-9]+", "");
            res.setValidUntil(text);
        }
    }

    res.setLent(media);
    res.setReservations(reservations);
    return res;
}

From source file:de.geeksfactory.opacclient.apis.BiBer1992.java

static List<ReservedItem> parseResList(Document doc, JSONObject data) throws JSONException {
    List<ReservedItem> reservations = new ArrayList<>();
    if (doc == null) {
        // error message as html result
        return reservations;
    }/*  w w  w.  j  ava  2s. c o m*/

    // parse result list
    JSONObject copymap;
    if (!data.has("reservationtable")) {
        // reservations not specifically supported, let's just try it
        // with default values but fail silently
        copymap = new JSONObject();
        copymap.put("author", 3);
        copymap.put("availability", 6);
        copymap.put("branch", -1);
        copymap.put("cancelurl", -1);
        copymap.put("expirationdate", 5);
        copymap.put("title", 3);
    } else {
        copymap = data.getJSONObject("reservationtable");
    }

    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN);
    Elements rowElements = doc.select("form[name=vorml] table tr");

    // rows: skip 1st row -> title row
    for (int i = 1; i < rowElements.size(); i++) {
        Element tr = rowElements.get(i);
        if (tr.child(0).tagName().equals("th")) {
            continue;
        }
        ReservedItem item = new ReservedItem();

        item.setCancelData(tr.select("input[type=checkbox]").attr("name"));

        // columns: all elements of one media
        Iterator<?> keys = copymap.keys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            int index = copymap.getInt(key);
            if (index >= 0) {
                String value = tr.child(index).text().trim();

                switch (key) {
                case "author":
                    value = findTitleAndAuthor(value)[1];
                    break;
                case "title":
                    value = findTitleAndAuthor(value)[0];
                    break;
                case "availability":
                    try {
                        value = fmt.parseLocalDate(value).toString();
                    } catch (IllegalArgumentException e1) {
                        key = "status";
                    }
                    break;
                case "expirationdate":
                    try {
                        value = fmt.parseLocalDate(value).toString();
                    } catch (IllegalArgumentException e1) {
                        key = "status";
                    }
                    break;
                }

                if (value != null && value.length() != 0) {
                    item.set(key, value);
                }

            }
        }
        reservations.add(item);
    }
    return reservations;
}

From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java

@Test
public void testCustomEditor() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
        @Override//from   w  w  w  .  ja  va 2s  .  c o  m
        public void registerCustomEditors(PropertyEditorRegistry registry) {
            NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
            registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
        }
    });
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1,1");
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
    bd.setPropertyValues(pvs);
    lbf.registerBeanDefinition("testBean", bd);
    TestBean testBean = (TestBean) lbf.getBean("testBean");
    assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java

@Test
public void testCustomConverter() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    GenericConversionService conversionService = new DefaultConversionService();
    conversionService.addConverter(new Converter<String, Float>() {
        @Override//from  w w  w.  jav  a2  s.  com
        public Float convert(String source) {
            try {
                NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
                return nf.parse(source).floatValue();
            } catch (ParseException ex) {
                throw new IllegalArgumentException(ex);
            }
        }
    });
    lbf.setConversionService(conversionService);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1,1");
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
    bd.setPropertyValues(pvs);
    lbf.registerBeanDefinition("testBean", bd);
    TestBean testBean = (TestBean) lbf.getBean("testBean");
    assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java

@Test
public void testCustomEditorWithBeanReference() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    lbf.addPropertyEditorRegistrar(new PropertyEditorRegistrar() {
        @Override//from   w  ww .  ja v  a2 s . c o  m
        public void registerCustomEditors(PropertyEditorRegistry registry) {
            NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
            registry.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, nf, true));
        }
    });
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
    bd.setPropertyValues(pvs);
    lbf.registerBeanDefinition("testBean", bd);
    lbf.registerSingleton("myFloat", "1,1");
    TestBean testBean = (TestBean) lbf.getBean("testBean");
    assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java

@Test
public void testCustomTypeConverter() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
    lbf.setTypeConverter(new CustomTypeConverter(nf));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", "1,1");
    ConstructorArgumentValues cav = new ConstructorArgumentValues();
    cav.addIndexedArgumentValue(0, "myName");
    cav.addIndexedArgumentValue(1, "myAge");
    lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
    TestBean testBean = (TestBean) lbf.getBean("testBean");
    assertEquals("myName", testBean.getName());
    assertEquals(5, testBean.getAge());/*from w  w w  .ja v  a 2s. c o  m*/
    assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

From source file:org.springframework.beans.factory.DefaultListableBeanFactoryTests.java

@Test
public void testCustomTypeConverterWithBeanReference() {
    DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
    NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
    lbf.setTypeConverter(new CustomTypeConverter(nf));
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("myFloat", new RuntimeBeanReference("myFloat"));
    ConstructorArgumentValues cav = new ConstructorArgumentValues();
    cav.addIndexedArgumentValue(0, "myName");
    cav.addIndexedArgumentValue(1, "myAge");
    lbf.registerBeanDefinition("testBean", new RootBeanDefinition(TestBean.class, cav, pvs));
    lbf.registerSingleton("myFloat", "1,1");
    TestBean testBean = (TestBean) lbf.getBean("testBean");
    assertEquals("myName", testBean.getName());
    assertEquals(5, testBean.getAge());//from  w w  w. j  a  v  a 2  s. co  m
    assertTrue(testBean.getMyFloat().floatValue() == 1.1f);
}

From source file:com.zoffcc.applications.zanavi.ZANaviMainIntroActivityStatic.java

@Override
public void processFinish(String output_part1) {
    String output = output_part1 + System.getProperty("line.separator") + System.getProperty("line.separator")
            + "LastStackTrace:" + System.getProperty("line.separator")
            + ZANaviMainApplication.last_stack_trace_as_string;
    ZANaviMainApplication.last_stack_trace_as_string = ""; // reset last stacktrace

    System.out.println("ZANaviMainIntroActivity:" + "processFinish");

    String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
    String full_file_name = Navit.NAVIT_DATA_DEBUG_DIR + "/crashlog_" + date + ".txt";
    String full_file_name_suppl = Navit.NAVIT_DATA_DEBUG_DIR + "/crashlog_single.txt";
    String feedback_text = Navit.get_text("Crashlog") + "\n" + Navit.get_text("You can use our PGP-Key") + ": "
            + Navit.PGP_KEY_ID;/*from w  w w .  j  a  va  2 s .  co m*/

    System.out.println("crashlogfile=" + full_file_name);

    ZANaviLogMessages.am(ZANaviLogMessages.STATUS_INFO,
            "ZANaviMainIntroActivityStatic:" + "crashlogfile=" + full_file_name);

    Logging.writeToFile(output, ZANaviMainIntroActivityStatic.this, full_file_name);

    String subject_d_version = "";
    if (Navit.Navit_DonateVersion_Installed) {
        subject_d_version = subject_d_version + "D,";
    }

    if (Navit.Navit_Largemap_DonateVersion_Installed) {
        subject_d_version = subject_d_version + "L,";
    }

    try {
        int rl = Navit.get_reglevel();

        if (rl > 0) {
            subject_d_version = "U" + rl + ",";
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    String FD_addon = "";
    if (Navit.FDBL) {
        FD_addon = ",FD";
    }

    try {
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                progressDialog2.dismiss();
                System.out.println("ZANaviMainIntroActivity:" + "progressDialog2.dismiss()");
            }
        });
    } catch (Exception ee) {
    }

    Navit.Global_Navit_Object.sendEmailWithAttachment(
            this, "feedback@zanavi.cc", "ZANavi Crashlog (v:" + subject_d_version + FD_addon
                    + Navit.NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")",
            feedback_text, full_file_name, full_file_name_suppl);

    // reset message
    ZANaviMainApplication.last_stack_trace_as_string = "";
    PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).edit()
            .putString("last_crash_text", ZANaviMainApplication.last_stack_trace_as_string).commit();

    // reset flag
    Navit.intro_flag_crash = false;
}

From source file:de.geeksfactory.opacclient.apis.SISIS.java

protected void parse_medialist(List<LentItem> media, Document doc, int offset) {
    Elements copytrs = doc.select(".data tr");
    doc.setBaseUri(opac_url);/*from  ww w  .  j a  v  a  2 s.  co m*/

    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd.MM.yyyy").withLocale(Locale.GERMAN);

    int trs = copytrs.size();
    if (trs == 1) {
        return;
    }
    assert (trs > 0);
    for (int i = 1; i < trs; i++) {
        Element tr = copytrs.get(i);
        LentItem item = new LentItem();

        if (tr.text().contains("keine Daten")) {
            return;
        }

        item.setTitle(tr.child(1).select("strong").text().trim());
        try {
            item.setAuthor(tr.child(1).html().split("<br[ /]*>")[1].trim());

            String[] col2split = tr.child(2).html().split("<br[ /]*>");
            String deadline = col2split[0].trim();
            if (deadline.contains("-")) {
                deadline = deadline.split("-")[1].trim();
            }
            try {
                item.setDeadline(fmt.parseLocalDate(deadline).toString());
            } catch (IllegalArgumentException e1) {
                e1.printStackTrace();
            }

            if (col2split.length > 1) {
                item.setHomeBranch(col2split[1].trim());
            }

            if (tr.select("a").size() > 0) {
                for (Element link : tr.select("a")) {
                    String href = link.attr("abs:href");
                    Map<String, String> hrefq = getQueryParamsFirst(href);
                    if (hrefq.get("methodToCall").equals("renewalPossible")) {
                        item.setProlongData(offset + "$" + href.split("\\?")[1]);
                        item.setRenewable(true);
                        break;
                    }
                }
            } else if (tr.select(".textrot, .textgruen, .textdunkelblau").size() > 0) {
                item.setProlongData("" + tr.select(".textrot, .textgruen, .textdunkelblau").text());
                item.setRenewable(false);
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }

        media.add(item);
    }
    assert (media.size() == trs - 1);

}