public virtual XMPProperty GetQualifier(String schemaNS, String propName, String qualNS, String qualName) { // qualNS and qualName are checked inside composeQualfierPath ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); String qualPath = propName + XMPPathFactory.ComposeQualifierPath(qualNS, qualName ); return GetProperty(schemaNS, qualPath); }
public virtual void SetQualifier(String schemaNS, String propName, String qualNS, String qualName, String qualValue, PropertyOptions options) { ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); if (!DoesPropertyExist(schemaNS, propName)) { throw new XMPException("Specified property does not exist!", XMPError.BADXPATH); } String qualPath = propName + XMPPathFactory.ComposeQualifierPath(qualNS, qualName ); SetProperty(schemaNS, qualPath, qualValue, options); }
/// <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; } }
public virtual bool DoesPropertyExist(String schemaNS, String propName) { try { ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); XMPPath expPath = XMPPathParser.ExpandXPath(schemaNS, propName); XMPNode propNode = XMPNodeUtils.FindNode(tree, expPath, false, null); return propNode != null; } catch (XMPException) { return false; } }
public virtual bool DoesQualifierExist(String schemaNS, String propName, String qualNS , String qualName) { try { // qualNS and qualName are checked inside composeQualifierPath() ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); String path = XMPPathFactory.ComposeQualifierPath(qualNS, qualName); return DoesPropertyExist(schemaNS, propName + path); } catch (XMPException) { return false; } }
public virtual void SetProperty(String schemaNS, String propName, Object propValue , PropertyOptions options) { ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); options = XMPNodeUtils.VerifySetOptions(options, propValue); XMPPath expPath = XMPPathParser.ExpandXPath(schemaNS, propName); XMPNode propNode = XMPNodeUtils.FindNode(tree, expPath, true, options); if (propNode != null) { SetNode(propNode, propValue, options, false); } else { throw new XMPException("Specified property does not exist", XMPError.BADXPATH); } }
public virtual void DeleteQualifier(String schemaNS, String propName, String qualNS , String qualName) { try { // Note: qualNS and qualName are checked inside composeQualfierPath ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); String qualPath = propName + XMPPathFactory.ComposeQualifierPath(qualNS, qualName ); DeleteProperty(schemaNS, qualPath); } catch (XMPException) { // EMPTY, exceptions within delete are ignored } }
public virtual void DeleteProperty(String schemaNS, String propName) { try { ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); XMPPath expPath = XMPPathParser.ExpandXPath(schemaNS, propName); XMPNode propNode = XMPNodeUtils.FindNode(tree, expPath, false, null); if (propNode != null) { XMPNodeUtils.DeleteNode(propNode); } } catch (XMPException) { // EMPTY, exceptions are ignored within delete } }
/// <summary>Returns a property, but the result value can be requested.</summary> /// <seealso cref="iText.Kernel.XMP.XMPMeta.GetProperty(System.String, System.String) /// "/> /// <param name="schemaNS">a schema namespace</param> /// <param name="propName">a property name or path</param> /// <param name="valueType">the type of the value, see VALUE_...</param> /// <returns> /// Returns the node value as an object according to the /// <code>valueType</code>. /// </returns> /// <exception cref="iText.Kernel.XMP.XMPException">Collects any exception that occurs.</exception> protected internal virtual Object GetPropertyObject(String schemaNS, String propName , int valueType) { ParameterAsserts.AssertSchemaNS(schemaNS); ParameterAsserts.AssertPropName(propName); XMPPath expPath = XMPPathParser.ExpandXPath(schemaNS, propName); XMPNode propNode = XMPNodeUtils.FindNode(tree, expPath, false, null); if (propNode != null) { if (valueType != VALUE_STRING && propNode.GetOptions().IsCompositeProperty()) { throw new XMPException("Property must be simple when a value type is requested", XMPError.BADXPATH); } return EvaluateNodeValue(valueType, propNode); } else { return null; } }