Example usage for java.util Locale ENGLISH

List of usage examples for java.util Locale ENGLISH

Introduction

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

Prototype

Locale ENGLISH

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

Click Source Link

Document

Useful constant for language.

Usage

From source file:com.spring.tutorial.messages.App.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext(
            "com/spring/tutorial/messages/applicationContext.xml");
    MessageSource ms = ctx.getBean(MessageSource.class);
    //Message resolution
    String success = ms.getMessage("msg.success", null, Locale.getDefault());
    String successEN = ms.getMessage("msg.success", null, Locale.ENGLISH);
    String successFR = ms.getMessage("msg.success", null, Locale.FRENCH);
    String successDE = ms.getMessage("msg.success", null, Locale.GERMAN);
    //Message resolution and i18n
    String label = ms.getMessage("lbl.result", null, Locale.getDefault());
    //Not necessary to pass the locale
    String error = ms.getMessage("err.failure", null, null);
    //Non-existent message (if the call does not specify, the default message argument,
    //and the message code does not exist, an exception will be thrown)
    String nonExistent = ms.getMessage("my.message", null, "Not found, defaults to this message", null);
    LOGGER.info("Success message (es - the default): " + success);
    LOGGER.info("Success message (en): " + successEN);
    LOGGER.info("Success message (fr): " + successFR);
    LOGGER.info("Success message (de) defaults to local language: " + successDE);
    LOGGER.info("Label text: " + label);
    LOGGER.info("Error message: " + error);
    LOGGER.info("Non-existent message (defaults to message specified as argument): " + nonExistent);
    ((ClassPathXmlApplicationContext) ctx).close();
}

From source file:com.easybanking.data.tester.java

/**
 * @param args the command line arguments
 *//*from  www  .j  a va2 s.co m*/
public static void main(String[] args) {
    // TODO code application logic here

    String pass = "123";
    String newPass = encriptPassword(pass);
    Bank bank = new Bank();
    bank.setId(1);
    System.out.println(newPass);

    BankBean bb = new BankBean();
    LoginBean lb = new LoginBean();
    lb.setSelectedBank(bank);
    BankData bd = new BankData();
    ArrayList<Person> resultList = bd.getListOfPersons(lb.getSelectedBank());

    BankAccountData bad = new BankAccountData();
    Client p = new Client();
    p.setId("456");
    p.setName("CARLOS");
    p.setLastName("Soto");
    p.setLastName2("soto");
    p.setEmail("wefd@DSF");
    p.setAddress("asdqw");
    p.setBirthDate(Calendar.getInstance(Locale.ENGLISH));
    p.setPhone("1234");

    PersonData pd = new PersonData();
    boolean insert = pd.create(p);

    System.out.println("" + insert);

    for (BankAccount ba : bad.getListOfAccounts(bank, p)) {

        System.out.println("" + ba.getId());

    }
    bb.loadTable();
}

From source file:com.doculibre.constellio.utils.resources.WriteResourceBundleUtils.java

