Beispiel #1
0
        /// <summary>
        /// Load the compiled XPath expression to prepare it for execution.
        /// </summary>
        /// <returns>
        /// An <c>XPathSelector</c>. The returned <c>XPathSelector</c> can be used to
        /// set up the dynamic context, and then to evaluate the expression.
        /// </returns>

        public XPathSelector Load()
        {
            ArrayList declaredVariables = new ArrayList();
            JIterator iter = env.iterateExternalVariables();

            while (iter.hasNext())
            {
                JXPathVariable var = (JXPathVariable)iter.next();
                declaredVariables.Add(var);
            }
            return(new XPathSelector(exp, config, declaredVariables));
        }
        public static IEnumerable <T> toIEnumerable <T>(this java.util.List list)
        {
            if (list != null)
            {
                java.util.Iterator itr = list.iterator();

                while (itr.hasNext())
                {
                    yield return((T)itr.next());
                }
            }
        }
Beispiel #3
0
 private java.util.Enumeration <Permission> getNextEnumeration()
 {
     while (pcIter.hasNext())
     {
         java.util.Enumeration <Permission> en = ((PermissionCollection)pcIter.next()).elements();
         if (en.hasMoreElements())
         {
             return(en);
         }
     }
     return(null);
 }
Beispiel #4
0
        /// <summary>
        /// Get a list of external variables used by the expression. This will include both variables that were explicitly
        /// declared to the <c>XPathCompiler</c>, and (if the <c>AllowUndeclaredVariables</c> option was set) variables that
        /// are referenced within the expression but not explicitly declared.
        /// </summary>
        /// <returns>
        /// An <c>IEnumerator</c> over the names of the external variables, as instances of <c>QName</c>.
        /// </returns>

        public IEnumerator <QName> EnumerateExternalVariables2()
        {
            IList <QName> list = new List <QName>();
            JIterator     iter = executable.iterateExternalVariables();

            while (iter.hasNext())
            {
                net.sf.saxon.s9api.QName var = (net.sf.saxon.s9api.QName)iter.next();
                list.Add(new QName(var));
            }
            return(list.GetEnumerator());
        }
 public virtual bool containsAll <_T0>(java.util.Collection <_T0> collection)
 {
     java.util.Iterator <_T0> it = collection.iterator();
     while (it.hasNext())
     {
         if (!contains(it.next()))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #6
0
        private static ImageCodec CreateWriter(java.util.Iterator iter)
        {
            if (!iter.hasNext())
            {
                return(null);
            }

            ImageCodec imageCodec = new ImageCodec();

            imageCodec.NativeWriter = (imageio.ImageWriter)iter.next();
            return(imageCodec);
        }
        /**
         * Invokes {@link #add(Object)} for each element in the given collection.
         *
         * @param coll  the collection to add
         * @return <code>true</code> if this call changed the bag
         */
        public virtual bool addAll(java.util.Collection <Object> coll)
        {
            bool changed = false;

            java.util.Iterator <Object> i = coll.iterator();
            while (i.hasNext())
            {
                bool added = add(i.next());
                changed = changed || added;
            }
            return(changed);
        }
Beispiel #8
0
        internal static void CloseSelector(java.nio.channels.Selector selector)
        {
            java.util.Set      keys = selector.keys();
            java.util.Iterator it   = keys.iterator();

            try
            {
                selector.close();
            }
            catch (Exception e)
            {
#if DEBUG
                Console.WriteLine("Caught exception during CloseSelector selector.close - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace);
#endif
            }

            while (it.hasNext())
            {
                java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)it.next();
                Socket source = (Socket)key.attachment();
                key.cancel();
                try
                {
                    if (source.Blocking)
                    {
                        /*
                         *      A channel must be placed into non-blocking mode before being registered
                         *      with a selector, and may not be returned to blocking mode until it has been
                         *      deregistered. So, I need set the channel back to the blocking mode, if it was
                         *      in blocking mode before select operation
                         */
                        source.Blocking = true;
                    }
                }
                catch (Exception be)
                {
#if DEBUG
                    Console.WriteLine("Caught exception during CloseSelector source.Blocking - {0}: {1}\n{2}", be.GetType(), be.Message, be.StackTrace);
#endif
                }
            }

            try
            {
                selector.close();
            }
            catch (Exception e)
            {
#if DEBUG
                Console.WriteLine("Caught exception during CloseSelector selector.close - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace);
#endif
            }
        }
Beispiel #9
0
        public ArrayList GetNearestNonRelations(string term)
        {
            ArrayList list = new ArrayList();

            java.util.Iterator it = _kb.getNearestNonRelations(term).iterator();
            while (it.hasNext())
            {
                Term t = new Term(this, it.next().ToString());
                list.Add(t);
            }
            return(list);
        }
        public virtual object[] toArray()
        {
            int size_1 = size();
            int index  = 0;

            java.util.Iterator <E> it = iterator();
            object[] array            = new object[size_1];
            while (index < size_1)
            {
                array[index++] = it.next();
            }
            return(array);
        }
 /**
  * Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
  * method returns a list containing all the elements in <code>c</code>
  * that are not in <code>remove</code>. The cardinality of an element <code>e</code>
  * in the returned collection is the same as the cardinality of <code>e</code>
  * in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
  * case the cardinality is zero. This method is useful if you do not wish to modify
  * <code>collection</code> and thus cannot call <code>collection.removeAll(remove);</code>.
  *
  * @param collection  the collection from which items are removed (in the returned collection)
  * @param remove  the items to be removed from the returned <code>collection</code>
  * @return a <code>List</code> containing all the elements of <code>c</code> except
  * any elements that also occur in <code>remove</code>.
  * @throws NullPointerException if either parameter is null
  * @since Commons Collections 3.2
  */
 public static java.util.List <Object> removeAll(java.util.Collection <Object> collection, java.util.Collection <Object> remove)
 {
     java.util.List <Object> list = new java.util.ArrayList <Object>();
     for (java.util.Iterator <Object> iter = collection.iterator(); iter.hasNext();)
     {
         Object obj = iter.next();
         if (remove.contains(obj) == false)
         {
             list.add(obj);
         }
     }
     return(list);
 }
Beispiel #12
0
 private System.Object currentValue(java.util.List <IAC_Range> ranges)
 {
     java.util.Iterator <IAC_Range> it = ranges.iterator();
     while (it.hasNext())
     {
         IAC_Range range = it.next();
         if (offset >= range.start && offset < range.end)
         {
             return(inRange(range) ? range.value : null);
         }
     }
     return(null);
 }
Beispiel #13
0
 public ServiceRegistry(java.util.Iterator <java.lang.Class> categoriesIterator)
 {
     this.categories = new CategoriesMap(this);
     if (null == categoriesIterator)
     {
         throw new java.lang.IllegalArgumentException("categories iterator should not be NULL");
     }
     while (categoriesIterator.hasNext())
     {
         java.lang.Class c = categoriesIterator.next();
         categories.addCategory(c);
     }
 }
Beispiel #14
0
 /**
  * Removes all nodes by iteration.
  */
 protected override void removeAllNodes()
 {
     if (size() > 0)
     {
         // superclass implementation would break all the iterators
         java.util.Iterator <Object> it = iterator();
         while (it.hasNext())
         {
             it.next();
             it.remove();
         }
     }
 }
Beispiel #15
0
        /// <summary>
        /// Get a list of external variables used by the expression. This will include both variables that were explicitly
        /// declared to the <c>XPathCompiler</c>, and (if the <c>AllowUndeclaredVariables</c> option was set) variables that
        /// are referenced within the expression but not explicitly declared.
        /// </summary>
        /// <returns>
        /// An IEnumerator over the names of the external variables, as instances of <c>QName</c>.</returns>

        public IEnumerator EnumerateExternalVariables()
        {
            ArrayList list = new ArrayList();
            JIterator iter = env.iterateExternalVariables();

            while (iter.hasNext())
            {
                JXPathVariable   var = (JXPathVariable)iter.next();
                JStructuredQName q   = var.getVariableQName();
                list.Add(new QName(q.getPrefix(), q.getURI(), q.getLocalPart()));
            }
            return(list.GetEnumerator());
        }
        /**
         * Returns <code>true</code> if the bag contains all elements in
         * the given collection, respecting cardinality.
         *
         * @param other  the bag to check against
         * @return <code>true</code> if the Bag contains all the collection
         */
        bool containsAll(Bag other)
        {
            bool result = true;

            java.util.Iterator <Object> it = other.uniqueSet().iterator();
            while (it.hasNext())
            {
                Object current  = it.next();
                bool   contains = getCount(current) >= other.getCount(current);
                result = result && contains;
            }
            return(result);
        }
 /**
  * Clear the map.
  * <p>
  * This clears each collection in the map, and so may be slow.
  */
 public override void clear()
 {
     // For gc, clear each list in the map
     java.util.Set <java.util.MapNS.Entry <Object, Object> >      pairs         = base.entrySet();
     java.util.Iterator <java.util.MapNS.Entry <Object, Object> > pairsIterator = pairs.iterator();
     while (pairsIterator.hasNext())
     {
         java.util.MapNS.Entry <Object, Object> keyValuePair = pairsIterator.next();
         java.util.Collection <Object>          coll         = (java.util.Collection <Object>)keyValuePair.getValue();
         coll.clear();
     }
     base.clear();
 }
Beispiel #18
0
        public override bool addAll <_T0>(int location, java.util.Collection <_T0> collection
                                          )
        {
            java.util.ListIterator <E> it    = listIterator(location);
            java.util.Iterator <_T0>   colIt = collection.iterator();
            int next = it.nextIndex();

            while (colIt.hasNext())
            {
                it.add(colIt.next());
            }
            return(next != it.nextIndex());
        }
Beispiel #19
0
 /*
  * Sets nextObj to a next provider matching the criterion given by the filter
  */
 private void findNext()
 {
     nextObj = default(E);
     while (backend.hasNext())
     {
         E o = backend.next();
         if (filter.filter(o))
         {
             nextObj = o;
             return;
         }
     }
 }
Beispiel #20
0
        //-----------------------------------------------------------------------

        /**
         * Constructor that wraps (not copies).
         * <p>
         * If there are any elements already in the collection being decorated, they
         * are validated.
         *
         * @param coll  the collection to decorate, must not be null
         * @param predicate  the predicate to use for validation, must not be null
         * @throws IllegalArgumentException if collection or predicate is null
         * @throws IllegalArgumentException if the collection contains invalid elements
         */
        protected internal PredicatedCollection(java.util.Collection <Object> coll, Predicate predicate)
            : base(coll)
        {
            if (predicate == null)
            {
                throw new java.lang.IllegalArgumentException("Predicate must not be null");
            }
            this.predicate = predicate;
            for (java.util.Iterator <Object> it = coll.iterator(); it.hasNext();)
            {
                validate(it.next());
            }
        }
Beispiel #21
0
        /**
         * Adds a collection of objects to the end of the list avoiding duplicates.
         * <p>
         * Only elements that are not already in this list will be added, and
         * duplicates from the specified collection will be ignored.
         * <p>
         * <i>(Violation)</i>
         * The <code>List</code> interface makes the assumption that the elements
         * are always inserted. This may not happen with this implementation.
         *
         * @param index  the index to insert at
         * @param coll  the collection to add in iterator order
         * @return true if this collection changed
         */
        public override bool addAll(int index, java.util.Collection <Object> coll)
        {
            // gets initial size
            int sizeBefore = size();

            // adds all elements
            for (java.util.Iterator <Object> it = coll.iterator(); it.hasNext();)
            {
                add(it.next());
            }

            // compares sizes to detect if collection changed
            return(sizeBefore != size());
        }
        //-----------------------------------------------------------------------

        /**
         * Clones the map creating an independent copy.
         * <p>
         * The clone will shallow clone the collections as well as the map.
         *
         * @return the cloned map
         */
        public Object clone()
        {
            MultiHashMap cloned = (MultiHashMap)base.MemberwiseClone();

            // clone each Collection container
            for (java.util.Iterator <java.util.MapNS.Entry <Object, Object> > it = cloned.entrySet().iterator(); it.hasNext();)
            {
                java.util.MapNS.Entry <Object, Object> entry   = it.next();
                java.util.Collection <Object>          coll    = (java.util.Collection <Object>)entry.getValue();
                java.util.Collection <Object>          newColl = createCollection(coll);
                entry.setValue(newColl);
            }
            return(cloned);
        }
Beispiel #23
0
        //-----------------------------------------------------------------------

        /**
         * Set nextObject to the next object. If there are no more
         * objects then return false. Otherwise, return true.
         */
        private bool setNextObject()
        {
            while (iterator.hasNext())
            {
                Object obj = iterator.next();
                if (predicate.evaluate(obj))
                {
                    nextObject    = obj;
                    nextObjectSet = true;
                    return(true);
                }
            }
            return(false);
        }
Beispiel #24
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);
         }
     }
 }
