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

kz.greetgo.msoffice.docx.RelationshipMap Maven / Gradle / Ivy

There is a newer version: 0.5.9
Show newest version
/**
 *
 */
package kz.greetgo.msoffice.docx;

import kz.greetgo.msoffice.util.UtilOffice;

import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;

class RelationshipMap implements FilePart {
  private Map relationships = new HashMap();
  private final String partName;

  private RelationshipMap(String partName) {
    this.partName = partName;
  }

  static RelationshipMap createBySubjectPartName(String subjectPartName) {
    return new RelationshipMap("/word/_rels/" + UtilOffice.extractBaseName(subjectPartName)
      + ".rels");
  }

  static RelationshipMap createWithPartName(String partName) {
    return new RelationshipMap(partName);
  }

  @Override
  public String getPartName() {
    return partName;
  }

  public void put(Relationship r) {
    relationships.put(r.getTarget(), r);
  }

  @Override
  public void write(PrintStream out) {
    out.print("\n");
    out.print("");
    for (Relationship r : relationships.values()) {
      r.write(out);
    }
    out.print("");
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy