Class POIXMLDocumentPart

    • Constructor Detail

      • POIXMLDocumentPart

        public POIXMLDocumentPart​(OPCPackage pkg)
        Construct POIXMLDocumentPart representing a "core document" package part.
        Parameters:
        pkg - the OPCPackage containing this document
      • POIXMLDocumentPart

        public POIXMLDocumentPart​(OPCPackage pkg,
                                  java.lang.String coreDocumentRel)
        Construct POIXMLDocumentPart representing a custom "core document" package part.
        Parameters:
        pkg - the OPCPackage containing this document
        coreDocumentRel - the relation type of this document
      • POIXMLDocumentPart

        public POIXMLDocumentPart​(PackagePart part)
        Creates an POIXMLDocumentPart representing the given package part and relationship. Called by read(POIXMLFactory, Map) when reading in an existing file.
        Parameters:
        part - - The package part that holds xml data representing this sheet.
        Since:
        POI 3.14-Beta1
        See Also:
        read(POIXMLFactory, Map)
      • POIXMLDocumentPart

        public POIXMLDocumentPart​(POIXMLDocumentPart parent,
                                  PackagePart part)
        Creates an POIXMLDocumentPart representing the given package part, relationship and parent Called by read(POIXMLFactory, Map) when reading in an existing file.
        Parameters:
        parent - - Parent part
        part - - The package part that holds xml data representing this sheet.
        Since:
        POI 3.14-Beta1
        See Also:
        read(POIXMLFactory, Map)
    • Method Detail

      • isCommitted

        public boolean isCommitted()
        to check whether embedded part is already committed
        Returns:
        return true if embedded part is committed
        Since:
        4.1.2
      • setCommitted

        public void setCommitted​(boolean isCommitted)
        setter method to set embedded part is committed
        Parameters:
        isCommitted - boolean value
      • getPackagePart

        public final PackagePart getPackagePart()
        Provides access to the underlying PackagePart
        Returns:
        the underlying PackagePart
      • getRelations

        public final java.util.List<POIXMLDocumentPart> getRelations()
        Returns the list of child relations for this POIXMLDocumentPart
        Returns:
        child relations
      • getRelationParts

        public final java.util.List<POIXMLDocumentPart.RelationPart> getRelationParts()
        Returns the list of child relations for this POIXMLDocumentPart
        Returns:
        child relations
      • getRelationById

        public final POIXMLDocumentPart getRelationById​(java.lang.String id)
        Returns the target POIXMLDocumentPart, where a PackageRelationship is set from the PackagePart of this POIXMLDocumentPart to the PackagePart of the target POIXMLDocumentPart with a PackageRelationship.getId() matching the given parameter value.
        Parameters:
        id - The relation id to look for
        Returns:
        the target part of the relation, or null, if none exists
      • getRelationId

        public final java.lang.String getRelationId​(POIXMLDocumentPart part)
        Returns the first PackageRelationship.getId() of the PackageRelationship, that sources from the PackagePart of this POIXMLDocumentPart to the PackagePart of the given parameter value.

        There can be multiple references to the given POIXMLDocumentPart and only the first in the order of creation is returned.

        Parameters:
        part - The POIXMLDocumentPart for which the according relation-id shall be found.
        Returns:
        The value of the PackageRelationship.getId() or null, if parts are not related.
      • addRelation

        public final POIXMLDocumentPart.RelationPart addRelation​(java.lang.String relId,
                                                                 POIXMLRelation relationshipType,
                                                                 POIXMLDocumentPart part)
        Add a new child POIXMLDocumentPart
        Parameters:
        relId - the preferred relation id, when null the next free relation id will be used
        relationshipType - the package relationship type
        part - the child to add
        Returns:
        the new RelationPart
        Since:
        3.14-Beta1
      • getParent

        public final POIXMLDocumentPart getParent()
        Returns the parent POIXMLDocumentPart. All parts except root have not-null parent.
        Returns:
        the parent POIXMLDocumentPart or null for the root element.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • createRelationship

        public final POIXMLDocumentPart createRelationship​(POIXMLRelation descriptor,
                                                           POIXMLFactory factory)
        Create a new child POIXMLDocumentPart
        Parameters:
        descriptor - the part descriptor
        factory - the factory that will create an instance of the requested relation
        Returns:
        the created child POIXMLDocumentPart
        Throws:
        PartAlreadyExistsException - If rule M1.12 is not verified : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names.
      • createRelationship

        public final POIXMLDocumentPart createRelationship​(POIXMLRelation descriptor,
                                                           POIXMLFactory factory,
                                                           int idx)
        Create a new child POIXMLDocumentPart
        Parameters:
        descriptor - the part descriptor
        factory - the factory that will create an instance of the requested relation
        idx - part number
        Returns:
        the created child POIXMLDocumentPart
        Throws:
        PartAlreadyExistsException - If rule M1.12 is not verified : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names.
      • createRelationship

        public final POIXMLDocumentPart.RelationPart createRelationship​(POIXMLRelation descriptor,
                                                                        POIXMLFactory factory,
                                                                        int idx,
                                                                        boolean noRelation)
        Create a new child POIXMLDocumentPart
        Parameters:
        descriptor - the part descriptor
        factory - the factory that will create an instance of the requested relation
        idx - part number
        noRelation - if true, then no relationship is added.
        Returns:
        the created child POIXMLDocumentPart
        Throws:
        PartAlreadyExistsException - If rule M1.12 is not verified : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names.
      • _invokeOnDocumentRead

        @Internal
        @Deprecated
        public static void _invokeOnDocumentRead​(POIXMLDocumentPart part)
                                          throws java.io.IOException
        Deprecated.
        This method only exists to allow access to protected onDocumentRead() from XWPFDocument without reflection. It should be removed.
        Internal method, do not use!
        Parameters:
        part - the part which is to be read
        Throws:
        java.io.IOException - if the part can't be read