Builds the Book_Info.xml file that is a basic requirement to build the book.

@param buildData        Information and data structures for the build.
@param bookInfoTemplate The Book_Info.xml template to add content to.
182029
protected void buildBookInfoFile(final BuildData buildData, final String bookInfoTemplate) throws BuildProcessingException {
        final ContentSpec contentSpec = buildData.getContentSpec();
        final Map<String, String> overrides = buildData.getBuildOptions().getOverrides();

        String bookInfo = bookInfoTemplate.replaceAll(BuilderConstants.ESCAPED_TITLE_REGEX, buildData.getEscapedBookTitle());

        // DocBook 5 changed the name of <articleinfo>/<bookinfo> to just <info>
        final String rootElementName;
        if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) {
            rootElementName = "info";
            bookInfo = bookInfo.replaceAll("<(/)?bookinfo", "<$1info").replaceAll("<(/)?articleinfo", "<$1info");

            // Change the corpauthor element to orgname
            bookInfo = bookInfo.replaceAll("<(/)?corpauthor>", "<$1orgname>");

            // change the "id" attribute to "xml:id"
            bookInfo = bookInfo.replace("id=\"", "xml:id=\"");
        } else {
            if (contentSpec.getBookType() == BookType.ARTICLE || contentSpec.getBookType() == BookType.ARTICLE_DRAFT) {
                rootElementName = "articleinfo";
            } else {
                rootElementName = "bookinfo";
            }
        }

        // Replace the book info elements with the data from the content spec
        boolean versionSet = false;
        boolean editionSet = false;
        boolean abstractSet = false;
        boolean subtitleSet = false;
        for (final org.jboss.pressgang.ccms.contentspec.Node node : contentSpec.getNodes()) {
            if (node instanceof KeyValueNode) {
                final KeyValueNode<?> keyValueNode = (KeyValueNode<?>) node;
                if (!(keyValueNode.getValue() instanceof String)) {
                    continue;
                }

                if (CommonConstants.CS_TITLE_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
                    // Set the book title
                    final String title = DocBookBuildUtilities.getKeyValueNodeText(buildData, keyValueNode);
                    bookInfo = bookInfo.replaceAll(BuilderConstants.TITLE_REGEX,
                            DocBookBuildUtilities.escapeForReplaceAll(DocBookUtilities.escapeForXML(title)));
                } else if (CommonConstants.CS_SUBTITLE_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
                    // Set the book subtitle
                    final String subtitle = DocBookBuildUtilities.getKeyValueNodeText(buildData, keyValueNode);
                    bookInfo = bookInfo.replaceAll(BuilderConstants.SUBTITLE_REGEX,
                            contentSpec.getSubtitle() == null ? BuilderConstants.SUBTITLE_DEFAULT : DocBookBuildUtilities
                                    .escapeForReplaceAll(DocBookUtilities.escapeForXML(subtitle)));
                    subtitleSet = true;
                } else if (CommonConstants.CS_PRODUCT_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
                    // Set the book product
                    final String product = DocBookBuildUtilities.getKeyValueNodeText(buildData, keyValueNode);
                    bookInfo = bookInfo.replaceAll(BuilderConstants.PRODUCT_REGEX,
                            DocBookBuildUtilities.escapeForReplaceAll(DocBookUtilities.escapeForXML(product)));
                } else if (CommonConstants.CS_VERSION_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
                    // Set the book version
                    final String version = DocBookBuildUtilities.getKeyValueNodeText(buildData, keyValueNode);
                    bookInfo = bookInfo.replaceAll(BuilderConstants.VERSION_REGEX, version == null ? "" : version);
                    versionSet = true;
                } else if (CommonConstants.CS_EDITION_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
                    // Set the book edition
                    final String edition = DocBookBuildUtilities.getKeyValueNodeText(buildData, keyValueNode);
                    bookInfo = bookInfo.replaceAll(BuilderConstants.EDITION_REGEX, edition);
                } else if (CommonConstants.CS_ABSTRACT_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
                    final String description = DocBookBuildUtilities.getKeyValueNodeText(buildData, keyValueNode);

                    final String fixedAbstract;
                    if (description.matches("^<(formal|sim)?para>(.|\\s)*")) {
                        fixedAbstract = "<abstract>\n\t\t" + description + "\n\t</abstract>\n";
                    } else {
                        fixedAbstract = "<abstract>\n\t\t<para>\n\t\t\t" + description + "\n\t\t</para>\n\t</abstract>\n";
                    }

                    // Set the book abstract
                    bookInfo = bookInfo.replaceAll(BuilderConstants.ABSTRACT_REGEX,
                            DocBookBuildUtilities.escapeForReplaceAll(DocBookUtilities.escapeForXML(fixedAbstract)));
                    abstractSet = true;
                }
            }
        }

        // Apply the null value defaults for version, edition and abstract
        if (!subtitleSet) {
            bookInfo = bookInfo.replaceAll(BuilderConstants.SUBTITLE_REGEX, BuilderConstants.SUBTITLE_DEFAULT);
        }
        if (!versionSet) {
            bookInfo = bookInfo.replaceAll(BuilderConstants.VERSION_REGEX, "");
        }
        if (!editionSet) {
            bookInfo = bookInfo.replaceAll("<edition>.*</edition>(\r)?\n", "");
        }
        if (!abstractSet) {
            final String fixedAbstract;
            if (contentSpec.getAbstractTopic() != null) {
                fixedAbstract = DocBookBuildUtilities.convertDocumentToFormattedString(contentSpec.getAbstractTopic().getXMLDocument(),
                        getXMLFormatProperties());
            } else {
                fixedAbstract = BuilderConstants.DEFAULT_ABSTRACT;
            }

            bookInfo = bookInfo.replaceAll(BuilderConstants.ABSTRACT_REGEX, DocBookBuildUtilities.escapeForReplaceAll(fixedAbstract));
        }

        // Get the pubsnumber
        final String pubsNumber = overrides.containsKey(CSConstants.PUBSNUMBER_OVERRIDE) ? overrides.get(
                CSConstants.PUBSNUMBER_OVERRIDE) : (contentSpec.getPubsNumber() == null ? BuilderConstants.DEFAULT_PUBSNUMBER :
                contentSpec.getPubsNumber().toString());

        // pubsnumber is different is docbook 5
        if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) {
            bookInfo = bookInfo.replaceAll(BuilderConstants.PUBSNUMBER_REGEX, "<biblioid class=\"pubsnumber\">" + pubsNumber +
                    "</biblioid>");
        } else {
            bookInfo = bookInfo.replaceAll(BuilderConstants.PUBSNUMBER_REGEX, "<pubsnumber>" + pubsNumber + "</pubsnumber>");
        }

        // Set the book to have a Legal Notice
        bookInfo = bookInfo.replaceAll(BuilderConstants.LEGAL_NOTICE_REGEX, BuilderConstants.LEGAL_NOTICE_XML);

        if (!isNullOrEmpty(contentSpec.getBrandLogo())) {
            final String fixedLogoPath = contentSpec.getBrandLogo().contains(
                    "Common_Content/images/") ? contentSpec.getBrandLogo() : ("Common_Content/images/" + contentSpec.getBrandLogo());
            bookInfo = bookInfo.replaceFirst("<imagedata.*?/>", "<imagedata fileref=\"" + fixedLogoPath + "\" />");
        }

        // Add the preamble to the book info
        bookInfo = DocBookBuildUtilities.addDocBookPreamble(buildData.getDocBookVersion(), bookInfo, rootElementName,
                buildData.getEntityFileName());

        if (contentSpec.getBookType() == BookType.ARTICLE || contentSpec.getBookType() == BookType.ARTICLE_DRAFT) {
            addToZip(buildData.getBookLocaleFolder() + "Article_Info.xml", bookInfo, buildData);
        } else {
            addToZip(buildData.getBookLocaleFolder() + "Book_Info.xml", bookInfo, buildData);
        }
    }
