Example #1
0
 public static Hashtable ToHashtable(java.util.Map map)
 {
     if(map == null) return null;
     Hashtable table = new Hashtable();
     java.util.Iterator it = map.keySet().iterator();
     while(it.hasNext())
     {
         string key = (string)it.next();
         object val = map.get(key);
         table[key] = val;
     }
     return table;
 }
Example #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);

            }
        }
Example #4
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);
						}
					}
				}
			}
		}
Example #5
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);
				}
			}
		}
Example #6
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));
     }
 }
 /**
  * Gets a Map from a Map in a null-safe manner.
  * <p>
  * If the value returned from the specified map is not a Map then
  * <code>null</code> is returned.
  *
  * @param map  the map to use
  * @param key  the key to look up
  * @return the value in the Map as a Map, <code>null</code> if null map input
  */
 public static java.util.Map<Object, Object> getMap(java.util.Map<Object, Object> map, Object key)
 {
     if (map != null)
     {
         Object answer = map.get(key);
         if (answer != null && answer is java.util.Map<Object, Object>)
         {
             return (java.util.Map<Object, Object>)answer;
         }
     }
     return null;
 }
		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;
		}
            Resource ToRes(object expr, java.util.Map knownValues, bool entities, Hashtable varMap1, Hashtable varMap2, RdfSourceWrapper src, QueryOptions opts, VariableList distinguishedVars, VariableList undistinguishedVars, java.util.Set sparqlDistinguished)
            {
                if (expr is SparqlVariable) {
                    Variable v;
                    if (varMap1.ContainsKey(expr)) {
                        v = (Variable)varMap1[expr];
                    } else {
                        v = new Variable(expr.ToString());
                        varMap1[expr] = v;
                        varMap2[v] = expr;

                        if (knownValues != null && knownValues.get(expr) != null) {
                            java.util.Set values = (java.util.Set)knownValues.get(expr);
                            VarKnownValuesList values2 = new VarKnownValuesList();
                            for (java.util.Iterator iter = values.iterator(); iter.hasNext(); ) {
                                Resource r = src.ToResource((name.levering.ryan.sparql.common.Value)iter.next());
                                if (r != null)
                                    values2.Add(r);
                            }

                            opts.VariableKnownValues[v] = values2;
                        }

                        if (sparqlDistinguished != null && sparqlDistinguished.contains(expr))
                            distinguishedVars.Add(v);
                        else
                            undistinguishedVars.Add(v);
                    }
                    return v;
                }

                return entities ? src.ToEntity((name.levering.ryan.sparql.common.Value)expr) : src.ToResource((name.levering.ryan.sparql.common.Value)expr);
            }
 private static int getFreq(Object obj, java.util.Map<Object, Object> freqMap)
 {
     java.lang.Integer count = (java.lang.Integer)freqMap.get(obj);
     if (count != null)
     {
         return count.intValue();
     }
     return 0;
 }
Example #11
0
        /// <summary>
        /// converts object list to int array
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public static int[] ToInt32Array(java.util.ArrayList u)
        {
            int[] x = new int[u.size()];

            for (int i = 0; i < u.size(); i++)
            {
                x[i] = (int)u.get(i);
            }

            return x;
        }
 /**
  * Gets a String from a Map in a null-safe manner.
  * <p>
  * The String is obtained via <code>toString</code>.
  *
  * @param map  the map to use
  * @param key  the key to look up
  * @return the value in the Map as a String, <code>null</code> if null map input
  */
 public static String getString(java.util.Map<Object, Object> map, Object key)
 {
     if (map != null)
     {
         Object answer = map.get(key);
         if (answer != null)
         {
             return answer.toString();
         }
     }
     return null;
 }
 // Type safe getters with default values
 //-------------------------------------------------------------------------
 /**
  *  Looks up the given key in the given map, converting null into the
  *  given default value.
  *
  *  @param map  the map whose value to look up
  *  @param key  the key of the value to look up in that map
  *  @param defaultValue  what to return if the value is null
  *  @return  the value in the map, or defaultValue if the original value
  *    is null or the map is null
  */
 public static Object getObject(java.util.Map<Object, Object> map, Object key, Object defaultValue)
 {
     if (map != null)
     {
         Object answer = map.get(key);
         if (answer != null)
         {
             return answer;
         }
     }
     return defaultValue;
 }
 // Type safe getters
 //-------------------------------------------------------------------------
 /**
  * Gets from a Map in a null-safe manner.
  *
  * @param map  the map to use
  * @param key  the key to look up
  * @return the value in the Map, <code>null</code> if null map input
  */
 public static Object getObject(java.util.Map<Object, Object> map, Object key)
 {
     if (map != null)
     {
         return map.get(key);
     }
     return null;
 }
        /**
         * Gets a Number from a Map in a null-safe manner.
         * <p>
         * If the value is a <code>Number</code> it is returned directly.
         * If the value is a <code>String</code> it is converted using
         * {@link NumberFormat#parse(String)} on the system default formatter
         * returning <code>null</code> if the conversion fails.
         * Otherwise, <code>null</code> is returned.
         *
         * @param map  the map to use
         * @param key  the key to look up
         * @return the value in the Map as a Number, <code>null</code> if null map input
         */
        public static java.lang.Number getNumber(java.util.Map<Object, Object> map, Object key)
        {
            if (map != null)
            {
                Object answer = map.get(key);
                if (answer != null)
                {
                    if (answer is java.lang.Number)
                    {
                        return (java.lang.Number)answer;

                    }
                    else if (answer is String)
                    {
                        try
                        {
                            String text = (String)answer;

                            return java.text.NumberFormat.getInstance().parse(text);

                        }
                        catch (java.text.ParseException e)
                        {
                            logInfo(e);
                        }
                    }
                }
            }
            return null;
        }
Example #16
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());
			}
Example #17
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;
            }
Example #18
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;
		}
Example #19
0
 public static java.lang.Class defineClass2(java.lang.ClassLoader thisClassLoader, string name, java.nio.ByteBuffer bb, int off, int len, java.security.ProtectionDomain pd, string source)
 {
     #if FIRST_PASS
     return null;
     #else
     byte[] buf = new byte[bb.remaining()];
     bb.get(buf);
     return defineClass1(thisClassLoader, name, buf, 0, buf.Length, pd, source);
     #endif
 }
Example #20
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()]);
		}
Example #21
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");
		}
        /**
         * Gets a bool from a Map in a null-safe manner.
         * <p>
         * If the value is a <code>Boolean</code> it is returned directly.
         * If the value is a <code>String</code> and it equals 'true' ignoring case
         * then <code>true</code> is returned, otherwise <code>false</code>.
         * If the value is a <code>Number</code> an integer zero value returns
         * <code>false</code> and non-zero returns <code>true</code>.
         * Otherwise, <code>null</code> is returned.
         *
         * @param map  the map to use
         * @param key  the key to look up
         * @return the value in the Map as a Boolean, <code>null</code> if null map input
         */
        public static java.lang.Boolean getBoolean(java.util.Map<Object, Object> map, Object key)
        {
            if (map != null)
            {
                Object answer = map.get(key);
                if (answer != null)
                {
                    if (answer is java.lang.Boolean)
                    {
                        return (java.lang.Boolean)answer;

                    }
                    else if (answer is String)
                    {
                        return new java.lang.Boolean((String)answer);

                    }
                    else if (answer is java.lang.Number)
                    {
                        java.lang.Number n = (java.lang.Number)answer;
                        return (n.intValue() != 0) ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE;
                    }
                }
            }
            return null;
        }