示例#1
0
        /**
         * Returns an InputStream for reading the contents of the given entry.
         *
         * @param ze the entry to get the stream for.
         * @return a stream to read the entry from.
         * @throws IOException if unable to create an input stream from the zipenty
         * @throws ZipException if the zipentry uses an unsupported feature
         */
        public java.io.InputStream getInputStream(ZipArchiveEntry ze)
        //throws IOException, ZipException
        {
            IAC_OffsetEntry offsetEntry = entries.get(ze);

            if (offsetEntry == null)
            {
                return(null);
            }
            ZipUtil.checkRequestedFeatures(ze);
            long start             = offsetEntry.dataOffset;
            BoundedInputStream bis =
                new BoundedInputStream(this, start, ze.getCompressedSize());

            switch (ze.getMethod())
            {
            case ZipArchiveEntry.STORED:
                return(bis);

            case ZipArchiveEntry.DEFLATED:
                bis.addDummy();
                return(new java.util.zip.InflaterInputStream(bis, new java.util.zip.Inflater(true)));

            default:
                throw new java.util.zip.ZipException("Found unsupported compression method "
                                                     + ze.getMethod());
            }
        }
示例#2
0
            public bool setOrdering <T>(T firstProvider, T secondProvider)
            {
                if (firstProvider == secondProvider)
                {
                    throw new java.lang.IllegalArgumentException(Messages.getString("imageio.98"));
                }

                if ((firstProvider == null) || (secondProvider == null))
                {
                    throw new java.lang.IllegalArgumentException("Provider should be != NULL");
                }

                ProviderNode firstNode  = nodeMap.get(firstProvider);
                ProviderNode secondNode = nodeMap.get(secondProvider);

                // if the ordering is already set, return false
                if ((firstNode == null) || (firstNode.contains(secondNode)))
                {
                    return(false);
                }

                // put secondProvider into firstProvider's outgoing nodes list
                firstNode.addOutEdge(secondNode);
                // increase secondNode's incoming edge by 1
                secondNode.addInEdge();

                return(true);
            }
        /**
         * Returns the number of occurrence of the given element in this bag
         * by looking up its count in the underlying map.
         *
         * @param object  the object to search for
         * @return the number of occurrences of the object, zero if not found
         */
        public virtual int getCount(Object obj)
        {
            MutableInteger count = (MutableInteger)map.get(obj);

            if (count != null)
            {
                return(count.value);
            }
            return(0);
        }
示例#4
0
        /**
         * Instantiates a zip encoding.
         *
         * @param name The name of the zip encoding. Specify <code>null</code> for
         *             the platform's default encoding.
         * @return A zip encoding for the given encoding name.
         */
        protected internal static ZipEncoding getZipEncoding(String name)
        {
            // fallback encoding is good enough for utf-8.
            if (isUTF8(name))
            {
                return(UTF8_ZIP_ENCODING);
            }

            if (name == null)
            {
                return(new FallbackZipEncoding());
            }

            SimpleEncodingHolder h =
                (SimpleEncodingHolder)simpleEncodings.get(name);

            if (h != null)
            {
                return(h.getEncoding());
            }

            try {
                java.nio.charset.Charset cs = java.nio.charset.Charset.forName(name);
                return(new NioZipEncoding(cs));
            }
            catch (java.nio.charset.UnsupportedCharsetException)
            {
                return(new FallbackZipEncoding(name));
            }
        }
示例#5
0
            public Object next()
            {
                if (firstNodes.empty())
                {
                    throw new java.util.NoSuchElementException();
                }

                // get a node from firstNodes
                ProviderNode node = firstNodes.pop();

                // find all the outgoing nodes
                java.util.Iterator <Object> it = node.getOutgoingNodes();
                while (it.hasNext())
                {
                    ProviderNode outNode = (ProviderNode)it.next();

                    // remove the incoming edge from the node.
                    int edges = incomingEdges.get(outNode);
                    edges--;
                    incomingEdges.put(outNode, new java.lang.Integer(edges));

                    // add to the firstNodes if this node's incoming edge is equal to 0
                    if (edges == 0)
                    {
                        firstNodes.push(outNode);
                    }
                }

                incomingEdges.remove(node);

                return(node.getProvider());
            }
示例#6
0
        public override bool Equals(Object o)
        {
            if (!(o is java.util.Map <Object, Object>))
            {
                return(false);
            }

            java.util.Map <Object, Object> m    = (java.util.Map <Object, Object>)o;
            java.util.Set <Object>         keys = keySet();
            if (!keys.equals(m.keySet()))
            {
                return(false);
            }

            java.util.Iterator <Object> it = keys.iterator();
            while (it.hasNext())
            {
                Key    key = (Key)it.next();
                Object v1  = get(key);
                Object v2  = m.get(key);
                if (!(v1 == null?v2 == null:v1.equals(v2)))
                {
                    return(false);
                }
            }
            return(true);
        }
