public bool add(Object obj)
        {
            int size = map.size();

            map.put(obj, dummyValue);
            return(map.size() != size);
        }
Exemple #2
0
 public OrderedProviderIterator(java.util.Iterator <Object> it)
 {
     // find all the nodes that with no incoming edges and
     // add them to firstNodes
     while (it.hasNext())
     {
         ProviderNode node = (ProviderNode)it.next();
         incomingEdges.put(node, new java.lang.Integer(node.getIncomingEdges()));
         if (node.getIncomingEdges() == 0)
         {
             firstNodes.push(node);
         }
     }
 }
 /**
  * Adds a new element to the bag by incrementing its count in the map.
  *
  * @param object  the object to search for
  * @param nCopies  the number of copies to add
  * @return <code>true</code> if the object was not already in the <code>uniqueSet</code>
  */
 public virtual bool add(Object obj, int nCopies)
 {
     _mods++;
     if (nCopies > 0)
     {
         int count = (nCopies + getCount(obj));
         _map.put(obj, new java.lang.Integer(count));
         _total += nCopies;
         return(count == nCopies);
     }
     else
     {
         return(false);
     }
 }
Exemple #4
0
 public void add(Token token, int docFreq)
 {
     if (tokenFrequency == null)
     {
         tokenFrequency = new LinkedHashMap/*<Token, Integer>*/ ();
     }
     tokenFrequency.put(token, docFreq);
 }
 /**
  * This implementation uses an internal {@link HashMap} to map the name
  * to the specified object.
  *
  * @throws NullPointerException {@inheritDoc}
  */
 public virtual Object setProperty(String name, Object value)
 {
     if (name == null)
     {
         throw new java.lang.NullPointerException("name is null");
     }
     return(propMap.put(name, value));
 }
Exemple #6
0
 /**
  * Sets the value associated with the key direct onto the map.
  *
  * @param value  the new value
  * @return the old value
  * @throws IllegalArgumentException if the value is set to this map entry
  */
 public Object setValue(Object value)
 {
     if (value == this)
     {
         throw new java.lang.IllegalArgumentException("Cannot set value to this map entry");
     }
     return(map.put(key, value));
 }
 /**
  * This implementation uses an internal {@link HashMap} to map the URI
  * to the specified prefix.
  *
  * @throws NullPointerException {@inheritDoc}
  */
 public virtual String putNamespacePrefix(String namespaceURI, String prefix)
 {
     if (namespaceURI == null)
     {
         throw new java.lang.NullPointerException("namespaceURI is null");
     }
     return(nsMap.put(namespaceURI, prefix));
 }
 awt.FontMetrics GetMetrics(FontStyle style)
 {
     if ((_lastStyle != style) || (_fontMetrics == null))
     {
         java.util.Map attrib = Font.DeriveStyle(FamilyFont.getAttributes(), style, true);
         attrib.put(TextAttribute.SIZE, new java.lang.Float((float)(UnitsPerEm << 1)));
         _fontMetrics = Container.getFontMetrics(FamilyFont.deriveFont(attrib));
     }
     return(_fontMetrics);
 }
Exemple #9
0
        /**
         * Gets the <code>BeanInfo</code> object which contains the information of
         * the properties, events and methods of the specified bean class.
         *
         * <p>
         * The <code>Introspector</code> will cache the <code>BeanInfo</code>
         * object. Subsequent calls to this method will be answered with the cached
         * data.
         * </p>
         *
         * @param beanClass
         *            the specified bean class.
         * @return the <code>BeanInfo</code> of the bean class.
         * @throws IntrospectionException
         */
        public static BeanInfo getBeanInfo(java.lang.Class beanClass)
        {//throws IntrospectionException {
            StandardBeanInfo beanInfo = theCache.get(beanClass);

            if (beanInfo == null)
            {
                beanInfo = getBeanInfoImplAndInit(beanClass, null, USE_ALL_BEANINFO);
                theCache.put(beanClass, beanInfo);
            }
            return(beanInfo);
        }