914655
protected void writeMethodInfo(MethodInfo info) {
        Node currentNode = this.currentNode;
        Element tmp = doc.createElementNS(XML_URI, "method");
        currentNode.appendChild(tmp);
        this.currentNode = tmp;
        addAccessFlags(info);

        if (info.getName() != null)
            tmp.setAttribute( "name", info.getName());
        if (info.getSignature() != null)
            tmp.setAttribute( "signature", info.getSignature());
        if (info.getDesc() != null)
            addMethodNodes(info.getDesc());
        String[] exceptions = info.getExceptions();
        if (exceptions != null) {
            for (int i = 0; i < exceptions.length; i++) {
                Element excep = doc.createElementNS(XML_URI, "exception");
                excep.setAttribute( "name", exceptions[i]);
                tmp.appendChild(excep);
            }
        }
        this.currentNode = currentNode;
    }
3362
protected String buildBookEntityFile(final BuildData buildData) throws BuildProcessingException {
        final ContentSpec contentSpec = buildData.getContentSpec();

        final StringBuilder retValue = new StringBuilder();

        if (!buildData.getBuildOptions().getUseOldBugLinks() && buildData.getBuildOptions().getInsertBugLinks()) {
            // Add the bug link entities
            retValue.append("<!-- BUG LINK ENTITIES -->\n");
            try {
                final BaseBugLinkStrategy bugLinkStrategy = buildData.getBugLinkStrategy();
                final BugLinkOptions bugLinkOptions = buildData.getBugLinkOptions();
                retValue.append(bugLinkStrategy.generateEntities(bugLinkOptions, buildData.getBuildName(), buildData.getBuildDate()));
            } catch (UnsupportedEncodingException e) {
                throw new BuildProcessingException(e);
            } catch (BugLinkException e) {
                throw new BuildProcessingException(e);
            } catch (final Exception ex) {
                throw new BuildProcessingException("Failed to insert Bug Links into the DOM Document", ex);
            }
        }

        retValue.append("<!-- CS ENTITIES -->\n");
        final String entities = ContentSpecUtilities.generateEntitiesForContentSpec(contentSpec, buildData.getDocBookVersion(),
                buildData.getEscapedBookTitle(), buildData.getOriginalBookTitle(), buildData.getOriginalBookProduct());
        retValue.append(entities);

        // Add the docbook.ent file for DocBook 5 builds
        if (buildData.getDocBookVersion() == DocBookVersion.DOCBOOK_50) {
            retValue.append("<!-- START DOCBOOK ENTITIES -->\n");
            retValue.append(docbook45Entities);
        }

        return retValue.toString();
    }