示例#7
0
 /**
  * Returns the <code>Element</code> with the specified ID attribute value.
  *
  * <p>This implementation uses an internal {@link HashMap} to get the
  * element that the specified attribute value maps to.
  *
  * @param idValue the value of the ID
  * @return the <code>Element</code> with the specified ID attribute value,
  *    or <code>null</code> if none.
  * @throws NullPointerException if <code>idValue</code> is <code>null</code>
  * @see #setIdAttributeNS
  */
 public virtual org.w3c.dom.Element getElementById(String idValue)
 {
     if (idValue == null)
     {
         throw new java.lang.NullPointerException("idValue is null");
     }
     return(idMap.get(idValue));
 }
示例#8
0
 /**
  * This implementation uses an internal {@link HashMap} to get the object
  * that the specified name maps to.
  *
  * @throws NullPointerException {@inheritDoc}
  */
 public virtual Object getProperty(String name)
 {
     if (name == null)
     {
         throw new java.lang.NullPointerException("name is null");
     }
     return(propMap.get(name));
 }
示例#9
0
 internal override android.widget.Filter.FilterResults performFiltering(java.lang.CharSequence
                                                                        prefix)
 {
     android.widget.Filter.FilterResults results = new android.widget.Filter.FilterResults
                                                       ();
     if (this._enclosing.mUnfilteredData == null)
     {
         this._enclosing.mUnfilteredData = new java.util.ArrayList <java.util.Map <string, object
                                                                                   > >(this._enclosing.mData);
     }
     if (prefix == null || prefix.Length == 0)
     {
         java.util.ArrayList <java.util.Map <string, object> > list = this._enclosing.mUnfilteredData;
         results.values = list;
         results.count  = list.size();
     }
     else
     {
         string prefixString = prefix.ToString().ToLower();
         java.util.ArrayList <java.util.Map <string, object> > unfilteredValues = this._enclosing
                                                                                  .mUnfilteredData;
         int count = unfilteredValues.size();
         java.util.ArrayList <java.util.Map <string, object> > newValues = new java.util.ArrayList
                                                                           <java.util.Map <string, object> >(count);
         {
             for (int i = 0; i < count; i++)
             {
                 java.util.Map <string, object> h = unfilteredValues.get(i);
                 if (h != null)
                 {
                     int len = this._enclosing.mTo.Length;
                     {
                         for (int j = 0; j < len; j++)
                         {
                             string   str       = (string)h.get(this._enclosing.mFrom[j]);
                             string[] words     = XobotOS.Runtime.Util.SplitStringRegex(str, " ");
                             int      wordCount = words.Length;
                             {
                                 for (int k = 0; k < wordCount; k++)
                                 {
                                     string word = words[k];
                                     if (word.ToLower().StartsWith(prefixString))
                                     {
                                         newValues.add(h);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         results.values = newValues;
         results.count  = newValues.size();
     }
     return(results);
 }
示例#10
0
        public void testTranslationDetails()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.testtranslations.test.adl");

            se.acode.openehr.parser.ADLParser  parser    = new se.acode.openehr.parser.ADLParser(adl);
            org.openehr.am.archetype.Archetype archetype = parser.parse();
            Assert.IsNotNull(archetype);

            java.util.Map      translations = archetype.getTranslations();
            TranslationDetails transDet     = (TranslationDetails)translations.get("de");

            Assert.AreEqual("test Accreditation!", transDet.getAccreditation());
            Assert.AreEqual("test organisation", transDet.getAuthor().get("organisation"));
            TranslationDetails transDet2 = (TranslationDetails)translations.get("es");

            Assert.AreEqual(null, transDet2.getAccreditation());
            Assert.AreEqual(null, transDet2.getAuthor().get("organisation"));
        }
示例#11
0
        //-----------------------------------------------------------------------

        /**
         * Puts all the entries from the specified map into this map.
         * This operation is <b>not atomic</b> and may have undesired effects.
         *
         * @param map  the map of entries to add
         */
        public void putAll(java.util.Map <Object, Object> map)
        {
            java.util.Iterator <Object> i = map.keySet().iterator();

            while (i.hasNext())
            {
                Object key = i.next();
                put(key, map.get(key));
            }
        }
示例#12
0
        /**
         * This implementation uses an internal {@link HashMap} to get the prefix
         * that the specified URI maps to. It returns the <code>defaultPrefix</code>
         * if it maps to <code>null</code>.
         *
         * @throws NullPointerException {@inheritDoc}
         */
        public String getNamespacePrefix(String namespaceURI,
                                         String defaultPrefix)
        {
            if (namespaceURI == null)
            {
                throw new java.lang.NullPointerException("namespaceURI cannot be null");
            }
            String prefix = nsMap.get(namespaceURI);

            return(prefix != null ? prefix : defaultPrefix);
        }
示例#13
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);
        }
示例#14
0
        protected override Object readResolve()
        {// throws InvalidObjectException {
            TextAttribute result = attrMap.get(this.getName());

            if (result != null)
            {
                return(result);
            }
            // awt.194=Unknown attribute name
            throw new java.io.InvalidObjectException("Unknown attribute name"); //$NON-NLS-1$
        }
示例#15
0
            bool removeProvider(Object provider,
                                ServiceRegistry registry, java.lang.Class category)
            {
                Object obj = providers.get(provider.getClass());

                if ((obj == null) || (obj != provider))
                {
                    return(false);
                }

                providers.remove(provider.getClass());
                nodeMap.remove(provider);

                if (provider is RegisterableService)
                {
                    ((RegisterableService)provider).onDeregistration(registry, category);
                }

                return(true);
            }
示例#16
0
 /*
  * Returns the value of the attribute with the specified {@code name}.
  *
  * @param name
  *            the name of the attribute.
  * @return the value of the attribute, or {@code null} if no attribute
  *         with the given name is set.
  * @throws NullPointerException
  *             if {@code name} is {@code null}.
  */
 public String getAttribute(String name)
 {
     if (name == null)
     {
         throw new java.lang.NullPointerException();
     }
     if (attributes == null)
     {
         return(null);
     }
     return(attributes.get(name));
 }
示例#17
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);
        }
示例#18
0
        /// <summary>
        /// Converts a map to Dictionary
        /// </summary>
        /// <typeparam name="K">the type of keys maintained by this map</typeparam>
        /// <typeparam name="V">the type of mapped values</typeparam>
        /// <param name="map">the map instance</param>
        /// <returns>Dictionary(of k,v)</k></returns>
        public static Dictionary <K, V> ToDictionary <K, V>(this java.util.Map map)
        {
            var dict     = new Dictionary <K, V>();
            var iterator = map.keySet().iterator();

            while (iterator.hasNext())
            {
                var key = (K)iterator.next();
                dict.Add(key, (V)map.get(key));
            }
            return(dict);
        }
示例#19
0
        /**
         * Create an instance of the approriate ExtraField, falls back to
         * {@link UnrecognizedExtraField UnrecognizedExtraField}.
         * @param headerId the header identifier
         * @return an instance of the appropiate ExtraField
         * @exception InstantiationException if unable to instantiate the class
         * @exception IllegalAccessException if not allowed to instatiate the class
         */
        public static ZipExtraField createExtraField(ZipShort headerId)
        //throws InstantiationException, IllegalAccessException
        {
            Type c = (Type)implementations.get(headerId);

            if (c != null)
            {
                return((ZipExtraField)Activator.CreateInstance(c));
            }
            UnrecognizedExtraField u = new UnrecognizedExtraField();

            u.setHeaderId(headerId);
            return(u);
        }
示例#20
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);
                    }
                }
            }
        }
