Example usage for java.util Locale getDisplayVariant

List of usage examples for java.util Locale getDisplayVariant

Introduction

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

Prototype

public final String getDisplayVariant() 

Source Link

Document

Returns a name for the locale's variant code that is appropriate for display to the user.

Usage

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Locale defaultLocale = Locale.getDefault();
    System.out.println(defaultLocale.getDisplayVariant());
    System.out.println(defaultLocale.getDisplayVariant(Locale.US));
    System.out.println((new Locale("en", "US", "WIN_TX_Austin")).getDisplayVariant());
}

From source file:DisplayVariantOutput.java

public static void main(String[] argv) {

    Locale defaultLocale = Locale.getDefault();
    System.out.println(defaultLocale.getDisplayVariant());
    System.out.println(defaultLocale.getDisplayVariant(Locale.US));
    System.out.println((new Locale("en", "US", "WIN_TX_Austin")).getDisplayVariant());
}

From source file:Main.java

public static void main(String[] args) {
    Locale locale = new Locale("ENGLISH", "US", "WIN");

    System.out.println("Locale:" + locale);

    // print display variant for locale - based on inLocale
    System.out.println("Variant:" + locale.getDisplayVariant());

}

From source file:no.abmu.common.locale.LocaleUtil.java

/**
 * Method for logging of locale. Used under test and development.
 * /*w w w  .  jav  a  2 s .c o  m*/
 * @param request current HTTP request
 */

public void logLocale(HttpServletRequest request) {
    HttpSession session = request.getSession(false);

    String parameterSiteLocale = request.getParameter("siteLocale");
    String parameterStartLocale = request.getParameter("startLocale");
    String rcSiteLocale = (String) request.getAttribute("siteLocale");
    //        String seSiteLocale = (String) session.getAttribute("siteLocale");

    Locale locale = RequestContextUtils.getLocale(request);

    logger.info("request siteLocale: " + rcSiteLocale);
    logger.info("request parameter siteLocale: " + parameterSiteLocale);
    logger.info("request parameter startLocale: " + parameterStartLocale);
    //        logger.info("session siteLocale: " + seSiteLocale);

    logger.info("Locale getDisplayCountry: " + locale.getDisplayCountry());
    logger.info("Locale getDisplayLanguage: " + locale.getDisplayLanguage());
    logger.info("Locale getDisplayVariant: " + locale.getDisplayVariant());
    logger.info("Locale getDisplayName: " + locale.getDisplayName());
    logger.info("Locale getISO3Country: " + locale.getISO3Country());
    logger.info("Locale getLanguage: " + locale.getLanguage());
    logger.info("Locale getVariant: " + locale.getVariant());
    logger.info("Locale toString: " + locale.toString());

}

From source file:org.tdl.vireo.search.impl.LuceneAbstractJobImpl.java

/**
 * Write a the provided submission and all associated action logs to the
 * index writer. This method expects that the submission and action logs
 * have been removed from the index, either through a specific delete,
 * or a delete all in the case of rebuilding the index.
 * //from w ww.ja  va2s  . c  om
 * This method is used to share code between the various index job
 * implementations so that submissions are written the same no matter
 * who indexes them first.
 * 
 * @param writer
 *            The index writer.
 * @param sub
 *            The submission to index.
 */
