void WriteGraph(RdfGraph graph, RdfSourceWrapper sourcewrapper, StatementSink sink)
        {
            java.util.Iterator iter = graph.iterator();
            while (iter.hasNext())
            {
                GraphStatement stmt = (GraphStatement)iter.next();
                Statement      s;
                if (stmt is GraphStatementWrapper)
                {
                    s = ((GraphStatementWrapper)stmt).s;
                }
                else
                {
                    s = new Statement(
                        sourcewrapper.ToEntity(stmt.getSubject()),
                        sourcewrapper.ToEntity(stmt.getPredicate()),
                        sourcewrapper.ToResource(stmt.getObject()),
                        stmt.getGraphName() == null ? Statement.DefaultMeta : sourcewrapper.ToEntity(stmt.getGraphName()));
                }

                if (s.AnyNull)
                {
                    continue;                            // unbound variable, or literal in bad position
                }
                sink.Add(s);
            }
        }
Beispiel #2
0
        /**
         * Adds an delete change.
         *
         * @param pChange
         *            the change which should result in a deletion
         */
        private void addDeletion(Change pChange)
        {
            if ((Change.TYPE_DELETE != pChange.type() &&
                 Change.TYPE_DELETE_DIR != pChange.type()) ||
                pChange.targetFile() == null)
            {
                return;
            }
            String source = pChange.targetFile();

            if (!changes.isEmpty())
            {
                for (java.util.Iterator <Change> it = changes.iterator(); it.hasNext();)
                {
                    Change change = (Change)it.next();
                    if (change.type() == Change.TYPE_ADD &&
                        change.getEntry() != null)
                    {
                        String target = change.getEntry().getName();

                        if (Change.TYPE_DELETE == pChange.type() && source.equals(target))
                        {
                            it.remove();
                        }
                        else if (Change.TYPE_DELETE_DIR == pChange.type() &&
                                 target.matches(source + "/.*"))
                        {
                            it.remove();
                        }
                    }
                }
            }
            changes.add(pChange);
        }
        /**
         * Returns an object array, populating the supplied array if possible.
         * See <code>Collection</code> interface for full details.
         *
         * @param array  the array to use, populating if possible
         * @return an array of all the elements in the collection
         */
        public virtual Object[] toArray <Object>(Object[] array)
        {
            int size = this.size();

            Object[] result = null;
            if (array.Length >= size)
            {
                result = array;
            }
            else
            {
                result = new Object[size];// (Object[]) Array.newInstance(array.getClass().getComponentType(), size);
            }

            int offset = 0;

            for (int i = 0; i < this.all.Length; ++i)
            {
                for (java.util.Iterator <Object> it = ((java.util.Iterator <Object>) this.all[i].iterator()); it.hasNext();)
                {
                    result[offset++] = it.next();
                }
            }
            if (result.Length > size)
            {
                result[size] = default(Object);
            }
            return(result);
        }
Beispiel #4
0
        /**
         * Tries to find a driver that can interpret the supplied URL.
         *
         * @param url
         *            the URL of a database.
         * @return a {@code Driver} that matches the provided URL. {@code null} if
         *         no {@code Driver} understands the URL
         * @throws SQLException
         *             if there is any kind of problem accessing the database.
         */
        public static Driver getDriver(String url)
        {                                                                                                         //throws SQLException {
            java.lang.ClassLoader callerClassLoader = java.lang.Runtime.getRuntime().getClass().getClassLoader(); // Basties note: sometime do the same as VM.callerClassLoader();

            lock (theDrivers)
            {
                /*
                 * Loop over the drivers in the DriverSet checking to see if one
                 * does understand the supplied URL - return the first driver which
                 * does understand the URL
                 */
                java.util.Iterator <Driver> theIterator = theDrivers.iterator();
                while (theIterator.hasNext())
                {
                    Driver theDriver = theIterator.next();
                    if (theDriver.acceptsURL(url) &&
                        DriverManager.isClassFromClassLoader(theDriver,
                                                             callerClassLoader))
                    {
                        return(theDriver);
                    }
                }
            }
            // If no drivers understand the URL, throw an SQLException
            // sql.6=No suitable driver
            // SQLState: 08 - connection exception
            // 001 - SQL-client unable to establish SQL-connection
            throw new SQLException("No suitable driver", "08001"); //$NON-NLS-1$ //$NON-NLS-2$
        }
