Beispiel #1
0
 /// <summary>Appends a qualifier to the qualifier list and sets respective options.</summary>
 /// <param name="qualNode">a qualifier node.</param>
 /// <exception cref="iText.Kernel.XMP.XMPException"></exception>
 public virtual void AddQualifier(iText.Kernel.XMP.Impl.XMPNode qualNode)
 {
     AssertQualifierNotExisting(qualNode.GetName());
     qualNode.SetParent(this);
     qualNode.GetOptions().SetQualifier(true);
     GetOptions().SetHasQualifiers(true);
     // contraints
     if (qualNode.IsLanguageNode())
     {
         // "xml:lang" is always first and the option "hasLanguage" is set
         options.SetHasLanguage(true);
         GetQualifier().Insert(0, qualNode);
     }
     else
     {
         if (qualNode.IsTypeNode())
         {
             // "rdf:type" must be first or second after "xml:lang" and the option "hasType" is set
             options.SetHasType(true);
             GetQualifier().Insert(!options.GetHasLanguage() ? 0 : 1, qualNode);
         }
         else
         {
             // other qualifiers are appended
             GetQualifier().Add(qualNode);
         }
     }
 }
Beispiel #2
0
        /// <summary>Removes one qualifier node and fixes the options.</summary>
        /// <param name="qualNode">qualifier to remove</param>
        public virtual void RemoveQualifier(iText.Kernel.XMP.Impl.XMPNode qualNode)
        {
            PropertyOptions opts = GetOptions();

            if (qualNode.IsLanguageNode())
            {
                // if "xml:lang" is removed, remove hasLanguage-flag too
                opts.SetHasLanguage(false);
            }
            else
            {
                if (qualNode.IsTypeNode())
                {
                    // if "rdf:type" is removed, remove hasType-flag too
                    opts.SetHasType(false);
                }
            }
            GetQualifier().Remove(qualNode);
            if (qualifier.Count == 0)
            {
                opts.SetHasQualifiers(false);
                qualifier = null;
            }
        }