示例#21
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));
        }
示例#22
0
            internal bool setOrdering <T>(java.lang.Class category, T firstProvider, T secondProvider)
            {
                ProvidersMap providers = categories.get(category);

                if (providers == null)
                {
                    throw new java.lang.IllegalArgumentException("Unknown category:" + category);
                }

                return(providers.setOrdering(firstProvider, secondProvider));
            }
示例#23
0
        public static Hashtable ToHashtable(java.util.Map map)
        {
            if (map == null)
            {
                return(null);
            }
            Hashtable table = new Hashtable();

            java.util.Iterator it = map.keySet().iterator();
            while (it.hasNext())
            {
                string key = (string)it.next();
                object val = map.get(key);
                table[key] = val;
            }
            return(table);
        }
示例#24
0
        /// <summary>
        /// Converts a map to a datatable
        /// </summary>
        /// <param name="map">the map instance</param>
        /// <returns>system.data.datatable object</returns>
        public static DataTable ToDataTabe(this java.util.Map map)
        {
            var dt = new DataTable();

            dt.Columns.Add("id", typeof(string));
            dt.Columns.Add("ProjectID", typeof(string));


            var iterator = map.keySet().iterator();

            while (iterator.hasNext())
            {
                DataRow r = dt.NewRow();
                var     o = iterator.next();
                r["id"]        = o;
                r["ProjectID"] = map.get(o);
                dt.Rows.Add(r);
            }
            return(dt);
        }
 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());
         }
     }
 }
 /// <summary>
 /// Utility method that displays permissions from a map containing group name and
 /// list of permission descriptions.
 /// </summary>
 /// <remarks>
 /// Utility method that displays permissions from a map containing group name and
 /// list of permission descriptions.
 /// </remarks>
 private void displayPermissions(bool dangerous)
 {
     java.util.Map <string, string> permInfoMap  = dangerous ? mDangerousMap : mNormalMap;
     android.widget.LinearLayout    permListView = dangerous ? mDangerousList : mNonDangerousList;
     permListView.removeAllViews();
     java.util.Set <string> permInfoStrSet = permInfoMap.keySet();
     foreach (string loopPermGrpInfoStr in Sharpen.IterableProxy.Create(permInfoStrSet
                                                                        ))
     {
         java.lang.CharSequence grpLabel = getGroupLabel(loopPermGrpInfoStr);
         //guaranteed that grpLabel wont be null since permissions without groups
         //will belong to the default group
         if (localLOGV)
         {
             android.util.Log.i(TAG, "Adding view group:" + grpLabel + ", desc:" + permInfoMap
                                .get(loopPermGrpInfoStr));
         }
         permListView.addView(getPermissionItemView(grpLabel, java.lang.CharSequenceProxy.Wrap
                                                        (permInfoMap.get(loopPermGrpInfoStr)), dangerous));
     }
 }
