Ejemplo n.º 1
0
        /// <summary>
        /// {@inheritDoc}
        ///
        /// @implSpec
        /// This implementation iterates over <tt>entrySet()</tt> searching
        /// for an entry with the specified key.  If such an entry is found,
        /// the entry's value is returned.  If the iteration terminates without
        /// finding such an entry, <tt>null</tt> is returned.  Note that this
        /// implementation requires linear time in the size of the map; many
        /// implementations will override this method.
        /// </summary>
        /// <exception cref="ClassCastException">            {@inheritDoc} </exception>
        /// <exception cref="NullPointerException">          {@inheritDoc} </exception>
        public virtual V Get(Object key)
        {
            Iterator <Map_Entry <K, V> > i = EntrySet().Iterator();

            if (key == Map_Fields.Null)
            {
                while (i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (e.Key == Map_Fields.Null)
                    {
                        return(e.Value);
                    }
                }
            }
            else
            {
                while (i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (key.Equals(e.Key))
                    {
                        return(e.Value);
                    }
                }
            }
            return(Map_Fields.Null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a string representation of this map.  The string representation
        /// consists of a list of key-value mappings in the order returned by the
        /// map's <tt>entrySet</tt> view's iterator, enclosed in braces
        /// (<tt>"{}"</tt>).  Adjacent mappings are separated by the characters
        /// <tt>", "</tt> (comma and space).  Each key-value mapping is rendered as
        /// the key followed by an equals sign (<tt>"="</tt>) followed by the
        /// associated value.  Keys and values are converted to strings as by
        /// <seealso cref="String#valueOf(Object)"/>.
        /// </summary>
        /// <returns> a string representation of this map </returns>
        public override String ToString()
        {
            Iterator <Map_Entry <K, V> > i = EntrySet().Iterator();

            if (!i.HasNext())
            {
                return("{}");
            }

            StringBuilder sb = new StringBuilder();

            sb.Append('{');
            for (;;)
            {
                Map_Entry <K, V> e = i.Next();
                K key   = e.Key;
                V value = e.Value;
                sb.Append(key == this ? "(this Map)" : key);
                sb.Append('=');
                sb.Append(value == this ? "(this Map)" : value);
                if (!i.HasNext())
                {
                    return(sb.Append('}').ToString());
                }
                sb.Append(',').Append(' ');
            }
        }
Ejemplo n.º 3
0
 private void CrossCheck(TemporalAccessor target)
 {
     for (IEnumerator <Map_Entry <TemporalField, Long> > it = FieldValues.GetEnumerator(); it.MoveNext();)
     {
         Map_Entry <TemporalField, Long> entry = it.Current;
         TemporalField field = entry.Key;
         if (target.IsSupported(field))
         {
             long val1;
             try
             {
                 val1 = target.GetLong(field);
             }
             catch (RuntimeException)
             {
                 continue;
             }
             long val2 = entry.Value;
             if (val1 != val2)
             {
                 throw new DateTimeException("Conflict found: Field " + field + " " + val1 + " differs from " + field + " " + val2 + " derived from " + target);
             }
             it.remove();
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// {@inheritDoc}
        ///
        /// @implSpec
        /// This implementation iterates over <tt>entrySet()</tt> searching
        /// for an entry with the specified value.  If such an entry is found,
        /// <tt>true</tt> is returned.  If the iteration terminates without
        /// finding such an entry, <tt>false</tt> is returned.  Note that this
        /// implementation requires linear time in the size of the map.
        /// </summary>
        /// <exception cref="ClassCastException">   {@inheritDoc} </exception>
        /// <exception cref="NullPointerException"> {@inheritDoc} </exception>
        public virtual bool ContainsValue(Object value)
        {
            Iterator <Map_Entry <K, V> > i = EntrySet().Iterator();

            if (value == Map_Fields.Null)
            {
                while (i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (e.Value == Map_Fields.Null)
                    {
                        return(Map_Fields.True);
                    }
                }
            }
            else
            {
                while (i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (value.Equals(e.Value))
                    {
                        return(Map_Fields.True);
                    }
                }
            }
            return(Map_Fields.False);
        }
Ejemplo n.º 5
0
            internal static Map_Entry <String, String> CheckedEntry(Object o)
            {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") Map_Entry<String,String> e = (Map_Entry<String,String>) o;
                Map_Entry <String, String> e = (Map_Entry <String, String>)o;

                NonNullString(e.Key);
                NonNullString(e.Value);
                return(e);
            }
Ejemplo n.º 6
0
        // Comparison and hashing

        /// <summary>
        /// Compares the specified object with this map for equality.  Returns
        /// <tt>true</tt> if the given object is also a map and the two maps
        /// represent the same mappings.  More formally, two maps <tt>m1</tt> and
        /// <tt>m2</tt> represent the same mappings if
        /// <tt>m1.entrySet().equals(m2.entrySet())</tt>.  This ensures that the
        /// <tt>equals</tt> method works properly across different implementations
        /// of the <tt>Map</tt> interface.
        ///
        /// @implSpec
        /// This implementation first checks if the specified object is this map;
        /// if so it returns <tt>true</tt>.  Then, it checks if the specified
        /// object is a map whose size is identical to the size of this map; if
        /// not, it returns <tt>false</tt>.  If so, it iterates over this map's
        /// <tt>entrySet</tt> collection, and checks that the specified map
        /// contains each mapping that this map contains.  If the specified map
        /// fails to contain such a mapping, <tt>false</tt> is returned.  If the
        /// iteration completes, <tt>true</tt> is returned.
        /// </summary>
        /// <param name="o"> object to be compared for equality with this map </param>
        /// <returns> <tt>true</tt> if the specified object is equal to this map </returns>
        public override bool Equals(Object o)
        {
            if (o == this)
            {
                return(Map_Fields.True);
            }

            if (!(o is Map))
            {
                return(Map_Fields.False);
            }
//JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
//ORIGINAL LINE: Map<?,?> m = (Map<?,?>) o;
            Map <?, ?> m = (Map <?, ?>)o;

            if (m.Size() != Size())
            {
                return(Map_Fields.False);
            }

            try
            {
                Iterator <Map_Entry <K, V> > i = EntrySet().Iterator();
                while (i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    K key   = e.Key;
                    V value = e.Value;
                    if (value == Map_Fields.Null)
                    {
                        if (!(m.Get(key) == Map_Fields.Null && m.ContainsKey(key)))
                        {
                            return(Map_Fields.False);
                        }
                    }
                    else
                    {
                        if (!value.Equals(m.Get(key)))
                        {
                            return(Map_Fields.False);
                        }
                    }
                }
            }
            catch (ClassCastException)
            {
                return(Map_Fields.False);
            }
            catch (NullPointerException)
            {
                return(Map_Fields.False);
            }

            return(Map_Fields.True);
        }
Ejemplo n.º 7
0
        private Object FindStore(TemporalField field, Locale locale)
        {
            Map_Entry <TemporalField, Locale> key = CreateEntry(field, locale);
            Object store = CACHE[key];

            if (store == null)
            {
                store = CreateStore(field, locale);
                CACHE.PutIfAbsent(key, store);
                store = CACHE[key];
            }
            return(store);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Export the specified Map<String,String> to a map document on
        /// the specified OutputStream as per the prefs DTD.  This is used
        /// as the internal (undocumented) format for FileSystemPrefs.
        /// </summary>
        /// <exception cref="IOException"> if writing to the specified output stream
        ///         results in an <tt>IOException</tt>. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static void exportMap(OutputStream os, Map<String, String> map) throws IOException
        internal static void ExportMap(OutputStream os, Map <String, String> map)
        {
            Document doc    = CreatePrefsDoc("map");
            Element  xmlMap = doc.DocumentElement;

            xmlMap.setAttribute("MAP_XML_VERSION", MAP_XML_VERSION);

            for (Iterator <Map_Entry <String, String> > i = map.EntrySet().Iterator(); i.HasNext();)
            {
                Map_Entry <String, String> e = i.Next();
                Element xe = (Element)xmlMap.appendChild(doc.createElement("entry"));
                xe.setAttribute("key", e.Key);
                xe.setAttribute("value", e.Value);
            }

            WriteDoc(doc, os);
        }
Ejemplo n.º 9
0
            public virtual bool HasMoreElements()
            {
                if (name != null)
                {
                    return(true);
                }

                while (Itor.HasNext())
                {
                    Map_Entry <String, CodeSigner[]> e = Itor.Next();
                    if (SignersReq.Contains(e.Value))
                    {
                        name = e.Key;
                        return(true);
                    }
                }
                while (Enum2.MoveNext())
                {
                    name = Enum2.Current;
                    return(true);
                }
                return(false);
            }
Ejemplo n.º 10
0
        /// <summary>
        /// {@inheritDoc}
        ///
        /// @implSpec
        /// This implementation iterates over <tt>entrySet()</tt> searching for an
        /// entry with the specified key.  If such an entry is found, its value is
        /// obtained with its <tt>getValue</tt> operation, the entry is removed
        /// from the collection (and the backing map) with the iterator's
        /// <tt>remove</tt> operation, and the saved value is returned.  If the
        /// iteration terminates without finding such an entry, <tt>null</tt> is
        /// returned.  Note that this implementation requires linear time in the
        /// size of the map; many implementations will override this method.
        ///
        /// <para>Note that this implementation throws an
        /// <tt>UnsupportedOperationException</tt> if the <tt>entrySet</tt>
        /// iterator does not support the <tt>remove</tt> method and this map
        /// contains a mapping for the specified key.
        ///
        /// </para>
        /// </summary>
        /// <exception cref="UnsupportedOperationException"> {@inheritDoc} </exception>
        /// <exception cref="ClassCastException">            {@inheritDoc} </exception>
        /// <exception cref="NullPointerException">          {@inheritDoc} </exception>
        public virtual V Remove(Object key)
        {
            Iterator <Map_Entry <K, V> > i            = EntrySet().Iterator();
            Map_Entry <K, V>             correctEntry = Map_Fields.Null;

            if (key == Map_Fields.Null)
            {
                while (correctEntry == Map_Fields.Null && i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (e.Key == Map_Fields.Null)
                    {
                        correctEntry = e;
                    }
                }
            }
            else
            {
                while (correctEntry == Map_Fields.Null && i.HasNext())
                {
                    Map_Entry <K, V> e = i.Next();
                    if (key.Equals(e.Key))
                    {
                        correctEntry = e;
                    }
                }
            }

            V Map_Fields.OldValue = Map_Fields.Null;

            if (correctEntry != Map_Fields.Null)
            {
                Map_Fields.OldValue = correctEntry.Value;
                i.remove();
            }
            return(Map_Fields.OldValue);
        }
Ejemplo n.º 11
0
 [FromJava] public SimpleEntry(Map_Entry entry)
 {
 }
Ejemplo n.º 12
0
 public CheckedEntry(Map_Entry <String, String> e)
 {
     this.e = e;
 }
Ejemplo n.º 13
0
 public SimpleImmutableEntry(Map_Entry <K, V> prm1)
 {
 }
Ejemplo n.º 14
0
 public SimpleEntry(Map_Entry <K, V> prm1)
 {
 }
Ejemplo n.º 15
0
 public int Compare(Map_Entry <String, String> e1, Map_Entry <String, String> e2)
 {
     return(NameComparator.Compare(e1.Key, e2.Key));
 }
Ejemplo n.º 16
0
 public virtual int Compare(Map_Entry <String, Long> obj1, Map_Entry <String, Long> obj2)
 {
     return(obj2.Key.Length() - obj1.Key.Length());                // longest to shortest
 }
Ejemplo n.º 17
0
 protected virtual bool removeEldestEntry(Map_Entry <K, V> prm1)
 {
     return(default(bool));
 }