only return a instance if the Resource is a valid bundle, otherwise it returns null

@param res
@return
977159
public static BundleFile newInstance(Resource res) {

	try {
	    BundleFile bf = new BundleFile(res);
	    if (bf.isBundle()) return bf;
	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	}

	return null;
    }
318972
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName, boolean processingBundle) {

		Reader rd = null;
		FileInputStream fis = (FileInputStream) getResourceAsStream(resourceName);
		if (fis != null) {
			FileChannel inchannel = fis.getChannel();
			rd = Channels.newReader(inchannel, charset.newDecoder(), -1);
		}

		return rd;
	}
938162
public boolean getCustomBundleBooleanProperty(String bundleName, String key) {
		return Boolean.parseBoolean(props.getProperty(
				prefix + PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_PROPERTY + bundleName + key, "false"));
	}
734597
public static Uri getUriFromResource(@NonNull Context context, @AnyRes int resId) throws Resources.NotFoundException {
        /** Return a Resources instance for your application's package. */
        Resources res = context.getResources();
        /**
         * Creates a Uri which parses the given encoded URI string.
         * @param uriString an RFC 2396-compliant, encoded URI
         * @throws NullPointerException if uriString is null
         * @return Uri for this given uri string
         */
        /** return uri */
        return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE +
                "://" + res.getResourcePackageName(resId)
                + '/' + res.getResourceTypeName(resId)
                + '/' + res.getResourceEntryName(resId));
    }
268623
public static Bundle getBundle(BundleContext bundleContext, String resourceAdapter) throws ConfigEvaluatorException {

        Bundle bundle = null;

        if (JMSResourceDefinitionConstants.RESOURCE_ADAPTER_WASJMS.equals(resourceAdapter)
            || JMSResourceDefinitionConstants.RESOURCE_ADAPTER_WMQJMS.equals(resourceAdapter)) {
            Collection<ServiceReference<ResourceAdapterBundleService>> resourceAdapterServices;
            try {
                resourceAdapterServices = bundleContext.getServiceReferences(ResourceAdapterBundleService.class,
                                                                             "(type=".concat(resourceAdapter).concat(")"));
                bundle = resourceAdapterServices.iterator().next().getBundle();

            } catch (InvalidSyntaxException e) {
            }
        } else {
            bundle = bundleContext.getBundle(BUNDLE_LOCATION + resourceAdapter);
        }

        return bundle;
    }
