/*
@see com.marklogic.contentpump.DocBuilder#build()
@throws IOException
963848
@Override
    public void build() throws IOException{
        generator.writeEndObject();
        generator.close();
        sb.append(baos.toString());
        
    }
821175
@Override
    public void build(final int layer, final List<WordFrequency> wordFrequencies) {
        final Future<?> completionFuture = executorservice.submit(() -> {
            LOGGER.info("Starting to build WordCloud Layer {} in new Thread", layer);
            super.build(layer, wordFrequencies);
        });

        executorFutures.add(completionFuture);
    }
155929
@Override
    public Path build(Path dir) throws IOException
    {
        String name = getName();
        lead = new Lead(name);
        addProvide(getString(RPMTAG_NAME), getString(RPMTAG_VERSION), Condition.EQUAL);
        addRequireInt("rpmlib(CompressedFileNames)", "3.0.4-1", Dependency.EQUAL, Dependency.LESS, Dependency.RPMLIB);
        addInt32(RPMTAG_SIZE, getInt32Array(RPMTAG_FILESIZES).stream().collect(Collectors.summingInt((i) -> i)));
        // trailer
        CPIO cpio = new CPIO();
        cpio.namesize = 11;
        fileRecords.add(new FileRecord(cpio, "TRAILER!!!", ByteBuffer.allocate(0)));
        // header
        ByteBuffer hdr = DynamicByteBuffer.create(Integer.MAX_VALUE);
        hdr.order(ByteOrder.BIG_ENDIAN);
        header.save(hdr);
        hdr.flip();
        // payload
        ByteBuffer payload = DynamicByteBuffer.create(Integer.MAX_VALUE);
        payload.order(ByteOrder.BIG_ENDIAN);
        try (final FilterByteBuffer fbb = new FilterByteBuffer(payload, null, GZIPOutputStream::new))
        {
            for (FileRecord fr : fileRecords)
            {
                fr.save(fbb);
            }
        }
        payload.flip();
        // signature
        MessageDigest md5;
        try
        {
            md5 = MessageDigest.getInstance("MD5");
        }
        catch (NoSuchAlgorithmException ex)
        {
            throw new IOException(ex);
        }
        ByteBuffer dupHdr = hdr.duplicate();
        md5.update(dupHdr);
        ByteBuffer dupPayload = payload.duplicate();
        md5.update(dupPayload);
        byte[] digest = md5.digest();
        setBin(RPMSIGTAG_MD5, digest);
        addInt32(RPMSIGTAG_SIZE, hdr.limit() + payload.limit());
        checkRequiredTags();
        ByteBuffer rpm = DynamicByteBuffer.create(Integer.MAX_VALUE);
        rpm.order(ByteOrder.BIG_ENDIAN);
        lead.save(rpm);
        signature.save(rpm);
        align(rpm, 8);
        rpm.put(hdr);
        rpm.put(payload);
        rpm.flip();
        Path path = dir.resolve("lsb-" + name + ".rpm");
        try (final FileChannel fc = FileChannel.open(path, StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING))
        {
            fc.write(rpm);
        }
        return path;
    }
166674
public function build()
    {
        $view = new View\AtomicKitten;
        $resultFile = new SplFileObject($this->buildSettings['target'] . 'index.html', 'w');
        $resultFile->fwrite($view->render('Generator/Index'));
    }
768669
@Override
    public void execute() throws BuildException {
        /*
         * A couple of the sample properties used in the download XML come from the Readme.html file and need the HTML elements stripped out before we can write the XML using the
         * supertype
         */
        String sampleName = null;
        String sampleAbstract = null;
        String readmeContent = null;

        // Parse the source readme file for the abstract, as it exists only in here
        try {
            Document doc = Jsoup.parse(sourceReadmeFile, "UTF-8");
            //Short abstract description is used by the tools (via download XML - "description"), and WASDev via wasdev.xml.
            Element abstractElement = getRequiredElementById(doc, "ibm-wasdev-sample-abstract-content");
            sampleAbstract = abstractElement.text();
            this.setDescription(abstractElement.text());

        } catch (IOException e) {
            // Can't read the readme so can't produce the XML
            throw new BuildException("Unable to load the Readme.html from " + sourceReadmeFile.getAbsolutePath() + " due to IOException: " + e.getMessage(), e);
        }

        // Parse the built readme file for everything else
        try {
            Document doc = Jsoup.parse(builtReadmeFile, "UTF-8");
            Element nameElement = getRequiredElementById(doc, "ibm-wasdev-sample-name-title");
            sampleName = nameElement.text();
            this.setName(sampleName);

            // Several nodes aren't needed for the WASDev page
            removeElementIfExistsById(doc, "ibm-wasdev-sample-name-title");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-desc-title");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-external-deps-title");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-external-deps-content");
            removeElementIfExistsById(doc, "ibm-wasdev-sample-abstract-content");
            removeElementIfExistsById(doc, "ibm-title-support-info");
            removeElementIfExistsById(doc, "ibm-support-info");
            removeElementIfExistsById(doc, "ibmLicenseFlowing");

            Element readmeElement = getRequiredElementById(doc, "ibm-wasdev-sample-readme-content");

            // If the source is supplied append it to the description
            if (this.sourceFilePath != null) {
                File sourceFile = new File(this.sourceFilePath);
                if (sourceFile.exists()) {
                    BufferedReader br = null;
                    try {
                        br = new BufferedReader(new FileReader(sourceFile));
                        Element sourceNode = new Element(Tag.valueOf("code"), "");
                        String line = null;
                        while ((line = br.readLine()) != null) {
                            // Add nice spacing in the HTML, first tabs to spaces
                            line = line.replaceAll("\\t", "    ");
                            while (line.startsWith(" ")) {
                                line = line.substring(1);
                                sourceNode.append("&nbsp;");
                            }
                            sourceNode.appendText(line);
                            sourceNode.append("<br/>");
                        }
                        readmeElement.appendChild(sourceNode);
                    } finally {
                        if (br != null) {
                            br.close();
                        }
                    }
                }
            }
            readmeContent = readmeElement.html();
        } catch (IOException e) {
            // Can't read the readme so can't produce the XML
            throw new BuildException("Unable to load the Readme.html from " + builtReadmeFile.getAbsolutePath() + " due to IOException: " + e.getMessage(), e);
        }

        // All processing done (everything is set by ANT) so let the supertype generate the XML
        super.execute();

        // We also need to generate a properties file and a description.html with content used to populate Massive
        // First the properties file
        File propertiesFile = new File(this.propertiesFilePath);
        Properties assetInfoProps = new Properties();
        if (propertiesFile.exists()) {
            // Append to an existing props
            FileInputStream in = null;
            try {
                in = new FileInputStream(propertiesFile);
                assetInfoProps.load(in);
            } catch (FileNotFoundException e) {
                throw new BuildException(e);
            } catch (IOException e) {
                throw new BuildException(e);
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
                        throw new BuildException(e);
                    }
                }
            }
        }
        assetInfoProps.put("name", sampleName);
        assetInfoProps.put("shortDescription", sampleAbstract);
        assetInfoProps.put("downloadURL", assetDownloadUrl);
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(propertiesFile);
            assetInfoProps.store(out, null);
        } catch (FileNotFoundException e) {
            throw new BuildException(e);
        } catch (IOException e) {
            throw new BuildException(e);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    throw new BuildException(e);
                }
            }
        }

        // In the same directory as the properties file, write the description.html file
        File descriptionFile = new File(propertiesFile.getParentFile(), "description.html");
        Writer descriptionWriter = null;
        try {
            descriptionWriter = new OutputStreamWriter(new FileOutputStream(descriptionFile), StandardCharsets.UTF_8);
            descriptionWriter.write(readmeContent);
        } catch (IOException e) {
            throw new BuildException(e);
        } finally {
            if (descriptionWriter != null) {
                try {
                    descriptionWriter.close();
                } catch (IOException e) {
                    throw new BuildException(e);
                }
            }
        }
    }