Beispiel #25
0
 internal void doForget()
 {
     lock (this)
     {
         java.util.Iterator <android.app.LoadedApk.ServiceDispatcher.ConnectionInfo> it = mActiveConnections
                                                                                          .values().iterator();
         while (it.hasNext())
         {
             android.app.LoadedApk.ServiceDispatcher.ConnectionInfo ci = it.next();
             ci.binder.unlinkToDeath(ci.deathMonitor, 0);
         }
         mActiveConnections.clear();
     }
 }
        public static List <Phrase> GetClauses(this Tree root, Rhetorica.Sentence sentence = null, string ignore = "", string punctuation = null, AnalyzerOptions options = AnalyzerOptions.None)
        {
            var phrases = new List <Phrase>();

            for (java.util.Iterator i = root.iterator(); i.hasNext();)
            {
                Tree tree = (Tree)i.next();

                var  treeLabel = tree.label().value();
                var  clauseRe  = @"^(S|SBAR|SBARQ|SINV|SQ|FRAG)$";
                bool isClausal = Regex.IsMatch(treeLabel, clauseRe, RegexOptions.IgnoreCase);

                if (isClausal)
                {
                    var current = new Phrase(tree.GetTokens(root, sentence, ignore, punctuation, options));
                    // If current node matches previous node but for punctuation omission, replace previous with current:
                    bool omitFalseDuplicatePhrases = options.HasFlag(AnalyzerOptions.OmitFalseDuplicatePhrases);
                    if (omitFalseDuplicatePhrases)
                    {
                        if (phrases.Count > 0)
                        {
                            Phrase previous = phrases.Last();
                            if (previous.EqualExceptPunctuationOmission(current))
                            {
                                phrases[phrases.Count - 1] = current;
                                continue;
                            }
                        }
                    }

                    if (current.Count == 0)
                    {
                        continue;
                    }

                    phrases.Add(current);
                }
            }

            if (phrases.Count == 0) // Since 'root' has been identified as a sentence, it should have at least one clause associated with it.
            {
                var pseudoClauses = root.GetPhrases(sentence, ignore, punctuation, options);
                if (pseudoClauses.Count > 0)
                {
                    phrases.Add(pseudoClauses[0]);
                }
            }

            return(phrases);
        }
        // Equals        // default object behaviour

        public virtual bool remove(object o)
        {
            java.util.Iterator i = iterator();
            while (i.hasNext())
            {
                object e = i.next();
                if (o == null ? e == null : o.Equals(e))
                {
                    i.remove();
                    return(true);
                }
            }
            return(false);
        }