Exemple #10
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);
        }
        /**
         * Read the map in using a custom routine.
         * @param map  the map to use
         * @param in  the input stream
         * @throws IOException
         * @throws ClassNotFoundException
         */
        protected virtual void doReadObject(java.util.Map <Object, Object> map, java.io.ObjectInputStream inJ)
        {// throws IOException, ClassNotFoundException {
            this.map = map;
            int entrySize = inJ.readInt();

            for (int i = 0; i < entrySize; i++)
            {
                Object obj   = inJ.readObject();
                int    count = inJ.readInt();
                map.put(obj, new MutableInteger(count));
                sizeJ += count;
            }
        }
 /**
  * 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);
     }
 }
Exemple #13
0
 /**
  * Register a ZipExtraField implementation.
  *
  * <p>The given class must have a no-arg constructor and implement
  * the {@link ZipExtraField ZipExtraField interface}.</p>
  * @param c the class to register
  */
 public static void register(Type c)
 {
     try {
         ZipExtraField ze = (ZipExtraField)Activator.CreateInstance(c);
         implementations.put(ze.getHeaderId(), c);
     } catch (InvalidCastException) {
         throw new java.lang.RuntimeException(c + " doesn\'t implement ZipExtraField");
     } catch (MethodAccessException) {
         throw new java.lang.RuntimeException(c + "\'s no-arg constructor is not public");
     }
     catch (MemberAccessException)
     {
         throw new java.lang.RuntimeException(c + " is not a concrete class");
     }
 }
Exemple #14
0
            bool addProvider(Object provider)
            {
                ProviderNode node = new ProviderNode(provider);

                nodeMap.put(provider, node);
                Object obj = providers.put(provider.getClass(), provider);

                if (obj != null)
                {
                    nodeMap.remove(obj);
                    return(false);
                }

                return(true);
            }
Exemple #15
0
        /**
         * Applies a given attribute to this string.
         *
         * @param attribute
         *            the attribute that will be applied to this string.
         * @param value
         *            the value of the attribute that will be applied to this
         *            string.
         * @throws IllegalArgumentException
         *             if the length of this attributed string is 0.
         * @throws NullPointerException
         *             if {@code attribute} is {@code null}.
         */
        public void addAttribute(AttributedCharacterIteratorNS.Attribute attribute,
                                 System.Object value)
        {
            if (null == attribute)
            {
                throw new java.lang.NullPointerException();
            }
            if (text.Length == 0)
            {
                throw new java.lang.IllegalArgumentException();
            }

            java.util.List <IAC_Range> ranges = attributeMap.get(attribute);
            if (ranges == null)
            {
                ranges = new java.util.ArrayList <IAC_Range>(1);
                attributeMap.put(attribute, ranges);
            }
            else
            {
                ranges.clear();
            }
            ranges.add(new IAC_Range(0, text.Length, value));
        }
Exemple #16
0
        /**
         * Registers the element's attribute specified by the namespace URI and
         * local name to be of type ID. The attribute must have a non-empty value.
         *
         * <p>This implementation uses an internal {@link HashMap} to map the
         * attribute's value to the specified element.
         *
         * @param element the element
         * @param namespaceURI the namespace URI of the attribute (specify
         *    <code>null</code> if not applicable)
         * @param localName the local name of the attribute
         * @throws IllegalArgumentException if <code>localName</code> is not an
         *    attribute of the specified element or it does not contain a specific
         *    value
         * @throws NullPointerException if <code>element</code> or
         *    <code>localName</code> is <code>null</code>
         * @see #getElementById
         */
        public void setIdAttributeNS(org.w3c.dom.Element element, String namespaceURI,
                                     String localName)
        {
            if (element == null)
            {
                throw new java.lang.NullPointerException("element is null");
            }
            if (localName == null)
            {
                throw new java.lang.NullPointerException("localName is null");
            }
            String idValue = element.getAttributeNS(namespaceURI, localName);

            if (idValue == null || idValue.length() == 0)
            {
                throw new java.lang.IllegalArgumentException(localName + " is not an " +
                                                             "attribute");
            }
            idMap.put(idValue, element);
        }
 private void aggregateGroupDescs(java.util.Map <string, java.util.List <android.content.pm.PermissionInfo
                                                                         > > map, java.util.Map <string, string> retMap)
 {
     if (map == null)
     {
         return;
     }
     if (retMap == null)
     {
         return;
     }
     java.util.Set <string>      grpNames     = map.keySet();
     java.util.Iterator <string> grpNamesIter = grpNames.iterator();
     while (grpNamesIter.hasNext())
     {
         string grpDesc    = null;
         string grpNameKey = grpNamesIter.next();
         java.util.List <android.content.pm.PermissionInfo> grpPermsList = map.get(grpNameKey
                                                                                   );
         if (grpPermsList == null)
         {
             continue;
         }
         foreach (android.content.pm.PermissionInfo permInfo in Sharpen.IterableProxy.Create
                      (grpPermsList))
         {
             java.lang.CharSequence permDesc = permInfo.loadLabel(mPm);
             grpDesc = formatPermissions(grpDesc, permDesc);
         }
         // Insert grpDesc into map
         if (grpDesc != null)
         {
             if (localLOGV)
             {
                 android.util.Log.i(TAG, "Group:" + grpNameKey + " description:" + grpDesc.ToString
                                        ());
             }
             retMap.put(grpNameKey, grpDesc.ToString());
         }
     }
 }
 /**
  * Adds a new element to the bag, incrementing its count in the map.
  *
  * @param object  the object to search for
  * @param nCopies  the number of copies to add
  * @return <code>true</code> if the object was not already in the <code>uniqueSet</code>
  */
 public virtual bool add(Object obj, int nCopies)
 {
     modCount++;
     if (nCopies > 0)
     {
         MutableInteger mut = (MutableInteger)map.get(obj);
         sizeJ += nCopies;
         if (mut == null)
         {
             map.put(obj, new MutableInteger(nCopies));
             return(true);
         }
         else
         {
             mut.value += nCopies;
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Exemple #19
0
 /**
  * Creates an {@code AttributedString} from the given text and the
  * attributes. The whole text has the given attributes applied.
  *
  * @param value
  *            the text to take as base for this attributed string.
  * @param attributes
  *            the attributes that the text is associated with.
  * @throws IllegalArgumentException
  *             if the length of {@code value} is 0 but the size of {@code
  *             attributes} is greater than 0.
  * @throws NullPointerException
  *             if {@code value} is {@code null}.
  */
 public AttributedString(System.String value,
                         java.util.Map <AttributedCharacterIteratorNS.Attribute, System.Object> attributes)
 {
     if (value == null)
     {
         throw new java.lang.NullPointerException();
     }
     if (value.Length == 0 && !attributes.isEmpty())
     {
         // text.0B=Cannot add attributes to empty string
         throw new java.lang.IllegalArgumentException("Cannot add attributes to empty string"); //$NON-NLS-1$
     }
     text         = value;
     attributeMap = new java.util.HashMap <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> >();//(attributes.size() * 4 / 3) + 1);
     java.util.Iterator <java.util.MapNS.Entry <AttributedCharacterIteratorNS.Attribute, System.Object> > it = attributes.entrySet().iterator();
     while (it.hasNext())
     {
         java.util.MapNS.Entry <AttributedCharacterIteratorNS.Attribute, System.Object> entry = it.next();
         java.util.ArrayList <IAC_Range> ranges = new java.util.ArrayList <IAC_Range>(1);
         ranges.add(new IAC_Range(0, text.Length, entry.getValue()));
         attributeMap.put((AttributedCharacterIteratorNS.Attribute)entry
                          .getKey(), ranges);
     }
 }
Exemple #20
0
 /**
  * Creates an {@code AttributedString} from the given text and the
  * attributes. The whole text has the given attributes applied.
  *
  * @param value
  *            the text to take as base for this attributed string.
  * @param attributes
  *            the attributes that the text is associated with.
  * @throws IllegalArgumentException
  *             if the length of {@code value} is 0 but the size of {@code
  *             attributes} is greater than 0.
  * @throws NullPointerException
  *             if {@code value} is {@code null}.
  */
 public AttributedString(System.String value,
         java.util.Map<AttributedCharacterIteratorNS.Attribute, System.Object> attributes)
 {
     if (value == null) {
         throw new java.lang.NullPointerException();
     }
     if (value.Length == 0 && !attributes.isEmpty()) {
         // text.0B=Cannot add attributes to empty string
         throw new java.lang.IllegalArgumentException("Cannot add attributes to empty string"); //$NON-NLS-1$
     }
     text = value;
     attributeMap = new java.util.HashMap<AttributedCharacterIteratorNS.Attribute, java.util.List<IAC_Range>>();//(attributes.size() * 4 / 3) + 1);
     java.util.Iterator<java.util.MapNS.Entry<AttributedCharacterIteratorNS.Attribute,System.Object>> it = attributes.entrySet().iterator();
     while (it.hasNext()) {
         java.util.MapNS.Entry<AttributedCharacterIteratorNS.Attribute, System.Object> entry = it.next();
         java.util.ArrayList<IAC_Range> ranges = new java.util.ArrayList<IAC_Range>(1);
         ranges.add(new IAC_Range(0, text.Length, entry.getValue()));
         attributeMap.put((AttributedCharacterIteratorNS.Attribute) entry
                 .getKey(), ranges);
     }
 }
Exemple #21
0
        /**
         * Reads the central directory of the given archive and populates
         * the internal tables with ZipArchiveEntry instances.
         *
         * <p>The ZipArchiveEntrys will know all data that can be obtained from
         * the central directory alone, but not the data that requires the
         * local file header or additional data to be read.</p>
         *
         * @return a Map&lt;ZipArchiveEntry, NameAndComment>&gt; of
         * zipentries that didn't have the language encoding flag set when
         * read.
         */
        private java.util.Map <ZipArchiveEntry, IAC_NameAndComment> populateFromCentralDirectory()
        //throws IOException
        {
            java.util.HashMap <ZipArchiveEntry, IAC_NameAndComment> noUTF8Flag = new java.util.HashMap <ZipArchiveEntry, IAC_NameAndComment>();

            positionAtCentralDirectory();

            byte[] cfh = new byte[CFH_LEN];

            byte[] signatureBytes = new byte[WORD];
            archive.readFully(signatureBytes);
            long sig    = ZipLong.getValue(signatureBytes);
            long cfhSig = ZipLong.getValue(ZipArchiveOutputStream.CFH_SIG);

            if (sig != cfhSig && startsWithLocalFileHeader())
            {
                throw new java.io.IOException("central directory is empty, can't expand"
                                              + " corrupt archive.");
            }
            while (sig == cfhSig)
            {
                archive.readFully(cfh);
                int             off = 0;
                ZipArchiveEntry ze  = new ZipArchiveEntry();

                int versionMadeBy = ZipShort.getValue(cfh, off);
                off += SHORT;
                ze.setPlatform((versionMadeBy >> BYTE_SHIFT) & NIBLET_MASK);

                off += SHORT; // skip version info

                GeneralPurposeBit gpFlag  = GeneralPurposeBit.parse(cfh, off);
                bool        hasUTF8Flag   = gpFlag.usesUTF8ForNames();
                ZipEncoding entryEncoding =
                    hasUTF8Flag ? ZipEncodingHelper.UTF8_ZIP_ENCODING : zipEncoding;
                ze.setGeneralPurposeBit(gpFlag);

                off += SHORT;

                ze.setMethod(ZipShort.getValue(cfh, off));
                off += SHORT;

                // FIXME this is actually not very cpu cycles friendly as we are converting from
                // dos to java while the underlying Sun implementation will convert
                // from java to dos time for internal storage...
                long time = ZipUtil.dosToJavaTime(ZipLong.getValue(cfh, off));
                ze.setTime(time);
                off += WORD;

                ze.setCrc(ZipLong.getValue(cfh, off));
                off += WORD;

                ze.setCompressedSize(ZipLong.getValue(cfh, off));
                off += WORD;

                ze.setSize(ZipLong.getValue(cfh, off));
                off += WORD;

                int fileNameLen = ZipShort.getValue(cfh, off);
                off += SHORT;

                int extraLen = ZipShort.getValue(cfh, off);
                off += SHORT;

                int commentLen = ZipShort.getValue(cfh, off);
                off += SHORT;

                off += SHORT; // disk number

                ze.setInternalAttributes(ZipShort.getValue(cfh, off));
                off += SHORT;

                ze.setExternalAttributes(ZipLong.getValue(cfh, off));
                off += WORD;

                byte[] fileName = new byte[fileNameLen];
                archive.readFully(fileName);
                ze.setName(entryEncoding.decode(fileName));

                // LFH offset,
                IAC_OffsetEntry offset = new IAC_OffsetEntry();
                offset.headerOffset = ZipLong.getValue(cfh, off);
                // data offset will be filled later
                entries.put(ze, offset);

                nameMap.put(ze.getName(), ze);

                byte[] cdExtraData = new byte[extraLen];
                archive.readFully(cdExtraData);
                ze.setCentralDirectoryExtra(cdExtraData);

                byte[] comment = new byte[commentLen];
                archive.readFully(comment);
                ze.setComment(entryEncoding.decode(comment));

                archive.readFully(signatureBytes);
                sig = ZipLong.getValue(signatureBytes);

                if (!hasUTF8Flag && useUnicodeExtraFields)
                {
                    noUTF8Flag.put(ze, new IAC_NameAndComment(fileName, comment));
                }
            }
            return(noUTF8Flag);
        }
 private void setPermissions(java.util.List <android.content.pm.PermissionInfo> permList
                             )
 {
     mGroupLabelCache = new java.util.HashMap <string, java.lang.CharSequence>();
     //add the default label so that uncategorized permissions can go here
     mGroupLabelCache.put(mDefaultGrpName, java.lang.CharSequenceProxy.Wrap(mDefaultGrpLabel
                                                                            ));
     // Map containing group names and a list of permissions under that group
     // categorized as dangerous
     mDangerousMap = new java.util.HashMap <string, string>();
     // Map containing group names and a list of permissions under that group
     // categorized as normal
     mNormalMap = new java.util.HashMap <string, string>();
     // Additional structures needed to ensure that permissions are unique under
     // each group
     java.util.Map <string, java.util.List <android.content.pm.PermissionInfo> > dangerousMap
         = new java.util.HashMap <string, java.util.List <android.content.pm.PermissionInfo
                                                          > >();
     java.util.Map <string, java.util.List <android.content.pm.PermissionInfo> > normalMap
         = new java.util.HashMap <string, java.util.List <android.content.pm.PermissionInfo
                                                          > >();
     android.widget.AppSecurityPermissions.PermissionInfoComparator permComparator = new
                                                                                     android.widget.AppSecurityPermissions.PermissionInfoComparator(mPm);
     if (permList != null)
     {
         // First pass to group permissions
         foreach (android.content.pm.PermissionInfo pInfo in Sharpen.IterableProxy.Create(
                      permList))
         {
             if (localLOGV)
             {
                 android.util.Log.i(TAG, "Processing permission:" + pInfo.name);
             }
             if (!isDisplayablePermission(pInfo))
             {
                 if (localLOGV)
                 {
                     android.util.Log.i(TAG, "Permission:" + pInfo.name + " is not displayable");
                 }
                 continue;
             }
             java.util.Map <string, java.util.List <android.content.pm.PermissionInfo> > permInfoMap
                 = (pInfo.protectionLevel == android.content.pm.PermissionInfo.PROTECTION_DANGEROUS
                    ) ? dangerousMap : normalMap;
             string grpName = (pInfo.group == null) ? mDefaultGrpName : pInfo.group;
             if (localLOGV)
             {
                 android.util.Log.i(TAG, "Permission:" + pInfo.name + " belongs to group:" + grpName
                                    );
             }
             java.util.List <android.content.pm.PermissionInfo> grpPermsList = permInfoMap.get(
                 grpName);
             if (grpPermsList == null)
             {
                 grpPermsList = new java.util.ArrayList <android.content.pm.PermissionInfo>();
                 permInfoMap.put(grpName, grpPermsList);
                 grpPermsList.add(pInfo);
             }
             else
             {
                 int idx = java.util.Collections.binarySearch(grpPermsList, pInfo, permComparator);
                 if (localLOGV)
                 {
                     android.util.Log.i(TAG, "idx=" + idx + ", list.size=" + grpPermsList.size());
                 }
                 if (idx < 0)
                 {
                     idx = -idx - 1;
                     grpPermsList.add(idx, pInfo);
                 }
             }
         }
         // Second pass to actually form the descriptions
         // Look at dangerous permissions first
         aggregateGroupDescs(dangerousMap, mDangerousMap);
         aggregateGroupDescs(normalMap, mNormalMap);
     }
     mCurrentState = android.widget.AppSecurityPermissions.State.NO_PERMS;
     if (mDangerousMap.size() > 0)
     {
         mCurrentState = (mNormalMap.size() > 0) ? android.widget.AppSecurityPermissions.State
                         .BOTH : android.widget.AppSecurityPermissions.State.DANGEROUS_ONLY;
     }
     else
     {
         if (mNormalMap.size() > 0)
         {
             mCurrentState = android.widget.AppSecurityPermissions.State.NORMAL_ONLY;
         }
     }
     if (localLOGV)
     {
         android.util.Log.i(TAG, "mCurrentState=" + mCurrentState);
     }
     showPermissions();
 }
Exemple #23
0
 internal void addCategory(java.lang.Class category)
 {
     categories.put(category, new ProvidersMap());
 }
        /**
         * Writes the local file header entry
         * @param ze the entry to write
         * @throws IOException on error
         */
        protected void writeLocalFileHeader(ZipArchiveEntry ze) //throws IOException
        {
            bool encodable = zipEncoding.canEncode(ze.getName());

            ZipEncoding entryEncoding;

            if (!encodable && fallbackToUTF8)
            {
                entryEncoding = ZipEncodingHelper.UTF8_ZIP_ENCODING;
            }
            else
            {
                entryEncoding = zipEncoding;
            }

            java.nio.ByteBuffer name = entryEncoding.encode(ze.getName());

            if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER)
            {
                if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS ||
                    !encodable)
                {
                    ze.addExtraField(new UnicodePathExtraField(ze.getName(),
                                                               (byte[])name.array(),
                                                               name.arrayOffset(),
                                                               name.limit()));
                }

                String comm = ze.getComment();
                if (comm != null && !"".equals(comm))
                {
                    bool commentEncodable = this.zipEncoding.canEncode(comm);

                    if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS ||
                        !commentEncodable)
                    {
                        java.nio.ByteBuffer commentB = entryEncoding.encode(comm);
                        ze.addExtraField(new UnicodeCommentExtraField(comm,
                                                                      (byte[])commentB.array(),
                                                                      commentB.arrayOffset(),
                                                                      commentB.limit())
                                         );
                    }
                }
            }

            offsets.put(ze, ZipLong.getBytes(written));

            writeOut(LFH_SIG);
            written += WORD;

            //store method in local variable to prevent multiple method calls
            int zipMethod = ze.getMethod();

            writeVersionNeededToExtractAndGeneralPurposeBits(zipMethod,
                                                             !encodable &&
                                                             fallbackToUTF8);
            written += WORD;

            // compression method
            writeOut(ZipShort.getBytes(zipMethod));
            written += SHORT;

            // last mod. time and date
            writeOut(ZipUtil.toDosTime(ze.getTime()));
            written += WORD;

            // CRC
            // compressed length
            // uncompressed length
            localDataStart = written;
            if (zipMethod == DEFLATED || raf != null)
            {
                writeOut(LZERO);
                writeOut(LZERO);
                writeOut(LZERO);
            }
            else
            {
                writeOut(ZipLong.getBytes(ze.getCrc()));
                writeOut(ZipLong.getBytes(ze.getSize()));
                writeOut(ZipLong.getBytes(ze.getSize()));
            }
            // CheckStyle:MagicNumber OFF
            written += 12;
            // CheckStyle:MagicNumber ON

            // file name length
            writeOut(ZipShort.getBytes(name.limit()));
            written += SHORT;

            // extra field length
            byte[] extra = ze.getLocalFileDataExtra();
            writeOut(ZipShort.getBytes(extra.Length));
            written += SHORT;

            // file name
            writeOut((byte[])name.array(), name.arrayOffset(), name.limit());
            written += name.limit();

            // extra field
            writeOut(extra);
            written += extra.Length;

            dataStart = written;
        }
