Example usage for java.util Locale toString

List of usage examples for java.util Locale toString

Introduction

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

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case.

Usage

From source file:org.alfresco.solr.SolrInformationServer.java

private static void addMLTextPropertyToDoc(SolrInputDocument doc, FieldInstance field,
        MLTextPropertyValue mlTextPropertyValue) throws IOException {
    if (field.isLocalised()) {
        StringBuilder sort = new StringBuilder(128);
        for (Locale locale : mlTextPropertyValue.getLocales()) {
            final String propValue = mlTextPropertyValue.getValue(locale);
            if (log.isDebugEnabled()) {
                log.debug("ML " + field.getField() + " in " + locale + " of " + propValue);
            }/*from   w ww. j  a  va 2 s  .  co  m*/

            if ((locale == null) || (propValue == null)) {
                continue;
            }

            StringBuilder builder = new StringBuilder(propValue.length() + 16);
            builder.append("\u0000").append(locale.toString()).append("\u0000").append(propValue);

            if (!field.isSort()) {
                doc.addField(field.getField(), builder.toString());
            }

            if (sort.length() > 0) {
                sort.append("\u0000");
            }
            sort.append(builder.toString());
        }
        if (field.isSort()) {
            doc.addField(field.getField(), sort.toString());
        }
    } else {
        for (Locale locale : mlTextPropertyValue.getLocales()) {
            doc.addField(field.getField(), mlTextPropertyValue.getValue(locale));
        }
    }
    addFieldIfNotSet(doc, field);
}

From source file:org.alfresco.solr.SolrInformationServer.java

private static void addStringPropertyToDoc(SolrInputDocument doc, FieldInstance field,
        StringPropertyValue stringPropertyValue, Map<QName, PropertyValue> properties) throws IOException {
    if (field.isLocalised()) {
        Locale locale = null;

        PropertyValue localePropertyValue = properties.get(ContentModel.PROP_LOCALE);
        if (localePropertyValue != null) {
            locale = DefaultTypeConverter.INSTANCE.convert(Locale.class,
                    ((StringPropertyValue) localePropertyValue).getValue());
        }/*from   w ww.  ja  v  a  2  s  . c o  m*/

        if (locale == null) {
            locale = I18NUtil.getLocale();
        }

        StringBuilder builder;
        builder = new StringBuilder();
        builder.append("\u0000").append(locale.toString()).append("\u0000")
                .append(stringPropertyValue.getValue());

        doc.addField(field.getField(), builder.toString());
    } else {
        doc.addField(field.getField(), stringPropertyValue.getValue());
    }
    addFieldIfNotSet(doc, field);
}

From source file:org.jahia.test.utils.TestHelper.java

private static JahiaSite addSiteWithoutTemplates(final JahiaUser currentUser, final String name,
        final String serverName, final Locale selectedLocale) throws Exception {
    JahiaSite site = null;/* w w  w.j a v a  2s  .  co m*/
    try {
        site = JCRTemplate.getInstance().doExecuteWithSystemSession(new JCRCallback<JahiaSite>() {
            public JahiaSite doInJCR(JCRSessionWrapper session) throws RepositoryException {
                // check there is no site with same server name before adding
                JCRSiteNode site = null;
                try {

                    if (!JahiaSitesService.getInstance().siteExists(name, session)) {
                        Query q = session.getWorkspace().getQueryManager()
                                .createQuery("SELECT * FROM [jnt:virtualsitesFolder]", Query.JCR_SQL2);
                        QueryResult qr = q.execute();
                        NodeIterator ni = qr.getNodes();

                        while (ni.hasNext()) {
                            JCRNodeWrapper sitesFolder = (JCRNodeWrapper) ni.nextNode();
                            String options = "";
                            if (sitesFolder.hasProperty("j:virtualsitesFolderConfig")) {
                                options = sitesFolder.getProperty("j:virtualsitesFolderConfig").getString();
                            }

                            JCRNodeWrapper f = JCRContentUtils.getPathFolder(sitesFolder, name, options,
                                    "jnt:virtualsitesFolder");
                            try {
                                f.getNode(name);
                                throw new IllegalArgumentException("Site already exists");
                            } catch (PathNotFoundException e) {
                                JCRNodeWrapper siteNode = f.addNode(name, "jnt:virtualsite");

                                if (sitesFolder.hasProperty("j:virtualsitesFolderSkeleton")) {
                                    String skeletons = sitesFolder.getProperty("j:virtualsitesFolderSkeleton")
                                            .getString();
                                    try {
                                        JCRContentUtils.importSkeletons(skeletons, f.getPath() + "/" + name,
                                                session);
                                    } catch (Exception importEx) {
                                        logger.error("Unable to import data using site skeleton " + skeletons,
                                                importEx);
                                    }
                                }

                                siteNode.setProperty("j:title", name);
                                siteNode.setProperty("j:description", name);
                                siteNode.setProperty("j:serverName", serverName);
                                siteNode.setProperty(SitesSettings.DEFAULT_LANGUAGE, selectedLocale.toString());
                                siteNode.setProperty(SitesSettings.MIX_LANGUAGES_ACTIVE, false);
                                siteNode.setProperty(SitesSettings.LANGUAGES,
                                        new String[] { selectedLocale.toString() });
                                siteNode.setProperty(SitesSettings.INACTIVE_LIVE_LANGUAGES, new String[] {});
                                siteNode.setProperty(SitesSettings.INACTIVE_LANGUAGES, new String[] {});
                                siteNode.setProperty(SitesSettings.MANDATORY_LANGUAGES, new String[] {});

                                site = (JCRSiteNode) siteNode;
                            }
                        }

                        session.save();
                    } else {
                        throw new IllegalArgumentException("Site already exists");
                    }

                    JCRSiteNode siteNode = (JCRSiteNode) session.getNode(site.getPath());

                    // continue if the site is added correctly...
                    if (!site.isDefault() && !site.getSiteKey().equals(JahiaSitesService.SYSTEM_SITE_KEY)
                            && JahiaSitesService.getInstance().getSitesNodeList().size() == 2) {
                        JahiaSitesService.getInstance().setDefaultSite(site, session);
                    }

                    JahiaGroupManagerService jgms = ServicesRegistry.getInstance()
                            .getJahiaGroupManagerService();

                    siteNode.setMixLanguagesActive(false);
                    session.save();

                    JCRGroupNode privGroup = jgms.lookupGroup(null,
                            JahiaGroupManagerService.PRIVILEGED_GROUPNAME, session);
                    if (privGroup == null) {
                        privGroup = jgms.createGroup(null, JahiaGroupManagerService.PRIVILEGED_GROUPNAME, null,
                                true, session);
                    }

                    JCRGroupNode adminGroup = jgms.lookupGroup(site.getSiteKey(),
                            JahiaGroupManagerService.SITE_ADMINISTRATORS_GROUPNAME, session);
                    if (adminGroup == null) {
                        adminGroup = jgms.createGroup(site.getSiteKey(),
                                JahiaGroupManagerService.SITE_ADMINISTRATORS_GROUPNAME, null, false, session);
                    }

                    // attach superadmin user (current) to administrators group...
                    if (currentUser != null) {
                        adminGroup.addMember(session.getNode(currentUser.getLocalPath()));
                    }

                    JCRGroupNode sitePrivGroup = jgms.lookupGroup(site.getSiteKey(),
                            JahiaGroupManagerService.SITE_PRIVILEGED_GROUPNAME, session);
                    if (sitePrivGroup == null) {
                        sitePrivGroup = jgms.createGroup(site.getSiteKey(),
                                JahiaGroupManagerService.SITE_PRIVILEGED_GROUPNAME, null, false, session);
                    }
                    // atach site privileged group to server privileged
                    privGroup.addMember(sitePrivGroup);

                    if (!name.equals(JahiaSitesService.SYSTEM_SITE_KEY)) {
                        siteNode.grantRoles("g:" + JahiaGroupManagerService.SITE_PRIVILEGED_GROUPNAME,
                                Collections.singleton("privileged"));
                        siteNode.denyRoles("g:" + JahiaGroupManagerService.PRIVILEGED_GROUPNAME,
                                Collections.singleton("privileged"));
                    }
                    siteNode.grantRoles("g:" + JahiaGroupManagerService.SITE_ADMINISTRATORS_GROUPNAME,
                            Collections.singleton("site-administrator"));
                    session.save();

                    JCRNodeWrapper home = siteNode.addNode("home", "jnt:page");
                    home.setProperty("j:templateName", "home");
                    home.setProperty("j:isHomePage", true);
                    session.save();
                    logger.debug("Site updated with Home Page");
                } catch (RepositoryException e) {
                    logger.warn("Error adding home node", e);
                }

                return site;

            }
        });
    } catch (RepositoryException e) {
        throw new JahiaException("", "", 0, 0, e);
    }
    return site;
}

From source file:org.jahia.modules.external.modules.ModulesDataSource.java

private ExternalData getChildNodeDefinitionData(String path, ExtendedNodeDefinition nodeDefinition,
        boolean unstructured) {
    Map<String, String[]> properties = new HashMap<String, String[]>();
    properties.put(J_AUTO_CREATED, new String[] { String.valueOf(nodeDefinition.isAutoCreated()) });
    properties.put(J_MANDATORY, new String[] { String.valueOf(nodeDefinition.isMandatory()) });
    properties.put(J_ON_PARENT_VERSION,/*from ww  w  .  j a  v a2  s.  c o m*/
            new String[] { OnParentVersionAction.nameFromValue(nodeDefinition.getOnParentVersion()) });
    properties.put(J_PROTECTED, new String[] { String.valueOf(nodeDefinition.isProtected()) });
    String[] requiredPrimaryTypeNames = nodeDefinition.getRequiredPrimaryTypeNames();
    if (requiredPrimaryTypeNames != null) {
        properties.put("j:requiredPrimaryTypes", requiredPrimaryTypeNames);
    }
    String defaultPrimaryTypeName = nodeDefinition.getDefaultPrimaryTypeName();
    if (defaultPrimaryTypeName != null) {
        properties.put("j:defaultPrimaryType", new String[] { defaultPrimaryTypeName });
    }
    ExternalData externalData = new ExternalData(path, path,
            unstructured ? "jnt:unstructuredChildNodeDefinition" : "jnt:childNodeDefinition", properties);

    Map<String, Map<String, String[]>> i18nProperties = new HashMap<String, Map<String, String[]>>();

    for (Locale locale : LanguageCodeConverters.getAvailableBundleLocales()) {
        Map<String, String[]> value = new HashMap<String, String[]>();
        i18nProperties.put(locale.toString(), value);
        value.put(Constants.JCR_TITLE, new String[] { nodeDefinition.getLabel(locale) });
    }

    externalData.setI18nProperties(i18nProperties);
    return externalData;
}

From source file:org.jahia.modules.external.modules.ModulesDataSource.java

private ExternalData getNodeTypeData(String path, ExtendedNodeType nodeType) {
    Map<String, String[]> properties = new HashMap<String, String[]>();
    ExtendedNodeType[] declaredSupertypes = nodeType.getDeclaredSupertypes();
    String supertype = null;/*from w ww. j  a v a 2 s.c  om*/
    List<String> mixins = new ArrayList<String>();
    for (ExtendedNodeType declaredSupertype : declaredSupertypes) {
        if (declaredSupertype.isMixin()) {
            mixins.add(declaredSupertype.getName());
        } else if (supertype == null) {
            supertype = declaredSupertype.getName();
        }
    }
    if (supertype != null) {
        properties.put("j:supertype", new String[] { supertype });
    }
    if (!mixins.isEmpty()) {
        properties.put("j:mixins", mixins.toArray(new String[mixins.size()]));
    }

    properties.put("j:isAbstract", new String[] { String.valueOf(nodeType.isAbstract()) });
    properties.put("j:isQueryable", new String[] { String.valueOf(nodeType.isQueryable()) });
    properties.put("j:hasOrderableChildNodes",
            new String[] { String.valueOf(nodeType.hasOrderableChildNodes()) });
    String itemsType = nodeType.getItemsType();
    if (itemsType != null) {
        properties.put("j:itemsType", new String[] { itemsType });
    }
    List<ExtendedNodeType> mixinExtends = nodeType.getMixinExtends();
    if (mixinExtends != null && !mixinExtends.isEmpty()) {
        Function<ExtendedNodeType, String> transformName = new Function<ExtendedNodeType, String>() {
            public String apply(@Nullable ExtendedNodeType from) {
                return from != null ? from.getName() : null;
            }
        };
        properties.put("j:mixinExtends",
                Collections2.<ExtendedNodeType, String>transform(mixinExtends, transformName)
                        .toArray(new String[mixinExtends.size()]));
    }
    String primaryItemName = nodeType.getPrimaryItemName();
    if (primaryItemName != null) {
        properties.put("j:primaryItemName", new String[] { primaryItemName });
    }
    ExternalData externalData = new ExternalData(path, path,
            nodeType.isMixin() ? JNT_MIXIN_NODE_TYPE : JNT_PRIMARY_NODE_TYPE, properties);
    Map<String, Map<String, String[]>> i18nProperties = new HashMap<String, Map<String, String[]>>();

    for (Locale locale : LanguageCodeConverters.getAvailableBundleLocales()) {
        Map<String, String[]> value = new HashMap<String, String[]>();
        i18nProperties.put(locale.toString(), value);
        value.put(Constants.JCR_TITLE, new String[] { nodeType.getLabel(locale) });
        value.put(Constants.JCR_DESCRIPTION, new String[] { nodeType.getDescription(locale) });
    }

    externalData.setI18nProperties(i18nProperties);
    return externalData;
}

From source file:org.jahia.modules.external.modules.ModulesDataSource.java

private ExternalData getPropertyDefinitionData(String path, ExtendedPropertyDefinition propertyDefinition,
        boolean unstructured) {
    Map<String, String[]> properties = new HashMap<String, String[]>();
    properties.put(J_AUTO_CREATED, new String[] { String.valueOf(propertyDefinition.isAutoCreated()) });
    properties.put(J_MANDATORY, new String[] { String.valueOf(propertyDefinition.isMandatory()) });
    properties.put(J_ON_PARENT_VERSION,//ww w.ja  v  a  2  s .  co  m
            new String[] { OnParentVersionAction.nameFromValue(propertyDefinition.getOnParentVersion()) });
    properties.put(J_PROTECTED, new String[] { String.valueOf(propertyDefinition.isProtected()) });
    properties.put(J_REQUIRED_TYPE,
            new String[] { PropertyType.nameFromValue(propertyDefinition.getRequiredType()) });
    properties.put(J_SELECTOR_TYPE,
            new String[] { SelectorType.nameFromValue(propertyDefinition.getSelector()) });
    Map<String, String> selectorOptions = propertyDefinition.getSelectorOptions();
    List<String> selectorOptionsList = new ArrayList<String>();
    for (Map.Entry<String, String> entry : selectorOptions.entrySet()) {
        String option = entry.getKey();
        String value = entry.getValue();
        if (StringUtils.isNotBlank(value)) {
            option += "='" + value + "'";
        }
        selectorOptionsList.add(option);
    }
    properties.put(J_SELECTOR_OPTIONS, selectorOptionsList.toArray(new String[selectorOptionsList.size()]));
    String[] valueConstraints = propertyDefinition.getValueConstraints();
    if (valueConstraints != null && valueConstraints.length > 0) {
        properties.put(J_VALUE_CONSTRAINTS, valueConstraints);
    }
    Value[] defaultValues = propertyDefinition.getDefaultValuesAsUnexpandedValue();
    if (defaultValues != null && defaultValues.length > 0) {
        try {
            List<String> defaultValuesAsString = JahiaCndWriter.getValuesAsString(defaultValues);
            List<String> unquotedValues = new ArrayList<String>();
            for (String value : defaultValuesAsString) {
                unquotedValues.add(StringUtils.removeEnd(StringUtils.removeStart(value, "'"), "'"));
            }
            properties.put(J_DEFAULT_VALUES, unquotedValues.toArray(new String[unquotedValues.size()]));
        } catch (IOException e) {
            logger.error("Failed to get default values", e);
        }
    }
    properties.put(J_MULTIPLE, new String[] { String.valueOf(propertyDefinition.isMultiple()) });
    String[] availableQueryOperators = propertyDefinition.getAvailableQueryOperators();
    List<String> ops = new ArrayList<String>();
    if (availableQueryOperators != null) {
        for (String op : availableQueryOperators) {
            if (QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO.equals(op)) {
                ops.add(Lexer.QUEROPS_EQUAL);
            } else if (QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO.equals(op)) {
                ops.add(Lexer.QUEROPS_NOTEQUAL);
            } else if (QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN.equals(op)) {
                ops.add(Lexer.QUEROPS_LESSTHAN);
            } else if (QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO.equals(op)) {
                ops.add(Lexer.QUEROPS_LESSTHANOREQUAL);
            } else if (QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN.equals(op)) {
                ops.add(Lexer.QUEROPS_GREATERTHAN);
            } else if (QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO.equals(op)) {
                ops.add(Lexer.QUEROPS_GREATERTHANOREQUAL);
            } else if (QueryObjectModelConstants.JCR_OPERATOR_LIKE.equals(op)) {
                ops.add(Lexer.QUEROPS_LIKE);
            }
        }
        if (!ops.isEmpty()) {
            properties.put(J_AVAILABLE_QUERY_OPERATORS, ops.toArray(new String[ops.size()]));
        }
    }
    properties.put(J_IS_FULL_TEXT_SEARCHABLE,
            new String[] { String.valueOf(propertyDefinition.isFullTextSearchable()) });
    properties.put(J_IS_QUERY_ORDERABLE,
            new String[] { String.valueOf(propertyDefinition.isQueryOrderable()) });
    properties.put(J_IS_FACETABLE, new String[] { String.valueOf(propertyDefinition.isFacetable()) });
    properties.put(J_IS_HIERARCHICAL, new String[] { String.valueOf(propertyDefinition.isHierarchical()) });
    properties.put(J_IS_INTERNATIONALIZED,
            new String[] { String.valueOf(propertyDefinition.isInternationalized()) });
    properties.put(J_IS_HIDDEN, new String[] { String.valueOf(propertyDefinition.isHidden()) });
    properties.put(J_INDEX, new String[] { IndexType.nameFromValue(propertyDefinition.getIndex()) });
    properties.put(J_SCOREBOOST, new String[] { String.valueOf(propertyDefinition.getScoreboost()) });
    String analyzer = propertyDefinition.getAnalyzer();
    if (analyzer != null) {
        properties.put(J_ANALYZER, new String[] { analyzer });
    }
    properties.put(J_ON_CONFLICT_ACTION,
            new String[] { OnConflictAction.nameFromValue(propertyDefinition.getOnConflict()) });
    String itemType = propertyDefinition.getLocalItemType();
    if (itemType != null) {
        properties.put(J_ITEM_TYPE, new String[] { itemType });
    }
    ExternalData externalData = new ExternalData(path, path,
            unstructured ? "jnt:unstructuredPropertyDefinition" : "jnt:propertyDefinition", properties);
    Map<String, Map<String, String[]>> i18nProperties = new HashMap<String, Map<String, String[]>>();

    for (Locale locale : LanguageCodeConverters.getAvailableBundleLocales()) {
        Map<String, String[]> value = new HashMap<String, String[]>();
        i18nProperties.put(locale.toString(), value);
        value.put(Constants.JCR_TITLE, new String[] { propertyDefinition.getLabel(locale) });
    }

    externalData.setI18nProperties(i18nProperties);
    return externalData;
}