Beispiel #5
0
		public SynsetCollection()
		{
			_synsets = new java.util.ArrayList();
			_synsets.addAll(SUMO.WordNet.Intern.nounSUMOHash.keySet());
			java.util.Iterator it = SUMO.WordNet.Intern.verbSUMOHash.keySet().iterator();
			while(it.hasNext())
			{
				string s = it.next().ToString();
				if(_synsets.contains(s)) continue;
				_synsets.add(s);
			}
			it = SUMO.WordNet.Intern.adjectiveSUMOHash.keySet().iterator();
			while(it.hasNext())
			{
				string s = it.next().ToString();
				if(_synsets.contains(s)) continue;
				_synsets.add(s);
			}
			it = SUMO.WordNet.Intern.adverbSUMOHash.keySet().iterator();
			while(it.hasNext())
			{
				string s = it.next().ToString();
				if(_synsets.contains(s)) continue;
				_synsets.add(s);
			}
			_it = _synsets.iterator();
		}
        /**
         * Tests two lists for value-equality as per the equality contract in
         * {@link java.util.List#equals(java.lang.Object)}.
         * <p>
         * This method is useful for implementing <code>List</code> when you cannot
         * extend AbstractList. The method takes Collection instances to enable other
         * collection types to use the List implementation algorithm.
         * <p>
         * The relevant text (slightly paraphrased as this is a static method) is:
         * <blockquote>
         * Compares the two list objects for equality.  Returns
         * <tt>true</tt> if and only if both
         * lists have the same size, and all corresponding pairs of elements in
         * the two lists are <i>equal</i>.  (Two elements <tt>e1</tt> and
         * <tt>e2</tt> are <i>equal</i> if <tt>(e1==null ? e2==null :
         * e1.equals(e2))</tt>.)  In other words, two lists are defined to be
         * equal if they contain the same elements in the same order.  This
         * definition ensures that the equals method works properly across
         * different implementations of the <tt>List</tt> interface.
         * </blockquote>
         *
         * <b>Note:</b> The behaviour of this method is undefined if the lists are
         * modified during the equals comparison.
         *
         * @see java.util.List
         * @param list1  the first list, may be null
         * @param list2  the second list, may be null
         * @return whether the lists are equal by value comparison
         */
        public static bool isEqualList(java.util.Collection <Object> list1, java.util.Collection <Object> list2)
        {
            if (list1 == list2)
            {
                return(true);
            }
            if (list1 == null || list2 == null || list1.size() != list2.size())
            {
                return(false);
            }

            java.util.Iterator <Object> it1 = list1.iterator();
            java.util.Iterator <Object> it2 = list2.iterator();
            Object obj1 = null;
            Object obj2 = null;

            while (it1.hasNext() && it2.hasNext())
            {
                obj1 = it1.next();
                obj2 = it2.next();

                if (!(obj1 == null ? obj2 == null : obj1.equals(obj2)))
                {
                    return(false);
                }
            }

            return(!(it1.hasNext() || it2.hasNext()));
        }