Beispiel #28
0
        /// <summary>
        /// Retrieve an IEnumerable interface to a Java collection.
        /// </summary>
        /// <param name="list">Java collection</param>
        /// <returns></returns>
        public static List <net.sf.mpxj.Task> ToTaskList(this java.util.Collection list)
        {
            var ret = new List <net.sf.mpxj.Task>();

            if (list != null)
            {
                java.util.Iterator itr = list.iterator();
                while (itr.hasNext())
                {
                    ret.Add((net.sf.mpxj.Task)itr.next());
                }
            }
            return(ret);
        }
Beispiel #29
0
            /// <summary>
            /// Retrieve all the senses that contain this word
            /// </summary>
            public static Hashtable GetSensesFromWord(string word)
            {
                java.util.TreeMap  tmap  = _wn.getSensesFromWord(word);
                java.util.Iterator it    = tmap.keySet().iterator();
                Hashtable          table = new Hashtable();

                while (it.hasNext())
                {
                    string key = (string)it.next();
                    java.util.ArrayList jlist = (java.util.ArrayList)tmap.get(key);
                    table.Add(key, HelperUtils.ToArrayList(jlist));
                }
                return(table);
            }
        //-----------------------------------------------------------------------

        /**
         * Returns a List containing all the elements in <code>collection</code>
         * that are also in <code>retain</code>. The cardinality of an element <code>e</code>
         * in the returned list is the same as the cardinality of <code>e</code>
         * in <code>collection</code> unless <code>retain</code> does not contain <code>e</code>, in which
         * case the cardinality is zero. This method is useful if you do not wish to modify
         * the collection <code>c</code> and thus cannot call <code>collection.retainAll(retain);</code>.
         *
         * @param collection  the collection whose contents are the target of the #retailAll operation
         * @param retain  the collection containing the elements to be retained in the returned collection
         * @return a <code>List</code> containing all the elements of <code>c</code>
         * that occur at least once in <code>retain</code>.
         * @throws NullPointerException if either parameter is null
         * @since Commons Collections 3.2
         */
        public static java.util.List <Object> retainAll(java.util.Collection <Object> collection, java.util.Collection <Object> retain)
        {
            java.util.List <Object> list = new java.util.ArrayList <Object>(java.lang.Math.min(collection.size(), retain.size()));

            for (java.util.Iterator <Object> iter = collection.iterator(); iter.hasNext();)
            {
                Object obj = iter.next();
                if (retain.contains(obj))
                {
                    list.add(obj);
                }
            }
            return(list);
        }