Class XJdfDocument

java.lang.Object
org.cip4.lib.xjdf.XJdfDocument

public class XJdfDocument extends Object
This class provides functionality all about XJDF Documents.
  • Constructor Details

    • XJdfDocument

      public XJdfDocument()
      Default constructor.
      Creates an empty XJDF Document.
    • XJdfDocument

      public XJdfDocument(String jobId, String... types)
      Custom Constructor.
      Accepting the required attributes of an XJDF Document for initializing.
      Parameters:
      jobId - The documents JobID.
      types - The documents types.
    • XJdfDocument

      public XJdfDocument(byte[] bytes) throws XJdfParseException
      Custom Constructor.
      Accepting an XJDF Document as byte array for initializing.
      Parameters:
      bytes - The XJDF Document as byte array.
      Throws:
      XJdfParseException
    • XJdfDocument

      public XJdfDocument(XJDF xjdf)
      Custom Constructor.
      Accepting an XJDF root node for initializing.
      Parameters:
      xjdf - The XJDF root node.
  • Method Details

    • setDescriptiveName

      public void setDescriptiveName(String descriptiveName)
      Sets the documents descriptive name.
      Parameters:
      descriptiveName - The human-readable job description.
    • getDescriptiveName

      public String getDescriptiveName()
      Getter of the descriptive name.
      Returns:
      Returns the human-readable job description.
    • setRelatedJobID

      public void setRelatedJobID(String relatedJobID)
      Sets the documents related job id.
      Parameters:
      relatedJobID - The documents related job id.
    • getRelatedJobID

      public String getRelatedJobID()
      Getter of the related job id.
      Returns:
      The related job id.
    • setJobID

      public void setJobID(String jobID)
      Sets the documents job id.
      Parameters:
      jobID - The document's job id.
    • getJobID

      public String getJobID()
      Getter of the job id.
      Returns:
      The job id.
    • getXJdf

      public XJDF getXJdf()
      Returns the XJDF Documents XJDF root node.
      Returns:
      The XJDF root node.
    • toXml

      public byte[] toXml() throws XJdfParseException, XJdfValidationException
      Returns the current XJDF Document as XML byte array.
      Returns:
      The XJDF Document as XML byte array.
      Throws:
      XJdfParseException
      XJdfValidationException
    • toXml

      public byte[] toXml(boolean validate) throws XJdfParseException, XJdfValidationException
      Returns the current XJDF Document as XML byte array.
      Parameters:
      validate - 'false' in case validation should be skipped.
      Returns:
      The XJDF Document as XML byte array.
      Throws:
      XJdfParseException
      XJdfValidationException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getCombinedProcess

      public List<String> getCombinedProcess()
      Returns the combined process (types) specified in the XJDF Document.
      Returns:
      The combined process specified in this document.
    • getCombinedProcessIndex

      public int getCombinedProcessIndex(String processName) throws XJdfDocumentException
      Returns the combined-process-index of a given process name.
      Returns:
      The combined process index as integer.
      Throws:
      XJdfDocumentException
    • addGeneralID

      public void addGeneralID(GeneralID generalID)
      Add a general id to the XJDF Document.
      Parameters:
      generalID - The GeneralID to be added.
    • addGeneralID

      public void addGeneralID(String idUsage, String idValue)
      Add a general id to the XJDF Document.
      Parameters:
      idUsage - The IDUsage value.
      idValue - The IDValue value.
    • addGeneralID

      public void addGeneralID(String idUsage, Object idValue)
      Add a general id to the XJDF Document.
      Parameters:
      idUsage - The IDUsage value.
      idValue - The IDValue value.
    • addGeneralIDs

      public void addGeneralIDs(GeneralID... generalIDs)
      Add multiple general ids to the XJDF Document.
      Parameters:
      generalIDs - The GeneralIDs to be added.
    • getGeneralID

      public GeneralID getGeneralID(String idUsage)
      Return GeneralID object by IDUsage value.
      Parameters:
      idUsage - The IDUsage value.
      Returns:
      The GeneralID object.
    • getGeneralID

      public <T> T getGeneralID(String idUsage, Class<T> type) throws ParseException
      Return the typed value of a GeneralID.
      Parameters:
      idUsage - The IDUsage value.
      type - The target type of the IDValue value.
      Returns:
      The typed value.
      Throws:
      ParseException
    • removeGeneralID

      public boolean removeGeneralID(String idUsage)
      Remove a GeneralID object by IDUsage.
      Parameters:
      idUsage - The generalId object's idUsage value.
      Returns:
      true in case the document had contained such a GeneralID.
    • removeGeneralID

      public boolean removeGeneralID(GeneralID generalID)
      Remove a GeneralID object.
      Parameters:
      generalID - The generalId object to be removed.
      Returns:
      true in case the document had contained such a GeneralID.
    • addAudits

      public void addAudits(Audit... audits)
      Append Audit elements to the XJDF Document.
      Parameters:
      audits - The audits to be appended.
    • getAuditCreated

      public Header getAuditCreated()
      Returns the AuditCreated's header element of the XJDF Document.
      Returns:
      The AuditCreated header element.
    • addFinalProduct

      public void addFinalProduct(FinalProduct... finalProducts)
      Append final products to the XJDF Document.
      Parameters:
      finalProducts - The final products to be appended.
    • getFinalProducts

      public List<FinalProduct> getFinalProducts()
      Returns a list of all final products contained by the XJDF Document.
      Returns:
      List of final products.
    • getFinalProduct

      public FinalProduct getFinalProduct(String id)
      Returns a final products identifierd by its product id.
      Returns:
      The final product if exists. Otherwise null.
    • addResourceSet

      public ResourceSet addResourceSet(@NotNull @NotNull Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage)
      Add resource set to the xjdf document.
      Parameters:
      resourceType - The type of the resource set.
      usage - The usgae of the resource set.
      Returns:
      The newly created resource set element.
    • addResourceSet

      public ResourceSet addResourceSet(@NotNull @NotNull Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage)
      Add resource set to the xjdf document.
      Parameters:
      resourceType - The type of the resource set.
      usage - The usgae of the resource set.
      processUsage - The process usage of the resource set
      Returns:
      The newly created resource set element.
    • addResourceSet

      public ResourceSet addResourceSet(@NotNull @NotNull Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, String processName) throws XJdfDocumentException
      Add resource set to the xjdf document.
      Parameters:
      resourceType - The type of the resource set.
      usage - The usgae of the resource set.
      Returns:
      The newly created resource set element.
      Throws:
      XJdfDocumentException
    • addResourceSet

      public ResourceSet addResourceSet(@NotNull @NotNull Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, IntegerList combinedProcessIndices)
      Add resource set to the xjdf document.
      Parameters:
      resourceType - The type of the resource set.
      usage - The usgae of the resource set.
      processUsage - The process usage of the resource set
      combinedProcessIndices - The combined-process-index list.
      Returns:
      The newly created resource set element.
    • addResourceSet

      public void addResourceSet(ResourceSet resourceSet)
      Add resource set to the xjdf document.
      Parameters:
      resourceSet - The resource set to be added.
    • removeResourceSet

      public boolean removeResourceSet(Class<? extends SpecificResource> resourceType) throws XJdfDocumentException
      Remove a resource set from xjdf document.
      Parameters:
      resourceType - The resource type of the resource set
      Returns:
      true if this list contained the specified element
      Throws:
      XJdfDocumentException
    • removeResourceSet

      public boolean removeResourceSet(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, String processName) throws XJdfDocumentException
      Remove a resource set from xjdf document.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      processName - The process name of the resource set
      Returns:
      true if this list contained the specified element
      Throws:
      XJdfDocumentException
    • removeResourceSet

      public boolean removeResourceSet(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, IntegerList combinedProcessIndices) throws XJdfDocumentException
      Remove a resource set from xjdf document.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      combinedProcessIndices - The combined process indexes of the resource set
      Returns:
      true if this list contained the specified element
      Throws:
      XJdfDocumentException
    • removeResourceSet

      public boolean removeResourceSet(ResourceSet resourceSet)
      Remove a resource set from xjdf document.
      Parameters:
      resourceSet - The resource set to be removed.
      Returns:
      true if this list contained the specified element
    • addSpecificResource

      public Resource addSpecificResource(ResourceSet resourceSet, SpecificResource specificResource) throws XJdfDocumentException
      Add a specific resource to a given resource set.
      Parameters:
      resourceSet - The given resource set.
      specificResource - The specific resource to be added.
      Returns:
      The resource object.
      Throws:
      XJdfDocumentException - Thrown in case of validation issues.
    • addSpecificResource

      public Resource addSpecificResource(ResourceSet resourceSet, SpecificResource specificResource, Part part) throws XJdfDocumentException
      Add a specific resource to a given resource set.
      Parameters:
      resourceSet - The given resource set.
      specificResource - The specific resource to be added.
      part - A single part tag.
      Returns:
      The resource object.
      Throws:
      XJdfDocumentException - Thrown in case of validation issues.
    • addSpecificResource

      public Resource addSpecificResource(ResourceSet resourceSet, SpecificResource specificResource, List<Part> parts)
      Add a specific resource to a given resource set.
      Parameters:
      resourceSet - The given resource set.
      specificResource - The specific resource to be added.
      parts - Partitioning of the specific resource.
      Returns:
      The resource object.
    • addResource

      public Resource addResource(ResourceSet resourceSet, Resource resource)
      Add a resource to a given resource set.
      Parameters:
      resourceSet - The given resource set.
      resource - The resource to be added.
      Returns:
      The resource.
    • getResourceSet

      public ResourceSet getResourceSet(Class<? extends SpecificResource> resourceType) throws XJdfDocumentException
      Returns the resource set of a specific resource.
      Parameters:
      resourceType - The resource type of the specific resource
      Returns:
      The resource set matching the parameters.
      Throws:
      XJdfDocumentException
    • getResourceSet

      public ResourceSet getResourceSet(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage) throws XJdfDocumentException
      Returns the resource set of a specific resource.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      Returns:
      The resource set matching the parameters.
      Throws:
      XJdfDocumentException
    • getResourceSet

      public ResourceSet getResourceSet(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage) throws XJdfDocumentException
      Returns the resource set of a specific resource.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      Returns:
      The resource set matching the parameters.
      Throws:
      XJdfDocumentException
    • getResourceSet

      public ResourceSet getResourceSet(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, String processName) throws XJdfDocumentException
      Returns the resource set of a specific resource.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      processName - The linked process name (via CombinedProcessIndex).
      Returns:
      The resource set matching the parameters.
      Throws:
      XJdfDocumentException
    • getResourceSet

      public ResourceSet getResourceSet(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, IntegerList combinedProcessIndices) throws XJdfDocumentException
      Returns the matching resource set.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      combinedProcessIndices - The combined process indexes of the resource set
      Returns:
      The matching resource set
      Throws:
      XJdfDocumentException - Thrown in case the resource set cannot be identified uniquely
    • getParts

      public List<Part> getParts(Class<? extends SpecificResource> resourceType) throws XJdfDocumentException
      Return the list of parts for a given resource set.
      Parameters:
      resourceType - The resource type of the resource set
      Returns:
      List of part elements in the resource set.
      Throws:
      XJdfDocumentException
    • getParts

      public List<Part> getParts(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage) throws XJdfDocumentException
      Return the list of parts for a given resource set.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      Returns:
      List of part elements in the resource set.
      Throws:
      XJdfDocumentException
    • getParts

      public List<Part> getParts(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, String processName) throws XJdfDocumentException
      Return the list of parts for a given resource set.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      processName - The combined process indexes of the resource set
      Returns:
      List of part elements in the resource set.
      Throws:
      XJdfDocumentException
    • getParts

      public List<Part> getParts(ResourceSet resourceSet)
      Return the list of parts for a given resource set.
      Parameters:
      resourceSet - The resource set to be analyzed.
      Returns:
      List of part elements in the resource set.
    • getResources

      public List<Resource> getResources(Class<? extends SpecificResource> resourceType) throws XJdfDocumentException
      Returns the generic resources of a resource set for a given specific resource.
      Parameters:
      resourceType - the specific resource.
      Returns:
      List of resources of the resource set matching the part keys.
      Throws:
      XJdfDocumentException
    • getResources

      public List<Resource> getResources(Class<? extends SpecificResource> resourceType, Part part) throws XJdfDocumentException
      Returns the generic resources of a resource set for a given specific resource by part keys.
      Parameters:
      resourceType - the specific resource.
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      List of resources of the resource set matching the part keys.
      Throws:
      XJdfDocumentException
    • getResources

      public List<Resource> getResources(ResourceSet resourceSet, Part part)
      Returns the generic resources of a given resource set by part keys.
      Parameters:
      resourceSet - the given resource set.
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      List of resources of the resource set matching the part keys.
    • getResource

      public Resource getResource(Class<? extends SpecificResource> resourceType, Part part) throws XJdfDocumentException
      Identifies and returns the first matching specific resource within a resource set using partition keys.
      Parameters:
      resourceType - The class of the specific resource.
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      The first Resource identified using partition keys.
      Throws:
      XJdfDocumentException
    • getResource

      public Resource getResource(ResourceSet resourceSet, Part part)
      Identifies and returns the first matching specific resource within a resource set using partition keys.
      Parameters:
      resourceSet - The given resource set
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      The first Resource identified using partition keys within a given resource set.
    • getResource

      public Resource getResource(Class<? extends SpecificResource> resourceType) throws XJdfDocumentException
      Returns a resource found by params.
      Parameters:
      resourceType - The resource type of the resource set
      Returns:
      The resource object.
      Throws:
      XJdfDocumentException
    • getResource

      public Resource getResource(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage) throws XJdfDocumentException
      Returns a resource found by params.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      Returns:
      The resource object.
      Throws:
      XJdfDocumentException
    • getResource

      public Resource getResource(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, String processName) throws XJdfDocumentException
      Returns a resource found by params.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      processName - The combined process indexes of the resource set
      Returns:
      The resource object.
      Throws:
      XJdfDocumentException
    • getResource

      public Resource getResource(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, IntegerList combinedProcessIndices) throws XJdfDocumentException
      Returns a resource found by params.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      combinedProcessIndices - The combined process indexes of the resource set
      Returns:
      The resource object.
      Throws:
      XJdfDocumentException
    • getResource

      public Resource getResource(String id)
      Returns a resource found by its unique identifier (ID or ExternalID).
      Parameters:
      id - The resource's unique identifier (ID or ExternalID).
      Returns:
      The resource object.
    • removeResource

      public boolean removeResource(ResourceSet resourceSet, Part part)
      Remove resource from a given resource set by part.
      Parameters:
      resourceSet - The resource set
      part - The partitioning of the resource to be deleted.
      Returns:
      true in case the resource set contained such an elements
    • getSpecificResources

      public <T extends SpecificResource> List<T> getSpecificResources(Class<T> resourceType) throws XJdfDocumentException
      Returns the specific resources of a resource set
      Parameters:
      resourceType - the specific resource.
      Returns:
      List of resources of the resource set.
      Throws:
      XJdfDocumentException
    • getSpecificResources

      public <T extends SpecificResource> List<T> getSpecificResources(Class<T> resourceType, Part part) throws XJdfDocumentException
      Returns the specific resources of a resource set for given partition keys
      Parameters:
      resourceType - the specific resource.
      part - The given partition
      Returns:
      List of resources of the resource set.
      Throws:
      XJdfDocumentException
    • getSpecificResources

      public <T extends SpecificResource> List<T> getSpecificResources(ResourceSet resourceSet, Part part)
      Returns the specific resources of a resource set for given partition keys
      Parameters:
      resourceSet - the resource set.
      part - The given partition
      Returns:
      List of resources of the resource set.
    • getSpecificResource

      public <T extends SpecificResource> T getSpecificResource(Class<T> resourceType, Part part) throws XJdfDocumentException
      Identifies and returns the first matching specific resource within a resource set using partition keys.
      Parameters:
      resourceType - The type of the specific resource.
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      The first specific resource identified using partition keys.
      Throws:
      XJdfDocumentException
    • getSpecificResource

      public <T extends SpecificResource> T getSpecificResource(ResourceSet resourceSet, Part part) throws XJdfDocumentException
      Identifies and returns the first matching specific resource within a resource set using partition keys.
      Parameters:
      resourceSet - The resource set.
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      The first specific resource identified using partition keys.
      Throws:
      XJdfDocumentException
    • getSpecificResource

      public <T extends SpecificResource> T getSpecificResource(String resourceId)
      Returns a specific resource found by id.
      Parameters:
      resourceId - The resource's unique identifier.
      Returns:
      The specific resource object.
    • getSpecificResource

      public <T extends SpecificResource> T getSpecificResource(Class<T> resourceType) throws XJdfDocumentException
      Identifies and returns the first matching specific resource within the given resource set.
      Parameters:
      resourceType - The class of the specific resource.
      Returns:
      The first specific resource identified using partition keys.
      Throws:
      XJdfDocumentException
    • getSpecificResource

      public <T extends SpecificResource> T getSpecificResource(Class<T> resourceType, ResourceSet.Usage usage) throws XJdfDocumentException
      Returns a specific resource found by params.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      Returns:
      The specific resource object.
      Throws:
      XJdfDocumentException
    • getSpecificResource

      public <T extends SpecificResource> T getSpecificResource(Class<T> resourceType, ResourceSet.Usage usage, String processUsage, String processName) throws XJdfDocumentException
      Returns a specific resource found by params.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      processName - The combined process indexes of the resource set
      Returns:
      The specific resource object.
      Throws:
      XJdfDocumentException
    • getSpecificResource

      public <T extends SpecificResource> T getSpecificResource(Class<T> resourceType, ResourceSet.Usage usage, String processUsage, IntegerList combinedProcessIndices) throws XJdfDocumentException
      Returns a specific resource found by params.
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      combinedProcessIndices - The combined process indexes of the resource set
      Returns:
      The specific resource object.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(ResourceSet resourceSet, Part part) throws XJdfDocumentException
      Returns the PartAmount of the first matching specific resource within a resource set using partition keys.
      Parameters:
      resourceSet - The given resource set
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      The PartAmount of the first Resource identified using partition keys within a given resource set.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(Class<? extends SpecificResource> resourceType, Part part) throws XJdfDocumentException
      Returns the PartAmount of the first matching specific resource within a resource set using partition keys.
      Parameters:
      resourceType - The class of the specific resource.
      part - The given Partition Keys used to identify a particular Resource
      Returns:
      The first Resource identified using partition keys.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(Class<? extends SpecificResource> resourceType) throws XJdfDocumentException
      Returns the PartAmount of the resource found by params .
      Parameters:
      resourceType - The resource type of the resource set
      Returns:
      The PartAmount of the identified resource.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage) throws XJdfDocumentException
      Returns the PartAmount of the resource found by params .
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      Returns:
      The PartAmount of the identified resource.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, String processName) throws XJdfDocumentException
      Returns the PartAmount of the resource found by params .
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      processName - The combined process indexes of the resource set
      Returns:
      The PartAmount of the identified resource.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(Class<? extends SpecificResource> resourceType, ResourceSet.Usage usage, String processUsage, IntegerList combinedProcessIndices) throws XJdfDocumentException
      Returns the PartAmount of the resource found by params .
      Parameters:
      resourceType - The resource type of the resource set
      usage - The usage of the resource set
      processUsage - The process usage of the resource set
      combinedProcessIndices - The combined process indexes of the resource set
      Returns:
      The first Resource identified using partition keys.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(String resourceId) throws XJdfDocumentException
      Returns the PartAmount of a resource found by id.
      Parameters:
      resourceId - The resource's unique identifier.
      Returns:
      The PartAmount object of the identified resource object.
      Throws:
      XJdfDocumentException
    • getPartAmount

      public PartAmount getPartAmount(Resource resource) throws XJdfDocumentException
      Returns the PartAmount of a given resource.
      Parameters:
      resource - The resource object to be analyzed.
      Returns:
      The PartAmount object if present.
      Throws:
      XJdfDocumentException - In case multiple PartAmount element exist.