public void indexSubmission(IndexWriter writer, Submission sub) throws CorruptIndexException, IOException {

    StringBuilder searchText = new StringBuilder();

    long subId = sub.getId();

    String state = sub.getState().getDisplayName();
    searchText.append(state).append(" ");

    long searchAssigned = 0;
    String sortAssigned = "";
    if (sub.getAssignee() != null) {
        searchAssigned = sub.getAssignee().getId();
        sortAssigned = sub.getAssignee().getFormattedName(NameFormat.LAST_FIRST_MIDDLE_BIRTH);
        searchText.append(sortAssigned).append(" ");
    }

    Date graduationSemester = null;
    if (sub.getGraduationYear() != null) {
        Calendar cal = Calendar.getInstance();
        cal.clear();
        cal.set(Calendar.YEAR, sub.getGraduationYear());
        if (sub.getGraduationMonth() != null)
            cal.set(Calendar.MONTH, sub.getGraduationMonth());

        graduationSemester = cal.getTime();
    }

    Date defenseDate = sub.getDefenseDate();

    String department = sub.getDepartment();
    String program = sub.getProgram();
    String college = sub.getCollege();
    String major = sub.getMajor();
    searchText.append(department).append(" ").append(program).append(" ").append(college).append(" ")
            .append(major).append(" ");

    String embargo = null;
    if (sub.getEmbargoType() != null) {
        embargo = sub.getEmbargoType().getName();
        searchText.append(embargo).append(" ");
    }

    String degree = sub.getDegree();
    String documentType = sub.getDocumentType();
    searchText.append(degree).append(" ").append(documentType).append(" ");

    Date submissionDate = sub.getSubmissionDate();

    String studentName = "";
    if (sub.getStudentLastName() != null)
        studentName += sub.getStudentLastName() + " ";
    if (sub.getStudentFirstName() != null)
        studentName += sub.getStudentFirstName() + " ";
    if (sub.getStudentMiddleName() != null)
        studentName += sub.getStudentMiddleName() + " ";
    searchText.append(studentName).append(" ");

    searchText.append(sub.getStudentFormattedName(NameFormat.LAST_FIRST_BIRTH)).append(" ");
    searchText.append(sub.getStudentFormattedName(NameFormat.FIRST_LAST_BIRTH)).append(" ");

    String studentEmail = sub.getSubmitter().getEmail();
    searchText.append(studentEmail).append(" ");

    String institutionalIdentifier = sub.getSubmitter().getInstitutionalIdentifier();
    searchText.append(institutionalIdentifier).append(" ");

    String documentTitle = sub.getDocumentTitle();
    String documentAbstract = sub.getDocumentAbstract();
    String documentKeywords = sub.getDocumentKeywords();
    searchText.append(documentTitle).append(" ").append(documentAbstract).append(" ").append(documentKeywords)
            .append(" ");

    String documentSubjects = "";
    for (String subject : sub.getDocumentSubjects()) {
        documentSubjects += subject + " ";
    }
    searchText.append(documentSubjects).append(" ");

    String documentLanguage = null;
    if (sub.getDocumentLanguageLocale() != null) {
        Locale locale = sub.getDocumentLanguageLocale();
        searchText.append(locale.getDisplayName()).append(" ");
        searchText.append(locale.getDisplayLanguage()).append(" ");
        searchText.append(locale.getDisplayCountry()).append(" ");
        searchText.append(locale.getDisplayVariant()).append(" ");

        documentLanguage = locale.getDisplayName();
    }

    String publishedMaterial = sub.getPublishedMaterial();
    searchText.append(publishedMaterial).append(" ");

    String primaryDocument = null;
    if (sub.getPrimaryDocument() != null) {
        primaryDocument = sub.getPrimaryDocument().getName();
        searchText.append(primaryDocument).append(" ");
    }

    Date licenseAgreementDate = sub.getLicenseAgreementDate();
    Date approvalDate = sub.getApprovalDate();
    Date committeeApprovalDate = sub.getCommitteeApprovalDate();
    Date committeeEmbargoApprovalDate = sub.getCommitteeEmbargoApprovalDate();

    String committeeMembers = "";
    for (CommitteeMember member : sub.getCommitteeMembers()) {
        // TODO: sort by display order?
        committeeMembers += member.getFormattedName(NameFormat.LAST_FIRST) + " " + member.getFormattedRoles();
    }
    searchText.append(committeeMembers).append(" ");

    String committeeContactEmail = sub.getCommitteeContactEmail();
    searchText.append(committeeContactEmail).append(" ");

    String umiRelease;
    if (sub.getUMIRelease() == null) {
        umiRelease = "";
    } else if (sub.getUMIRelease()) {
        umiRelease = "yes";
    } else {
        umiRelease = "no";
    }

    int customActions = 0;
    for (CustomActionValue action : sub.getCustomActions()) {
        if (action.getValue())
            customActions++;
    }

    String degreeLevel = null;
    if (sub.getDegreeLevel() != null)
        degreeLevel = sub.getDegreeLevel().name();
    searchText.append(degreeLevel).append(" ");

    String depositId = sub.getDepositId();
    searchText.append(depositId).append(" ");

    String reviewerNotes = sub.getReviewerNotes();
    searchText.append(reviewerNotes).append(" ");

    String lastEventEntry = null;
    Date lastEventTime = null;

    List<ActionLog> logs = indexer.subRepo.findActionLog(sub);
    if (logs.size() > 0) {
        lastEventEntry = logs.get(0).getEntry();
        lastEventTime = logs.get(0).getActionDate();
        searchText.append(lastEventEntry);
    }

    Document doc = new Document();

    doc.add(new NumericField("subId", Field.Store.YES, true).setLongValue(subId));
    doc.add(new Field("type", "submission", Field.Store.YES, Index.NOT_ANALYZED));
    doc.add(new Field("searchText", searchText.toString(), Field.Store.NO, Index.ANALYZED_NO_NORMS));
    if (state != null)
        doc.add(new Field("state", state, Field.Store.NO, Index.NOT_ANALYZED));

    doc.add(new NumericField("searchAssigned", Field.Store.NO, true).setLongValue(searchAssigned));

    if (sortAssigned != null)
        doc.add(new Field("sortAssigned", sortAssigned, Field.Store.NO, Index.NOT_ANALYZED));

    if (graduationSemester != null)
        doc.add(new NumericField("graduationSemester", Field.Store.NO, true)
                .setLongValue(graduationSemester.getTime()));

    if (defenseDate != null)
        doc.add(new NumericField("defenseDate", Field.Store.NO, true).setLongValue(defenseDate.getTime()));

    if (department != null)
        doc.add(new Field("department", department, Field.Store.NO, Index.NOT_ANALYZED));

    if (program != null)
        doc.add(new Field("program", program, Field.Store.NO, Index.NOT_ANALYZED));

    if (college != null)
        doc.add(new Field("college", college, Field.Store.NO, Index.NOT_ANALYZED));

    if (major != null)
        doc.add(new Field("major", major, Field.Store.NO, Index.NOT_ANALYZED));

    if (embargo != null)
        doc.add(new Field("embargo", embargo, Field.Store.NO, Index.NOT_ANALYZED));

    if (degree != null)
        doc.add(new Field("degree", degree, Field.Store.NO, Index.NOT_ANALYZED));

    if (documentType != null)
        doc.add(new Field("documentType", documentType, Field.Store.NO, Index.NOT_ANALYZED));

    if (submissionDate != null)
        doc.add(new NumericField("submissionDate", Field.Store.NO, true)
                .setLongValue(submissionDate.getTime()));

    if (studentName != null)
        doc.add(new Field("studentName", studentName, Field.Store.NO, Index.NOT_ANALYZED));

    if (studentEmail != null)
        doc.add(new Field("studentEmail", studentEmail, Field.Store.NO, Index.NOT_ANALYZED));

    if (institutionalIdentifier != null)
        doc.add(new Field("institutionalIdentifier", institutionalIdentifier, Field.Store.NO,
                Index.NOT_ANALYZED));

    if (documentTitle != null)
        doc.add(new Field("documentTitle", documentTitle, Field.Store.NO, Index.NOT_ANALYZED));

    if (documentAbstract != null)
        doc.add(new Field("documentAbstract", documentAbstract, Field.Store.NO, Index.NOT_ANALYZED));

    if (documentKeywords != null)
        doc.add(new Field("documentKeywords", documentKeywords, Field.Store.NO, Index.NOT_ANALYZED));

    if (documentSubjects != null)
        doc.add(new Field("documentSubjects", documentSubjects, Field.Store.NO, Index.NOT_ANALYZED));

    if (documentLanguage != null)
        doc.add(new Field("documentLanguage", documentLanguage, Field.Store.NO, Index.NOT_ANALYZED));

    if (publishedMaterial != null)
        doc.add(new Field("publishedMaterial", publishedMaterial, Field.Store.NO, Index.NOT_ANALYZED));

    if (primaryDocument != null)
        doc.add(new Field("primaryDocument", primaryDocument, Field.Store.NO, Index.NOT_ANALYZED));

    if (licenseAgreementDate != null)
        doc.add(new NumericField("licenseAgreementDate", Field.Store.NO, true)
                .setLongValue(licenseAgreementDate.getTime()));

    if (approvalDate != null)
        doc.add(new NumericField("approvalDate", Field.Store.NO, true).setLongValue(approvalDate.getTime()));

    if (committeeApprovalDate != null)
        doc.add(new NumericField("committeeApprovalDate", Field.Store.NO, true)
                .setLongValue(committeeApprovalDate.getTime()));

    if (committeeEmbargoApprovalDate != null)
        doc.add(new NumericField("committeeEmbargoApprovalDate", Field.Store.NO, true)
                .setLongValue(committeeEmbargoApprovalDate.getTime()));

    if (committeeMembers != null)
        doc.add(new Field("committeeMembers", committeeMembers, Field.Store.NO, Index.NOT_ANALYZED));

    if (committeeContactEmail != null)
        doc.add(new Field("committeeContactEmail", committeeContactEmail, Field.Store.NO, Index.NOT_ANALYZED));

    if (umiRelease != null)
        doc.add(new Field("umiRelease", umiRelease, Field.Store.NO, Index.NOT_ANALYZED));

    doc.add(new NumericField("customActions", Field.Store.NO, true).setIntValue(customActions));

    if (degreeLevel != null)
        doc.add(new Field("degreeLevel", degreeLevel, Field.Store.NO, Index.NOT_ANALYZED));

    if (depositId != null)
        doc.add(new Field("depositId", depositId, Field.Store.NO, Index.NOT_ANALYZED));

    if (reviewerNotes != null)
        doc.add(new Field("reviewerNotes", reviewerNotes, Field.Store.NO, Index.NOT_ANALYZED));

    if (lastEventEntry != null)
        doc.add(new Field("lastEventEntry", lastEventEntry, Field.Store.NO, Index.NOT_ANALYZED));

    if (lastEventTime != null)
        doc.add(new NumericField("lastEventTime", Field.Store.NO, true).setLongValue(lastEventTime.getTime()));

    writer.addDocument(doc);

    for (ActionLog log : logs) {

        Long logId = log.getId();
        String logEntry = log.getEntry();
        String logState = log.getSubmissionState().getDisplayName();
        long logSearchAssigned = 0;
        String logSortAssigned = null;
        if (log.getPerson() != null) {
            logSearchAssigned = log.getPerson().getId();
            logSortAssigned = log.getPerson().getFormattedName(NameFormat.FIRST_LAST);
        }
        Date logTime = log.getActionDate();

        // The new special things for action logs.
        doc = new Document();
        doc.add(new NumericField("subId", Field.Store.YES, true).setLongValue(subId));
        doc.add(new NumericField("logId", Field.Store.YES, true).setLongValue(logId));
        doc.add(new Field("type", "actionlog", Field.Store.YES, Index.NOT_ANALYZED));

        if (logEntry != null)
            doc.add(new Field("searchText", logEntry, Field.Store.NO, Index.ANALYZED_NO_NORMS));

        if (logState != null)
            doc.add(new Field("state", logState, Field.Store.NO, Index.NOT_ANALYZED));

        doc.add(new NumericField("searchAssigned", Field.Store.NO, true).setLongValue(logSearchAssigned));

        if (logSortAssigned != null)
            doc.add(new Field("sortAssigned", logSortAssigned, Field.Store.NO, Index.NOT_ANALYZED));

        if (logEntry != null)
            doc.add(new Field("lastEventEntry", logEntry, Field.Store.NO, Index.NOT_ANALYZED));

        if (logTime != null)
            doc.add(new NumericField("lastEventTime", Field.Store.NO, true).setLongValue(logTime.getTime()));

        // Stuff that is the same as the submission.
        if (graduationSemester != null)
            doc.add(new NumericField("graduationSemester", Field.Store.NO, true)
                    .setLongValue(graduationSemester.getTime()));

        if (defenseDate != null)
            doc.add(new NumericField("defenseDate", Field.Store.NO, true).setLongValue(defenseDate.getTime()));

        if (department != null)
            doc.add(new Field("department", department, Field.Store.NO, Index.NOT_ANALYZED));

        if (program != null)
            doc.add(new Field("program", program, Field.Store.NO, Index.NOT_ANALYZED));

        if (college != null)
            doc.add(new Field("college", college, Field.Store.NO, Index.NOT_ANALYZED));

        if (major != null)
            doc.add(new Field("major", major, Field.Store.NO, Index.NOT_ANALYZED));

        if (embargo != null)
            doc.add(new Field("embargo", embargo, Field.Store.NO, Index.NOT_ANALYZED));

        if (degree != null)
            doc.add(new Field("degree", degree, Field.Store.NO, Index.NOT_ANALYZED));

        if (documentType != null)
            doc.add(new Field("documentType", documentType, Field.Store.NO, Index.NOT_ANALYZED));

        if (submissionDate != null)
            doc.add(new NumericField("submissionDate", Field.Store.NO, true)
                    .setLongValue(submissionDate.getTime()));

        if (studentName != null)
            doc.add(new Field("studentName", studentName, Field.Store.NO, Index.NOT_ANALYZED));

        if (studentEmail != null)
            doc.add(new Field("studentEmail", studentEmail, Field.Store.NO, Index.NOT_ANALYZED));

        if (institutionalIdentifier != null)
            doc.add(new Field("institutionalIdentifier", institutionalIdentifier, Field.Store.NO,
                    Index.NOT_ANALYZED));

        if (documentAbstract != null)
            doc.add(new Field("documentAbstract", documentAbstract, Field.Store.NO, Index.NOT_ANALYZED));

        if (documentKeywords != null)
            doc.add(new Field("documentKeywords", documentKeywords, Field.Store.NO, Index.NOT_ANALYZED));

        if (documentSubjects != null)
            doc.add(new Field("documentSubjects", documentSubjects, Field.Store.NO, Index.NOT_ANALYZED));

        if (documentLanguage != null)
            doc.add(new Field("documentLanguage", documentLanguage, Field.Store.NO, Index.NOT_ANALYZED));

        if (publishedMaterial != null)
            doc.add(new Field("publishedMaterial", publishedMaterial, Field.Store.NO, Index.NOT_ANALYZED));

        if (primaryDocument != null)
            doc.add(new Field("primaryDocument", primaryDocument, Field.Store.NO, Index.NOT_ANALYZED));

        if (licenseAgreementDate != null)
            doc.add(new NumericField("licenseAgreementDate", Field.Store.NO, true)
                    .setLongValue(licenseAgreementDate.getTime()));

        if (approvalDate != null)
            doc.add(new NumericField("approvalDate", Field.Store.NO, true)
                    .setLongValue(approvalDate.getTime()));

        if (committeeApprovalDate != null)
            doc.add(new NumericField("committeeApprovalDate", Field.Store.NO, true)
                    .setLongValue(committeeApprovalDate.getTime()));

        if (committeeEmbargoApprovalDate != null)
            doc.add(new NumericField("committeeEmbargoApprovalDate", Field.Store.NO, true)
                    .setLongValue(committeeEmbargoApprovalDate.getTime()));

        if (committeeMembers != null)
            doc.add(new Field("committeeMembers", committeeMembers, Field.Store.NO, Index.NOT_ANALYZED));

        if (committeeContactEmail != null)
            doc.add(new Field("committeeContactEmail", committeeContactEmail, Field.Store.NO,
                    Index.NOT_ANALYZED));

        if (umiRelease != null)
            doc.add(new Field("umiRelease", umiRelease, Field.Store.NO, Index.NOT_ANALYZED));

        doc.add(new NumericField("customActions", Field.Store.NO, true).setIntValue(customActions));

        if (degreeLevel != null)
            doc.add(new Field("degreeLevel", degreeLevel, Field.Store.NO, Index.NOT_ANALYZED));

        if (depositId != null)
            doc.add(new Field("depositId", depositId, Field.Store.NO, Index.NOT_ANALYZED));

        if (reviewerNotes != null)
            doc.add(new Field("reviewerNotes", reviewerNotes, Field.Store.NO, Index.NOT_ANALYZED));

        writer.addDocument(doc);

        // Detach the log so it dosn't keep stacking up in memory.
        log.detach();
    } // for logs
}