All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.acrolinx.sidebar.pojo.document.externalcontent.ExternalContent Maven / Gradle / Ivy

/* Copyright (c) 2018 Acrolinx GmbH */
package com.acrolinx.sidebar.pojo.document.externalcontent;

import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

/** Only supported with Acrolinx Platform 2019.10 (Sidebar version 14.16) and newer. */
public class ExternalContent {
  private final List textReplacements;
  private final List entities;
  private final List ditaReferences;
  private final List xincludeReferences;

  public ExternalContent(
      List textReplacements,
      List entities,
      List ditaReferences,
      List xincludeReferences) {
    this.textReplacements = textReplacements;
    this.entities = entities;
    this.ditaReferences = ditaReferences;
    this.xincludeReferences = xincludeReferences;
  }

  public List getTextReplacements() {
    return textReplacements;
  }

  public List getEntities() {
    return entities;
  }

  public List getDitaReferences() {
    return ditaReferences;
  }

  public List getXIncludeReferences() {
    return xincludeReferences;
  }

  public List getAll() {
    List flattenedList = new ArrayList<>();
    Stream.of(textReplacements, entities, ditaReferences, xincludeReferences)
        .forEach(flattenedList::addAll);
    return flattenedList;
  }

  public String getContentForReference(String reference) {
    String contentForReference = "";

    for (ExternalContentField externalContentField : ditaReferences) {
      if (externalContentField.getId().equals(reference)) {
        contentForReference = externalContentField.getContent();
      }
    }

    return contentForReference;
  }

  public void updateContentForReference(String reference, String newContent) {
    for (ExternalContentField externalContentField : ditaReferences) {
      if (externalContentField.getId().equals(reference)) {
        externalContentField.setContent(newContent);
      }
    }
  }

  @Override
  public String toString() {
    return new Gson().toJson(this);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy