Exemplo n.º 1
0
 /*
  * Indicates whether or not the specified class is a dynamically generated
  * proxy class.
  *
  * @param cl
  *            the class
  * @return {@code true} if the class is a proxy class, {@code false}
  *         otherwise
  * @throws NullPointerException
  *                if the class is {@code null}
  */
 public static bool isProxyClass(Class cl)
 {
     if (cl == null)
     {
         throw new NullPointerException();
     }
     lock (proxyCache) {
         return(proxyCache.containsKey(cl));
     }
 }
 public override void putAll(java.util.Map <Object, Object> mapToCopy)
 {
     for (java.util.Iterator <Object> it = mapToCopy.keySet().iterator(); it.hasNext();)
     {
         if (mapToCopy.containsKey(it.next()) == false)
         {
             throw new java.lang.IllegalArgumentException("Cannot put new key/value pair - Map is fixed size");
         }
     }
     map.putAll(mapToCopy);
 }
Exemplo n.º 3
0
        public static Type GetTypeForJavaClass(java.lang.Class jclass)
        {
            if (jclass2type.containsKey(jclass))
            {
                return((Type)jclass2type.get(jclass));
            }

            Type t = new InternalTypes.InternalType(jclass);

            jclass2type.put(jclass, t);
            return(t);
        }
Exemplo n.º 4
0
        /**
         * Walks through all recorded entries and adds the data available
         * from the local file header.
         *
         * <p>Also records the offsets for the data to read from the
         * entries.</p>
         */
        private void resolveLocalFileHeaderData(java.util.Map <ZipArchiveEntry, IAC_NameAndComment> entriesWithoutUTF8Flag)
        //throws IOException
        {
            java.util.Enumeration <ZipArchiveEntry> e = getEntries();
            while (e.hasMoreElements())
            {
                ZipArchiveEntry ze          = e.nextElement();
                IAC_OffsetEntry offsetEntry = entries.get(ze);
                long            offset      = offsetEntry.headerOffset;
                archive.seek(offset + LFH_OFFSET_FOR_FILENAME_LENGTH);
                byte[] b = new byte[SHORT];
                archive.readFully(b);
                int fileNameLen = ZipShort.getValue(b);
                archive.readFully(b);
                int extraFieldLen = ZipShort.getValue(b);
                int lenToSkip     = fileNameLen;
                while (lenToSkip > 0)
                {
                    int skipped = archive.skipBytes(lenToSkip);
                    if (skipped <= 0)
                    {
                        throw new java.lang.RuntimeException("failed to skip file name in"
                                                             + " local file header");
                    }
                    lenToSkip -= skipped;
                }
                byte[] localExtraData = new byte[extraFieldLen];
                archive.readFully(localExtraData);
                ze.setExtra(localExtraData);

                /*dataOffsets.put(ze,
                 *              new Long(offset + LFH_OFFSET_FOR_FILENAME_LENGTH
                 + SHORT + SHORT + fileNameLen + extraFieldLen));
                 */
                offsetEntry.dataOffset = offset + LFH_OFFSET_FOR_FILENAME_LENGTH
                                         + SHORT + SHORT + fileNameLen + extraFieldLen;

                if (entriesWithoutUTF8Flag.containsKey(ze))
                {
                    String             orig = ze.getName();
                    IAC_NameAndComment nc   = (IAC_NameAndComment)entriesWithoutUTF8Flag.get(ze);
                    ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name, nc.comment);
                    if (!orig.equals(ze.getName()))
                    {
                        nameMap.remove(orig);
                        nameMap.put(ze.getName(), ze);
                    }
                }
            }
        }
 /**
  * Puts a key-value mapping into the map at the specified index.
  * <p>
  * If the map already contains the key, then the original mapping
  * is removed and the new mapping added at the specified index.
  * The remove may change the effect of the index. The index is
  * always calculated relative to the original state of the map.
  * <p>
  * Thus the steps are: (1) remove the existing key-value mapping,
  * then (2) insert the new key-value mapping at the position it
  * would have been inserted had the remove not ocurred.
  *
  * @param index  the index at which the mapping should be inserted
  * @param key  the key
  * @param value  the value
  * @return the value previously mapped to the key
  * @throws IndexOutOfBoundsException if the index is out of range
  * @since Commons Collections 3.2
  */
 public virtual Object put(int index, Object key, Object value)
 {
     java.util.Map <Object, Object> m = getMap();
     if (m.containsKey(key))
     {
         Object result = m.remove(key);
         int    pos    = insertOrder.indexOf(key);
         insertOrder.remove(pos);
         if (pos < index)
         {
             index--;
         }
         insertOrder.add(index, key);
         m.put(key, value);
         return(result);
     }
     else
     {
         insertOrder.add(index, key);
         m.put(key, value);
         return(null);
     }
 }
 public virtual bool containsKey(Object key)
 {
     return(map.containsKey(key));
 }
        //-----------------------------------------------------------------------

        /**
         * Determines if the bag contains the given element by checking if the
         * underlying map contains the element as a key.
         *
         * @param object  the object to search for
         * @return true if the bag contains the given element
         */
        public virtual bool contains(Object obj)
        {
            return(map.containsKey(obj));
        }
Exemplo n.º 8
0
        // Basic object methods
        // ----------------------------------------------------------------------

        /**
         * Compare the specified object with this list for equality.  This
         * implementation uses exactly the code that is used to define the
         * list equals function in the documentation for the
         * <code>Map.equals</code> method.
         *
         * @param o  the object to be compared to this list
         * @return true if the two maps are equal
         */
        public override bool Equals(Object o)
        {
            // Simple tests that require no synchronization
            if (o == this)
            {
                return(true);
            }
            else if (!(o is java.util.Map <Object, Object>))
            {
                return(false);
            }
            java.util.Map <Object, Object> mo = (java.util.Map <Object, Object>)o;

            // Compare the two maps for equality
            if (fast)
            {
                if (mo.size() != map.size())
                {
                    return(false);
                }
                java.util.Iterator <java.util.MapNS.Entry <Object, Object> > i = map.entrySet().iterator();
                while (i.hasNext())
                {
                    java.util.MapNS.Entry <Object, Object> e = i.next();
                    Object key   = e.getKey();
                    Object value = e.getValue();
                    if (value == null)
                    {
                        if (!(mo.get(key) == null && mo.containsKey(key)))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (!value.equals(mo.get(key)))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else
            {
                lock (map)
                {
                    if (mo.size() != map.size())
                    {
                        return(false);
                    }
                    java.util.Iterator <java.util.MapNS.Entry <Object, Object> > i = map.entrySet().iterator();
                    while (i.hasNext())
                    {
                        java.util.MapNS.Entry <Object, Object> e = i.next();
                        Object key   = e.getKey();
                        Object value = e.getValue();
                        if (value == null)
                        {
                            if (!(mo.get(key) == null && mo.containsKey(key)))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!value.equals(mo.get(key)))
                            {
                                return(false);
                            }
                        }
                    }
                    return(true);
                }
            }
        }