示例#27
0
        protected object GetStateFromClient(FacesContext facesContext, String viewId, String renderKitId)
        {
            //RenderKit renderKit = RenderKitFactory.getRenderKit (facesContext, renderKitId);
            //ResponseStateManager responseStateManager = renderKit.getResponseStateManager ();
            //responseStateManager.getTreeStructureToRestore (facesContext, viewId); //ignore result. Must call for compatibility with sun implementation.
            //return responseStateManager.getComponentStateToRestore (facesContext);

            java.util.Map map = facesContext.getExternalContext().getRequestParameterMap();
            string        s1  = (string)map.get(VIEWSTATE);

            byte [] buffer = Convert.FromBase64String(s1);
            java.io.ByteArrayInputStream bytearrayinputstream = new java.io.ByteArrayInputStream(vmw.common.TypeUtils.ToSByteArray(buffer));
            java.io.ObjectInputStream    inputStream          = new java.io.ObjectInputStream(bytearrayinputstream);
            //ignore tree structure
            //inputStream.readObject ();
            object state = inputStream.readObject();

            inputStream.close();
            bytearrayinputstream.close();

            return(state);
        }
示例#28
0
        private static IList <KeyValuePair <T, int> > GetFieldHits <T>(java.util.Map facetMap, string fieldName, Func <string, T> decode)
        {
            var facetAccessor = (FacetAccessible)facetMap.get(fieldName);

            if (facetAccessor == null)
            {
                return(null);
            }

            var hits   = new List <KeyValuePair <T, int> >();
            var facets = facetAccessor.getFacets();

            for (var iter = facets.iterator(); iter.hasNext();)
            {
                var facet       = (BrowseFacet)iter.next();
                var valueString = facet.getValue();
                var value       = decode(valueString);
                var hitCount    = facet.getFacetValueHitCount();
                hits.Add(new KeyValuePair <T, int>(value, hitCount));
            }

            return(hits);
        }
示例#29
0
        /**
         * Starts a new process based on the current state of this process builder.
         *
         * @return the new {@code Process} instance.
         * @throws NullPointerException
         *             if any of the elements of {@link #command()} is {@code null}.
         * @throws IndexOutOfBoundsException
         *             if {@link #command()} is empty.
         * @throws SecurityException
         *             if {@link SecurityManager#checkExec(String)} doesn't allow
         *             process creation.
         * @throws IOException
         *             if an I/O error happens.
         */
        public Process start()//throws IOException {
        {
            if (commandJ.isEmpty())
            {
                throw new IndexOutOfBoundsException();
            }
            String[] cmdArray = new String[commandJ.size()];
            for (int i = 0; i < cmdArray.Length; i++)
            {
                if ((cmdArray[i] = commandJ.get(i)) == null)
                {
                    throw new NullPointerException();
                }
            }
            String[] envArray = new String[environmentJ.size()];
            int      i2       = 0;

            /*
             * foreach (Map.Entry<String, String> entry in environmentJ.entrySet()) {
             * envArray[i2++] = entry.getKey() + "=" + entry.getValue(); //$NON-NLS-1$
             * }
             */
            java.util.Iterator <String> it = environmentJ.keySet().iterator();
            while (it.hasNext())
            {
                String key   = it.next();
                String value = environmentJ.get(key);
                envArray[i2++] = key + "=" + value;
            }

            java.lang.Process process = Runtime.getRuntime().exec(cmdArray, envArray,
                                                                  directoryJ);

            // TODO implement support for redirectErrorStream
            return(process);
        }
 public virtual Object get(Object key)
 {
     return(map.get(key));
 }