@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
    File binDir = ClasspathUtils.getClassesDir();
    File projectDir = binDir.getParentFile();
    File sourceDir = new File(projectDir, "source");

    String defaultLanguage;// w ww  .ja  v a2s  . c  om
    String otherLanguage;
    if (args.length > 0) {
        defaultLanguage = args[0];
        otherLanguage = args[1];
    } else {
        defaultLanguage = Locale.ENGLISH.getLanguage();
        otherLanguage = Locale.FRENCH.getLanguage();
    }

    List<File> propertiesFiles = (List<File>) FileUtils.listFiles(sourceDir, new String[] { "properties" },
            true);
    for (File propertiesFile : propertiesFiles) {
        File propertiesDir = propertiesFile.getParentFile();

        String propertiesNameWoutSuffix = StringUtils.substringBefore(propertiesFile.getName(), "_");
        propertiesNameWoutSuffix = StringUtils.substringBefore(propertiesNameWoutSuffix, ".properties");

        String noLanguageFileName = propertiesNameWoutSuffix + ".properties";
        String defaultLanguageFileName = propertiesNameWoutSuffix + "_" + defaultLanguage + ".properties";
        String otherLanguageFileName = propertiesNameWoutSuffix + "_" + otherLanguage + ".properties";

        File noLanguageFile = new File(propertiesDir, noLanguageFileName);
        File defaultLanguageFile = new File(propertiesDir, defaultLanguageFileName);
        File otherLanguageFile = new File(propertiesDir, otherLanguageFileName);

        if (defaultLanguageFile.exists() && otherLanguageFile.exists() && !noLanguageFile.exists()) {
            System.out.println(defaultLanguageFile.getPath() + " > " + noLanguageFileName);
            System.out.println(defaultLanguageFile.getPath() + " > empty file");

            defaultLanguageFile.renameTo(noLanguageFile);
            FileWriter defaultLanguageEmptyFileWriter = new FileWriter(defaultLanguageFile);
            defaultLanguageEmptyFileWriter.write("");
            IOUtils.closeQuietly(defaultLanguageEmptyFileWriter);
        }
    }
}

From source file:PropertiesDemo.java

static public void main(String[] args) {

    Locale[] supportedLocales = { Locale.FRENCH, Locale.GERMAN, Locale.ENGLISH };

    for (int i = 0; i < supportedLocales.length; i++) {
        displayValue(supportedLocales[i], "s2");
    }/*from w  w  w  .ja va2s  .c  om*/

    System.out.println();

    iterateKeys(supportedLocales[0]);

}

From source file:be.dnsbelgium.rdap.client.RDAPCLI.java

public static void main(String[] args) {

    LOGGER.debug("Create the command line parser");
    CommandLineParser parser = new GnuParser();

    LOGGER.debug("Create the options");
    Options options = new RDAPOptions(Locale.ENGLISH);

    try {//from   w w w.jav  a  2 s .  co m
        LOGGER.debug("Parse the command line arguments");
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("help")) {
            printHelp(options);
            return;
        }

        if (line.getArgs().length == 0) {
            throw new IllegalArgumentException("You must provide a query");
        }
        String query = line.getArgs()[0];

        Type type = (line.getArgs().length == 2) ? Type.valueOf(line.getArgs()[1].toUpperCase())
                : guessQueryType(query);

        LOGGER.debug("Query: {}, Type: {}", query, type);

        try {
            SSLContextBuilder sslContextBuilder = SSLContexts.custom();
            if (line.hasOption(RDAPOptions.TRUSTSTORE)) {
                sslContextBuilder.loadTrustMaterial(
                        RDAPClient.getKeyStoreFromFile(new File(line.getOptionValue(RDAPOptions.TRUSTSTORE)),
                                line.getOptionValue(RDAPOptions.TRUSTSTORE_TYPE, RDAPOptions.DEFAULT_STORETYPE),
                                line.getOptionValue(RDAPOptions.TRUSTSTORE_PASS, RDAPOptions.DEFAULT_PASS)));
            }
            if (line.hasOption(RDAPOptions.KEYSTORE)) {
                sslContextBuilder.loadKeyMaterial(
                        RDAPClient.getKeyStoreFromFile(new File(line.getOptionValue(RDAPOptions.KEYSTORE)),
                                line.getOptionValue(RDAPOptions.KEYSTORE_TYPE, RDAPOptions.DEFAULT_STORETYPE),
                                line.getOptionValue(RDAPOptions.KEYSTORE_PASS, RDAPOptions.DEFAULT_PASS)),
                        line.getOptionValue(RDAPOptions.KEYSTORE_PASS, RDAPOptions.DEFAULT_PASS).toCharArray());
            }
            SSLContext sslContext = sslContextBuilder.build();

            final String url = line.getOptionValue(RDAPOptions.URL);
            final HttpHost host = Utils.httpHost(url);

            HashSet<Header> headers = new HashSet<Header>();
            headers.add(new BasicHeader("Accept-Language",
                    line.getOptionValue(RDAPOptions.LANG, Locale.getDefault().toString())));
            HttpClientBuilder httpClientBuilder = HttpClients.custom().setDefaultHeaders(headers)
                    .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext,
                            (line.hasOption(RDAPOptions.INSECURE) ? new AllowAllHostnameVerifier()
                                    : new BrowserCompatHostnameVerifier())));

            if (line.hasOption(RDAPOptions.USERNAME) && line.hasOption(RDAPOptions.PASSWORD)) {
                BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(new AuthScope(host.getHostName(), host.getPort()),
                        new UsernamePasswordCredentials(line.getOptionValue(RDAPOptions.USERNAME),
                                line.getOptionValue(RDAPOptions.PASSWORD)));
                httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
            }

            RDAPClient rdapClient = new RDAPClient(httpClientBuilder.build(), url);
            ObjectMapper mapper = new ObjectMapper();

            JsonNode json = null;
            switch (type) {
            case DOMAIN:
                json = rdapClient.getDomainAsJson(query);
                break;
            case ENTITY:
                json = rdapClient.getEntityAsJson(query);
                break;
            case AUTNUM:
                json = rdapClient.getAutNum(query);
                break;
            case IP:
                json = rdapClient.getIp(query);
                break;
            case NAMESERVER:
                json = rdapClient.getNameserver(query);
                break;
            }
            PrintWriter out = new PrintWriter(System.out, true);
            if (line.hasOption(RDAPOptions.RAW)) {
                mapper.writer().writeValue(out, json);
            } else if (line.hasOption(RDAPOptions.PRETTY)) {
                mapper.writer(new DefaultPrettyPrinter()).writeValue(out, json);
            } else if (line.hasOption(RDAPOptions.YAML)) {
                DumperOptions dumperOptions = new DumperOptions();
                dumperOptions.setPrettyFlow(true);
                dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
                dumperOptions.setSplitLines(true);
                Yaml yaml = new Yaml(dumperOptions);
                Map data = mapper.convertValue(json, Map.class);
                yaml.dump(data, out);
            } else {
                mapper.writer(new MinimalPrettyPrinter()).writeValue(out, json);
            }
            out.flush();
        } catch (Exception e) {
            LOGGER.error(e.getMessage(), e);
            System.exit(-1);
        }
    } catch (org.apache.commons.cli.ParseException e) {
        printHelp(options);
        System.exit(-1);
    }
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.Step7aLearningDataProducer.java

@SuppressWarnings("unchecked")
public static void main(String[] args) throws IOException {
    String inputDir = args[0];//from  www  .  ja va 2s .  c o  m
    File outputDir = new File(args[1]);

    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    Collection<File> files = IOHelper.listXmlFiles(new File(inputDir));

    // for generating ConvArgStrict use this
    String prefix = "no-eq_DescendingScoreArgumentPairListSorter";

    // for oversampling using graph transitivity properties use this
    //        String prefix = "generated_no-eq_AscendingScoreArgumentPairListSorter";

    Iterator<File> iterator = files.iterator();
    while (iterator.hasNext()) {
        File file = iterator.next();

        if (!file.getName().startsWith(prefix)) {
            iterator.remove();
        }
    }

    int totalGoldPairsCounter = 0;

    Map<String, Integer> goldDataDistribution = new HashMap<>();

    DescriptiveStatistics statsPerTopic = new DescriptiveStatistics();

    int totalPairsWithReasonSameAsGold = 0;

    DescriptiveStatistics ds = new DescriptiveStatistics();

    for (File file : files) {
        List<AnnotatedArgumentPair> argumentPairs = (List<AnnotatedArgumentPair>) XStreamTools.getXStream()
                .fromXML(file);

        int pairsPerTopicCounter = 0;

        String name = file.getName().replaceAll(prefix, "").replaceAll("\\.xml", "");

        PrintWriter pw = new PrintWriter(new File(outputDir, name + ".csv"), "utf-8");

        pw.println("#id\tlabel\ta1\ta2");

        for (AnnotatedArgumentPair argumentPair : argumentPairs) {
            String goldLabel = argumentPair.getGoldLabel();

            if (!goldDataDistribution.containsKey(goldLabel)) {
                goldDataDistribution.put(goldLabel, 0);
            }

            goldDataDistribution.put(goldLabel, goldDataDistribution.get(goldLabel) + 1);

            pw.printf(Locale.ENGLISH, "%s\t%s\t%s\t%s%n", argumentPair.getId(), goldLabel,
                    multipleParagraphsToSingleLine(argumentPair.getArg1().getText()),
                    multipleParagraphsToSingleLine(argumentPair.getArg2().getText()));

            pairsPerTopicCounter++;

            int sameInOnePair = 0;

            // get gold reason statistics
            for (AnnotatedArgumentPair.MTurkAssignment assignment : argumentPair.mTurkAssignments) {
                String label = assignment.getValue();

                if (goldLabel.equals(label)) {
                    sameInOnePair++;
                }
            }

            ds.addValue(sameInOnePair);
            totalPairsWithReasonSameAsGold += sameInOnePair;
        }

        totalGoldPairsCounter += pairsPerTopicCounter;
        statsPerTopic.addValue(pairsPerTopicCounter);

        pw.close();
    }

    System.out.println("Total reasons matching gold " + totalPairsWithReasonSameAsGold);
    System.out.println(ds);

    System.out.println("Total gold pairs: " + totalGoldPairsCounter);
    System.out.println(statsPerTopic);

    int totalPairs = 0;
    for (Integer pairs : goldDataDistribution.values()) {
        totalPairs += pairs;
    }
    System.out.println("Total pairs: " + totalPairs);
    System.out.println(goldDataDistribution);

}