535455
public void buildPackageHeader(XMLNode node, Content packageSerializedTree) {
        packageSerializedTree.addContent(writer.getPackageHeader(
                utils.getPackageName(currentPackage)));
    }
182555
public void buildClassSummary(XMLNode node, Content packageSummaryContentTree) {
        String classTableSummary =
                configuration.getText("doclet.Member_Table_Summary",
                configuration.getText("doclet.Class_Summary"),
                configuration.getText("doclet.classes"));
        String[] classTableHeader = new String[] {
            configuration.getText("doclet.Class"),
            configuration.getText("doclet.Description")
        };
        ClassDoc[] classes = pkg.ordinaryClasses();
        if (classes.length > 0) {
            profileWriter.addClassesSummary(
                    classes,
                    configuration.getText("doclet.Class_Summary"),
                    classTableSummary, classTableHeader, packageSummaryContentTree);
        }
    }
392237
FunctionTypeBuilder inferConstructorParameters(Node argsParent, @Nullable JSDocInfo info) {
    // Look for template parameters in 'info': these will be added to anything from the class.
    if (info != null) {
      setConstructorTemplateTypeNames(
          buildTemplateTypesFromJSDocInfo(info, true), argsParent.getParent());
    }

    inferParameterTypes(argsParent, info);

    return this;
  }
173452
public void buildPackageHeader(XMLNode node, Content summariesTree) {
        String parsedPackageName = parsePackageName(currentPackage.name());
        if (! printedPackageHeaders.contains(parsedPackageName)) {
            writer.addPackageName(currentPackage,
                parsePackageName(currentPackage.name()), summariesTree);
            printedPackageHeaders.add(parsedPackageName);
        }
    }
