Exemple #1
0
        /// <summary>
        /// Checks that an ID can be used as a Blank Node ID remapping it to another ID if necessary.
        /// </summary>
        /// <param name="id">ID to be checked.</param>
        /// <remarks>
        /// If the ID is not known it is added to the ID maps.  If the ID is known but is user-assigned then this can be used fine.  If the ID is known and was auto-assigned then it has to be remapped to a different ID.
        /// </remarks>
        public void CheckID(ref String id)
        {
            if (_remappings.ContainsKey(id))
            {
                // Is remapped to something else
                id = _remappings[id];
            }
            else if (_idmap.ContainsKey(id))
            {
                BlankNodeIDAssigment idinfo = _idmap[id];
                if (idinfo.AutoAssigned)
                {
                    // This ID has been auto-assigned so remap to something else
                    String newid = "remapped" + Interlocked.Increment(ref _nextremap);
                    while (_idmap.ContainsKey(newid))
                    {
                        newid = "remapped" + Interlocked.Increment(ref _nextremap);
                    }

                    // Add to ID Map
                    _idmap.Add(newid, new BlankNodeIDAssigment(newid, false));
                    _remappings.Add(id, newid);
                    id = newid;
                }
                // Otherwise this ID can be used fine
            }
            else
            {
                // Register the ID
                _idmap.Add(id, new BlankNodeIDAssigment(id, false));
            }
        }
Exemple #2
0
        /// <summary>
        /// Checks that an ID can be used as a Blank Node ID remapping it to another ID if necessary
        /// </summary>
        /// <param name="id">ID to be checked</param>
        /// <remarks>
        /// If the ID is not known it is added to the ID maps.  If the ID is known but is user-assigned then this can be used fine.  If the ID is known and was auto-assigned then it has to be remapped to a different ID.
        /// </remarks>
        public void CheckID(ref String id)
        {
            if (this._remappings.ContainsKey(id))
            {
                //Is remapped to something else
                id = this._remappings[id];
            }
            else if (this._idmap.ContainsKey(id))
            {
                BlankNodeIDAssigment idinfo = this._idmap[id];
                if (idinfo.AutoAssigned)
                {
                    //This ID has been auto-assigned so remap to something else
                    String newid = "remapped" + this._nextremap;
                    while (this._idmap.ContainsKey(newid))
                    {
                        this._nextremap++;
                        newid = "remapped" + this._nextremap;
                    }
                    this._nextremap++;

                    //Add to ID Map
                    this._idmap.Add(newid, new BlankNodeIDAssigment(newid, false));
                    this._remappings.Add(id, newid);
                    id = newid;
                }
                //Otherwise this ID can be used fine
            }
            else
            {
                //Register the ID
                this._idmap.Add(id, new BlankNodeIDAssigment(id, false));
            }
        }
Exemple #3
0
 /// <summary>
 /// Returns whether a given Object is equal to this Blank Node ID assignment
 /// </summary>
 /// <param name="obj">Object to test</param>
 /// <returns></returns>
 public override bool Equals(object obj)
 {
     if (obj is BlankNodeIDAssigment)
     {
         BlankNodeIDAssigment other = (BlankNodeIDAssigment)obj;
         return(other.ID.Equals(this._id) && other.AutoAssigned == this._auto);
     }
     else
     {
         return(false);
     }
 }