From source file:com.edgenius.core.webapp.filter.LocaleFilter.java

public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    //       if(log.isDebugEnabled()){
    //          log.debug("Request URL: " + request.getRequestURI());
    //       }/*from  w w  w  .  j  ava 2  s  . c om*/

    //charset encoding
    if (!StringUtils.isEmpty(this.encoding))
        request.setCharacterEncoding(encoding);
    else
        request.setCharacterEncoding(Constants.UTF8);

    String direction = null;
    Locale preferredLocale = null;
    TimeZone timezone = null;
    HttpSession session = request.getSession(false);
    if (getUserService() != null) { //for Install mode, it will return null
        User user = getUserService().getUserByName(request.getRemoteUser());
        if (user != null && !user.isAnonymous()) {
            //locale
            UserSetting set = user.getSetting();
            String userLang = set.getLocaleLanguage();
            String userCountry = set.getLocaleCountry();
            if (userLang != null && userCountry != null) {
                preferredLocale = new Locale(userLang, userCountry);
            }
            //text direction in HTML 
            direction = set.getDirection();
            //timezone
            if (set.getTimeZone() != null)
                timezone = TimeZone.getTimeZone(set.getTimeZone());
        }
    }
    if (preferredLocale == null) {
        if (Global.DetectLocaleFromRequest) {
            Locale locale = request.getLocale();
            if (locale != null) {
                preferredLocale = locale;
            }
        }
        if (preferredLocale == null) {
            preferredLocale = Global.getDefaultLocale();
        }
    }

    if (direction == null) {
        direction = Global.DefaultDirection;
    }

    if (timezone == null) {
        if (session != null) {
            //try to get timezone from HttpSession, which will be intial set in SecurityControllerImpl.checkLogin() method
            timezone = (TimeZone) session.getAttribute(Constants.TIMEZONE);
        }
        if (timezone == null)
            timezone = TimeZone.getTimeZone(Global.DefaultTimeZone);
    }

    //set locale for STURTS and JSTL
    // set the time zone - must be set for dates to display the time zone
    if (session != null) {
        Config.set(session, Config.FMT_LOCALE, preferredLocale);
        session.setAttribute(Constants.DIRECTION, direction);
        Config.set(session, Config.FMT_TIME_ZONE, timezone);
    }

    //replace request by LocaleRequestWrapper
    if (!(request instanceof LocaleRequestWrapper)) {
        request = new LocaleRequestWrapper(request, preferredLocale);
        LocaleContextConfHolder.setLocale(preferredLocale);
    }

    if (chain != null) {
        request.setAttribute(PREFERRED_LOCALE, preferredLocale.toString());
        chain.doFilter(request, response);
    }
    // Reset thread-bound LocaleContext.
    LocaleContextConfHolder.setLocaleContext(null);
}