712351
private JoinableResourceBundle buildJoinableResourceBundle(PropertiesConfigHelper props, String bundleName,
			String fileExtension, ResourceReaderHandler rsHandler) {

		// Id for the bundle
		String bundleId = props.getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_ID);

		String bundlePrefix = props.getCustomBundleProperty(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_BUNDLE_PREFIX);

		boolean isComposite = props.getCustomBundleBooleanProperty(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_COMPOSITE_FLAG);

		InclusionPattern inclusionPattern = getInclusionPattern(props, bundleName);
		JoinableResourceBundleImpl bundle = null;
		if (isComposite) {
			List<JoinableResourceBundle> nestedBundles = new ArrayList<>();
			List<String> nestedBundleNames = props.getCustomBundlePropertyAsList(bundleName,
					PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_COMPOSITE_NAMES);
			for (String nestedBundleName : nestedBundleNames) {
				JoinableResourceBundle nestedBundle = buildJoinableResourceBundle(props, nestedBundleName,
						fileExtension, rsHandler);
				nestedBundles.add(nestedBundle);
			}
			bundle = new CompositeResourceBundle(bundleId, bundleName, nestedBundles, inclusionPattern, rsHandler,
					bundlePrefix, fileExtension, generatorRegistry);
		} else {

			bundle = new JoinableResourceBundleImpl(bundleId, bundleName, bundlePrefix, fileExtension, inclusionPattern,
					rsHandler, generatorRegistry);
		}

		// Override bundle postprocessor
		String bundlePostProcessors = props.getCustomBundleProperty(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_POSTPROCESSOR);
		if (StringUtils.isNotEmpty(bundlePostProcessors)) {
			bundle.setBundlePostProcessor(chainFactory.buildPostProcessorChain(bundlePostProcessors));
		}

		// Override unitary postprocessor
		String unitaryPostProcessors = props.getCustomBundleProperty(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_FILE_POSTPROCESSOR);
		if (StringUtils.isNotEmpty(unitaryPostProcessors)) {
			bundle.setUnitaryPostProcessor(chainFactory.buildPostProcessorChain(unitaryPostProcessors));
		}

		// Set conditional comment for IE, in case one is specified
		String explorerConditionalCondition = props.getCustomBundleProperty(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_IE_CONDITIONAL_EXPRESSION);
		if (StringUtils.isNotEmpty(explorerConditionalCondition)) {
			bundle.setExplorerConditionalExpression(explorerConditionalCondition);
		}

		// Sets the alternate URL for production mode.
		String alternateProductionURL = props.getCustomBundleProperty(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_PRODUCTION_ALT_URL);
		if (StringUtils.isNotEmpty(alternateProductionURL)) {
			bundle.setAlternateProductionURL(props.getCustomBundleProperty(bundleName,
					PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_PRODUCTION_ALT_URL));
		}

		boolean hasDebugURL = false;
		// Sets the debug URL for debug mode.
		if (null != props.getCustomBundleProperty(bundleName, BUNDLE_FACTORY_CUSTOM_DEBUG_URL)) {
			bundle.setDebugURL(props.getCustomBundleProperty(bundleName, BUNDLE_FACTORY_CUSTOM_DEBUG_URL));
			hasDebugURL = true;
			if (StringUtils.isEmpty(bundle.getAlternateProductionURL())) {
				throw new IllegalArgumentException("The bundle '" + bundleName
						+ "', which use a static external resource in debug mode, must use an external resource in Production mode.\n"
						+ "Please check your configuration. ");
			}

			if (StringUtils.isNotEmpty(props.getCustomBundleProperty(bundleName, BUNDLE_FACTORY_CUSTOM_MAPPINGS))) {
				throw new IllegalArgumentException("The bundle '" + bundleName
						+ "', which use a static external resource in debug mode, can't have a bundle mapping.\n"
						+ "Please check your configuration. ");
			}
		}

		// Sets the licence path lists.
		Set<String> licencePathList = props.getCustomBundlePropertyAsSet(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_LICENCE_PATH_LIST);
		if (!licencePathList.isEmpty()) {
			bundle.setLicensesPathList(licencePathList);
		}

		List<String> mappings = props.getCustomBundlePropertyAsList(bundleName,
				PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_MAPPINGS);
		if (!hasDebugURL && mappings.isEmpty() && !bundle.isComposite()) {
			throw new IllegalArgumentException("No mappings were defined for the bundle with name: " + bundleName
					+ ". Please specify at least one in configuration. ");
		}

		if (!hasDebugURL) {

			// Add the mappings
			bundle.setMappings(mappings);

			Map<String, VariantSet> variants = props.getCustomBundleVariantSets(bundleName);
			bundle.setVariants(variants);

			// Checks if the bundle files have been modified
			verifyIfBundleIsModified(bundle, mappings, props);
			if (!bundle.isDirty()) {
				for (String variantKey : bundle.getVariantKeys()) {
					if (StringUtils.isNotEmpty(variantKey)) {
						String hashcode = props.getCustomBundleProperty(bundleName,
								PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_HASHCODE_VARIANT + variantKey);
						bundle.setBundleDataHashCode(variantKey, hashcode);
					}
				}

				String hashcode = props.getCustomBundleProperty(bundleName,
						PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_HASHCODE);
				bundle.setBundleDataHashCode(null, hashcode);
			}
		}

		return bundle;
	}
1121282
public static Map<String, String> toMap(ResourceBundle bundle) {
		Map<String, String> map = new HashMap<String, String>();
		Enumeration<String> keys = bundle.getKeys();
		while(keys.hasMoreElements()) {
			String key = keys.nextElement();
			map.put(key, bundle.getString(key));
		}
		return map;
	}
1231314
@Override
	public Bundle getBundle(String bundleName) {
		final String sourceMethod = "getBundle"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(FallbackBundleResolver.class.getName(), sourceMethod, new Object[]{bundleName});
		}
		Bundle result = Platform.getBundle(bundleName);
		if (isTraceLogging) {
			log.exiting(FallbackBundleResolver.class.getName(), sourceMethod, result);
		}
		return result;
	}
76460
private boolean isAvailable(String... bundleNames) {

    for (String name : bundleNames) {
      ResourceBundle.getBundle(name, AbstractNlsMessage.LOCALE_ROOT);
    }
    return true;
  }
