Package com.itextpdf.kernel.pdf.tagging
Class PdfNamespace
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
-
- com.itextpdf.kernel.pdf.tagging.PdfNamespace
-
public class PdfNamespace extends PdfObjectWrapper<PdfDictionary>
A wrapper for namespace dictionaries (ISO 32000-2 section 14.7.4). A namespace dictionary defines a namespace within the structure tree.This pdf entity is meaningful only for the PDF documents of version 2.0 and higher.
-
-
Constructor Summary
Constructors Constructor Description PdfNamespace(PdfDictionary dictionary)
Constructs namespace from the givenPdfDictionary
that represents namespace dictionary.PdfNamespace(PdfString namespaceName)
Constructs a namespace defined by the given namespace name.PdfNamespace(java.lang.String namespaceName)
Constructs a namespace defined by the given namespace name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PdfNamespace
addNamespaceRoleMapping(java.lang.String thisNsRole, java.lang.String defaultNsRole)
Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)
) a single role mapping to the default standard structure namespace.PdfNamespace
addNamespaceRoleMapping(java.lang.String thisNsRole, java.lang.String targetNsRole, PdfNamespace targetNs)
Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)
) a single role mapping to the target namespace.java.lang.String
getNamespaceName()
Gets the string defining the namespace name.PdfDictionary
getNamespaceRoleMap()
A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.private PdfDictionary
getNamespaceRoleMap(boolean createIfNotExist)
PdfFileSpec
getSchema()
Gets file specification identifying the schema file, which defines this namespace.protected boolean
isWrappedObjectMustBeIndirect()
Defines if the object behind this wrapper must be an indirect object in the resultant document.private void
logOverwritingOfMappingIfNeeded(java.lang.String thisNsRole, PdfObject prevVal)
private PdfNamespace
put(PdfName key, PdfObject value)
PdfNamespace
setNamespaceName(PdfString namespaceName)
Sets the string defining the namespace name.PdfNamespace
setNamespaceName(java.lang.String namespaceName)
Sets the string defining the namespace name.PdfNamespace
setNamespaceRoleMap(PdfDictionary roleMapNs)
A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.PdfNamespace
setSchema(PdfFileSpec fileSpec)
Sets file specification identifying the schema file, which defines this namespace.-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
-
-
-
Constructor Detail
-
PdfNamespace
public PdfNamespace(PdfDictionary dictionary)
Constructs namespace from the givenPdfDictionary
that represents namespace dictionary. This method is useful for property reading in reading mode or modifying in stamping mode.- Parameters:
dictionary
- aPdfDictionary
that represents namespace in the document.
-
PdfNamespace
public PdfNamespace(java.lang.String namespaceName)
Constructs a namespace defined by the given namespace name.- Parameters:
namespaceName
- aString
defining the namespace name (conventionally a uniform resource identifier, or URI).
-
-
Method Detail
-
setNamespaceName
public PdfNamespace setNamespaceName(java.lang.String namespaceName)
Sets the string defining the namespace name.- Parameters:
namespaceName
- aString
defining the namespace name (conventionally a uniform resource identifier, or URI).- Returns:
- this
PdfNamespace
instance.
-
setNamespaceName
public PdfNamespace setNamespaceName(PdfString namespaceName)
Sets the string defining the namespace name.- Parameters:
namespaceName
- aPdfString
defining the namespace name (conventionally a uniform resource identifier, or URI).- Returns:
- this
PdfNamespace
instance.
-
getNamespaceName
public java.lang.String getNamespaceName()
Gets the string defining the namespace name.- Returns:
- a
String
defining the namespace name (conventionally a uniform resource identifier, or URI).
-
setSchema
public PdfNamespace setSchema(PdfFileSpec fileSpec)
Sets file specification identifying the schema file, which defines this namespace.- Parameters:
fileSpec
- aPdfFileSpec
identifying the schema file.- Returns:
- this
PdfNamespace
instance.
-
getSchema
public PdfFileSpec getSchema()
Gets file specification identifying the schema file, which defines this namespace.- Returns:
- a
PdfFileSpec
identifying the schema file.
-
setNamespaceRoleMap
public PdfNamespace setNamespaceRoleMap(PdfDictionary roleMapNs)
A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.- Parameters:
roleMapNs
- aPdfDictionary
which is comprised of a set of keys representing structure element types in the namespace defined within this namespace dictionary. The corresponding value for each of these keys shall either be a singlePdfName
identifying a structure element type in the default namespace or anPdfArray
where the first value shall be a structure element type name in a target namespace with the second value being an indirect reference to the target namespace dictionary.- Returns:
- this
PdfNamespace
instance.
-
getNamespaceRoleMap
public PdfDictionary getNamespaceRoleMap()
A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.- Returns:
- a
PdfDictionary
which is comprised of a set of keys representing structure element types in the namespace defined within this namespace dictionary. The corresponding value for each of these keys shall either be a singlePdfName
identifying a structure element type in the default namespace or anPdfArray
where the first value shall be a structure element type name in a target namespace with the second value being an indirect reference to the target namespace dictionary.
-
addNamespaceRoleMapping
public PdfNamespace addNamespaceRoleMapping(java.lang.String thisNsRole, java.lang.String defaultNsRole)
Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)
) a single role mapping to the default standard structure namespace.- Parameters:
thisNsRole
- aString
identifying structure element type in this namespace.defaultNsRole
- aString
identifying a structure element type in the default standard structure namespace.- Returns:
- this
PdfNamespace
instance.
-
addNamespaceRoleMapping
public PdfNamespace addNamespaceRoleMapping(java.lang.String thisNsRole, java.lang.String targetNsRole, PdfNamespace targetNs)
Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)
) a single role mapping to the target namespace.- Parameters:
thisNsRole
- aString
identifying structure element type in this namespace.targetNsRole
- aString
identifying a structure element type in the target namespace.targetNs
- aPdfNamespace
identifying the target namespace.- Returns:
- this
PdfNamespace
instance.
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()
Description copied from class:PdfObjectWrapper
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
put
private PdfNamespace put(PdfName key, PdfObject value)
-
getNamespaceRoleMap
private PdfDictionary getNamespaceRoleMap(boolean createIfNotExist)
-
logOverwritingOfMappingIfNeeded
private void logOverwritingOfMappingIfNeeded(java.lang.String thisNsRole, PdfObject prevVal)
-
-