From source file:org.eclipse.jubula.client.core.businessprocess.ExternalTestDataBP.java

/**
 * Creates a DataTable of the given file name with the given Locale or 
 * gets it from the cache if available.//from   w  w  w .java 2 s. co  m
 * @param dataDir
 *      directory for data files
 * @param fileName the name of the data source
 * @param locale the local of the  data
 * @return a DataTable
 * @throws JBException id data source is not supported
 */
public DataTable createDataTable(File dataDir, String fileName, Locale locale) throws JBException {

    File dataFile = new File(dataDir, fileName);
    DataTable dataTable = m_dataTableCache.get(dataFile);
    if (dataTable != null) {
        return dataTable;
    }
    String dataFileName = String.valueOf(dataFile);
    try {
        IDataImportFilter filter = getFilterFromFileType(fileName);
        if (filter != null) {
            dataTable = filter.parse(dataDir, fileName, locale);
            m_dataTableCache.put(dataFile, dataTable);
            return dataTable;
        }
        LOG.error(Messages.DataSource + StringConstants.COLON + StringConstants.SPACE
                + StringConstants.APOSTROPHE + dataFileName + StringConstants.APOSTROPHE + StringConstants.SPACE
                + Messages.NotSupported);
        throw new JBException(NLS.bind(Messages.ErrorMessageNOT_SUPP_DATASOURCE, dataFileName),
                MessageIDs.E_NOT_SUPP_DATASOURCE);
    } catch (IOException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.ErrorReadingFile + StringConstants.COLON + StringConstants.SPACE + dataFileName,
                    e);
        }
        throw new JBException(NLS.bind(Messages.ErrorMessageNOT_SUPP_DATASOURCE, dataFileName),
                MessageIDs.E_DATASOURCE_FILE_IO);
    } catch (DataReadException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.ErrorReadingFile + StringConstants.COLON + StringConstants.SPACE + dataFileName,
                    e);
        }
        throw new JBException(NLS.bind(Messages.ErrorMessageDATASOURCE_READ_ERROR, dataFileName),
                MessageIDs.E_DATASOURCE_READ_ERROR);
    } catch (NoSupportForLocaleException e) {
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.LocaleNotSupported + StringConstants.COLON + StringConstants.SPACE
                    + String.valueOf(locale) + StringConstants.SPACE + Messages.InDataSource
                    + StringConstants.COLON + StringConstants.SPACE + dataFileName);
        }
        throw new JBException(
                NLS.bind(Messages.ErrorMessageDATASOURCE_LOCALE_NOTSUPPORTED,
                        new Object[] { locale.toString(), locale.getDisplayLanguage() }),
                MessageIDs.E_DATASOURCE_LOCALE_NOTSUPPORTED);
    }
}

