Package org.apache.poi.openxml4j.opc
Class PackageRelationshipCollection
java.lang.Object
org.apache.poi.openxml4j.opc.PackageRelationshipCollection
- All Implemented Interfaces:
Iterable<PackageRelationship>
public final class PackageRelationshipCollection
extends Object
implements Iterable<PackageRelationship>
Represents a collection of PackageRelationship elements that are owned by a
given PackagePart or the Package.
-
Constructor Summary
ConstructorsConstructorDescriptionPackageRelationshipCollection(OPCPackage container) Constructor.PackageRelationshipCollection(OPCPackage container, PackagePart part) Constructor.Constructor.PackageRelationshipCollection(PackageRelationshipCollection coll, String filter) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddRelationship(URI targetUri, TargetMode targetMode, String relationshipType, String id) Add a relationship to the collection.voidaddRelationship(PackageRelationship relPart) Add the specified relationship to the collection.voidclear()Clear all relationships.findExistingInternalRelation(PackagePart packagePart) getRelationship(int index) Retrieves a relationship by its index in the collection.Retrieves a package relationship based on its id.getRelationships(String typeFilter) Retrieves all relations with the specified type.booleanisEmpty()Is this collection empty?iterator()Get this collection's iterator.Get an iterator of a collection with all relationship with the specified type.voidparseRelationshipsPart(PackagePart relPart) Parse the relationship part and add all relationship in this collection.voidRemove a relationship by its ID.intsize()Get the number of relationships in the collection.Get this collection's spliterator.toString()
-
Constructor Details
-
PackageRelationshipCollection
Copy constructor. This collection will contain only elements from the specified collection for which the type is compatible with the specified relationship type filter.- Parameters:
coll- Collection to import.filter- Relationship type filter.
-
PackageRelationshipCollection
Constructor.- Throws:
InvalidFormatException
-
PackageRelationshipCollection
Constructor.- Throws:
InvalidFormatException- Throws if the format of the content part is invalid.InvalidOperationException- Throws if the specified part is a relationship part.
-
PackageRelationshipCollection
public PackageRelationshipCollection(OPCPackage container, PackagePart part) throws InvalidFormatException Constructor. Parse the existing package relationship part if one exists.- Parameters:
container- The parent package.part- The part that own this relationships collection. If null then this part is considered as the package root.- Throws:
InvalidFormatException- If an error occurs during the parsing of the relatinships part fo the specified part.
-
-
Method Details
-
addRelationship
Add the specified relationship to the collection.- Parameters:
relPart- The relationship to add.
-
addRelationship
public PackageRelationship addRelationship(URI targetUri, TargetMode targetMode, String relationshipType, String id) Add a relationship to the collection.- Parameters:
targetUri- Target URI.targetMode- The target mode : INTERNAL or EXTERNALrelationshipType- Relationship type.id- Relationship ID.- Returns:
- The newly created relationship.
- See Also:
-
removeRelationship
Remove a relationship by its ID.- Parameters:
id- The relationship ID to remove.
-
getRelationship
Retrieves a relationship by its index in the collection.- Parameters:
index- Must be a value between [0-relationships_count-1]
-
getRelationshipByID
Retrieves a package relationship based on its id.- Parameters:
id- ID of the package relationship to retrieve.- Returns:
- The package relationship identified by the specified id.
-
size
public int size()Get the number of relationships in the collection. -
isEmpty
public boolean isEmpty()Is this collection empty?- Since:
- POI 5.2.0
-
parseRelationshipsPart
Parse the relationship part and add all relationship in this collection.- Parameters:
relPart- The package part to parse.- Throws:
InvalidFormatException- Throws if the relationship part is invalid.
-
getRelationships
Retrieves all relations with the specified type.- Parameters:
typeFilter- Relationship type filter. If null then all relationships are returned.- Returns:
- All relationships of the type specified by the filter.
-
iterator
Get this collection's iterator.- Specified by:
iteratorin interfaceIterable<PackageRelationship>
-
spliterator
Get this collection's spliterator.- Specified by:
spliteratorin interfaceIterable<PackageRelationship>- Since:
- POI 5.2.0
-
iterator
Get an iterator of a collection with all relationship with the specified type.- Parameters:
typeFilter- Type filter.- Returns:
- An iterator to a collection containing all relationships with the specified type contain in this collection.
-
clear
public void clear()Clear all relationships. -
findExistingInternalRelation
-
toString
-