650519
protected T build() {
        if (encoder != null) {
            assert decoder != null;
            return buildFromCodec(decoder, encoder);
        }

        Http2Connection connection = this.connection;
        if (connection == null) {
            connection = new DefaultHttp2Connection(isServer(), maxReservedStreams());
        }

        return buildFromConnection(connection);
    }
7433
@NotNull
    public static DocumentBuilder createDocumentBuilder() {
        try {
            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            return factory.newDocumentBuilder();
        } catch (final ParserConfigurationException ex) {
            throw new RuntimeException("Couldn't create document builder", ex);
        }
    }
593411
public function build()
    {
        $this->classMetadata->addExtension($this->getExtensionName(), [
            'softDeleteable' => true,
            'fieldName'      => $this->fieldName,
            'timeAware'      => $this->timeAware,
        ]);
    }
1077553
@Override
    public void build() {
        if (site != null) {
            site.getProcessors().beforeBuildTheme(this);
        }

        initializeResourceBuilders();
        if (!builders.isEmpty()) {
            try {
                for (ResourceBuilder builder : builders) {
                    builder.build();
                }
            } catch (RuntimeException e) {
                throw e;
            } catch (Exception e) {
                throw new RuntimeException("Theme build exception", e);
            }
        }

        if (site != null) {
            site.getProcessors().afterBuildTheme(this);
        }
    }