Exemple #25
0
 protected TextAttribute(String name)
     : base(name)
 {
     attrMap.put(name, this);
 }
 public virtual Object put(Object key, Object value)
 {
     return(map.put(key, value));
 }
        static ZipEncodingHelper()
        {
            simpleEncodings = new java.util.HashMap <String, SimpleEncodingHolder>();

            char[] cp437_high_chars =
                new char[] { '\u00c7', '\u00fc', '\u00e9', '\u00e2', '\u00e4', '\u00e0',
                             '\u00e5', '\u00e7', '\u00ea', '\u00eb', '\u00e8', '\u00ef',
                             '\u00ee', '\u00ec', '\u00c4', '\u00c5', '\u00c9', '\u00e6',
                             '\u00c6', '\u00f4', '\u00f6', '\u00f2', '\u00fb', '\u00f9',
                             '\u00ff', '\u00d6', '\u00dc', '\u00a2', '\u00a3', '\u00a5',
                             '\u20a7', '\u0192', '\u00e1', '\u00ed', '\u00f3', '\u00fa',
                             '\u00f1', '\u00d1', '\u00aa', '\u00ba', '\u00bf', '\u2310',
                             '\u00ac', '\u00bd', '\u00bc', '\u00a1', '\u00ab', '\u00bb',
                             '\u2591', '\u2592', '\u2593', '\u2502', '\u2524', '\u2561',
                             '\u2562', '\u2556', '\u2555', '\u2563', '\u2551', '\u2557',
                             '\u255d', '\u255c', '\u255b', '\u2510', '\u2514', '\u2534',
                             '\u252c', '\u251c', '\u2500', '\u253c', '\u255e', '\u255f',
                             '\u255a', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550',
                             '\u256c', '\u2567', '\u2568', '\u2564', '\u2565', '\u2559',
                             '\u2558', '\u2552', '\u2553', '\u256b', '\u256a', '\u2518',
                             '\u250c', '\u2588', '\u2584', '\u258c', '\u2590', '\u2580',
                             '\u03b1', '\u00df', '\u0393', '\u03c0', '\u03a3', '\u03c3',
                             '\u00b5', '\u03c4', '\u03a6', '\u0398', '\u03a9', '\u03b4',
                             '\u221e', '\u03c6', '\u03b5', '\u2229', '\u2261', '\u00b1',
                             '\u2265', '\u2264', '\u2320', '\u2321', '\u00f7', '\u2248',
                             '\u00b0', '\u2219', '\u00b7', '\u221a', '\u207f', '\u00b2',
                             '\u25a0', '\u00a0' };

            SimpleEncodingHolder cp437 = new SimpleEncodingHolder(cp437_high_chars);

            simpleEncodings.put("CP437", cp437);
            simpleEncodings.put("Cp437", cp437);
            simpleEncodings.put("cp437", cp437);
            simpleEncodings.put("IBM437", cp437);
            simpleEncodings.put("ibm437", cp437);

            char[] cp850_high_chars =
                new char[] { '\u00c7', '\u00fc', '\u00e9', '\u00e2', '\u00e4', '\u00e0',
                             '\u00e5', '\u00e7', '\u00ea', '\u00eb', '\u00e8', '\u00ef',
                             '\u00ee', '\u00ec', '\u00c4', '\u00c5', '\u00c9', '\u00e6',
                             '\u00c6', '\u00f4', '\u00f6', '\u00f2', '\u00fb', '\u00f9',
                             '\u00ff', '\u00d6', '\u00dc', '\u00f8', '\u00a3', '\u00d8',
                             '\u00d7', '\u0192', '\u00e1', '\u00ed', '\u00f3', '\u00fa',
                             '\u00f1', '\u00d1', '\u00aa', '\u00ba', '\u00bf', '\u00ae',
                             '\u00ac', '\u00bd', '\u00bc', '\u00a1', '\u00ab', '\u00bb',
                             '\u2591', '\u2592', '\u2593', '\u2502', '\u2524', '\u00c1',
                             '\u00c2', '\u00c0', '\u00a9', '\u2563', '\u2551', '\u2557',
                             '\u255d', '\u00a2', '\u00a5', '\u2510', '\u2514', '\u2534',
                             '\u252c', '\u251c', '\u2500', '\u253c', '\u00e3', '\u00c3',
                             '\u255a', '\u2554', '\u2569', '\u2566', '\u2560', '\u2550',
                             '\u256c', '\u00a4', '\u00f0', '\u00d0', '\u00ca', '\u00cb',
                             '\u00c8', '\u0131', '\u00cd', '\u00ce', '\u00cf', '\u2518',
                             '\u250c', '\u2588', '\u2584', '\u00a6', '\u00cc', '\u2580',
                             '\u00d3', '\u00df', '\u00d4', '\u00d2', '\u00f5', '\u00d5',
                             '\u00b5', '\u00fe', '\u00de', '\u00da', '\u00db', '\u00d9',
                             '\u00fd', '\u00dd', '\u00af', '\u00b4', '\u00ad', '\u00b1',
                             '\u2017', '\u00be', '\u00b6', '\u00a7', '\u00f7', '\u00b8',
                             '\u00b0', '\u00a8', '\u00b7', '\u00b9', '\u00b3', '\u00b2',
                             '\u25a0', '\u00a0' };

            SimpleEncodingHolder cp850 = new SimpleEncodingHolder(cp850_high_chars);

            simpleEncodings.put("CP850", cp850);
            simpleEncodings.put("Cp850", cp850);
            simpleEncodings.put("cp850", cp850);
            simpleEncodings.put("IBM850", cp850);
            simpleEncodings.put("ibm850", cp850);
        }