summaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/internal/docx/RelationshipsXml.java
blob: 938776ef89054e7974499c49f39e172a6c205061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package org.zwobble.mammoth.internal.docx;

import org.zwobble.mammoth.internal.xml.XmlElement;

import java.util.Map;

import static com.google.common.collect.Maps.immutableEntry;
import static org.zwobble.mammoth.internal.util.MammothMaps.toMap;

public class RelationshipsXml {
    public static Relationships readRelationshipsXmlElement(XmlElement element) {
        return new Relationships(toMap(
            element.findChildren("relationships:Relationship"),
            RelationshipsXml::readRelationship));
    }

    private static Map.Entry<String, Relationship> readRelationship(XmlElement element) {
        return immutableEntry(
            element.getAttribute("Id"),
            new Relationship(element.getAttribute("Target")));
    }
}