From source file:net.minecraftforge.fml.common.patcher.GenDiffSet.java

public static void main(String[] args) throws IOException {
    String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar
    String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft
    String deobfData = args[2]; //Path to FML's deobfusication_data.lzma
    String outputDir = args[3]; //Path to place generated .binpatch
    String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch

    LogManager.getLogger("GENDIFF").log(Level.INFO,
            String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir));
    Delta delta = new Delta();
    FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
    remapper.setupLoadOnly(deobfData, false);
    JarFile sourceZip = new JarFile(sourceJar);
    boolean kill = killTarget.equalsIgnoreCase("true");

    File f = new File(outputDir);
    f.mkdirs();/*from  w  ww. j  av a  2  s  .co  m*/

    for (String name : remapper.getObfedClasses()) {
        //            Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name));
        String fileName = name;
        String jarName = name;
        if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH))) {
            fileName = "_" + name;
        }
        File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class");
        jarName = jarName + ".class";
        if (targetFile.exists()) {
            String sourceClassName = name.replace('/', '.');
            String targetClassName = remapper.map(name).replace('/', '.');
            JarEntry entry = sourceZip.getJarEntry(jarName);
            byte[] vanillaBytes = toByteArray(sourceZip, entry);
            byte[] patchedBytes = Files.toByteArray(targetFile);

            byte[] diff = delta.compute(vanillaBytes, patchedBytes);

            ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50);
            // Original name
            diffOut.writeUTF(name);
            // Source name
            diffOut.writeUTF(sourceClassName);
            // Target name
            diffOut.writeUTF(targetClassName);
            // exists at original
            diffOut.writeBoolean(entry != null);
            if (entry != null) {
                diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt());
            }
            // length of patch
            diffOut.writeInt(diff.length);
            // patch
            diffOut.write(diff);

            File target = new File(outputDir, targetClassName + ".binpatch");
            target.getParentFile().mkdirs();
            Files.write(diffOut.toByteArray(), target);
            Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s", name,
                    targetClassName, target.getAbsolutePath()));
            if (kill) {
                targetFile.delete();
                Logger.getLogger("GENDIFF").info(String.format("  Deleted target: %s", targetFile.toString()));
            }
        }
    }
    sourceZip.close();
}

From source file:at.ac.univie.isc.asio.Asio.java

public static void main(String[] args) {
    Launcher.currentProcess().daemonize();
    Locale.setDefault(Locale.ENGLISH);
    application().run(args);
}

From source file:org.opcfoundation.ua.examples.SampleClient.java

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("Usage: SampleClient [server uri]");
        return;/*from  www. j  av a  2 s. c o  m*/
    }
    String url = args[0];
    System.out.print("SampleClient: Connecting to " + url + " .. ");

    //////////////  CLIENT  //////////////
    // Create Client
    Application myApplication = new Application();
    Client myClient = new Client(myApplication);
    myApplication.addLocale(ENGLISH);
    myApplication.setApplicationName(new LocalizedText("Java Sample Client", Locale.ENGLISH));
    myApplication.setProductUri("urn:JavaSampleClient");

    CertificateUtils.setKeySize(1024); // default = 1024
    KeyPair pair = ExampleKeys.getCert("SampleClient");
    myApplication.addApplicationInstanceCertificate(pair);

    // The HTTPS SecurityPolicies are defined separate from the endpoint securities
    myApplication.getHttpsSettings().setHttpsSecurityPolicies(HttpsSecurityPolicy.ALL);

    // Peer verifier
    myApplication.getHttpsSettings().setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    myApplication.getHttpsSettings().setCertificateValidator(CertificateValidator.ALLOW_ALL);

    // The certificate to use for HTTPS
    KeyPair myHttpsCertificate = ExampleKeys.getHttpsCert("SampleClient");
    myApplication.getHttpsSettings().setKeyPair(myHttpsCertificate);

    // Connect to the given uri
    SessionChannel mySession = myClient.createSessionChannel(url);
    //      mySession.activate("username", "123");
    mySession.activate();
    //////////////////////////////////////      

    /////////////  EXECUTE  //////////////      
    // Browse Root
    BrowseDescription browse = new BrowseDescription();
    browse.setNodeId(Identifiers.RootFolder);
    browse.setBrowseDirection(BrowseDirection.Forward);
    browse.setIncludeSubtypes(true);
    browse.setNodeClassMask(NodeClass.Object, NodeClass.Variable);
    browse.setResultMask(BrowseResultMask.All);
    BrowseResponse res3 = mySession.Browse(null, null, null, browse);
    System.out.println(res3);

    // Read Namespace Array
    ReadResponse res5 = mySession.Read(null, null, TimestampsToReturn.Neither,
            new ReadValueId(Identifiers.Server_NamespaceArray, Attributes.Value, null, null));
    String[] namespaceArray = (String[]) res5.getResults()[0].getValue().getValue();
    System.out.println(Arrays.toString(namespaceArray));

    // Read a variable
    ReadResponse res4 = mySession.Read(null, 500.0, TimestampsToReturn.Source,
            new ReadValueId(new NodeId(6, 1710), Attributes.Value, null, null));
    System.out.println(res4);

    res4 = mySession.Read(null, 500.0, TimestampsToReturn.Source,
            new ReadValueId(new NodeId(6, 1710), Attributes.DataType, null, null));
    System.out.println(res4);

    /////////////  SHUTDOWN  /////////////
    mySession.close();
    mySession.closeAsync();
    //////////////////////////////////////   

}

From source file:com.unispezi.cpanelremotebackup.CPanelRemoteBackup.java

/**
 * main//from   w  w w .  ja v  a2  s .  c o  m
 * @param args arguments
 */
public static void main(String[] args) {

    Locale.setDefault(Locale.ENGLISH); // We don't support I18n yet, but args4j does. Set args4j to English.
    CPanelRemoteBackup backup = new CPanelRemoteBackup();

    CmdLineParser parser = new CmdLineParser(backup);
    try {
        parser.parseArgument(args);
        backup.run();
    } catch (CmdLineException e) {
        // handling of wrong arguments
        System.err.println(
                "CPanelRemoteBackup - Triggers full backup on remote CPanel server, then downloads it");
        System.err.println(e.getMessage());
        System.err.println("Usage: java -jar CPanelRemoteBackup.jar hostname [outdir]");
        parser.printUsage(System.err);
    }
}