1029725
function buildMetadata(f, metadataTarget, options, isText) {

  var ext = path.extname(f);
  var name = path.basename(f, ext);

  var data = buildMetadataContent(name, options, ext, isText);

  fs.ensureFileSync(metadataTarget);
  fs.writeFileSync(metadataTarget, data, 'utf8');

}
860965
public void initDocument()
    throws TemplateInitException
    {
        /*
         *  send an empty InternalContextAdapter down into the AST to initialize it
         */

        InternalContextAdapterImpl ica = new InternalContextAdapterImpl(  new VelocityContext() );

        try
        {
            /*
             *  put the current template name on the stack
             */

            ica.pushCurrentTemplateName( name );
            ica.setCurrentResource( this );

            /*
             *  init the AST
             */

            ((SimpleNode)data).init( ica, rsvc);

            String property = scopeName+'.'+RuntimeConstants.PROVIDE_SCOPE_CONTROL;
            provideScope = rsvc.getBoolean(property, provideScope);
        }
        finally
        {
            /*
             *  in case something blows up...
             *  pull it off for completeness
             */

            ica.popCurrentTemplateName();
            ica.setCurrentResource( null );
        }

    }
246583
public static void extendData(SheetTemplate template, Map<String, String> data) {
        if (data == null)
            return;
        for (Row row : template.sheet) {
            for (Cell c : row) {
                if (c.getCellTypeEnum() != CellType.STRING)
                    continue;
                String str = c.getStringCellValue().trim();
                if (str.startsWith("#") && data.containsKey(str.substring(1))) {
                    c.setCellValue(data.get(str.substring(1)));
                }
            }
        }
    }
1101821
protected void buildBookPreface(final BuildData buildData) throws BuildProcessingException {
        final ContentSpec contentSpec = buildData.getContentSpec();

        // Check that should actually use the preface
        if (contentSpec.getUseDefaultPreface()) {
            final Map<String, String> overrides = buildData.getBuildOptions().getOverrides();
            final Map<String, byte[]> overrideFiles = buildData.getOverrideFiles();

            final Document prefaceDoc;
            try {
                prefaceDoc = XMLUtilities.convertStringToDocument("<preface></preface>");
            } catch (Exception e) {
                throw new BuildProcessingException(e);
            }

            // Add the title
            final String prefaceTitleTranslation = buildData.getConstants().getString("PREFACE");
            final Element titleEle = prefaceDoc.createElement("title");
            titleEle.setTextContent(prefaceTitleTranslation);
            prefaceDoc.getDocumentElement().appendChild(titleEle);

            // Add the Conventions.xml
            final Element conventions = XMLUtilities.createXIInclude(prefaceDoc, "Common_Content/Conventions.xml");
            prefaceDoc.getDocumentElement().appendChild(conventions);

            // Add the Feedback.xml
            if (overrides.containsKey(CSConstants.FEEDBACK_OVERRIDE) && overrideFiles.containsKey(
                    CSConstants.FEEDBACK_OVERRIDE) || contentSpec.getFeedback() != null) {
                final Element xinclude = XMLUtilities.createXIInclude(prefaceDoc, "Feedback.xml");
                prefaceDoc.getDocumentElement().appendChild(xinclude);
            } else {
                final Element xinclude = XMLUtilities.createXIInclude(prefaceDoc, "Common_Content/Feedback.xml");
                prefaceDoc.getDocumentElement().appendChild(xinclude);
            }

            final String prefaceXml = DocBookBuildUtilities.convertDocumentToDocBookFormattedString(buildData.getDocBookVersion(),
                    prefaceDoc, "preface", buildData.getEntityFileName(), getXMLFormatProperties());
            addToZip(buildData.getBookLocaleFolder() + PREFACE_FILE_NAME, prefaceXml, buildData);
        }
    }
1038003
private static void storeStatusUpdateTemplate(
			final AbstractGraphDatabase graphDatabase,
			final StatusUpdateTemplate template, final Node previousTemplateNode) {
		final Transaction transaction = graphDatabase.beginTx();
		try {
			// create template node
			final Node templateNode = StatusUpdateTemplate.createTemplateNode(
					graphDatabase, template);

			// link to the latest previous version
			if (previousTemplateNode != null) {
				templateNode.createRelationshipTo(previousTemplateNode,
						SocialGraphRelationshipType.Templates.PREVIOUS);
			}

			// store the template node
			NeoUtils.storeStatusUpdateTemplateNode(graphDatabase,
					template.getName(), templateNode, previousTemplateNode);

			transaction.success();
		} finally {
			transaction.finish();
		}
	}