657724
protected function build()
    {
        $operation = $this->buildOperation('TransactionStatus');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        if ($this->mpayTid) {
            $xmlMPayTid = $this->document->createElement('mpayTID', $this->mpayTid);
            $operation->appendChild($xmlMPayTid);
        }

        if ($this->tid) {
            $xmlTid = $this->document->createElement('tid', $this->tid);
            $operation->appendChild($xmlTid);
        }
    }
809254
protected function build()
    {
        $operation = $this->buildOperation('ListPaymentMethods');

        $merchantID = $this->document->createElement('merchantID', $this->merchantId);
        $operation->appendChild($merchantID);

        if ($this->pType) {
            $pType = $this->document->createElement('pType', $this->pType);
            $operation->appendChild($pType);
        }
    }
872591
public Document buildPage(ContentElement content) {
    Document doc = documentBuilder.newDocument();
    Element jcrRoot = createJcrRoot(doc, NT_PAGE);
    Element jcrContent = createJcrContent(doc, jcrRoot, NT_PAGE_CONTENT);

    exportPayload(doc, jcrContent, content);

    return doc;
  }
394867
protected static SiftsChainToUniprotMapping build() throws IOException {
		SiftsChainToUniprotMapping sifts = new SiftsChainToUniprotMapping();
		BufferedReader br = new BufferedReader(new FileReader(DEFAULT_FILE));
		String line = "";
		while ((line = br.readLine()) != null) {
			if (line.isEmpty() || line.startsWith("#") || line.startsWith("PDB")) continue;
			String[] parts = line.split("\t");
			String pdbId = parts[0];
			String chainId = parts[1];
			String uniProtId = parts[2];
			String seqresStart = parts[3];
			String seqresEnd = parts[4];
			String pdbStart = parts[5];
			String pdbEnd = parts[6];
			String uniprotStart = parts[7];
			String uniprotEnd = parts[8];
			SiftsChainEntry entry = new SiftsChainEntry(pdbId, chainId, uniProtId, seqresStart, seqresEnd,
					pdbStart, pdbEnd, uniprotStart, uniprotEnd);
			sifts.byChainId.put(pdbId + "." + chainId, entry);
			sifts.byUniProtId.put(uniProtId, entry);
		}
		br.close();
		return sifts;
	}
1368790
public InternalDocumentRevision build() {
        DocumentRevisionOptions options = new DocumentRevisionOptions();
        options.sequence = sequence;
        options.docInternalId = docInternalId;
        options.deleted = deleted;
        options.current = current;
        options.parent = parent;
        options.attachments = attachments;
        return new InternalDocumentRevision(docId, revId, body, options);
    }
687543
@Override
    public void build() throws DocletException {
        if (writer == null) {
            //Doclet does not support this output.
            return;
        }
        build(layoutParser.parseXML(ROOT), contentTree);
    }
793471
public static Document buildDocument(DocumentBuilder withBuilder,
                                         InputSource fromSource) throws IOException, SAXException {
        return withBuilder.parse(fromSource);
    }
839050
public Document buildContent(Map<String, Object> content) {
    Document doc = documentBuilder.newDocument();

    String primaryType = StringUtils.defaultString((String)content.get(PN_PRIMARY_TYPE), NT_UNSTRUCTURED);
    Element jcrRoot = createJcrRoot(doc, primaryType);

    exportPayload(doc, jcrRoot, content);

    return doc;
  }