1119471
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName, boolean processingBundle) {

		Locale locale = null;
		String path = generator.getResolver().getResourcePath(resourceName);

		Map<String, String> contextVariants = new HashMap<>();
		Map<String, VariantSet> variantSets = new HashMap<>();
		if (generator instanceof VariantResourceGenerator || generator instanceof LocaleAwareResourceGenerator) {

			int variantSuffixIdx = path.indexOf("@");
			if (variantSuffixIdx != -1) {

				String variantKey = path.substring(path.indexOf('@') + 1);

				// Remove variant suffix
				path = path.substring(0, variantSuffixIdx);

				String[] variants = variantKey.split("@");
				if (generator instanceof VariantResourceGenerator) {
					variantSets = ((VariantResourceGenerator) generator).getAvailableVariants(path);
				} else { // instanceof LocaleAwareResourceGenerator
					List<String> availableLocales = ((LocaleAwareResourceGenerator) generator)
							.getAvailableLocales(path);
					if (availableLocales != null) {
						variantSets.put(JawrConstant.LOCALE_VARIANT_TYPE,
								new VariantSet(JawrConstant.LOCALE_VARIANT_TYPE, "", availableLocales));
					}
				}

				// Sort the variant types
				List<String> variantTypes = new ArrayList<>(variantSets.keySet());
				Collections.sort(variantTypes);
				int nbVariants = variants.length;

				for (int i = 0; i < nbVariants; i++) {
					String variantType = variantTypes.get(i);
					String variantValue = variants[i];
					contextVariants.put(variantType, variantValue);
					if (variantType.equals(JawrConstant.LOCALE_VARIANT_TYPE)) {
						// Resourcebundle should be doing this for me...
						String[] params = variantValue.split("_");
						switch (params.length) {
						case 3:
							locale = new Locale(params[0], params[1], params[2]);
							break;
						case 2:
							locale = new Locale(params[0], params[1]);
							break;
						default:
							locale = new Locale(variantValue);
						}
					}
				}
			}
		}

		GeneratorContext context = new GeneratorContext(bundle, config, path);
		context.setVariantMap(contextVariants);
		context.setVariantSets(variantSets);

		context.setLocale(locale);
		context.setResourceReaderHandler(rsHandler);
		context.setProcessingBundle(processingBundle);

		return generator.createResource(context);
	}
925772
int getResponseCodeFromBundle(Bundle b) {
        Object o = b.get(RESPONSE_CODE);
        if (o == null) {
            logDebug("Bundle with null response code, assuming OK (known issue)");
            return BILLING_RESPONSE_RESULT_OK;
        }
        else if (o instanceof Integer) return ((Integer)o).intValue();
        else if (o instanceof Long) return (int)((Long)o).longValue();
        else {
            logError("Unexpected type for bundle response code.");
            logError(o.getClass().getName());
            throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
        }
    }
403846
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName) {

		Reader rd = null;
		if (!jawrConfig.isDebugModeOn()) {
			((TextResourceReader) resourceReader).getResource(bundle, resourceName);
		}

		return rd;
	}
510691
public static <T, R extends Resource<T>> T getEntity(R resource) {
        return resource.getEntity();
    }
585581
public ResourceBundle getResourceBundle() {
        if (bundle == null) {
            String lang = "";
            String country = "";
            final String _locale = getPm().getCfg().getProperty("locale", "");
            if (_locale != null && !"".equals(_locale.trim())) {
                final String[] __locale = _locale.split("[_]");
                lang = __locale[0];
                if (__locale.length > 1) {
                    country = __locale[1];
                }
            }
            final Locale locale = new Locale(lang, country);
            bundle = ResourceBundle.getBundle("ApplicationResource", locale);
        }
        return bundle;
    }
976738
public FacesConfigApplicationResourceBundleType<FacesConfigApplicationType<T>> getOrCreateResourceBundle()
   {
      List<Node> nodeList = childNode.get("resource-bundle");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new FacesConfigApplicationResourceBundleTypeImpl<FacesConfigApplicationType<T>>(this, "resource-bundle", childNode, nodeList.get(0));
      }
      return createResourceBundle();
   }
1296158
public static String get(Bundle bundle) {
    String applicationPath = ApplicationPath.get(bundle);
    if (applicationPath == null) {
      return null;
    }
    if (!hasHalDocs(bundle)) {
      return null;
    }
    return get(applicationPath);
  }
969267
public boolean getBoolean( String key )
        throws MissingResourceException
    {
        ResourceBundle bundle = getBundle();
        String value = bundle.getString( key );
        return "true".equalsIgnoreCase( value );
    }