private JoinableResourceBundleContent joinAndPostprocessBundle(JoinableResourceBundle bundle,
			Map<String, String> variants, BundleProcessingStatus status) {

		JoinableResourceBundleContent bundleContent = new JoinableResourceBundleContent();

		StringBuffer bundleData = new StringBuffer();
		StringBuffer store = null;

		try {

			boolean firstPath = true;
			// Run through all the files belonging to the bundle
			Iterator<BundlePath> pathIterator = null;
			if (bundle.getInclusionPattern().isIncludeOnlyOnDebug()) {
				pathIterator = bundle.getItemDebugPathList(variants).iterator();
			} else {
				pathIterator = bundle.getItemPathList(variants).iterator();
			}

			for (Iterator<BundlePath> it = pathIterator; it.hasNext();) {

				// File is first created in memory using a stringwriter.
				StringWriter writer = new StringWriter();
				BufferedWriter bwriter = new BufferedWriter(writer);

				String path = (String) it.next().getPath();
				if (LOGGER.isDebugEnabled())
					LOGGER.debug("Adding file [" + path + "] to bundle " + bundle.getId());

				// Get a reader on the resource, with appropriate encoding
				Reader rd = null;

				try {
					rd = resourceHandler.getResource(bundle, path, true);
				} catch (ResourceNotFoundException e) {
					// If a mapped file does not exist, a warning is issued and
					// process continues normally.
					LOGGER.warn("A mapped resource was not found: [" + path + "]. Please check your configuration");
					continue;
				}

				// Update the status.
				status.setLastPathAdded(path);

				rd = new UnicodeBOMReader(rd, config.getResourceCharset());
				if (!firstPath && ((UnicodeBOMReader) rd).hasBOM()) {
					((UnicodeBOMReader) rd).skipBOM();
				} else {
					firstPath = false;
				}

				IOUtils.copy(rd, bwriter, true);

				// Add new line at the end if it doesn't exist
				StringBuffer buffer = writer.getBuffer();

				if (!buffer.toString().endsWith(StringUtils.STR_LINE_FEED)) {
					buffer.append(StringUtils.STR_LINE_FEED);
				}

				// Do unitary postprocessing.
				status.setProcessingType(BundleProcessingStatus.FILE_PROCESSING_TYPE);
				bundleData.append(executeUnitaryPostProcessing(bundle, status, buffer, this.unitaryPostProcessor));
			}

			// Post process bundle as needed
			store = executeBundlePostProcessing(bundle, status, bundleData);

		} catch (IOException e) {
			throw new BundlingProcessException(
					"Unexpected IOException generating collected file [" + bundle.getId() + "].", e);
		}

		bundleContent.setContent(store);
		return bundleContent;
	}
private JoinableResourceBundleContent joinAndPostprocessBundle ( JoinableResourceBundle bundle , Map < String , String > variants , BundleProcessingStatus status ) { JoinableResourceBundleContent bundleContent = new JoinableResourceBundleContent ( ) ; StringBuffer bundleData = new StringBuffer ( ) ; StringBuffer store = null ; try { boolean firstPath = true ; Iterator < BundlePath > pathIterator = null ; if ( bundle . getInclusionPattern ( ) . isIncludeOnlyOnDebug ( ) ) { pathIterator = bundle . getItemDebugPathList ( variants ) . iterator ( ) ; } else { pathIterator = bundle . getItemPathList ( variants ) . iterator ( ) ; } for ( Iterator < BundlePath > it = pathIterator ; it . hasNext ( ) ; ) { StringWriter writer = new StringWriter ( ) ; BufferedWriter bwriter = new BufferedWriter ( writer ) ; String path = ( String ) it . next ( ) . getPath ( ) ; if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Adding file [" + path + "] to bundle " + bundle . getId ( ) ) ; Reader rd = null ; try { rd = resourceHandler . getResource ( bundle , path , true ) ; } catch ( ResourceNotFoundException e ) { LOGGER . warn ( "A mapped resource was not found: [" + path + "]. Please check your configuration" ) ; continue ; } status . setLastPathAdded ( path ) ; rd = new UnicodeBOMReader ( rd , config . getResourceCharset ( ) ) ; if ( ! firstPath && ( ( UnicodeBOMReader ) rd ) . hasBOM ( ) ) { ( ( UnicodeBOMReader ) rd ) . skipBOM ( ) ; } else { firstPath = false ; } IOUtils . copy ( rd , bwriter , true ) ; StringBuffer buffer = writer . getBuffer ( ) ; if ( ! buffer . toString ( ) . endsWith ( StringUtils . STR_LINE_FEED ) ) { buffer . append ( StringUtils . STR_LINE_FEED ) ; } status . setProcessingType ( BundleProcessingStatus . FILE_PROCESSING_TYPE ) ; bundleData . append ( executeUnitaryPostProcessing ( bundle , status , buffer , this . unitaryPostProcessor ) ) ; } store = executeBundlePostProcessing ( bundle , status , bundleData ) ; } catch ( IOException e ) { throw new BundlingProcessException ( "Unexpected IOException generating collected file [" + bundle . getId ( ) + "]." , e ) ; } bundleContent . setContent ( store ) ; return bundleContent ; }
Reads all the members of a bundle and executes all associated
postprocessors.

@param bundle
the bundle
@param variants
the variant map
@param the
bundling processing status
@param the
flag indicating if we should process the bundle or not
@return the resource bundle content, where all postprocessors have been
executed