1289587
public void init(FgExampleList data) {
        if (data == null && prm.featCountCutoff > 0) {
            throw new IllegalArgumentException("Data can only be null if there is no feature count cutoff.");
        }
        
        // Ensure the FactorTemplateList is initialized, and maybe count features along the way.
        if (templates.isGrowing() && data != null) {
            log.info("Growing feature template list by iterating over examples");
            extractAllFeats(data, templates);
            templates.stopGrowth();
            feAlphabet.stopGrowth();
        }
        numTemplates = templates.size();
        
        // Apply a feature count cutoff.
        this.included = new boolean[numTemplates][][];
        for (int t=0; t<numTemplates; t++) {
            FactorTemplate template = templates.get(t);
            int numConfigs = template.getNumConfigs();
            int numFeats = template.getAlphabet().size();
            included[t] = new boolean[numConfigs][numFeats];
        }
        BoolArrays.fill(included, true);
        if (prm.featCountCutoff >= 1) {
            log.info("Applying feature count cutoff: " + prm.featCountCutoff);
            IntIntDenseVector[][] counts = countFeatures(data, templates);
            excludeByFeatCount(counts);
        }
        
        // Always include the bias features.
        for (int t=0; t<included.length; t++) {
            FactorTemplate template = templates.get(t);
            FeatureNames alphabet = template.getAlphabet();            
            for (int k = 0; k < alphabet.size(); k++) {
                if (alphabet.isBiasFeature(k)) {
                    for (int c = 0; c < included[t].length; c++) {
                        included[t][c][k] = true;
                    }
                }
            }
        }

        // Set the indices to track only the included parameters.
        // All other entries are set to -1.
        // Also: Count the number of parameters, accounting for excluded params.
        numParams = feAlphabet.size();
        this.indices = new int[numTemplates][][];
        for (int t=0; t<indices.length; t++) {
            FactorTemplate template = templates.get(t);
            int numConfigs = template.getNumConfigs();
            int numFeats = template.getAlphabet().size();
            indices[t] = new int[numConfigs][numFeats];
            for (int c = 0; c < indices[t].length; c++) {
                for (int k = 0; k < indices[t][c].length; k++) {
                    indices[t][c][k] = included[t][c][k] ? numParams++ : -1;
                }
            }
        }
        reservedOffset = numParams;
        numParams += reservedMax;
        if (reservedMax > 0) {
            log.debug("Reserved {} parameters starting at {}", reservedMax, reservedOffset);
        }
        if (fcmAlphabet.size() > 0) { 
            log.debug("FCM is using {} features", fcmAlphabet.size());
        }
        fcmAlphabet.stopGrowth();
        
        // If we are using the feature hashing trick, we may want to further increase
        // the number of model parameters.
        numParams = Math.max(numParams, featureHashModMax);
        
        initialized = true;
    }
1134397
@Override
	public ItemDocument build() {
		prepareBuild();
		return factory.getItemDocument((ItemIdValue) this.entityIdValue,
				this.labels, this.descriptions, this.aliases,
				getStatementGroups(), this.siteLinks, this.revisionId);
	}
245601
public void copyProviderDataToBuilder(TemplateBuilder builder,
										  TemplateBuilderDataProvider templateBuilderDataProvider) {
		PageSize size = templateBuilderDataProvider.getPageSize();
		if (templateBuilderDataProvider.isLandscape()) {
			builder.setPageHeight(size.getWidth());
			builder.setPageWidth(size.getHeight());
		} else {
			builder.setPageHeight(size.getHeight());
			builder.setPageWidth(size.getWidth());
		}
		builder.setTitleText(templateBuilderDataProvider.getTitle());
		builder.setWithArrow(templateBuilderDataProvider.isWithArrow());
		builder.setWithScaleBar(templateBuilderDataProvider.isWithScaleBar());
		builder.setRasterDpi(templateBuilderDataProvider.getRasterDpi());
		builder.setDpi(templateBuilderDataProvider.getDpi());
	}
1248557
public void buildDeprecatedMethodInfo(XMLNode node, Content methodsContentTree) {
        methodWriter.addDeprecatedMemberInfo((ExecutableElement)currentMember, methodsContentTree);
    }
533771
public static TemplatePathInfo forPage(@NotNull Page page, @NotNull TemplatePathInfo @NotNull... templates) {
    if (page == null || templates == null) {
      return null;
    }
    String templatePath = page.getProperties().get(NameConstants.PN_TEMPLATE, String.class);
    return forTemplatePath(templatePath, templates);
  }