List of usage examples for java.util Locale toString
@Override public final String toString()
Locale
object, consisting of language, country, variant, script, and extensions as below: language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensionsLanguage is always lower case, country is always upper case, script is always title case, and extensions are always lower case.
From source file:com.concursive.connect.web.utils.ClientType.java
/** * Sets the parameters attribute of the ClientType object * * @param request The new parameters value *//*from w ww. j av a 2 s .c o m*/ public void setParameters(HttpServletRequest request) { this.type = HTML_BROWSER; String wapCheck = request.getHeader("x-up-subno"); if (wapCheck != null) { LOG.trace("WAP String: " + wapCheck); } if (wapCheck != null) { this.type = WAP_BROWSER; } String header = request.getHeader("USER-AGENT"); if (header == null) { header = request.getHeader("User-Agent"); } if (header == null) { header = request.getHeader("user-agent"); } if (header != null) { header = header.toLowerCase(); LOG.debug("Client browser header string: " + header); // Determine OS if (header.contains("linux")) { os = LINUX; } else if (header.contains("mac_powerpc")) { os = MAC; } else if (header.contains("macintosh")) { os = MAC; } if (header.contains("msie")) { //User-Agent: mozilla/5.0 (compatible; msie 9.0; windows nt 6.0; wow64; trident/5.0) //User-Agent: mozilla/4.0 (compatible; msie 8.0; windows nt 6.0; wow64; trident/4.0; slcc1; .net clr 2.0.50727; media center pc 5.0; .net clr 3.0.30729) //User-Agent: mozilla/4.0 (compatible; msie 7.0; windows nt 6.0; wow64; slcc1; .net clr 2.0.50727; media center pc 5.0; .net clr 3.0.30729) //User-Agent: mozilla/4.0 (compatible; msie 6.0; windows 98; .net clr 1.0.3705) //User-Agent: mozilla/4.0 (compatible; msie 5.01; windows nt 5.0) this.id = IE; //Search for "msie x" int idx = header.indexOf("msie "); if (idx + 5 < header.length() && header.indexOf(";", idx) > -1) { version = parseVersion(header.substring(header.indexOf("msie ") + 5, header.indexOf(";", header.indexOf("msie ")))); } } else if (header.contains("applewebkit")) { //User-Agent: mozilla/5.0 (macintosh; intel mac os x 10_8) applewebkit/536.25 (khtml, like gecko) version/6.0 safari/536.25 //User-Agent: mozilla/5.0 (macintosh; intel mac os x 10_8_0) applewebkit/535.2 (khtml, like gecko) chrome/15.0.854.0 safari/535.2 //User-Agent: mozilla/5.0 (macintosh; u; ppc mac os x; en) applewebkit/125.2 (khtml, like gecko) safari/125.7 //User-Agent: mozilla/5.0 (macintosh; u; ppc mac os x; en) applewebkit/125.2 (khtml, like gecko) safari/125.8 this.id = APPLEWEBKIT; // Header String: mozilla/5.0 (iphone; u; cpu like mac os x; en) applewebkit/420+ (khtml, like gecko) version/3.0 mobile/1a543a safari/419.3 // Browser Id: applewebkit // Browser Version: 420.0 if (header.contains("mobile") || header.contains("iphone")) { mobileFound = true; mobile = true; } int idx = header.indexOf("applewebkit/"); if (idx + 12 < header.length() && header.indexOf("(khtml", idx) > -1) { version = parseVersion(header.substring(idx + 12, header.indexOf("(khtml"))); } } else if (header.contains("opera")) { //User-Agent: opera/9.80 (macintosh; intel mac os x 10.8.0; u; en) presto/2.10.289 version/12.01 //User-Agent: opera/9.80 (macintosh; intel mac os x; u; en) presto/2.2.15 version/10.00 //User-Agent: mozilla/4.0 (compatible; msie 6.0; msie 5.5; windows 98) opera 7.02 [en] //User-Agent: mozilla/3.0 (windows 98; u) opera 7.02 [en] //User-Agent: opera/9.25 (macintosh; intel mac os x; u; en) this.id = OPERA; if (header.indexOf("[", header.indexOf("opera")) != -1) { version = parseVersion(header .substring(header.indexOf("opera") + 5, header.indexOf("[", header.indexOf("opera"))) .trim()); } if (header.indexOf("(", header.indexOf("opera")) != -1) { version = parseVersion(header .substring(header.indexOf("opera") + 5, header.indexOf("(", header.indexOf("opera"))) .trim()); } } else if (header.contains("mozilla")) { //User-Agent: mozilla/5.0 (macintosh; intel mac os x 10.8; rv:7.0.1) gecko/20100101 firefox/7.0.1 //User-Agent: mozilla/5.0 (x11; u; linux i686; en-us; rv:1.3b) gecko/20030211 //User-Agent: mozilla/5.0 (macintosh; u; ppc mac os x; en-us; rv:1.0.1) gecko/20021104 chimera/0.6 //User-Agent: mozilla/5.0 (x11; u; linux i686; en-us; rv:1.0.1) gecko/20020830 //User-Agent: mozilla/5.0 (windows; u; win98; en-us; rv:1.0.2) gecko/20030208 netscape/7.02 if (header.contains("gecko/") && header.contains("rv:")) { this.id = MOZILLA; int idx = header.indexOf("rv:"); if (idx + 3 < header.length() && header.indexOf(")", idx) > -1) { version = parseVersion(header.substring(idx + 3, header.indexOf(")", idx))); versionString = header.substring(idx + 3, header.indexOf(")", idx)); } } else if (header.contains("gecko")) { this.id = NETSCAPE; version = 6; } else { //Just make a default this.id = NETSCAPE; this.version = 4; } } else if (header.contains("iphone") || header.contains("appcelerator titanium")) { // handles requests from iOS devices using this platform this.id = APPLEWEBKIT; mobileFound = true; mobile = true; } else { this.id = NETSCAPE; this.version = 4; } // Test for a few bots to reduce tracker counts if (header.contains("googlebot/")) { // Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) bot = true; } else if (header.contains("yahoo! slurp")) { // Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp) bot = true; } else if (header.contains("bingbot/")) { // Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) bot = true; } else if (header.contains("msnbot-media/")) { // msnbot-media/1.1 (+http://search.msn.com/msnbot.htm) bot = true; } else if (header.contains("baiduspider/")) { // Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html) bot = true; } else if (header.contains("yandexbot/")) { // Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots) bot = true; } else if (header.contains("ezooms/")) { // Mozilla/5.0 (compatible; Ezooms/1.0; ezooms.bot@gmail.com) bot = true; } else if (header.contains("seznambot/")) { // SeznamBot/3.0 (+http://fulltext.sblog.cz/) // SeznamBot/2.0 (+http://fulltext.sblog.cz/robot/) // SeznamBot/3.0-beta (+http://fulltext.sblog.cz/) bot = true; } else if (header.contains("y!j-bro/yfsj crawler")) { // Y!J-BRO/YFSJ crawler (compatible; Mozilla 4.0; MSIE 5.5; http://help.yahoo.co.jp/help/jp/search/indexing/indexing-15.html; YahooFeedSeekerJp/2.0) bot = true; } else if (header.contains("voilabot")) { bot = true; } else if (header.contains("zyborg")) { bot = true; } else if (header.contains("fast-webcrawler")) { bot = true; } else if (header.contains("deepindex")) { bot = true; } else if (header.contains("ask jeeves")) { bot = true; } else if (header.contains("gigabot")) { bot = true; } else if (header.contains("openbot")) { bot = true; } LOG.trace("Browser Id: " + getBrowserId()); LOG.trace("Browser Version: " + getBrowserVersion()); LOG.trace("Browser VersionString: " + versionString); LOG.trace("Browser O/S: " + getOsString()); } String acceptLanguage = request.getHeader("Accept-Language"); if (acceptLanguage != null) { StringTokenizer languages = new StringTokenizer(acceptLanguage, ","); if (languages.hasMoreTokens()) { String firstLanguage = languages.nextToken(); if (firstLanguage.contains(";")) { firstLanguage = firstLanguage.substring(0, firstLanguage.indexOf(";")); } firstLanguage = firstLanguage.trim(); try { Locale locale = null; int index = firstLanguage.indexOf("-"); if (index > -1) { locale = new Locale(firstLanguage.substring(0, index), firstLanguage.substring(index + 1)); } else { locale = new Locale(firstLanguage, ""); } language = locale.toString(); if (language != null) { LOG.trace("Language: " + language); } } catch (Exception e) { language = "en_US"; } } } // During the logout process, re-use the previous language setting if (request.getAttribute("webSiteLanguage") != null) { language = (String) request.getAttribute("webSiteLanguage"); } referer = request.getHeader("Referer"); if (referer != null) { LOG.trace("Referer: " + referer); } //TODO: Log this new user's information for reference }
From source file:com.jfinal.core.Controller.java
private Locale getLocaleFromCookie() { Cookie cookie = getCookieObject(I18N_LOCALE); if (cookie != null) { return I18N.localeFromString(cookie.getValue()); } else {/*from w ww .j a v a 2s. com*/ Locale defaultLocale = I18N.getDefaultLocale(); setLocaleToCookie(defaultLocale); return I18N.localeFromString(defaultLocale.toString()); } }
From source file:org.alfresco.repo.search.impl.lucene.LuceneQueryParser.java
/** * @param field String//from w ww . ja v a2 s .co m * @param queryText String * @param subQueryBuilder SubQuery * @param analysisMode AnalysisMode * @param luceneFunction LuceneFunction * @param expandedFieldName String * @param tokenisationMode IndexTokenisationMode * @param booleanQuery BooleanQuery * @param mlAnalysisMode MLAnalysisMode * @param locale Locale * @throws ParseException */ protected void addTextAttributeQuery(String field, String queryText, SubQuery subQueryBuilder, AnalysisMode analysisMode, LuceneFunction luceneFunction, String expandedFieldName, IndexTokenisationMode tokenisationMode, BooleanQuery booleanQuery, MLAnalysisMode mlAnalysisMode, Locale locale) throws ParseException { String textFieldName = expandedFieldName; if ((tokenisationMode == IndexTokenisationMode.BOTH) && ((analysisMode == AnalysisMode.IDENTIFIER) || (analysisMode == AnalysisMode.LIKE))) { if ((null != locale) && (0 == locale.toString().length())) { textFieldName += FIELD_NO_LOCALE_SUFFIX; } else { textFieldName = textFieldName + "." + locale + FIELD_SORT_SUFFIX; } } boolean lowercaseExpandedTerms = getLowercaseExpandedTerms(); try { switch (tokenisationMode) { case BOTH: switch (analysisMode) { default: case DEFAULT: case TOKENISE: addLocaleSpecificTokenisedMLOrTextAttribute(queryText, subQueryBuilder, analysisMode, luceneFunction, booleanQuery, locale, textFieldName); break; case IDENTIFIER: case FUZZY: case PREFIX: case WILD: case LIKE: setLowercaseExpandedTerms(false); addLocaleSpecificUntokenisedMLOrTextAttribute(field, queryText, subQueryBuilder, analysisMode, luceneFunction, booleanQuery, mlAnalysisMode, locale, textFieldName); break; } break; case FALSE: setLowercaseExpandedTerms(false); addLocaleSpecificUntokenisedMLOrTextAttribute(field, queryText, subQueryBuilder, analysisMode, luceneFunction, booleanQuery, mlAnalysisMode, locale, textFieldName); break; case TRUE: default: switch (analysisMode) { case DEFAULT: case TOKENISE: case IDENTIFIER: addLocaleSpecificTokenisedMLOrTextAttribute(queryText, subQueryBuilder, analysisMode, luceneFunction, booleanQuery, locale, expandedFieldName); break; case FUZZY: case PREFIX: case WILD: case LIKE: addLocaleSpecificUntokenisedMLOrTextAttribute(field, queryText, subQueryBuilder, analysisMode, luceneFunction, booleanQuery, mlAnalysisMode, locale, textFieldName); break; } break; } } finally { setLowercaseExpandedTerms(lowercaseExpandedTerms); } }
From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java
private void validateSdfFormatFdpParseEquality(final String format, final Locale locale, final TimeZone tz, final DateParser fdp, final Date in, final int year, final Date cs) throws ParseException { final SimpleDateFormat sdf = new SimpleDateFormat(format, locale); sdf.setTimeZone(tz);/*from w w w . ja v a 2 s .co m*/ if (format.equals(SHORT_FORMAT)) { sdf.set2DigitYearStart(cs); } final String fmt = sdf.format(in); try { final Date out = fdp.parse(fmt); assertEquals(locale.toString() + " " + in + " " + format + " " + tz.getID(), in, out); } catch (final ParseException pe) { if (year >= 1868 || !locale.getCountry().equals("JP")) {// LANG-978 throw pe; } } }
From source file:org.jahia.services.mail.MailServiceImpl.java
@Override public void sendMessageWithTemplate(String template, Map<String, Object> boundObjects, String toMail, String fromMail, String ccList, String bcclist, Locale locale, String templatePackageName) throws RepositoryException, ScriptException { // Resolve template : ScriptEngine scriptEngine = scriptEngineUtils.scriptEngine(StringUtils.substringAfterLast(template, ".")); ScriptContext scriptContext = new SimpleScriptContext(); //try if it is multilingual String suffix = StringUtils.substringAfterLast(template, "."); String languageMailConfTemplate = template.substring(0, template.length() - (suffix.length() + 1)) + "_" + locale.toString() + "." + suffix; JahiaTemplatesPackage templatePackage = templateManagerService.getTemplatePackage(templatePackageName); Resource templateRealPath = templatePackage.getResource(languageMailConfTemplate); if (templateRealPath == null) { templateRealPath = templatePackage.getResource(template); }/* w w w .j a va 2s.c o m*/ InputStream scriptInputStream = null; try { scriptInputStream = templateRealPath.getInputStream(); } catch (IOException e) { logger.error(e.getMessage(), e); } if (scriptInputStream != null) { ResourceBundle resourceBundle; if (templatePackageName == null) { String resourceBundleName = StringUtils.substringBeforeLast(Patterns.SLASH .matcher(StringUtils.substringAfter(Patterns.WEB_INF.matcher(template).replaceAll(""), "/")) .replaceAll("."), "."); resourceBundle = ResourceBundles.get(resourceBundleName, locale); } else { resourceBundle = ResourceBundles.get(ServicesRegistry.getInstance().getJahiaTemplateManagerService() .getTemplatePackage(templatePackageName), locale); } final Bindings bindings = new SimpleBindings(); bindings.put("bundle", resourceBundle); bindings.putAll(boundObjects); Reader scriptContent = null; // Subject String subject; try { String subjectTemplatePath = StringUtils.substringBeforeLast(template, ".") + ".subject." + StringUtils.substringAfterLast(template, "."); InputStream stream = templatePackage.getResource(subjectTemplatePath).getInputStream(); scriptContent = templateCharset != null ? new InputStreamReader(stream, templateCharset) : new InputStreamReader(stream); scriptContext.setBindings(bindings, ScriptContext.ENGINE_SCOPE); scriptContext.setBindings(scriptEngine.getContext().getBindings(ScriptContext.GLOBAL_SCOPE), ScriptContext.GLOBAL_SCOPE); scriptContext.setWriter(new StringWriter()); scriptEngine.eval(scriptContent, scriptContext); subject = scriptContext.getWriter().toString().trim(); } catch (Exception e) { logger.warn("Not able to render mail subject using " + StringUtils.substringBeforeLast(template, ".") + ".subject." + StringUtils.substringAfterLast(template, ".") + " template file - set org.jahia.services.mail.MailService in debug for more information"); if (logger.isDebugEnabled()) { logger.debug("generating the mail subject throw an exception : ", e); } subject = resourceBundle.getString( StringUtils.substringBeforeLast(StringUtils.substringAfterLast(template, "/"), ".") + ".subject"); } finally { IOUtils.closeQuietly(scriptContent); } try { try { scriptContent = templateCharset != null ? new InputStreamReader(scriptInputStream, templateCharset) : new InputStreamReader(scriptInputStream); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } scriptContext.setWriter(new StringWriter()); scriptContext.setErrorWriter(new StringWriter()); // The following binding is necessary for JavaScript, which // doesn't offer a console by default. bindings.put("out", new PrintWriter(scriptContext.getWriter())); scriptContext.setBindings(bindings, ScriptContext.ENGINE_SCOPE); scriptEngine.eval(scriptContent, scriptContext); StringWriter writer = (StringWriter) scriptContext.getWriter(); String body = writer.toString(); sendMessage(fromMail, toMail, ccList, bcclist, subject, null, body); } finally { IOUtils.closeQuietly(scriptContent); } } else { logger.warn("Cannot send mail, template [" + template + "] from module [" + templatePackageName + "] not found"); } }
From source file:org.betaconceptframework.astroboa.portal.utility.SyndicationFeedGenerator.java
public SyndFeed generateFeedForResourceList(ResourceResponse<ContentObject, T> resourceResponse, String feedType, String feedTitle, String feedDescription, String feedImageURL, String portalHost, String portalContext, TimeZone timeZone, Locale locale) { try {/*from w w w. ja v a 2s . c om*/ List<ContentObject> contentObjectList = resourceResponse.getResourceRepresentation(); SyndFeed feed = new SyndFeedImpl(); if (!(SyndicationFeedType.RSS_VERSION_2_0.equals(feedType) || SyndicationFeedType.RSS_VERSION_1_0.equals(feedType) || SyndicationFeedType.ATOM_VERSION_1_0.equals(feedType))) { logger.warn("Feed Type: " + feedType + " is not supported. An null feed will be returned"); return null; } feed.setFeedType(feedType); String currentLocale = null; if (locale != null) { currentLocale = locale.toString(); } else { locale = new Locale("el"); currentLocale = PortalStringConstants.DEFAULT_LOCALE; } if (timeZone == null) { timeZone = TimeZone.getDefault(); } feed.setTitle(generateFeedTitle(resourceResponse, feedTitle, currentLocale)); String feedLinkURL = generateFeedLink(resourceResponse, portalHost, portalContext); feed.setLink(feedLinkURL); feed.setDescription(generateFeedDescription(resourceResponse, feedDescription, currentLocale)); feed.setPublishedDate(GregorianCalendar.getInstance(timeZone, locale).getTime()); if (StringUtils.isNotBlank(feedImageURL)) { SyndImage syndImage = new SyndImageImpl(); syndImage.setTitle("Logo"); syndImage.setUrl(feedImageURL); syndImage.setLink(feedLinkURL); feed.setImage(syndImage); } List<SyndEntry> entries = new ArrayList<SyndEntry>(); SyndEntry entry; for (ContentObject contentObject : contentObjectList) { entry = new SyndEntryImpl(); StringProperty titleProperty = (StringProperty) contentObject.getCmsProperty("profile.title"); if (titleProperty != null && StringUtils.isNotBlank(titleProperty.getSimpleTypeValue())) { entry.setTitle( ((StringProperty) contentObject.getCmsProperty("profile.title")).getSimpleTypeValue()); } else { // if no title exists skip this entry continue; } BinaryProperty thumbnailProperty = null; BinaryProperty imageProperty = null; if (contentObject.getTypeDefinition().hasCmsPropertyDefinition("thumbnail")) { thumbnailProperty = (BinaryProperty) contentObject.getCmsProperty("thumbnail"); } if (contentObject.getTypeDefinition().hasCmsPropertyDefinition("image")) { imageProperty = (BinaryProperty) contentObject.getCmsProperty("image"); } StringProperty descriptionProperty = (StringProperty) contentObject .getCmsProperty("profile.description"); // we will generate a description if at least a thumbnail or a description exists URL thumbnailURL = null; SyndContent syndContent = new SyndContentImpl(); if (thumbnailProperty != null && thumbnailProperty.getSimpleTypeValue() != null) { //thumbnailURL = new URL("http://" + portalHost + "/resource-api/f/binaryChannel/" + thumbnailProperty.getSimpleTypeValue().getFileAccessInfo()); thumbnailURL = new URL("http://" + portalHost + thumbnailProperty.getSimpleTypeValue() .buildResourceApiURL(null, null, null, null, null, false, true)); syndContent.setValue("<img src=\"" + thumbnailURL.toString() + "\"" + "</img>"); } if (descriptionProperty != null && StringUtils.isNotBlank(descriptionProperty.getSimpleTypeValue())) { if (StringUtils.isBlank(syndContent.getValue())) { syndContent.setValue(((StringProperty) contentObject.getCmsProperty("profile.description")) .getSimpleTypeValue()); } else { syndContent.setValue(syndContent.getValue() + "<p>" + ((StringProperty) contentObject.getCmsProperty("profile.description")) .getSimpleTypeValue() + "</p>"); } } //Raise event to allow users to add custom information related to syndication feed entry Events.instance().raiseEvent(PortalEventNames.EVENT_CONTENT_OBJECT_ADD_SYNDICATION_FEED_CONTENT, contentObject, syndContent); if (StringUtils.isNotBlank(syndContent.getValue())) { entry.setDescription(syndContent); entry.setContents(Collections.singletonList(syndContent)); } entry.setLink(generateFeedEntryLink(contentObject.getId(), portalHost, portalContext)); // check for image and thumbnail to create a MediaRSS entry if (imageProperty != null && imageProperty.hasValues()) { //It may be the case that image is a multiple property BinaryChannel image = null; if (imageProperty.getPropertyDefinition() != null) { if (imageProperty.getPropertyDefinition().isMultiple()) { image = imageProperty.getSimpleTypeValues().get(0); } else { image = imageProperty.getSimpleTypeValue(); } } if (image != null) { MediaContent[] mediaContents = new MediaContent[1]; //MediaContent mediaContent = new MediaContent( new UrlReference("http://" + portalHost + "/resource-api/f/binaryChannel/" + imageProperty.getSimpleTypeValue().getFileAccessInfo())); MediaContent mediaContent = new MediaContent(new UrlReference("http://" + portalHost + image.buildResourceApiURL(null, null, null, null, null, false, true))); mediaContents[0] = mediaContent; if (thumbnailURL != null) { Metadata md = new Metadata(); Thumbnail[] thumbs = new Thumbnail[1]; thumbs[0] = new Thumbnail(thumbnailURL.toURI()); md.setThumbnail(thumbs); mediaContent.setMetadata(md); } MediaEntryModuleImpl module = new MediaEntryModuleImpl(); module.setMediaContents(mediaContents); entry.getModules().add(module); } } CalendarProperty webPublicationProperty = (CalendarProperty) contentObject .getCmsProperty("webPublication.webPublicationStartDate"); if (webPublicationProperty != null && webPublicationProperty.getSimpleTypeValue() != null) { entry.setPublishedDate(webPublicationProperty.getSimpleTypeValueAsDate()); } else { CalendarProperty lastModificationDate = (CalendarProperty) contentObject .getCmsProperty("profile.modified"); entry.setPublishedDate(lastModificationDate.getSimpleTypeValueAsDate()); } entries.add(entry); } feed.setEntries(entries); return feed; } catch (Exception e) { logger.error("An error occured while creating the feed", e); return null; } }
From source file:com.assetmanager.service.auth.UserDetailsServiceImpl.java
/** * Adds a user./*from w w w. j ava 2 s .c o m*/ * * @param user the user * @param locale the locale */ @Override @Transactional public final void addUser(final UserAccount user, final Locale locale) { final UserAccount cachedUser = (UserAccount) memcacheService.get(user.getUsername()); if (cachedUser != null) { throw new DuplicateUserException(); } final Query query = entityManager.createQuery("SELECT u FROM UserAccount u WHERE username = :username"); query.setParameter(USERNAME, user.getUsername()); @SuppressWarnings("unchecked") final List results = query.getResultList(); if (results != null && !results.isEmpty()) { throw new DuplicateUserException(); } entityManager.persist(user); memcacheService.put(user.getUsername(), user, Expiration.byDeltaSeconds(DEFAULT_EXPIRATION)); final TaskOptions taskOptions = TaskOptions.Builder.withUrl(mailTaskUrl) .param("username", user.getUsername()).param("locale", locale.toString()); final Queue queue = QueueFactory.getQueue(mailTaskName); queue.add(datastoreService.getCurrentTransaction(), taskOptions); }
From source file:org.codice.ddf.admin.core.impl.ConfigurationAdminImpl.java
public ObjectClassDefinition getObjectClassDefinition(Bundle bundle, String pid) { Locale locale = Locale.getDefault(); if (bundle != null) { MetaTypeService mts = this.getMetaTypeService(); if (mts != null) { MetaTypeInformation mti = mts.getMetaTypeInformation(bundle); if (mti != null) { // see #getObjectClasses( final IdGetter idGetter, final String locale ) try { return mti.getObjectClassDefinition(pid, locale.toString()); } catch (IllegalArgumentException e) { // MetaTypeProvider.getObjectClassDefinition might throw illegal // argument exception. So we must catch it here, otherwise the // other configurations will not be shown // See https://issues.apache.org/jira/browse/FELIX-2390 // https://issues.apache.org/jira/browse/FELIX-3694 }/*from w w w .j ava2 s . c o m*/ } } } // fallback to nothing found return null; }
From source file:org.eclipse.jubula.client.archive.XmlExporter.java
/** * Write the information from the Object to its corresponding XML element. * /* w w w . j a va 2 s . c o m*/ * @param xml * The XML element to be filled * @param po * The persistent object which contains the information */ private void fillAUT(Aut xml, IAUTMainPO po) { xml.setId(i2id(TABLE_AUT, po.getId())); xml.setName(po.getName()); xml.setAutToolkit(po.getToolkit()); xml.setGenerateNames(po.isGenerateNames()); ObjectMapping om = xml.addNewObjectMapping(); fillObjectMapping(om, po.getObjMap()); for (Locale l : po.getLangHelper().getLanguageList()) { xml.addLanguage(l.toString()); } // Sort the list of AUT Configurations alphabetically by name List<IAUTConfigPO> sortedAutConfigs = new ArrayList<IAUTConfigPO>(po.getAutConfigSet()); Collections.sort(sortedAutConfigs, new Comparator<IAUTConfigPO>() { public int compare(IAUTConfigPO autConfig1, IAUTConfigPO autConfig2) { return autConfig1.getName().compareTo(autConfig2.getName()); } }); for (IAUTConfigPO conf : sortedAutConfigs) { AutConfig xmlConf = xml.addNewConfig(); fillAUTConfig(xmlConf, conf); } for (String autId : po.getAutIds()) { xml.addAutId(autId); } }