From source file:com.ifoer.expeditionphone.MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(Flags.FLAG8, Flags.FLAG8);
    contexts = this;
    this.loadSpecail = getIntent().getBooleanExtra("loadSpecail", false);
    FROMPATH = Constant.assestsPath;/*from w ww . j  a  v a 2s. c  om*/
    Locale locale = Locale.getDefault();
    country = MainMenuActivity.country;
    if (country == null) {
        country = locale.getCountry();
    }
    this.lanName = AndroidToLan.toLan(country);
    this.language = locale.getLanguage();
    Constant.language = locale.toString();
    if (this.loadSpecail) {
        setContentView(C0136R.layout.specia_function2);
        this.SpecialGridView = (GridView) findViewById(C0136R.id.main_WorkSpace);
        this.SpecialGridView.setHorizontalSpacing(15);
        this.SpecialGridView.setVerticalSpacing(15);
        this.SpecialGridView.setSelector(C0136R.color.transparent);
        this.SpecialGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE);
        this.mSpecilaBaseDiagAdapeter = createBaseDiagAdapter2(this.specialList);
        this.SpecialGridView.setAdapter(this.mSpecilaBaseDiagAdapeter);
        this.SpecialGridView.setOnItemClickListener(this);
    } else {
        setContentView(C0136R.layout.base_diagnose);
        LinearLayout lineLinear = (LinearLayout) findViewById(C0136R.id.diagnose_line2);
        this.mSlidePoinView = new SlidePointView(this);
        lineLinear.addView(this.mSlidePoinView);
        this.mSlidePoinView.postInvalidate();
        this.mChinaCarGridView = new GridView(this);
        this.mAsiaCarGridView = new GridView(this);
        this.mEuroCarGridView = new GridView(this);
        this.mAmericaCarGridView = new GridView(this);
        this.mAmericaCarGridView.setHorizontalSpacing(15);
        this.mAmericaCarGridView.setVerticalSpacing(15);
        this.mAsiaCarGridView.setHorizontalSpacing(15);
        this.mAsiaCarGridView.setVerticalSpacing(15);
        this.mEuroCarGridView.setHorizontalSpacing(15);
        this.mEuroCarGridView.setVerticalSpacing(15);
        this.mAmericaCarGridView.setVerticalScrollBarEnabled(false);
        this.mAsiaCarGridView.setVerticalScrollBarEnabled(false);
        this.mEuroCarGridView.setVerticalScrollBarEnabled(false);
        this.mAsiaCarGridView.setSelector(C0136R.color.transparent);
        this.mEuroCarGridView.setSelector(C0136R.color.transparent);
        this.mAmericaCarGridView.setSelector(C0136R.color.transparent);
        LayoutParams linearParams = new LayoutParams(-2, -2);
        linearParams.width = C0136R.dimen.itemSize;
        linearParams.height = C0136R.dimen.itemSize;
        this.mChinaCarGridView.setLayoutParams(linearParams);
        this.mAsiaCarGridView.setLayoutParams(linearParams);
        this.mEuroCarGridView.setLayoutParams(linearParams);
        this.mAmericaCarGridView.setLayoutParams(linearParams);
        this.mChinaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE);
        this.mAsiaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE);
        this.mEuroCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE);
        this.mAmericaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE);
    }
    MyApplication.getInstance().addActivity(this);
    createMainActivity();
    MySharedPreferences.getSharedPref(this).edit().putString("CurrentPosition", Constant.language).commit();
    MySharedPreferences.setString(contexts, MySharedPreferences.generateOperatingRecord, Contact.RELATION_ASK);
    if (MainMenuActivity.database != null) {
        database = MainMenuActivity.database;
    } else {
        database = DBDao.getInstance(this).getConnection();
    }
    new Thread(new UpgradeRunnable(contexts)).start();
    registerBoradcastReceiver();
    try {
        dataDir = getPackageManager().getApplicationInfo(getPackageName(), 0).dataDir;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    try {
        serialPort = new SerialPortManager().getSerialPort();
    } catch (InvalidParameterException e2) {
        e2.printStackTrace();
    } catch (SecurityException e3) {
        e3.printStackTrace();
    } catch (Exception e4) {
        e4.printStackTrace();
    }
    if (MySharedPreferences.share == null) {
        MySharedPreferences.getSharedPref(this);
    }
}