コード例 #1
0
ファイル: JDFAttributeMap.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * orMap - put all key/value pairs which are not in this map to this map. Clear this, if both maps have the same
        ///	 * keys with different values.
        ///	 *  </summary>
        ///	 * <param name="subMap"> the map to compare with <code>this</this> </param>
        ///
        public virtual JDFAttributeMap orMap(JDFAttributeMap subMap)
        {
            IEnumerator <string> subMapEnum = subMap.getKeyIterator();

            while (subMapEnum.MoveNext())
            {
                string subMapKey    = subMapEnum.Current;
                string subMapVal    = subMap[subMapKey];
                string hashTableVal = this[subMapKey];

                if (hashTableVal != null)
                {
                    if (!hashTableVal.Equals(subMapVal))
                    {
                        this.Clear();
                        break;
                    }
                }
                else
                {
                    this.put(subMapKey, subMapVal);
                }
            }

            return(this);
        }
コード例 #2
0
ファイル: JDFAttributeMap.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * overlapMap - identical keys must have the same values in both maps i.e submap is either a superset or a subset of
        ///	 * this
        ///	 *  </summary>
        ///	 * <param name="subMap"> the map to compare with <code>this</this>
        ///	 *  </param>
        ///	 * <returns> boolean - true if identical keys have the same values in both maps </returns>
        ///
        public virtual bool overlapMap(JDFAttributeMap subMap)
        {
            if (subMap == null || subMap.Count == 0)
            {
                return(true);
            }

            IEnumerator <string> subMapEnum = subMap.getKeyIterator();

            while (subMapEnum.MoveNext())
            {
                string subMapKey = subMapEnum.Current;
                string subMapVal = subMap[subMapKey];
                if (KElement.isWildCard(subMapVal))
                {
                    continue;
                }

                string val = this[subMapKey];
                if (val != null && !subMapVal.Equals(val))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: VJDFAttributeMap.cs プロジェクト: cip4/JDFLibNet
        public virtual bool hasEntryWithEqualKeyValuePairs(JDFAttributeMap attmap)
        {
            bool bEquals = false;

            for (int i = 0; i < Count; i++)
            {
                // if its the same object...ne further action needed
                if (attmap == this[i])
                {
                    return(true);
                }

                // reset for every entry
                bEquals = false;
                JDFAttributeMap map = this[i];

                // only check if both have the same size

                if (map.Count == attmap.Count)
                {
                    // now that we found a entry with same entry counter set
                    // this to true. A single wrong entry will set it to false and
                    // break. If bEquals is still true after all checks, we found
                    // the map
                    bEquals = true;
                    IEnumerator <string> it = map.getKeyIterator();
                    while (it.MoveNext())
                    {
                        string key = it.Current;
                        if (!attmap.ContainsKey(key))
                        {
                            bEquals = false;
                            break;
                        }
                        string value1 = map.get(key);
                        string value2 = attmap.get(key);
                        if (!value1.Equals(value2))
                        {
                            bEquals = false;
                            break;
                        }
                    }
                    // if bEquals is still true we found a matching map
                    if (bEquals)
                    {
                        return(bEquals);
                    }
                }
            }

            return(bEquals);
        }
コード例 #4
0
ファイル: JDFAttributeMap.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * andMap - builds a new map with identical pairs of both maps
        ///	 *  </summary>
        ///	 * <param name="subMap"> the given map </param>
        ///
        public virtual void andMap(JDFAttributeMap subMap)
        {
            Dictionary <string, string> ht = new Dictionary <string, string>();

            IEnumerator <string> subMapEnum = subMap.getKeyIterator();

            while (subMapEnum.MoveNext())
            {
                string subMapKey    = subMapEnum.Current;
                string subMapVal    = subMap[subMapKey];
                string hashTableVal = this[subMapKey];

                if (hashTableVal != null)
                {
                    if (hashTableVal.Equals(subMapVal))
                    {
                        ht.Add(subMapKey, subMapVal);
                    }
                }
            }

            m_hashTable = ht;
        }