public XmpAliasInfo(string actualNs, string actualPrefix, string actualProp, AliasOptions aliasOpts) { Namespace = actualNs; Prefix = actualPrefix; PropName = actualProp; AliasForm = aliasOpts; }
public XmpAliasInfoImpl(string @namespace, string prefix, string propName, AliasOptions aliasForm) { _namespace = @namespace; _prefix = prefix; _propName = propName; _aliasForm = aliasForm; }
public _XMPAliasInfo_409(String actualNS, String actualPrefix, String actualProp, AliasOptions aliasOpts) { this.actualNS = actualNS; this.actualPrefix = actualPrefix; this.actualProp = actualProp; this.aliasOpts = aliasOpts; }
/// <summary> /// Register the standard aliases. /// Note: This method is not lock because only called by the constructor. /// </summary> /// <exception cref="XmpException"> If the registrations of at least one alias fails. </exception> private void RegisterStandardAliases() { AliasOptions aliasToArrayOrdered = new AliasOptions(); aliasToArrayOrdered.ArrayOrdered = true; AliasOptions aliasToArrayAltText = new AliasOptions(); aliasToArrayAltText.ArrayAltText = true; // Aliases from XMP to DC. RegisterAlias(NS_XMP, "Author", NS_DC, "creator", aliasToArrayOrdered); RegisterAlias(NS_XMP, "Authors", NS_DC, "creator", null); RegisterAlias(NS_XMP, "Description", NS_DC, "description", null); RegisterAlias(NS_XMP, "Format", NS_DC, "format", null); RegisterAlias(NS_XMP, "Keywords", NS_DC, "subject", null); RegisterAlias(NS_XMP, "Locale", NS_DC, "language", null); RegisterAlias(NS_XMP, "Title", NS_DC, "title", null); RegisterAlias(NS_XMP_RIGHTS, "Copyright", NS_DC, "rights", null); // Aliases from PDF to DC and XMP. RegisterAlias(NS_PDF, "Author", NS_DC, "creator", aliasToArrayOrdered); RegisterAlias(NS_PDF, "BaseURL", NS_XMP, "BaseURL", null); RegisterAlias(NS_PDF, "CreationDate", NS_XMP, "CreateDate", null); RegisterAlias(NS_PDF, "Creator", NS_XMP, "CreatorTool", null); RegisterAlias(NS_PDF, "ModDate", NS_XMP, "ModifyDate", null); RegisterAlias(NS_PDF, "Subject", NS_DC, "description", aliasToArrayAltText); RegisterAlias(NS_PDF, "Title", NS_DC, "title", aliasToArrayAltText); // Aliases from PHOTOSHOP to DC and XMP. RegisterAlias(NS_PHOTOSHOP, "Author", NS_DC, "creator", aliasToArrayOrdered); RegisterAlias(NS_PHOTOSHOP, "Caption", NS_DC, "description", aliasToArrayAltText); RegisterAlias(NS_PHOTOSHOP, "Copyright", NS_DC, "rights", aliasToArrayAltText); RegisterAlias(NS_PHOTOSHOP, "Keywords", NS_DC, "subject", null); RegisterAlias(NS_PHOTOSHOP, "Marked", NS_XMP_RIGHTS, "Marked", null); RegisterAlias(NS_PHOTOSHOP, "Title", NS_DC, "title", aliasToArrayAltText); RegisterAlias(NS_PHOTOSHOP, "WebStatement", NS_XMP_RIGHTS, "WebStatement", null); // Aliases from TIFF and EXIF to DC and XMP. RegisterAlias(NS_TIFF, "Artist", NS_DC, "creator", aliasToArrayOrdered); RegisterAlias(NS_TIFF, "Copyright", NS_DC, "rights", null); RegisterAlias(NS_TIFF, "DateTime", NS_XMP, "ModifyDate", null); RegisterAlias(NS_TIFF, "ImageDescription", NS_DC, "description", null); RegisterAlias(NS_TIFF, "Software", NS_XMP, "CreatorTool", null); // Aliases from PNG (Acrobat ImageCapture) to DC and XMP. RegisterAlias(NS_PNG, "Author", NS_DC, "creator", aliasToArrayOrdered); RegisterAlias(NS_PNG, "Copyright", NS_DC, "rights", aliasToArrayAltText); RegisterAlias(NS_PNG, "CreationTime", NS_XMP, "CreateDate", null); RegisterAlias(NS_PNG, "Description", NS_DC, "description", aliasToArrayAltText); RegisterAlias(NS_PNG, "ModificationTime", NS_XMP, "ModifyDate", null); RegisterAlias(NS_PNG, "Software", NS_XMP, "CreatorTool", null); RegisterAlias(NS_PNG, "Title", NS_DC, "title", aliasToArrayAltText); }
private void RegisterStandardAliases() { var aliasToArrayOrdered = new AliasOptions { IsArrayOrdered = true }; var aliasToArrayAltText = new AliasOptions { IsArrayAltText = true }; // Aliases from XMP to DC. RegisterAlias(XmpConstants.NsXmp, "Author", XmpConstants.NsDC, "creator", aliasToArrayOrdered); RegisterAlias(XmpConstants.NsXmp, "Authors", XmpConstants.NsDC, "creator", null); RegisterAlias(XmpConstants.NsXmp, "Description", XmpConstants.NsDC, "description", null); RegisterAlias(XmpConstants.NsXmp, "Format", XmpConstants.NsDC, "format", null); RegisterAlias(XmpConstants.NsXmp, "Keywords", XmpConstants.NsDC, "subject", null); RegisterAlias(XmpConstants.NsXmp, "Locale", XmpConstants.NsDC, "language", null); RegisterAlias(XmpConstants.NsXmp, "Title", XmpConstants.NsDC, "title", null); RegisterAlias(XmpConstants.NsXmpRights, "Copyright", XmpConstants.NsDC, "rights", null); // Aliases from PDF to DC and XMP. RegisterAlias(XmpConstants.NsPdf, "Author", XmpConstants.NsDC, "creator", aliasToArrayOrdered); RegisterAlias(XmpConstants.NsPdf, "BaseURL", XmpConstants.NsXmp, "BaseURL", null); RegisterAlias(XmpConstants.NsPdf, "CreationDate", XmpConstants.NsXmp, "CreateDate", null); RegisterAlias(XmpConstants.NsPdf, "Creator", XmpConstants.NsXmp, "CreatorTool", null); RegisterAlias(XmpConstants.NsPdf, "ModDate", XmpConstants.NsXmp, "ModifyDate", null); RegisterAlias(XmpConstants.NsPdf, "Subject", XmpConstants.NsDC, "description", aliasToArrayAltText); RegisterAlias(XmpConstants.NsPdf, "Title", XmpConstants.NsDC, "title", aliasToArrayAltText); // Aliases from PHOTOSHOP to DC and XMP. RegisterAlias(XmpConstants.NsPhotoshop, "Author", XmpConstants.NsDC, "creator", aliasToArrayOrdered); RegisterAlias(XmpConstants.NsPhotoshop, "Caption", XmpConstants.NsDC, "description", aliasToArrayAltText); RegisterAlias(XmpConstants.NsPhotoshop, "Copyright", XmpConstants.NsDC, "rights", aliasToArrayAltText); RegisterAlias(XmpConstants.NsPhotoshop, "Keywords", XmpConstants.NsDC, "subject", null); RegisterAlias(XmpConstants.NsPhotoshop, "Marked", XmpConstants.NsXmpRights, "Marked", null); RegisterAlias(XmpConstants.NsPhotoshop, "Title", XmpConstants.NsDC, "title", aliasToArrayAltText); RegisterAlias(XmpConstants.NsPhotoshop, "WebStatement", XmpConstants.NsXmpRights, "WebStatement", null); // Aliases from TIFF and EXIF to DC and XMP. RegisterAlias(XmpConstants.NsTiff, "Artist", XmpConstants.NsDC, "creator", aliasToArrayOrdered); RegisterAlias(XmpConstants.NsTiff, "Copyright", XmpConstants.NsDC, "rights", null); RegisterAlias(XmpConstants.NsTiff, "DateTime", XmpConstants.NsXmp, "ModifyDate", null); RegisterAlias(XmpConstants.NsExif, "DateTimeDigitized", XmpConstants.NsXmp, "CreateDate", null); RegisterAlias(XmpConstants.NsTiff, "ImageDescription", XmpConstants.NsDC, "description", null); RegisterAlias(XmpConstants.NsTiff, "Software", XmpConstants.NsXmp, "CreatorTool", null); // Aliases from PNG (Acrobat ImageCapture) to DC and XMP. RegisterAlias(XmpConstants.NsPng, "Author", XmpConstants.NsDC, "creator", aliasToArrayOrdered); RegisterAlias(XmpConstants.NsPng, "Copyright", XmpConstants.NsDC, "rights", aliasToArrayAltText); RegisterAlias(XmpConstants.NsPng, "CreationTime", XmpConstants.NsXmp, "CreateDate", null); RegisterAlias(XmpConstants.NsPng, "Description", XmpConstants.NsDC, "description", aliasToArrayAltText); RegisterAlias(XmpConstants.NsPng, "ModificationTime", XmpConstants.NsXmp, "ModifyDate", null); RegisterAlias(XmpConstants.NsPng, "Software", XmpConstants.NsXmp, "CreatorTool", null); RegisterAlias(XmpConstants.NsPng, "Title", XmpConstants.NsDC, "title", aliasToArrayAltText); }
private void RegisterAlias(string aliasNs, string aliasProp, string actualNs, string actualProp, AliasOptions aliasForm) { ParameterAsserts.AssertSchemaNs(aliasNs); ParameterAsserts.AssertPropName(aliasProp); ParameterAsserts.AssertSchemaNs(actualNs); ParameterAsserts.AssertPropName(actualProp); // Fix the alias options AliasOptions aliasOpts = aliasForm != null ? new AliasOptions( XmpNodeUtils.VerifySetOptions(aliasForm.ToPropertyOptions(), null). Options) : new AliasOptions(); if (_regex.IsMatch(aliasProp) || _regex.IsMatch(actualProp)) { throw new XmpException("Alias and actual property names must be simple", XmpError.BADXPATH); } // check if both namespaces are registered string aliasPrefix = GetNamespacePrefix(aliasNs); string actualPrefix = GetNamespacePrefix(actualNs); if (aliasPrefix == null) { throw new XmpException("Alias namespace is not registered", XmpError.BADSCHEMA); } if (actualPrefix == null) { throw new XmpException("Actual namespace is not registered", XmpError.BADSCHEMA); } string key = aliasPrefix + aliasProp; // check if alias is already existing if (_aliasMap.Contains(key)) { throw new XmpException("Alias is already existing", XmpError.BADPARAM); } if (_aliasMap.Contains(actualPrefix + actualProp)) { throw new XmpException("Actual property is already an alias, use the base property", XmpError.BADPARAM); } IXmpAliasInfo aliasInfo = new XmpAliasInfoImpl(actualNs, actualPrefix, actualProp, aliasOpts); _aliasMap[key] = aliasInfo; }
/// <summary>Associates an alias name with an actual name.</summary> /// <remarks> /// Associates an alias name with an actual name. /// <para> /// Define a alias mapping from one namespace/property to another. Both /// property names must be simple names. An alias can be a direct mapping, /// where the alias and actual have the same data type. It is also possible /// to map a simple alias to an item in an array. This can either be to the /// first item in the array, or to the 'x-default' item in an alt-text array. /// Multiple alias names may map to the same actual, as long as the forms /// match. It is a no-op to reregister an alias in an identical fashion. /// Note: This method is not locking because only called by registerStandardAliases /// which is only called by the constructor. /// Note2: The method is only package-private so that it can be tested with unittests /// </para> /// </remarks> /// <param name="aliasNS"> /// The namespace URI for the alias. Must not be null or the empty /// string. /// </param> /// <param name="aliasProp"> /// The name of the alias. Must be a simple name, not null or the /// empty string and not a general path expression. /// </param> /// <param name="actualNS"> /// The namespace URI for the actual. Must not be null or the /// empty string. /// </param> /// <param name="actualProp"> /// The name of the actual. Must be a simple name, not null or the /// empty string and not a general path expression. /// </param> /// <param name="aliasForm"> /// Provides options for aliases for simple aliases to array /// items. This is needed to know what kind of array to create if /// set for the first time via the simple alias. Pass /// <code>XMP_NoOptions</code>, the default value, for all /// direct aliases regardless of whether the actual data type is /// an array or not (see /// <see cref="iText.Kernel.XMP.Options.AliasOptions"/> /// ). /// </param> /// <exception cref="iText.Kernel.XMP.XMPException">for inconsistant aliases.</exception> internal void RegisterAlias(String aliasNS, String aliasProp, String actualNS, String actualProp, AliasOptions aliasForm) { lock (this) { ParameterAsserts.AssertSchemaNS(aliasNS); ParameterAsserts.AssertPropName(aliasProp); ParameterAsserts.AssertSchemaNS(actualNS); ParameterAsserts.AssertPropName(actualProp); // Fix the alias options AliasOptions aliasOpts = aliasForm != null ? new AliasOptions(XMPNodeUtils.VerifySetOptions (aliasForm.ToPropertyOptions(), null).GetOptions()) : new AliasOptions(); if (_regex.IsMatch(aliasProp) || _regex.IsMatch(actualProp)) { throw new XMPException("Alias and actual property names must be simple", XMPError.BADXPATH); } // check if both namespaces are registered String aliasPrefix = GetNamespacePrefix(aliasNS); String actualPrefix = GetNamespacePrefix(actualNS); if (aliasPrefix == null) { throw new XMPException("Alias namespace is not registered", XMPError.BADSCHEMA); } else { if (actualPrefix == null) { throw new XMPException("Actual namespace is not registered", XMPError.BADSCHEMA); } } String key = aliasPrefix + aliasProp; // check if alias is already existing if (aliasMap.Contains(key)) { throw new XMPException("Alias is already existing", XMPError.BADPARAM); } else { if (aliasMap.Contains(actualPrefix + actualProp)) { throw new XMPException("Actual property is already an alias, use the base property" , XMPError.BADPARAM); } } XMPAliasInfo aliasInfo = new _XMPAliasInfo_409(actualNS, actualPrefix, actualProp , aliasOpts); aliasMap[key] = aliasInfo; } }
/// <summary>Associates an alias name with an actual name.</summary> /// <remarks> /// Associates an alias name with an actual name. /// <p> /// Define a alias mapping from one namespace/property to another. Both /// property names must be simple names. An alias can be a direct mapping, /// where the alias and actual have the same data type. It is also possible /// to map a simple alias to an item in an array. This can either be to the /// first item in the array, or to the 'x-default' item in an alt-text array. /// Multiple alias names may map to the same actual, as long as the forms /// match. It is a no-op to reregister an alias in an identical fashion. /// Note: This method is not locking because only called by registerStandardAliases /// which is only called by the constructor. /// Note2: The method is only package-private so that it can be tested with unittests /// </remarks> /// <param name="aliasNS"> /// The namespace URI for the alias. Must not be null or the empty /// string. /// </param> /// <param name="aliasProp"> /// The name of the alias. Must be a simple name, not null or the /// empty string and not a general path expression. /// </param> /// <param name="actualNS"> /// The namespace URI for the actual. Must not be null or the /// empty string. /// </param> /// <param name="actualProp"> /// The name of the actual. Must be a simple name, not null or the /// empty string and not a general path expression. /// </param> /// <param name="aliasForm"> /// Provides options for aliases for simple aliases to array /// items. This is needed to know what kind of array to create if /// set for the first time via the simple alias. Pass /// <code>XMP_NoOptions</code>, the default value, for all /// direct aliases regardless of whether the actual data type is /// an array or not (see /// <see cref="Com.Adobe.Xmp.Options.AliasOptions"/> /// ). /// </param> /// <exception cref="Com.Adobe.Xmp.XMPException">for inconsistant aliases.</exception> internal void RegisterAlias(string aliasNS, string aliasProp, string actualNS, string actualProp, AliasOptions aliasForm) { lock (this) { ParameterAsserts.AssertSchemaNS(aliasNS); ParameterAsserts.AssertPropName(aliasProp); ParameterAsserts.AssertSchemaNS(actualNS); ParameterAsserts.AssertPropName(actualProp); // Fix the alias options AliasOptions aliasOpts = aliasForm != null ? new AliasOptions(XMPNodeUtils.VerifySetOptions(aliasForm.ToPropertyOptions(), null).GetOptions()) : new AliasOptions(); if (p.Matcher(aliasProp).Find() || p.Matcher(actualProp).Find()) { throw new XMPException("Alias and actual property names must be simple", XMPErrorConstants.Badxpath); } // check if both namespaces are registered string aliasPrefix = GetNamespacePrefix(aliasNS); string actualPrefix = GetNamespacePrefix(actualNS); if (aliasPrefix == null) { throw new XMPException("Alias namespace is not registered", XMPErrorConstants.Badschema); } else { if (actualPrefix == null) { throw new XMPException("Actual namespace is not registered", XMPErrorConstants.Badschema); } } string key = aliasPrefix + aliasProp; // check if alias is already existing if (aliasMap.ContainsKey(key)) { throw new XMPException("Alias is already existing", XMPErrorConstants.Badparam); } else { if (aliasMap.ContainsKey(actualPrefix + actualProp)) { throw new XMPException("Actual property is already an alias, use the base property", XMPErrorConstants.Badparam); } } XMPAliasInfo aliasInfo = new _XMPAliasInfo_390(actualNS, actualPrefix, actualProp, aliasOpts); aliasMap.Put(key, aliasInfo); } }
/// <summary>Associates an alias name with an actual name.</summary> /// <remarks> /// Associates an alias name with an actual name. /// <para /> /// Define a alias mapping from one namespace/property to another. Both /// property names must be simple names. An alias can be a direct mapping, /// where the alias and actual have the same data type. It is also possible /// to map a simple alias to an item in an array. This can either be to the /// first item in the array, or to the 'x-default' item in an alt-text array. /// Multiple alias names may map to the same actual, as long as the forms /// match. It is a no-op to reregister an alias in an identical fashion. /// Note: This method is not locking because only called by registerStandardAliases /// which is only called by the constructor. /// Note2: The method is only package-private so that it can be tested with unittests /// </remarks> /// <param name="aliasNs">The namespace URI for the alias. Must not be null or the empty string.</param> /// <param name="aliasProp">The name of the alias. Must be a simple name, not null or the empty string and not a general path expression.</param> /// <param name="actualNs">The namespace URI for the actual. Must not be null or the empty string.</param> /// <param name="actualProp">The name of the actual. Must be a simple name, not null or the empty string and not a general path expression.</param> /// <param name="aliasForm">Provides options for aliases for simple aliases to array items. This is needed to know what kind of array to create if /// set for the first time via the simple alias. Pass <c>XMP_NoOptions</c>, the default value, for all direct aliases regardless of whether the actual /// data type is an array or not (see <see cref="AliasOptions"/>).</param> /// <exception cref="XmpException">for inconsistant aliases.</exception> private void RegisterAlias(string aliasNs, string aliasProp, string actualNs, string actualProp, AliasOptions aliasForm) { lock (_lock) { ParameterAsserts.AssertSchemaNs(aliasNs); ParameterAsserts.AssertPropName(aliasProp); ParameterAsserts.AssertSchemaNs(actualNs); ParameterAsserts.AssertPropName(actualProp); // Fix the alias options var aliasOpts = aliasForm != null ? new AliasOptions(XmpNodeUtils.VerifySetOptions(aliasForm.ToPropertyOptions(), null).GetOptions()) : new AliasOptions(); if (_p.IsMatch(aliasProp) || _p.IsMatch(actualProp)) { throw new XmpException("Alias and actual property names must be simple", XmpErrorCode.BadXPath); } // check if both namespaces are registered var aliasPrefix = GetNamespacePrefix(aliasNs); var actualPrefix = GetNamespacePrefix(actualNs); if (aliasPrefix == null) { throw new XmpException("Alias namespace is not registered", XmpErrorCode.BadSchema); } if (actualPrefix == null) { throw new XmpException("Actual namespace is not registered", XmpErrorCode.BadSchema); } var key = aliasPrefix + aliasProp; // check if alias is already existing if (_aliasMap.ContainsKey(key)) { throw new XmpException("Alias is already existing", XmpErrorCode.BadParam); } if (_aliasMap.ContainsKey(actualPrefix + actualProp)) { throw new XmpException("Actual property is already an alias, use the base property", XmpErrorCode.BadParam); } _aliasMap[key] = new XmpAliasInfo(actualNs, actualPrefix, actualProp, aliasOpts); } }