Ejemplo n.º 1
0
        /// <summary>
        /// Internal utility to dump relationship lists in a structured format that can 
        /// easily be compared with the tabular data in MS Project.
        /// </summary>
        /// <param name="relations">project file</param>
        private static void dumpRelationList(java.util.List relations)
        {
            if (relations != null && relations.isEmpty() == false)
            {
                if (relations.size() > 1)
                {
                    System.Console.Write('"');
                }
                bool first = true;
                foreach (Relation relation in relations.ToIEnumerable())
                {
                    if (!first)
                    {
                        System.Console.Write(',');
                    }
                    first = false;
                    System.Console.Write(relation.TargetTask.ID);
                    Duration lag = relation.Lag;
                    if (relation.Type != RelationType.FINISH_START || lag.Duration != 0)
                    {
                        System.Console.Write(relation.Type);
                    }

                    if (lag.Duration != 0)
                    {
                        if (lag.Duration > 0)
                        {
                            System.Console.Write("+");
                        }
                        System.Console.Write(lag);
                    }
                }
                if (relations.size() > 1)
                {
                    System.Console.Write('"');
                }
            }
        }
Ejemplo n.º 2
0
        public SelectList(String title, String description, String group, java.util.List idPList)
        {
            InitializeComponent();

            this.groupBox1.Text = group;
            this.Text = title;
            this.label3.Text = description;

            this.listView1.View = View.Details;
            this.listView1.AllowColumnReorder = true;
            this.listView1.FullRowSelect = true;

            for (int i = 0; i < idPList.size(); i++)
            {
                ListViewItem item = new ListViewItem(idPList.get(i).ToString(), 0);
                listView1.Items.Add(item);
            }

            listView1.Refresh();

            this.groupBox1.Controls.Add(listView1);
        }
        /// <summary>
        /// Encodes and writes multiple images without colour depth conversion.
        /// </summary>
        /// <param name="images">
        ///            the list of source images to be encoded </param>
        /// <param name="stream">
        ///            the output to which the encoded image will be written </param>
        internal void Write(java.util.List images, System.IO.Stream stream)
        {
            writer = new BinaryWriter(stream);

            int count = images.size();

            // file header 6
            WriteFileHeader(count, TYPE_ICON);

            // file offset where images start
            int fileOffset = 6 + count * 16;

            // icon entries 16 * count
            for (int i = 0; i < count; i++)
            {
                BufferedImage imgc = (BufferedImage)images.get(i);
                fileOffset += WriteIconEntry(imgc, fileOffset);
            }

            // images
            for (int i = 0; i < count; i++)
            {
                BufferedImage imgc = (BufferedImage)images.get(i);

                // info header
                WriteInfoHeader(imgc);
                // color map
                if (imgc.getColorModel().getPixelSize() <= 8)
                {
                    IndexColorModel icm = (IndexColorModel)imgc.getColorModel();
                    WriteColorMap(icm);
                }
                // xor bitmap
                WriteXorBitmap(imgc);
                // and bitmap
                WriteAndBitmap(imgc);

            }
        }
 /**
  * Returns <code>true</code> iff at least one element is in both collections.
  * <p>
  * In other words, this method returns <code>true</code> iff the
  * {@link #intersection} of <i>coll1</i> and <i>coll2</i> is not empty.
  *
  * @param coll1  the first collection, must not be null
  * @param coll2  the first collection, must not be null
  * @return <code>true</code> iff the intersection of the collections is non-empty
  * @since 2.1
  * @see #intersection
  */
 public static bool containsAny(java.util.Collection<Object> coll1, java.util.Collection<Object> coll2)
 {
     if (coll1.size() < coll2.size())
     {
         for (java.util.Iterator<Object> it = coll1.iterator(); it.hasNext(); )
         {
             if (coll2.contains(it.next()))
             {
                 return true;
             }
         }
     }
     else
     {
         for (java.util.Iterator<Object> it = coll2.iterator(); it.hasNext(); )
         {
             if (coll1.contains(it.next()))
             {
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 5
0
		/// <summary>Flatten a List into an XmlSerializer.</summary>
		/// <remarks>
		/// Flatten a List into an XmlSerializer.  The list can later be read back
		/// with readThisListXml().
		/// </remarks>
		/// <param name="val">The list to be flattened.</param>
		/// <param name="name">
		/// Name attribute to include with this list's tag, or null for
		/// none.
		/// </param>
		/// <param name="out">XmlSerializer to write the list into.</param>
		/// <seealso cref="writeListXml(java.util.List{E}, java.io.OutputStream)">writeListXml(java.util.List&lt;E&gt;, java.io.OutputStream)
		/// 	</seealso>
		/// <seealso cref="writeMapXml(java.util.Map{K, V}, java.io.OutputStream)">writeMapXml(java.util.Map&lt;K, V&gt;, java.io.OutputStream)
		/// 	</seealso>
		/// <seealso cref="writeValueXml(object, string, org.xmlpull.v1.XmlSerializer)">writeValueXml(object, string, org.xmlpull.v1.XmlSerializer)
		/// 	</seealso>
		/// <seealso cref="readListXml(java.io.InputStream)">readListXml(java.io.InputStream)
		/// 	</seealso>
		/// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public static void writeListXml(java.util.List<object> val, string name, org.xmlpull.v1.XmlSerializer
			 @out)
		{
			if (val == null)
			{
				@out.startTag(null, "null");
				@out.endTag(null, "null");
				return;
			}
			@out.startTag(null, "list");
			if (name != null)
			{
				@out.attribute(null, "name", name);
			}
			int N = val.size();
			int i = 0;
			while (i < N)
			{
				writeValueXml(val.get(i), null, @out);
				i++;
			}
			@out.endTag(null, "list");
		}
 /**
  * Validate the predicates to ensure that all is well.
  *
  * @param predicates  the predicates to validate
  * @return predicate array
  */
 internal static Predicate[] validate(java.util.Collection<Predicate> predicates)
 {
     if (predicates == null)
     {
         throw new java.lang.IllegalArgumentException("The predicate collection must not be null");
     }
     // convert to array like this to guarantee iterator() ordering
     Predicate[] preds = new Predicate[predicates.size()];
     int i = 0;
     for (java.util.Iterator<Predicate> it = predicates.iterator(); it.hasNext(); )
     {
         preds[i] = it.next();
         if (preds[i] == null)
         {
             throw new java.lang.IllegalArgumentException("The predicate collection must not contain a null predicate, index " + i + " was null");
         }
         i++;
     }
     return preds;
 }
 /**
  * Create a new Transformer that uses the input object as a key to find the
  * transformer to call.
  * <p>
  * The Map consists of object keys and Transformer values. A transformer
  * is called if the input object equals the key. If there is no match, the
  * default transformer is called. The default transformer is set in the map
  * using a null key. If no default is set, null will be returned in a default case.
  *
  * @see org.apache.commons.collections.functors.SwitchTransformer
  *
  * @param objectsAndTransformers  a map of objects to transformers
  * @return the transformer
  * @throws IllegalArgumentException if the map is null
  * @throws IllegalArgumentException if the map is empty
  * @throws IllegalArgumentException if any transformer in the map is null
  */
 public static Transformer switchMapTransformer(java.util.Map<Object, Object> objectsAndTransformers)
 {
     Transformer[] trs = null;
     Predicate[] preds = null;
     if (objectsAndTransformers == null)
     {
         throw new java.lang.IllegalArgumentException("The object and transformer map must not be null");
     }
     Transformer def = (Transformer)objectsAndTransformers.remove(null);
     int size = objectsAndTransformers.size();
     trs = new Transformer[size];
     preds = new Predicate[size];
     int i = 0;
     for (java.util.Iterator<java.util.MapNS.Entry<Object, Object>> it = objectsAndTransformers.entrySet().iterator(); it.hasNext(); )
     {
         java.util.MapNS.Entry<Object, Object> entry = (java.util.MapNS.Entry<Object, Object>)it.next();
         preds[i] = EqualPredicate.getInstance(entry.getKey());
         trs[i] = (Transformer)entry.getValue();
         i++;
     }
     return switchTransformer(preds, trs, def);
 }
Ejemplo n.º 8
0
			private StatementIterator GetIterator(Entity[] subjects, Entity[] predicates, Resource[] objects, Entity[] metas, java.util.List litFilters, bool defaultGraph) {
				DateTime start = DateTime.Now;

				if (subjects == null && predicates == null && objects == null)
					throw new QueryExecutionException("Query would select all statements in the store.");
				
				if (subjects != null) Depersist(subjects);
				if (predicates != null) Depersist(predicates);
				if (objects != null) Depersist(objects);
				if (metas != null) Depersist(metas);
				
				if (subjects != null && subjects.Length == 0) return new StatementIterator(null);
				if (predicates != null && predicates.Length == 0) return new StatementIterator(null);
				if (objects != null && objects.Length == 0) return new StatementIterator(null);
				if (metas != null && metas.Length == 0) return new StatementIterator(null);
				
				MemoryStore results = new MemoryStore();
				StatementSink sink = results;
				
				if (!source.Distinct)
					sink = new SemWeb.Util.DistinctStatementsSink(results, defaultGraph && metas == null);

				SelectFilter filter = new SelectFilter(subjects, predicates, objects, metas);
				if (litFilters != null) {
					filter.LiteralFilters = new LiteralFilter[litFilters.size()];
					for (int i = 0; i < litFilters.size(); i++)
						filter.LiteralFilters[i] = (LiteralFilter)litFilters.get(i);
				}

				source.Select(filter, sink);
				
				Log("SELECT: " + filter + " => " + results.StatementCount + " statements [" + (DateTime.Now-start) + "s]");
				
				return new StatementIterator(results.ToArray());
			}
Ejemplo n.º 9
0
		internal void deliverResults(android.app.ActivityThread.ActivityClientRecord r, java.util.List
			<android.app.ResultInfo> results)
		{
			int N = results.size();
			{
				for (int i = 0; i < N; i++)
				{
					android.app.ResultInfo ri = results.get(i);
					try
					{
						if (ri.mData != null)
						{
							ri.mData.setExtrasClassLoader(r.activity.getClassLoader());
						}
						r.activity.dispatchActivityResult(ri.mResultWho, ri.mRequestCode, ri.mResultCode, 
							ri.mData);
					}
					catch (System.Exception e)
					{
						if (!mInstrumentation.onException(r.activity, e))
						{
							throw new java.lang.RuntimeException("Failure delivering result " + ri + " to activity "
								 + r.intent.getComponent().toShortString() + ": " + e.ToString(), e);
						}
					}
				}
			}
		}
        /**
         * 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());
        }
Ejemplo n.º 11
0
		private static int findInsertIndex(java.util.ArrayList<*****@*****.**
			> items, int ordering)
		{
			{
				for (int i = items.size() - 1; i >= 0; i--)
				{
					[email protected] item = items.get(i);
					if (item.getOrdering() <= ordering)
					{
						return i + 1;
					}
				}
			}
			return 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);
 }
 /**
  * Constructor copying elements from another map.
  * <p/>
  * The maximum size is set from the map's size.
  *
  * @param map  the map to copy
  * @param scanUntilRemovable  scan until a removeable entry is found, default false
  * @throws NullPointerException if the map is null
  * @throws IllegalArgumentException if the map is empty
  * @since Commons Collections 3.1
  */
 public LRUMap(java.util.Map<Object, Object> map, bool scanUntilRemovable)
     : this(map.size(), DEFAULT_LOAD_FACTOR, scanUntilRemovable)
 {
     putAll(map);
 }
 /**
  * Returns <tt>true</tt> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>,
  * that is, iff the cardinality of <i>e</i> in <i>a</i> is less
  * than or equal to the cardinality of <i>e</i> in <i>b</i>,
  * for each element <i>e</i> in <i>a</i>, and there is at least one
  * element <i>f</i> such that the cardinality of <i>f</i> in <i>b</i>
  * is strictly greater than the cardinality of <i>f</i> in <i>a</i>.
  * <p>
  * The implementation assumes
  * <ul>
  *    <li><code>a.size()</code> and <code>b.size()</code> represent the
  *    total cardinality of <i>a</i> and <i>b</i>, resp. </li>
  *    <li><code>a.size() < Integer.MAXVALUE</code></li>
  * </ul>
  *
  * @param a  the first (sub?) collection, must not be null
  * @param b  the second (super?) collection, must not be null
  * @return <code>true</code> iff <i>a</i> is a <i>proper</i> sub-collection of <i>b</i>
  * @see #isSubCollection
  * @see Collection#containsAll
  */
 public static bool isProperSubCollection(java.util.Collection<Object> a, java.util.Collection<Object> b)
 {
     return (a.size() < b.size()) && CollectionUtils.isSubCollection(a, b);
 }
 /**
  * Returns <tt>true</tt> iff the given {@link Collection}s contain
  * exactly the same elements with exactly the same cardinalities.
  * <p>
  * That is, iff the cardinality of <i>e</i> in <i>a</i> is
  * equal to the cardinality of <i>e</i> in <i>b</i>,
  * for each element <i>e</i> in <i>a</i> or <i>b</i>.
  *
  * @param a  the first collection, must not be null
  * @param b  the second collection, must not be null
  * @return <code>true</code> iff the collections contain the same elements with the same cardinalities.
  */
 public static bool isEqualCollection(java.util.Collection<Object> a, java.util.Collection<Object> b)
 {
     if (a.size() != b.size())
     {
         return false;
     }
     else
     {
         java.util.Map<Object, Object> mapa = getCardinalityMap(a);
         java.util.Map<Object, Object> mapb = getCardinalityMap(b);
         if (mapa.size() != mapb.size())
         {
             return false;
         }
         else
         {
             java.util.Iterator<Object> it = mapa.keySet().iterator();
             while (it.hasNext())
             {
                 Object obj = it.next();
                 if (getFreq(obj, mapa) != getFreq(obj, mapb))
                 {
                     return false;
                 }
             }
             return true;
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Constructs a new MultiRectArea and append rectangle from array
  */
 public MultiRectArea(java.util.ArrayList<java.awt.Rectangle> buf)
     : this()
 {
     for (int i = 0; i < buf.size(); i++)
     { //Basties note: also foreach available...
         add(buf.get(i));
     }
 }
 public override bool addAll(java.util.Collection<Object> c)
 {
     lock (lockJ)
     {
         timeoutWait(c.size());
         return getBuffer().addAll(c);
     }
 }
        //-----------------------------------------------------------------------
        /**
         * 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;
        }
Ejemplo n.º 19
0
		// Ignore
		internal void deliverNewIntents(android.app.ActivityThread.ActivityClientRecord r
			, java.util.List<android.content.Intent> intents)
		{
			int N = intents.size();
			{
				for (int i = 0; i < N; i++)
				{
					android.content.Intent intent = intents.get(i);
					intent.setExtrasClassLoader(r.activity.getClassLoader());
					r.activity.mFragments.noteStateNotSaved();
					mInstrumentation.callActivityOnNewIntent(r.activity, intent);
				}
			}
		}
 /**
  * Create a new Closure that uses the input object as a key to find the
  * closure to call.
  * <p>
  * The Map consists of object keys and Closure values. A closure
  * is called if the input object equals the key. If there is no match, the
  * default closure is called. The default closure is set in the map
  * using a null key.
  *
  * @see org.apache.commons.collections.functors.SwitchClosure
  *
  * @param objectsAndClosures  a map of objects to closures
  * @return the closure
  * @throws IllegalArgumentException if the map is null
  * @throws IllegalArgumentException if the map is empty
  * @throws IllegalArgumentException if any closure in the map is null
  */
 public static Closure switchMapClosure(java.util.Map<Object, Object> objectsAndClosures)
 {
     Closure[] trs = null;
     Predicate[] preds = null;
     if (objectsAndClosures == null)
     {
         throw new java.lang.IllegalArgumentException("The object and closure map must not be null");
     }
     Closure def = (Closure)objectsAndClosures.remove(null);
     int size = objectsAndClosures.size();
     trs = new Closure[size];
     preds = new Predicate[size];
     int i = 0;
     for (java.util.Iterator<java.util.MapNS.Entry<Object, Object>> it = objectsAndClosures.entrySet().iterator(); it.hasNext(); )
     {
         java.util.MapNS.Entry<Object, Object> entry = it.next();
         preds[i] = EqualPredicate.getInstance(entry.getKey());
         trs[i] = (Closure)entry.getValue();
         i++;
     }
     return switchClosure(preds, trs, def);
 }
Ejemplo n.º 21
0
		public override void addFocusables(java.util.ArrayList<android.view.View> views, 
			int direction, int focusableMode)
		{
			int focusableCount = views.size();
			int descendantFocusability = getDescendantFocusability();
			if (descendantFocusability != FOCUS_BLOCK_DESCENDANTS)
			{
				int count = mChildrenCount;
				android.view.View[] children = mChildren;
				{
					for (int i = 0; i < count; i++)
					{
						android.view.View child = children[i];
						if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE)
						{
							child.addFocusables(views, direction, focusableMode);
						}
					}
				}
			}
			// we add ourselves (if focusable) in all cases except for when we are
			// FOCUS_AFTER_DESCENDANTS and there are some descendants focusable.  this is
			// to avoid the focus search finding layouts when a more precise search
			// among the focusable children would be more interesting.
			if (descendantFocusability != FOCUS_AFTER_DESCENDANTS || (focusableCount == views
				.size()))
			{
				// No focusable descendants
				base.addFocusables(views, direction, focusableMode);
			}
		}
 /**
  * Factory method to create a transforming map that will transform
  * existing contents of the specified map.
  * <p>
  * If there are any elements already in the map being decorated, they
  * will be transformed by this method.
  * Constrast this with {@link #decorate}.
  *
  * @param map  the map to decorate, must not be null
  * @param keyTransformer  the transformer to use for key conversion, null means no transformation
  * @param valueTransformer  the transformer to use for value conversion, null means no transformation
  * @throws IllegalArgumentException if map is null
  * @since Commons Collections 3.2
  */
 public static java.util.Map<Object, Object> decorateTransform(java.util.Map<Object, Object> map, Transformer keyTransformer, Transformer valueTransformer)
 {
     TransformedMap decorated = new TransformedMap(map, keyTransformer, valueTransformer);
     if (map.size() > 0)
     {
         java.util.Map<Object, Object> transformed = decorated.transformMap(map);
         decorated.clear();
         decorated.getMap().putAll(transformed);  // avoids double transformation
     }
     return decorated;
 }
Ejemplo n.º 23
0
            protected override RdfBindingSet runTripleConstraints(java.util.List tripleConstraints, 
		    	name.levering.ryan.sparql.model.logic.ConstraintLogic.CallParams p)
            {
                if (DisableQuery)
                    return null;

                RdfSourceWrapper s = (RdfSourceWrapper)p.source;

                if (s.source is QueryableSource) {
                    QueryableSource qs = (QueryableSource)s.source;
                    QueryOptions opts = new QueryOptions();

                    opts.Limit = p.limit;

                    VariableList distinguishedVars = new VariableList();
                    VariableList undistinguishedVars = new VariableList();

                   opts.VariableKnownValues = new VarKnownValuesType();

                    Statement[] graph = new Statement[tripleConstraints.size()];
                    Hashtable varMap1 = new Hashtable();
                    Hashtable varMap2 = new Hashtable();

                    Entity metaField;
                    // In this case, we want to treat the meta fields of all of the statements
                    // in this group as bound by a single variable.
                    if (p.graphVariable != null) {
                        metaField = ToRes(p.graphVariable, p.knownValues, true, varMap1, varMap2, s, opts, distinguishedVars, undistinguishedVars, p.distinguishedVariables) as Entity;

                    // Otherwise, we are told what graph to use. If sourceDatasets is null,
                    // we are looking in the default graph.
                    } else if (p.sourceDatasets == null) {
                        /*if (p.defaultDatasets.size() == 0) {
                            metaField = Statement.DefaultMeta;
                        } else if (p.defaultDatasets.size() == 1) {
                            metaField = s.ToEntity((Value)p.defaultDatasets.iterator().next());
                        } else {
                            metaField = new SemWebVariable();
                            opts.VariableKnownValues[(Variable)metaField] = s.ToEntities((Value[])p.defaultDatasets.toArray(new Value[0]));
                        }*/

                        // For the default Graph, we always pass DefaultMeta.
                        metaField = Statement.DefaultMeta;

                    // Otherwise, we are looking in the indicated graphs.
                    } else {
                        if (p.sourceDatasets.size() == 0) {
                            metaField = new SemWebVariable();
                        } else if (p.sourceDatasets.size() == 1) {
                            metaField = s.ToEntity((Value)p.sourceDatasets.iterator().next());
                        } else {
                            metaField = new SemWebVariable();
                            opts.VariableKnownValues[(Variable)metaField] = s.ToEntities((Value[])p.sourceDatasets.toArray(new Value[0]));
                        }
                    }

                    for (int i = 0; i < tripleConstraints.size(); i++) {
                        TripleConstraintData triple = tripleConstraints.get(i) as TripleConstraintData;
                        if (triple == null) return null;

                        graph[i] = new Statement(null, null, null, null); // I don't understand why this should be necessary for a struct, but I get a null reference exception otherwise (yet, that didn't happen initially)
                        graph[i].Subject = ToRes(triple.getSubjectExpression(), p.knownValues, true, varMap1, varMap2, s, opts, distinguishedVars, undistinguishedVars, p.distinguishedVariables) as Entity;
                        graph[i].Predicate = ToRes(triple.getPredicateExpression(), p.knownValues, true, varMap1, varMap2, s, opts, distinguishedVars, undistinguishedVars, p.distinguishedVariables) as Entity;
                        graph[i].Object = ToRes(triple.getObjectExpression(), p.knownValues, false, varMap1, varMap2, s, opts, distinguishedVars, undistinguishedVars, p.distinguishedVariables);
                        graph[i].Meta = metaField;
                        if (graph[i].AnyNull) return new RdfBindingSetImpl();
                        if (!(graph[i].Subject is Variable) && !(graph[i].Predicate is Variable) && !(graph[i].Object is Variable) && !(graph[i].Meta is Variable))
                            return null; // we could use Contains(), but we'll just abandon the Query() path altogether
                    }

                    if (p.distinguishedVariables == null) {
                        opts.DistinguishedVariables = null;
                    } else if (distinguishedVars.Count > 0) {
                        opts.DistinguishedVariables = distinguishedVars;
                    } else if (undistinguishedVars.Count > 0) {
                        // we don't mean to make it distinguished, but we need at least one,
                        // and for now we'll just take the first
                        opts.DistinguishedVariables = new VariableList();
                        ((VariableList)opts.DistinguishedVariables).Add(undistinguishedVars[0]);
                    } else {
                        // no variables!
                        return null;
                    }

                    opts.VariableLiteralFilters = new LitFilterMap();
                    foreach (DictionaryEntry kv in varMap1) {
                        if (p.knownFilters != null && p.knownFilters.containsKey(kv.Key)) {
                            LitFilterList filters = new LitFilterList();
                            for (java.util.Iterator iter = ((java.util.List)p.knownFilters.get(kv.Key)).iterator(); iter.hasNext(); )
                                filters.Add((LiteralFilter)iter.next());
                            opts.VariableLiteralFilters[(Variable)kv.Value] = filters;
                        }
                    }

                    // too expensive to do...
                    //if (!qs.MetaQuery(graph, opts).QuerySupported)
                    //	return null; // TODO: We could also check if any part has NoData, we can abandon the query entirely

                    QueryResultBuilder builder = new QueryResultBuilder();
                    builder.varMap = varMap2;
                    builder.source = s;
                    qs.Query(graph, opts, builder);
                    return builder.bindings;
                }

                return null;
            }
 /**
  * Transforms a map.
  * <p>
  * The transformer itself may throw an exception if necessary.
  *
  * @param map  the map to transform
  * @throws the transformed object
  */
 protected virtual java.util.Map<Object, Object> transformMap(java.util.Map<Object, Object> map)
 {
     if (map.isEmpty())
     {
         return map;
     }
     java.util.Map<Object, Object> result = new LinkedMap(map.size());
     for (java.util.Iterator<java.util.MapNS.Entry<Object, Object>> it = map.entrySet().iterator(); it.hasNext(); )
     {
         java.util.MapNS.Entry<Object, Object> entry = it.next();
         result.put(transformKey(entry.getKey()), transformValue(entry.getValue()));
     }
     return result;
 }
 /**
  * Transforms a collection.
  * <p>
  * The transformer itself may throw an exception if necessary.
  *
  * @param coll  the collection to transform
  * @return a transformed object
  */
 protected virtual java.util.Collection<Object> transform(java.util.Collection<Object> coll)
 {
     java.util.List<Object> list = new java.util.ArrayList<Object>(coll.size());
     for (java.util.Iterator<Object> it = coll.iterator(); it.hasNext(); )
     {
         list.add(transform(it.next()));
     }
     return list;
 }
 /**
  * Create a new Transformer that calls each transformer in turn, passing the
  * result into the next transformer. The ordering is that of the iterator()
  * method on the collection.
  *
  * @param transformers  a collection of transformers to chain
  * @return the <code>chained</code> transformer
  * @throws IllegalArgumentException if the transformers collection is null
  * @throws IllegalArgumentException if any transformer in the collection is null
  */
 public static Transformer getInstance(java.util.Collection<Object> transformers)
 {
     if (transformers == null)
     {
         throw new java.lang.IllegalArgumentException("Transformer collection must not be null");
     }
     if (transformers.size() == 0)
     {
         return NOPTransformer.INSTANCE;
     }
     // convert to array like this to guarantee iterator() ordering
     Transformer[] cmds = new Transformer[transformers.size()];
     int i = 0;
     for (java.util.Iterator<Object> it = transformers.iterator(); it.hasNext(); )
     {
         cmds[i++] = (Transformer)it.next();
     }
     FunctorUtils.validate(cmds);
     return new ChainedTransformer(cmds);
 }
Ejemplo n.º 27
0
		static internal java.util.Map DeriveStyle(java.util.Map attribs, FontStyle style, bool createNew) {
			java.util.Map newAttribs;
			if (createNew) {
				newAttribs = new java.util.Hashtable( attribs.size() );
				java.util.Iterator it = attribs.keySet().iterator();
				while (it.hasNext ()) {
					object key = it.next ();
					object value = attribs.get (key);
					if (value != null)
						newAttribs.put (key, value);
				}
			}
			else
				newAttribs = attribs;

			//Bold
			if((style & FontStyle.Bold) == FontStyle.Bold)
				newAttribs.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
			else
				newAttribs.remove(TextAttribute.WEIGHT);

			//Italic
			if((style & FontStyle.Italic) == FontStyle.Italic)
				newAttribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
			else
				newAttribs.put(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);

			//Underline
			if((style & FontStyle.Underline) == FontStyle.Underline)
				newAttribs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
			else
				newAttribs.remove(TextAttribute.UNDERLINE);

			//Strikeout
			if((style & FontStyle.Strikeout) == FontStyle.Strikeout)
				newAttribs.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
			else
				newAttribs.remove(TextAttribute.STRIKETHROUGH);

			return newAttribs;
		}
Ejemplo n.º 28
0
		private static string[] finishSplit(java.util.List<string> list, string input, int
			 begin, int maxSize, int limit)
		{
			// Add trailing text.
			if (begin < input.Length)
			{
				list.add(Sharpen.StringHelper.Substring(input, begin));
			}
			else
			{
				if (limit != 0)
				{
					// No point adding the empty string if limit == 0, just to remove it below.
					list.add(string.Empty);
				}
			}
			// Remove all trailing empty matches in the limit == 0 case.
			if (limit == 0)
			{
				int i = list.size() - 1;
				while (i >= 0 && string.IsNullOrEmpty(list.get(i)))
				{
					list.remove(i);
					i--;
				}
			}
			// Convert to an array.
			return list.toArray(new string[list.size()]);
		}
        //-----------------------------------------------------------------------
        /**
         * Tests two sets for equality as per the <code>equals()</code> contract
         * in {@link java.util.Set#equals(java.lang.Object)}.
         * <p>
         * This method is useful for implementing <code>Set</code> when you cannot
         * extend AbstractSet. The method takes Collection instances to enable other
         * collection types to use the Set implementation algorithm.
         * <p>
         * The relevant text (slightly paraphrased as this is a static method) is:
         * <blockquote>
         * <p>Two sets are considered equal if they have
         * the same size, and every member of the first set is contained in
         * the second. This ensures that the <tt>equals</tt> method works
         * properly across different implementations of the <tt>Set</tt>
         * interface.</p>
         *
         * <p>
         * This implementation first checks if the two sets are the same object:
         * if so it returns <tt>true</tt>.  Then, it checks if the two sets are
         * identical in size; if not, it returns false. If so, it returns
         * <tt>a.containsAll((Collection) b)</tt>.</p>
         * </blockquote>
         *
         * @see java.util.Set
         * @param set1  the first set, may be null
         * @param set2  the second set, may be null
         * @return whether the sets are equal by value comparison
         */
        public static bool isEqualSet(java.util.Collection<Object> set1, java.util.Collection<Object> set2)
        {
            if (set1 == set2)
            {
                return true;
            }
            if (set1 == null || set2 == null || set1.size() != set2.size())
            {
                return false;
            }

            return set1.containsAll(set2);
        }
 /**
  * Returns a new Collection consisting of the elements of inputCollection transformed
  * by the given transformer.
  * <p>
  * If the input transformer is null, the result is an empty list.
  *
  * @param inputCollection  the collection to get the input from, may not be null
  * @param transformer  the transformer to use, may be null
  * @return the transformed result (new list)
  * @throws NullPointerException if the input collection is null
  */
 public static java.util.Collection<Object> collect(java.util.Collection<Object> inputCollection, Transformer transformer)
 {
     java.util.ArrayList<Object> answer = new java.util.ArrayList<Object>(inputCollection.size());
     collect(inputCollection, transformer, answer);
     return answer;
 }