Beispiel #7
0
        public override bool removeAll <_T0>(java.util.Collection <_T0> collection)
        {
            bool result = false;

            if (size() <= collection.size())
            {
                java.util.Iterator <E> it = iterator();
                while (it.hasNext())
                {
                    if (collection.contains(it.next()))
                    {
                        it.remove();
                        result = true;
                    }
                }
            }
            else
            {
                java.util.Iterator <_T0> it = collection.iterator();
                while (it.hasNext())
                {
                    result = remove(it.next()) || result;
                }
            }
            return(result);
        }
 public virtual bool remove(object @object)
 {
     java.util.Iterator <E> it = iterator();
     if (@object != null)
     {
         while (it.hasNext())
         {
             if (@object.Equals(it.next()))
             {
                 it.remove();
                 return(true);
             }
         }
     }
     else
     {
         while (it.hasNext())
         {
             if (it.next() == null)
             {
                 it.remove();
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #9
0
 public void registerServiceProviders(java.util.Iterator <Object> providers)
 {
     for (java.util.Iterator <Object> iterator = providers; iterator.hasNext();)
     {
         categories.addProvider(iterator.next(), null);
     }
 }
Beispiel #10
0
 /**
  * Destroys all instances in the stack and clears the stack.
  *
  * @param key key passed to factory when destroying instances
  * @param stack stack to destroy
  */
 private void destroyStack(K key, java.util.Stack <V> stack)
 {
     lock (this)
     {
         if (null == stack)
         {
             return;
         }
         else
         {
             if (null != _factory)
             {
                 java.util.Iterator <V> it = stack.iterator();
                 while (it.hasNext())
                 {
                     try
                     {
                         _factory.destroyObject(key, it.next());
                     }
                     catch (Exception e)
                     {
                         // ignore error, keep destroying the rest
                     }
                 }
             }
             _totIdle -= stack.size();
             _activeCount.remove(key);
             stack.clear();
         }
     }
 }
Beispiel #11
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());
            }
        //-----------------------------------------------------------------------

        /**
         * Returns the Map as a string.
         *
         * @return the Map as a String
         */
        public override String ToString()
        {
            if (isEmpty())
            {
                return("{}");
            }
            java.lang.StringBuffer buf = new java.lang.StringBuffer();
            buf.append('{');
            bool first = true;

            java.util.Iterator <Object> it = entrySet().iterator();
            while (it.hasNext())
            {
                java.util.MapNS.Entry <Object, Object> entry = (java.util.MapNS.Entry <Object, Object>)it.next();
                Object key   = entry.getKey();
                Object value = entry.getValue();
                if (first)
                {
                    first = false;
                }
                else
                {
                    buf.append(", ");
                }
                buf.append(key == this ? "(this Map)" : key);
                buf.append('=');
                buf.append(value == this ? "(this Map)" : value);
            }
            buf.append('}');
            return(buf.toString());
        }
        /**
         * Create a new Closure that calls one of the closures depending
         * on the predicates.
         * <p>
         * The Map consists of Predicate keys and Closure values. A closure
         * is called if its matching predicate returns true. Each predicate is evaluated
         * until one returns true. If no predicates evaluate to true, the default
         * closure is called. The default closure is set in the map with a
         * null key. The ordering is that of the iterator() method on the entryset
         * collection of the map.
         *
         * @param predicatesAndClosures  a map of predicates to closures
         * @return the <code>switch</code> closure
         * @throws IllegalArgumentException if the map is null
         * @throws IllegalArgumentException if any closure in the map is null
         * @throws ClassCastException  if the map elements are of the wrong type
         */
        public static Closure getInstance(java.util.Map <Object, Object> predicatesAndClosures)
        {
            Closure[]   closures = null;
            Predicate[] preds    = null;
            if (predicatesAndClosures == null)
            {
                throw new java.lang.IllegalArgumentException("The predicate and closure map must not be null");
            }
            if (predicatesAndClosures.size() == 0)
            {
                return(NOPClosure.INSTANCE);
            }
            // convert to array like this to guarantee iterator() ordering
            Closure defaultClosure = (Closure)predicatesAndClosures.remove(null);
            int     size           = predicatesAndClosures.size();

            if (size == 0)
            {
                return(defaultClosure == null ? NOPClosure.INSTANCE : defaultClosure);
            }
            closures = new Closure[size];
            preds    = new Predicate[size];
            int i = 0;

            for (java.util.Iterator <Object> it = (java.util.Iterator <Object>)predicatesAndClosures.entrySet().iterator(); it.hasNext();)
            {
                java.util.MapNS.Entry <Object, Object> entry = (java.util.MapNS.Entry <Object, Object>)it.next();
                preds[i]    = (Predicate)entry.getKey();
                closures[i] = (Closure)entry.getValue();
                i++;
            }
            return(new SwitchClosure(preds, closures, defaultClosure));
        }
Beispiel #14
0
        /**
         *
         * Adds information about provider services into HashMap.
         *
         * @param p
         */
        public static void initServiceInfo(java.security.Provider p)
        {
            java.security.Provider.Service serv;
            String key;
            String type;
            String alias;

            java.lang.StringBuilder sb = new java.lang.StringBuilder(128);

            for (java.util.Iterator <java.security.Provider.Service> it1 = p.getServices().iterator(); it1.hasNext();)
            {
                serv = it1.next();
                type = serv.getType();
                sb.delete(0, sb.length());
                key = sb.append(type).append(".").append( //$NON-NLS-1$
                    Util.toUpperCase(serv.getAlgorithm())).toString();
                if (!services.containsKey(key))
                {
                    services.put(key, serv);
                }
                for (java.util.Iterator <String> it2 = Engine.door.getAliases(serv); it2.hasNext();)
                {
                    alias = it2.next();
                    sb.delete(0, sb.length());
                    key = sb.append(type).append(".").append(Util.toUpperCase(alias)) //$NON-NLS-1$
                          .toString();
                    if (!services.containsKey(key))
                    {
                        services.put(key, serv);
                    }
                }
            }
        }
        static void Main()
        {
            java.util.ArrayList <int> primeNumbers = new java.util.ArrayList <int>();
            primeNumbers.add(1);
            primeNumbers.add(2);
            primeNumbers.add(3);
            primeNumbers.add(5);
            primeNumbers.add(7);

            java.lang.SystemJ.outJ.println("Work with all collection elements");

            java.lang.SystemJ.outJ.println("Using collection with for loop");
            for (int i = 0; i < primeNumbers.size(); i++)
            {
                java.lang.SystemJ.outJ.println(primeNumbers.get(i));
            }

            java.lang.SystemJ.outJ.println("Using collection with iterator while loop");
            java.util.Iterator <int> it = primeNumbers.iterator();
            while (it.hasNext())
            {
                java.lang.SystemJ.outJ.println(it.next());
            }

            java.lang.SystemJ.outJ.println("Using Java collection with .NET foreach loop");
            foreach (int prime in primeNumbers)
            {
                java.lang.SystemJ.outJ.println(prime);
            }

            java.lang.SystemJ.outJ.print("");
        }
 public BagIterator(DefaultMapBag parent, java.util.Iterator <Object> support)
 {
     _parent  = parent;
     _support = support;
     _current = null;
     _mods    = parent.modCount();
 }
Beispiel #17
0
		public WordCollection(Synset synset, SpeechTypes type)
		{
			_synset = synset;
			_words = (java.util.ArrayList)SUMO.WordNet.Intern.synsetsToWords.get((int)type + _synset.ID);
			if(_words == null) _words = new java.util.ArrayList();
			_it = _words.iterator();
		}
 public override string ToString()
 {
     if (isEmpty())
     {
         return("[]");
     }
     java.lang.StringBuilder buffer = new java.lang.StringBuilder(size() * 16);
     buffer.append('[');
     java.util.Iterator <E> it = iterator();
     while (it.hasNext())
     {
         object next = it.next();
         if (next != this)
         {
             buffer.append(next);
         }
         else
         {
             buffer.append("(this Collection)");
         }
         if (it.hasNext())
         {
             buffer.append(", ");
         }
     }
     buffer.append(']');
     return(buffer.ToString());
 }
Beispiel #19
0
        /**
         * Create a new Transformer that calls one of the transformers depending
         * on the predicates.
         * <p>
         * The Map consists of Predicate keys and Transformer values. A transformer
         * is called if its matching predicate returns true. Each predicate is evaluated
         * until one returns true. If no predicates evaluate to true, the default
         * transformer is called. The default transformer is set in the map with a
         * null key. The ordering is that of the iterator() method on the entryset
         * collection of the map.
         *
         * @param predicatesAndTransformers  a map of predicates to transformers
         * @return the <code>switch</code> transformer
         * @throws IllegalArgumentException if the map is null
         * @throws IllegalArgumentException if any transformer in the map is null
         * @throws ClassCastException  if the map elements are of the wrong type
         */
        public static Transformer getInstance(java.util.Map <Object, Object> predicatesAndTransformers)
        {
            Transformer[] transformers = null;
            Predicate[]   preds        = null;
            if (predicatesAndTransformers == null)
            {
                throw new java.lang.IllegalArgumentException("The predicate and transformer map must not be null");
            }
            if (predicatesAndTransformers.size() == 0)
            {
                return(ConstantTransformer.NULL_INSTANCE);
            }
            // convert to array like this to guarantee iterator() ordering
            Transformer defaultTransformer = (Transformer)predicatesAndTransformers.remove(null);
            int         size = predicatesAndTransformers.size();

            if (size == 0)
            {
                return(defaultTransformer == null ? ConstantTransformer.NULL_INSTANCE : defaultTransformer);
            }
            transformers = new Transformer[size];
            preds        = new Predicate[size];
            int i = 0;

            for (java.util.Iterator <Object> it = (java.util.Iterator <Object>)predicatesAndTransformers.entrySet().iterator(); it.hasNext();)
            {
                java.util.MapNS.Entry <Object, Object> entry = (java.util.MapNS.Entry <Object, Object>)it.next();
                preds[i]        = (Predicate)entry.getKey();
                transformers[i] = (Transformer)entry.getValue();
                i++;
            }
            return(new SwitchTransformer(preds, transformers, defaultTransformer));
        }
        public override String ToString()
        {
            if (size() == 0)
            {
                return("[]");
            }
            java.lang.StringBuffer buf = new java.lang.StringBuffer(16 * size());
            buf.append("[");

            java.util.Iterator <Object> it = iterator();
            bool hasNext = it.hasNext();

            while (hasNext)
            {
                Object value = it.next();
                buf.append(value == this ? "(this Collection)" : value);
                hasNext = it.hasNext();
                if (hasNext)
                {
                    buf.append(", ");
                }
            }
            buf.append("]");
            return(buf.toString());
        }
Beispiel #21
0
 public ValuesIterator(Object key, MultiValueMap root)
 {
     this.root     = root;
     this.key      = key;
     this.values   = root.getCollection(key);
     this.iterator = values.iterator();
 }
Beispiel #22
0
        /**
         * Returns an {@code Enumeration} that contains all of the loaded JDBC
         * drivers that the current caller can access.
         *
         * @return An {@code Enumeration} containing all the currently loaded JDBC
         *         {@code Drivers}.
         */
        public static java.util.Enumeration <Driver> getDrivers()
        {
            java.lang.ClassLoader callerClassLoader = java.lang.Runtime.getRuntime().getClass().getClassLoader();// Basties note: sometime do the same as VM.callerClassLoader();

            /*
             * Synchronize to avoid clashes with additions and removals of drivers
             * in the DriverSet
             */
            lock (theDrivers)
            {
                /*
                 * Create the Enumeration by building a Vector from the elements of
                 * the DriverSet
                 */
                java.util.Vector <Driver>   theVector   = new java.util.Vector <Driver>();
                java.util.Iterator <Driver> theIterator = theDrivers.iterator();
                while (theIterator.hasNext())
                {
                    Driver theDriver = theIterator.next();
                    if (DriverManager.isClassFromClassLoader(theDriver,
                                                             callerClassLoader))
                    {
                        theVector.add(theDriver);
                    }
                }
                return(theVector.elements());
            }
        }
 /**
  * Clears any objects sitting idle in the pool.
  */
 public override void clear()
 {
     lock (this)
     {
         if (null != _factory)
         {
             java.util.Iterator <java.lang.refj.SoftReference <T> > iter = _pool.iterator();
             while (iter.hasNext())
             {
                 try
                 {
                     T obj = iter.next().get();
                     if (null != obj)
                     {
                         _factory.destroyObject(obj);
                     }
                 }
                 catch (Exception e)
                 {
                     // ignore error, keep destroying the rest
                 }
             }
         }
         _pool.clear();
         pruneClearedReferences();
     }
 }
 /**
  * Return the hash code value for this map.  This implementation uses
  * exactly the code that is used to define the list hash function in the
  * documentation for the <code>Map.hashCode</code> method.
  *
  * @return a suitable integer hash code
  */
 public override int GetHashCode()
 {
     if (fast)
     {
         int h = 0;
         java.util.Iterator <java.util.MapNS.Entry <Object, Object> > i = map.entrySet().iterator();
         while (i.hasNext())
         {
             h += i.next().GetHashCode();
         }
         return(h);
     }
     else
     {
         lock (map)
         {
             int h = 0;
             java.util.Iterator <java.util.MapNS.Entry <Object, Object> > i = map.entrySet().iterator();
             while (i.hasNext())
             {
                 h += i.next().GetHashCode();
             }
             return(h);
         }
     }
 }
        /// <summary>
        /// https://universaldependencies.org/u/dep/index.html
        /// Stratify a sentence according to the subject-predicate relationship
        /// </summary>
        /// <param name="sentence"></param>
        /// <returns>sentence, subject, predicate, objective</returns>
        public List <(edu.stanford.nlp.util.CoreMap, edu.stanford.nlp.ling.IndexedWord, edu.stanford.nlp.ling.IndexedWord, edu.stanford.nlp.ling.IndexedWord)> StepSamplingDependency(edu.stanford.nlp.util.CoreMap sentence)
        {
            List <(edu.stanford.nlp.util.CoreMap, edu.stanford.nlp.ling.IndexedWord, edu.stanford.nlp.ling.IndexedWord, edu.stanford.nlp.ling.IndexedWord)> samplings = new List <(edu.stanford.nlp.util.CoreMap, edu.stanford.nlp.ling.IndexedWord, edu.stanford.nlp.ling.IndexedWord, edu.stanford.nlp.ling.IndexedWord)>();

            edu.stanford.nlp.semgraph.SemanticGraph dependencies = sentence.get(enhancedPlusPlusDependenciesAnnotationClass) as edu.stanford.nlp.semgraph.SemanticGraph;
            java.util.Collection typedDependencies = dependencies.typedDependencies();
            java.util.Iterator   itr = typedDependencies.iterator();
            while (itr.hasNext())
            {
                edu.stanford.nlp.trees.TypedDependency td = itr.next() as edu.stanford.nlp.trees.TypedDependency;
                string relationType = td.reln().getShortName();
                //Nominals
                if (relationType == "nsubj" || relationType == "nsubjpass")
                {
                    edu.stanford.nlp.ling.IndexedWord subject, predicate, objective;
                    subject = td.dep(); predicate = td.gov();
                    //在谓语位置上,缺不满足谓语角色的词,此种谓语可缺省
                    edu.stanford.nlp.ling.IndexedWord expl = FindIndexedWordByDependencyType(dependencies, predicate, "expl");
                    predicate = expl == null ? predicate : null;
                    //直接宾语,
                    objective = FindIndexedWordByDependencyType(dependencies, predicate, "obj", "dobj");
                    //动词或形容词的补语做宾语, open clausal complement
                    objective = objective ?? FindIndexedWordByDependencyType(dependencies, predicate, "ccomp", "xcomp");
                    //加入层次集合
                    samplings.Add((sentence, subject, predicate, objective));
                }
            }
            return(samplings);
        }
Beispiel #26
0
        public override bool retainAll(java.util.Collection <Object> coll)
        {
            bool result = collection.retainAll(coll);

            if (result == false)
            {
                return(false);
            }
            else if (collection.size() == 0)
            {
                setOrder.clear();
            }
            else
            {
                for (java.util.Iterator <Object> it = setOrder.iterator(); it.hasNext();)
                {
                    Object obj = it.next();
                    if (collection.contains(obj) == false)
                    {
                        it.remove();
                    }
                }
            }
            return(result);
        }
        /**
         * Returns true if the given object is not null, has the precise type
         * of this bag, and contains the same number of occurrences of all the
         * same elements.
         *
         * @param object  the object to test for equality
         * @return true if that object equals this bag
         */
        public override bool Equals(Object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            if (obj is Bag == false)
            {
                return(false);
            }
            Bag other = (Bag)obj;

            if (other.size() != size())
            {
                return(false);
            }
            for (java.util.Iterator <Object> it = _map.keySet().iterator(); it.hasNext();)
            {
                Object element = it.next();
                if (other.getCount(element) != getCount(element))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #28
0
 /**
  * Return the hash code value for this list.  This implementation uses
  * exactly the code that is used to define the list hash function in the
  * documentation for the <code>List.hashCode</code> method.
  */
 public override int GetHashCode()
 {
     if (fast)
     {
         int hashCode = 1;
         java.util.Iterator <Object> i = list.iterator();
         while (i.hasNext())
         {
             Object o = i.next();
             hashCode = 31 * hashCode + (o == null ? 0 : o.GetHashCode());
         }
         return(hashCode);
     }
     else
     {
         lock (list)
         {
             int hashCode = 1;
             java.util.Iterator <Object> i = list.iterator();
             while (i.hasNext())
             {
                 Object o = i.next();
                 hashCode = 31 * hashCode + (o == null ? 0 : o.GetHashCode());
             }
             return(hashCode);
         }
     }
 }
        /**
         * Remove any members of the bag that are not in the given
         * bag, respecting cardinality.
         * @see #retainAll(Collection)
         *
         * @param other  the bag to retain
         * @return <code>true</code> if this call changed the collection
         */
        public virtual bool retainAll(Bag other)
        {
            bool result = false;
            Bag  excess = new HashBag();

            java.util.Iterator <Object> i = uniqueSet().iterator();
            while (i.hasNext())
            {
                Object current    = i.next();
                int    myCount    = getCount(current);
                int    otherCount = other.getCount(current);
                if (1 <= otherCount && otherCount <= myCount)
                {
                    excess.add(current, myCount - otherCount);
                }
                else
                {
                    excess.add(current, myCount);
                }
            }
            if (!excess.isEmpty())
            {
                result = removeAll(excess);
            }
            return(result);
        }
Beispiel #30
0
        /**
         * Adds an addition change.
         *
         * @param pChange
         *            the change which should result in an addition
         */
        private void addAddition(Change pChange)
        {
            if (Change.TYPE_ADD != pChange.type() ||
                pChange.getInput() == null)
            {
                return;
            }

            if (!changes.isEmpty())
            {
                for (java.util.Iterator <Change> it = changes.iterator(); it.hasNext();)
                {
                    Change change = it.next();
                    if (change.type() == Change.TYPE_ADD && change.getEntry() != null)
                    {
                        org.apache.commons.compress.archivers.ArchiveEntry entry = change.getEntry();
                        if (entry.equals(pChange.getEntry()))
                        {
                            if (pChange.isReplaceMode())
                            {
                                it.remove();
                                changes.add(pChange);
                                return;
                            }
                            else
                            {
                                // do not add this change
                                return;
                            }
                        }
                    }
                }
            }
            changes.add(pChange);
        }
Beispiel #31
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);
        }
 /**
  * Constructor.
  *
  * @param parent  the parent bag
  */
 public BagIterator(AbstractMapBag parent)
 {
     this.parent        = parent;
     this.entryIterator = parent.map.entrySet().iterator();
     this.current       = null;
     this.mods          = parent.modCount;
     this.canRemove     = false;
 }
Beispiel #33
0
		public WordCollection(Synset synset)
		{
			_synset = synset;
			_words = new java.util.ArrayList();
			java.util.ArrayList nouns = (java.util.ArrayList)SUMO.WordNet.Intern.synsetsToWords.get((int)SpeechTypes.Noun + _synset.ID);
			java.util.ArrayList verbs = (java.util.ArrayList)SUMO.WordNet.Intern.synsetsToWords.get((int)SpeechTypes.Verb + _synset.ID);
			java.util.ArrayList adjs = (java.util.ArrayList)SUMO.WordNet.Intern.synsetsToWords.get((int)SpeechTypes.Adjective + _synset.ID);
			java.util.ArrayList advs = (java.util.ArrayList)SUMO.WordNet.Intern.synsetsToWords.get((int)SpeechTypes.Adverb + _synset.ID);
			if(nouns != null) _words.addAll(nouns);
			if(verbs != null) _words.addAll(verbs);
			if(adjs != null) _words.addAll(adjs);
			if(advs != null) _words.addAll(advs);
			_it = _words.iterator();
		}
Beispiel #34
0
		public AxiomCollection(KnowledgeBase kb)
		{
			_kb = kb;
			_it = _kb.Intern.formulaMap.keySet().iterator();
		}
 // Constructor
 //-------------------------------------------------------------------------
 /**
  * Constructs a new <code>ListIteratorWrapper</code> that will wrap
  * the given iterator.
  *
  * @param iterator  the iterator to wrap
  * @throws NullPointerException if the iterator is null
  */
 public ListIteratorWrapper(java.util.Iterator<Object> iterator)
     : base()
 {
     if (iterator == null)
     {
         throw new java.lang.NullPointerException("Iterator must not be null");
     }
     this.iterator = iterator;
 }
Beispiel #36
0
 public void Reset()
 {
     _it = _kb.Intern.collectPredicates().iterator();
 }
Beispiel #37
0
 public PredicateCollection(KnowledgeBase kb)
 {
     _kb = kb;
     _it = _kb.Intern.collectPredicates().iterator();
 }
 public void Reset()
 {
     _it = _mgr.getKBnames().iterator();
 }
Beispiel #39
0
 public TermCollection(KnowledgeBase kb)
 {
     _kb = kb;
     _it = _kb.Intern.terms.iterator();
 }
 /**
  * Resets the iterator back to the start of the collection.
  */
 public void reset()
 {
     iterator = collection.iterator();
 }
Beispiel #41
0
 public void Reset()
 {
 	_it = _synsets.iterator();
 }
Beispiel #42
0
 public void Reset()
 {
     _it = _words.iterator();
 }
 //-----------------------------------------------------------------------
 /**
  * Resets the state of the iterator.
  */
 public void reset()
 {
     iterator = (java.util.Iterator<Object>)map.entrySet().iterator();
     last = null;
     canRemove = false;
 }
 /**
  * Constructor.
  *
  * @param map  the map to iterate over
  */
 public EntrySetMapIterator(java.util.Map<Object, Object> map)
     : base()
 {
     this.map = map;
     this.iterator = (java.util.Iterator<Object>)map.entrySet().iterator();
 }
 public void Reset()
 {
     _it = _kb.Intern.constituents.iterator();
 }
Beispiel #46
0
 public void Reset()
 {
 	_it = _formula.Intern.getClauses().iterator();
 }
Beispiel #47
0
 public void Reset()
 {
 	_it = _kb.Intern.formulaMap.keySet().iterator();
 }
Beispiel #48
0
 public ClauseCollection(Formula formula)
 {
     _formula = formula;
     _it = _formula.Intern.getClauses().iterator();
 }
 public KnowledgeBaseCollection()
 {
     _mgr = KBmanager.getMgr();
     _it = _mgr.getKBnames().iterator();
 }
 public ConstituentCollection(KnowledgeBase kb)
 {
     _kb = kb;
     _it = _kb.Intern.constituents.iterator();
 }
Beispiel #51
0
 public void Reset()
 {
     _it = _kb.Intern.terms.iterator();
 }