示例#1
0
        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("");
        }
示例#2
0
        // Load statically registered providers and init Services Info
        private static void loadProviders()
        {
            String providerClassName = null;
            int    i = 1;

            java.lang.ClassLoader  cl = java.lang.ClassLoader.getSystemClassLoader();
            java.security.Provider p;

            while ((providerClassName = java.security.Security.getProperty("security.provider." //$NON-NLS-1$
                                                                           + i++)) != null)
            {
                try
                {
                    p = (java.security.Provider)java.lang.Class
                        .forName(providerClassName.trim(), true, cl)
                        .newInstance();
                    providers.add(p);
                    providersNames.put(p.getName(), p);
                    initServiceInfo(p);
                }
                catch (java.lang.ClassNotFoundException)
                { // ignore Exceptions
                }
                catch (java.lang.IllegalAccessException)
                {
                }
                catch (java.lang.InstantiationException)
                {
                }
            }
            Engine.door.renumProviders();
        }
示例#3
0
        private weka.core.Instances CreateEmptyInstances()
        {
            var atts = new java.util.ArrayList();

            atts.add(new weka.core.Attribute("x"));
            atts.add(new weka.core.Attribute("y"));

            if (!ckbClassIsNominal.Checked)
            {
                atts.add(new weka.core.Attribute("v"));
            }
            else
            {
                // - nominal
                var attVals = new java.util.ArrayList();
                //for(int i=0; i<MAXCLASSNUM; ++i)
                //    attVals.add(i.ToString());
                attVals.add("0");
                attVals.add("1");
                atts.add(new weka.core.Attribute("v", attVals));
            }

            weka.core.Instances data = new weka.core.Instances("MyRelation", atts, 0);
            data.setClassIndex(data.numAttributes() - 1);

            return(data);
        }
示例#4
0
        public static string[] SplitStringByChar(string e, char p)
        {
            if (null == e)
            {
                throw new InvalidOperationException();
            }

            var a = new java.util.ArrayList();

            int  i = -1;
            bool b = true;

            while (b)
            {
                int j = e.IndexOf(p, i + 1);

                if (j == -1)
                {
                    a.add(e.Substring(i + 1));
                    b = false;
                }
                else
                {
                    a.add(e.Substring(i + 1, j - i - 1));
                    i = j;
                }
            }

            return((string[])a.toArray(new string[a.size()]));
        }
        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("");
        }
示例#6
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();
		}
示例#7
0
        private static void SplitCharacter(java.lang.String str, int length,
                                           java.util.ArrayList list, int maxCount,
                                           bool omit, char[] anyOf)
        {
            int listCount = 0;
            int lastIndex = -1;

            for (int index = 0; index < length; index++)
            {
                if (!CharAtIsAnyOf(str, index, anyOf))
                {
                    continue;
                }
                if (index == ++lastIndex && omit)
                {
                    continue;
                }
                if (++listCount == maxCount)
                {
                    list.add(str.substring(lastIndex));
                    return;
                }
                list.add(str.substring(lastIndex, index));
                lastIndex = index;
            }
            if (length != ++lastIndex || !omit)
            {
                list.add(str.substring(lastIndex));
            }
        }
 /// <summary>
 /// Gets the response and modify the headers.
 /// </summary>
 /// <returns>The response.</returns>
 /// <param name="request">Request.</param>
 public override WebResponse getResponse(WebRequest request)
 {
     WebResponse response = base.getResponse(request);
     //
     // Only if Url matches
     //
     if (request.getUrl().toExternalForm().Contains("mb.aspx")) {
         string content = response.getContentAsString("UTF-8");
         java.util.ArrayList newheaders = new java.util.ArrayList();
         java.util.List headers = response.getResponseHeaders();
         java.util.Iterator it = headers.iterator();
         //
         // Remove the 'Access-Control-Allow-Origin' header
         //
         while (it.hasNext()) {
             com.gargoylesoftware.htmlunit.util.NameValuePair o = (com.gargoylesoftware.htmlunit.util.NameValuePair)it.next();
             if (o.getName().Equals("Access-Control-Allow-Origin")) {
                 string value = response.getResponseHeaderValue("Access-Control-Allow-Origin");
                 Console.WriteLine("Found header 'Access-Control-Allow-Origin' = \"{0}\" and stripping it from new headers for response", value);
                 continue; //headers.remove(o);
             }
             newheaders.add(o);
         }
         byte[] utf = System.Text.Encoding.UTF8.GetBytes(content);
         WebResponseData data = new WebResponseData(utf,
             response.getStatusCode(), response.getStatusMessage(), newheaders);
         response = new WebResponse(data, request, response.getLoadTime());
         return response;
     }
     return response;
 }
示例#9
0
文件: Type.cs 项目: wclwksn/code
        // Returns all the public fields of the current System.Type.
        public __FieldInfo[] GetFields()
        {
            var f = this.InternalTypeDescription.getDeclaredFields();
            var a = new java.util.ArrayList <__FieldInfo>();

            for (int i = 0; i < f.Length; i++)
            {
                var fi = f[i];

                // via https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2012/20120-1/20120817-wordpress
                var isPublic = Modifier.isPublic(fi.getModifiers());
                var isFinal  = Modifier.isFinal(fi.getModifiers());

                if (isPublic || isFinal)
                {
                    a.add(
                        new __FieldInfo {
                        InternalField = fi
                    }
                        );
                }
            }


            // otherwise, a new array of the same runtime type is allocated
            return(a.toArray(new __FieldInfo[0]));
        }
示例#10
0
        //
        // GetNestedTypes
        //

        public override Type[] GetNestedTypes(BindingFlags bindingAttr)
        {
            bool takePublic    = (bindingAttr & BindingFlags.Public) != 0;
            bool takeNonPublic = (bindingAttr & BindingFlags.NonPublic) != 0;

            if (takePublic || takeNonPublic)
            {
                var innerClasses = JavaClass.getDeclaredClasses();
                if (innerClasses.Length > 0)
                {
                    var list = new java.util.ArrayList();
                    for (int i = 0; i < innerClasses.Length; i++)
                    {
                        var innerCls = innerClasses[i];
                        var isPublic = (0 != (innerCls.getModifiers()
                                              & java.lang.reflect.Modifier.PUBLIC));

                        if (takePublic == isPublic || takeNonPublic != isPublic)
                        {
                            var innerType = GetType(innerCls);
                            var generic   = ((RuntimeType)innerType).Generic;
                            list.add(generic != null ? generic.PrimaryType : innerType);
                        }
                    }

                    return((Type[])list.toArray(system.RuntimeType.EmptyTypeArray));
                }
            }

            return(system.RuntimeType.EmptyTypeArray);
        }
示例#11
0
文件: Schema.cs 项目: orbeon/saxon-he
        /// <summary>
        /// Run the validation of the supplied source document, optionally
        /// writing the validated document to the supplied destination.
        /// </summary>

        public void Run()
        {
            if (source == null)
            {
                if (sources.Count == 0)
                {
                    throw new StaticError(new net.sf.saxon.trans.XPathException("No source(s) set for the SchemaValidator"));
                }
                java.util.List iter = new java.util.ArrayList();
                foreach (JSource src in sources)
                {
                    iter.add(src);
                }
                try
                {
                    schemaValidator.validateMultiple(iter);
                }
                catch (net.sf.saxon.s9api.SaxonApiException ex) {
                    throw new StaticError(ex);
                }
            }
            else
            {
                JAugmentedSource aug = JAugmentedSource.makeAugmentedSource(source);
                aug.setSchemaValidationMode(lax ? JValidation.LAX : JValidation.STRICT);
                try {
                    schemaValidator.validate(aug);
                }
                catch (net.sf.saxon.s9api.SaxonApiException ex)
                {
                    throw new StaticError(ex);
                }
            }
        }
        /// <summary>
        /// Create a value from a list of items
        /// </summary>
        /// <param name="items">An enumerator providing the items to make up the sequence. Every
        /// member of this list must be an instance of <c>XdmItem</c>
        /// </param>

        public XdmValue(IEnumerable items) {
            JArrayList list = new JArrayList();
            foreach (XdmItem c in items) {
                list.add((Item)c.Unwrap());
            }
            value = new SequenceExtent(list);
        }
示例#13
0
        private imageio.IIOImage GetIIOImageContainer(PlainImage pi)
        {
            java.util.ArrayList al = null;

            // prepare thumbnails list
            if (pi.Thumbnails != null)
            {
                al = new java.util.ArrayList(pi.Thumbnails.Length);
                for (int i = 0; i < pi.Thumbnails.Length; i++)
                {
                    al.add(pi.Thumbnails[i]);
                }
            }

            // prepare IIOImage container
            if (pi.NativeImage is image.BufferedImage)
            {
                imageio.IIOImage iio = new javax.imageio.IIOImage(
                    (image.BufferedImage)pi.NativeImage, al, null /*pi.NativeMetadata*/);
                return(iio);
            }
            else
            {
                // TBD: This codec is for raster formats only
                throw new NotSupportedException("Only raster formats are supported");
            }
        }
示例#14
0
 public virtual bool hasNext()
 {
     if (current.size() > 0)
     {
         return(true);
     }
     while (bucket < root.buckets.Length)
     {
         lock (root.locks[bucket])
         {
             Node n = root.buckets[bucket];
             while (n != null)
             {
                 current.add(n);
                 n = n.next;
             }
             bucket++;
             if (current.size() > 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#15
0
        public static string[] split(java.util.regex.Pattern pattern, string re, string input
                                     , int limit)
        {
            string[] fastResult = fastSplit(re, input, limit);
            if (fastResult != null)
            {
                return(fastResult);
            }
            // Unlike Perl, which considers the result of splitting the empty string to be the empty
            // array, Java returns an array containing the empty string.
            if (string.IsNullOrEmpty(input))
            {
                return(new string[] { string.Empty });
            }
            // Collect text preceding each occurrence of the separator, while there's enough space.
            java.util.ArrayList <string> list = new java.util.ArrayList <string>();
            int maxSize = limit <= 0 ? int.MaxValue : limit;

            java.util.regex.Matcher matcher = new java.util.regex.Matcher(pattern, java.lang.CharSequenceProxy.Wrap
                                                                              (input));
            int begin = 0;

            while (matcher.find() && list.size() + 1 < maxSize)
            {
                list.add(Sharpen.StringHelper.Substring(input, begin, matcher.start()));
                begin = matcher.end();
            }
            return(finishSplit(list, input, begin, maxSize, limit));
        }
示例#16
0
        /// <summary>Add a child animation to this animation set.</summary>
        /// <remarks>
        /// Add a child animation to this animation set.
        /// The transforms of the child animations are applied in the order
        /// that they were added
        /// </remarks>
        /// <param name="a">Animation to add.</param>
        public virtual void addAnimation(android.view.animation.Animation a)
        {
            mAnimations.add(a);
            bool noMatrix = (mFlags & PROPERTY_MORPH_MATRIX_MASK) == 0;

            if (noMatrix && a.willChangeTransformationMatrix())
            {
                mFlags |= PROPERTY_MORPH_MATRIX_MASK;
            }
            bool changeBounds = (mFlags & PROPERTY_CHANGE_BOUNDS_MASK) == 0;

            if (changeBounds && a.willChangeTransformationMatrix())
            {
                mFlags |= PROPERTY_CHANGE_BOUNDS_MASK;
            }
            if ((mFlags & PROPERTY_DURATION_MASK) == PROPERTY_DURATION_MASK)
            {
                mLastEnd = mStartOffset + mDuration;
            }
            else
            {
                if (mAnimations.size() == 1)
                {
                    mDuration = a.getStartOffset() + a.getDuration();
                    mLastEnd  = mStartOffset + mDuration;
                }
                else
                {
                    mLastEnd  = System.Math.Max(mLastEnd, a.getStartOffset() + a.getDuration());
                    mDuration = mLastEnd - mStartOffset;
                }
            }
            mDirty = true;
        }
示例#17
0
        private void _addItemVariable(DfsItemInfo dfsItem, ucar.nc2.NetcdfFileWriteable newNetcdfFile, ucar.nc2.Dimension timeDim, ucar.nc2.Dimension xDim, float delVal, int itemCount)
        {
            java.util.ArrayList varDims = new java.util.ArrayList();
            varDims.add(timeDim);
            varDims.add(xDim);

            newNetcdfFile.addVariable(dfsItem.Name.Replace(' ', '_'), ucar.ma2.DataType.FLOAT, varDims);
            newNetcdfFile.addVariableAttribute(dfsItem.Name.Replace(' ', '_'), "units", _settings.VariablesMappings[itemCount].CFStandardUnit);
            newNetcdfFile.addVariableAttribute(dfsItem.Name.Replace(' ', '_'), "long_name", _settings.VariablesMappings[itemCount].CFStandardName);
            if (!String.IsNullOrEmpty(_settings.VariablesMappings[itemCount].CFStandardDesc))
            {
                newNetcdfFile.addVariableAttribute(dfsItem.Name.Replace(' ', '_'), "description", _settings.VariablesMappings[itemCount].CFStandardDesc);
            }
            newNetcdfFile.addVariableAttribute(dfsItem.Name.Replace(' ', '_'), "missing_value", new java.lang.Float(delVal));
            newNetcdfFile.addVariableAttribute(dfsItem.Name.Replace(' ', '_'), "DHIUnitName", dfsItem.EUMUnitString);
        }
示例#18
0
        public void evaluate(org.openrdf.query.TupleQueryResultHandler tqrh)
        {
            SparqlResultSet rset = this.EvaluateQuery();

            java.util.ArrayList vars = new java.util.ArrayList();
            foreach (String var in rset.Variables)
            {
                vars.add(var);
            }

            tqrh.startQueryResult(vars);
            SesameMapping mapping = new SesameMapping(new Graph(), new dotSesame.impl.GraphImpl());

            foreach (SparqlResult r in rset)
            {
                dotSesameQuery.impl.MapBindingSet binding = new org.openrdf.query.impl.MapBindingSet();
                foreach (String var in r.Variables)
                {
                    binding.addBinding(var, SesameConverter.ToSesameValue(r[var], mapping));
                }
                tqrh.handleSolution(binding);
            }

            tqrh.endQueryResult();
        }
示例#19
0
        /// <summary>
        /// Gets the response and modify the headers.
        /// </summary>
        /// <returns>The response.</returns>
        /// <param name="request">Request.</param>
        public override WebResponse getResponse(WebRequest request)
        {
            WebResponse response = base.getResponse(request);

            //
            // Only if Url matches
            //
            if (request.getUrl().toExternalForm().Contains("com"))
            {
                string content = response.getContentAsString("UTF-8");
                java.util.ArrayList newheaders = new java.util.ArrayList();
                java.util.List      headers    = response.getResponseHeaders();
                java.util.Iterator  it         = headers.iterator();
                //
                // Remove the 'Access-Control-Allow-Origin' header
                //
                while (it.hasNext())
                {
                    com.gargoylesoftware.htmlunit.util.NameValuePair o = (com.gargoylesoftware.htmlunit.util.NameValuePair)it.next();
                    if (o.getName().Equals("Access-Control-Allow-Origin"))
                    {
                        string value = response.getResponseHeaderValue("Access-Control-Allow-Origin");
                        Console.WriteLine("Found header 'Access-Control-Allow-Origin' = \"{0}\" and stripping it from new headers for response", value);
                        continue; //headers.remove(o);
                    }
                    newheaders.add(o);
                }
                byte[]          utf  = System.Text.Encoding.UTF8.GetBytes(content);
                WebResponseData data = new WebResponseData(utf,
                                                           response.getStatusCode(), response.getStatusMessage(), newheaders);
                response = new WebResponse(data, request, response.getLoadTime());
                return(response);
            }
            return(response);
        }
示例#20
0
        /*
         * Returns a string containing a concise, human-readable description of this
         * {@code PermissionCollection}.
         *
         * @return a printable representation for this {@code PermissionCollection}.
         */
        public override String ToString()
        {
            java.util.ArrayList <String>       elist  = new java.util.ArrayList <String>(100);
            java.util.Enumeration <Permission> elenum = elements();
            String superStr    = base.ToString();
            int    totalLength = superStr.length() + 5;

            if (elenum != null)
            {
                while (elenum.hasMoreElements())
                {
                    String el = elenum.nextElement().toString();
                    totalLength += el.length();
                    elist.add(el);
                }
            }
            int esize = elist.size();

            totalLength += esize * 4;
            java.lang.StringBuilder result = new java.lang.StringBuilder(totalLength).append(superStr)
                                             .append(" ("); //$NON-NLS-1$
            for (int i = 0; i < esize; i++)
            {
                result.append("\n ").append(elist.get(i).toString()); //$NON-NLS-1$
            }
            return(result.append("\n)\n").toString());                //$NON-NLS-1$
        }
        public void ListConstructorsAndGetters()
        {
            var dll1 = new DoubleLinkedList();

            Assert.IsNull(dll1.getHead());
            Assert.IsNull(dll1.getTail());
            var names = new java.util.ArrayList();

            names.add("Ala");
            names.add("Ola");
            names.add("Ula");
            var dll2 = new DoubleLinkedList(names);

            Assert.AreEqual("Ala", dll2.getHead().getValue());
            Assert.AreEqual("Ula", dll2.getTail().getValue());
            Assert.IsTrue(dll2.Cast <string>().SequenceEqual(new string[] { "Ala", "Ola", "Ula" }));
        }
示例#22
0
 /**
  * Adds system listener to this list.
  *
  * @param listener - listener to be added.
  */
 public void addSystemListener(T listener)
 {
     if (systemList == null)
     {
         systemList = new java.util.ArrayList <T>();
     }
     systemList.add(listener);
 }
示例#23
0
 public override void registerComponentCallbacks(android.content.ComponentCallbacks
                                                 callback)
 {
     lock (mComponentCallbacks)
     {
         mComponentCallbacks.add(callback);
     }
 }
示例#24
0
 public virtual android.view.MenuItem add(int groupId, int itemId, int order, java.lang.CharSequence
                                          title)
 {
     [email protected] item = new [email protected]
                                                           (getContext(), groupId, itemId, 0, order, title);
     mItems.add(order, item);
     return(item);
 }
示例#25
0
 public virtual void registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks
                                                        callback)
 {
     lock (mActivityLifecycleCallbacks)
     {
         mActivityLifecycleCallbacks.add(callback);
     }
 }
示例#26
0
 internal override android.widget.Filter.FilterResults performFiltering(java.lang.CharSequence
                                                                        prefix)
 {
     android.widget.Filter.FilterResults results = new android.widget.Filter.FilterResults
                                                       ();
     if (this._enclosing.mUnfilteredData == null)
     {
         this._enclosing.mUnfilteredData = new java.util.ArrayList <java.util.Map <string, object
                                                                                   > >(this._enclosing.mData);
     }
     if (prefix == null || prefix.Length == 0)
     {
         java.util.ArrayList <java.util.Map <string, object> > list = this._enclosing.mUnfilteredData;
         results.values = list;
         results.count  = list.size();
     }
     else
     {
         string prefixString = prefix.ToString().ToLower();
         java.util.ArrayList <java.util.Map <string, object> > unfilteredValues = this._enclosing
                                                                                  .mUnfilteredData;
         int count = unfilteredValues.size();
         java.util.ArrayList <java.util.Map <string, object> > newValues = new java.util.ArrayList
                                                                           <java.util.Map <string, object> >(count);
         {
             for (int i = 0; i < count; i++)
             {
                 java.util.Map <string, object> h = unfilteredValues.get(i);
                 if (h != null)
                 {
                     int len = this._enclosing.mTo.Length;
                     {
                         for (int j = 0; j < len; j++)
                         {
                             string   str       = (string)h.get(this._enclosing.mFrom[j]);
                             string[] words     = XobotOS.Runtime.Util.SplitStringRegex(str, " ");
                             int      wordCount = words.Length;
                             {
                                 for (int k = 0; k < wordCount; k++)
                                 {
                                     string word = words[k];
                                     if (word.ToLower().StartsWith(prefixString))
                                     {
                                         newValues.add(h);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         results.values = newValues;
         results.count  = newValues.size();
     }
     return(results);
 }
示例#27
0
 /// <summary>
 /// Converts a list of Vector3D to an arraylist of PVectors
 /// </summary>
 /// <param name="vectorList">the list to convert</param>
 /// <returns>the arraylist of PVectors</returns>
 public static java.util.ArrayList ToPVecList(List <Vector3d> vectorList)
 {
     java.util.ArrayList javalist = new java.util.ArrayList();
     foreach (Vector3d v in vectorList)
     {
         javalist.add(ToPVec(v));
     }
     return(javalist);
 }
 /**
  * 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);
 }
        public List <double> testMLPUsingWeka(string[] attributeArray, string[] classNames, double[] dataValues, string classHeader, string defaultclass, string modelName, int hiddelLayers = 7, double learningRate = 0.03, double momentum = 0.4, int decimalPlaces = 2, int trainingTime = 1000)
        {
            java.util.ArrayList classLabel = new java.util.ArrayList();
            foreach (string className in classNames)
            {
                classLabel.Add(className);
            }
            weka.core.Attribute classHeaderName = new weka.core.Attribute(classHeader, classLabel);

            java.util.ArrayList attributeList = new java.util.ArrayList();
            foreach (string attribute in attributeArray)
            {
                weka.core.Attribute newAttribute = new weka.core.Attribute(attribute);
                attributeList.Add(newAttribute);
            }
            attributeList.add(classHeaderName);
            weka.core.Instances data = new weka.core.Instances("TestInstances", attributeList, 0);
            data.setClassIndex(data.numAttributes() - 1);
            // Set instance's values for the attributes
            weka.core.Instance inst_co = new DenseInstance(data.numAttributes());
            for (int i = 0; i < data.numAttributes() - 1; i++)
            {
                inst_co.setValue(i, dataValues.ElementAt(i));
            }

            inst_co.setValue(classHeaderName, defaultclass);
            data.add(inst_co);

            java.io.File path = new java.io.File("/models/");
            weka.classifiers.functions.MultilayerPerceptron clRead = loadModel(modelName, path);
            clRead.setHiddenLayers(hiddelLayers.ToString());
            clRead.setLearningRate(learningRate);
            clRead.setMomentum(momentum);
            clRead.setNumDecimalPlaces(decimalPlaces);
            clRead.setTrainingTime(trainingTime);
            weka.filters.Filter myRandom = new weka.filters.unsupervised.instance.Randomize();
            myRandom.setInputFormat(data);
            data = weka.filters.Filter.useFilter(data, myRandom);
            double classValue = clRead.classifyInstance(data.get(0));

            double[]      predictionDistribution  = clRead.distributionForInstance(data.get(0));
            List <double> predictionDistributions = new List <double>();

            for (int predictionDistributionIndex = 0;
                 predictionDistributionIndex < predictionDistribution.Count();
                 predictionDistributionIndex++)
            {
                string classValueString1 = classLabel.get(predictionDistributionIndex).ToString();
                double prob = predictionDistribution[predictionDistributionIndex] * 100;
                predictionDistributions.Add(prob);
            }
            List <double> prediction = new List <double>();

            prediction.Add(classValue);
            prediction.AddRange(predictionDistributions);
            return(prediction);
        }
示例#30
0
 private static java.util.List <String> toList(String[] strings)
 {
     java.util.ArrayList <String> arrayList = new java.util.ArrayList <String>(strings.Length);
     foreach (String str in strings)
     {
         arrayList.add(str);
     }
     return(arrayList);
 }
示例#31
0
 /// <summary>
 /// Converts List of Creeper objects to a java.util.List of java creepers
 /// </summary>
 /// <param name="genericList">the list to convert</param>
 /// <returns>the java.util.List of java creepers</returns>
 public static java.util.List ToJavaList(List <CulebraData.Objects.CulebraObject> genericList)
 {
     java.util.List javalist = new java.util.ArrayList();
     foreach (CulebraData.Objects.CulebraObject c in genericList)
     {
         javalist.add(c.GetObject());
     }
     return(javalist);
 }
示例#32
0
 /// <summary>
 /// Converts a single polyline to a shape for Culebra Java Tracking Behaviors
 /// </summary>
 /// <param name="pline">the polyline to convert</param>
 /// <returns>the arraylist of shapes</returns>
 public static java.util.ArrayList PolylineToShape(Polyline pline)
 {
     java.util.ArrayList javalist = new java.util.ArrayList();
     for (int i = 0; i < pline.SegmentCount + 1; i++)
     {
         javalist.add(ToPVec(pline.PointAt(i)));
     }
     return(javalist);
 }
 /**
  * Returns the values for the BeanMap.
  *
  * @return values for the BeanMap.  The returned collection is not
  *        modifiable.
  */
 public override java.util.Collection <Object> values()
 {
     java.util.ArrayList <Object> answer = new java.util.ArrayList <Object>(readMethods.size());
     for (java.util.Iterator <Object> iter = valueIterator(); iter.hasNext();)
     {
         answer.add(iter.next());
     }
     return(UnmodifiableList.decorate(answer));
 }
示例#34
0
 public static void AddInstanceQuickly(weka.core.Instances instances, IList <weka.core.Instance> listInstances)
 {
     java.util.ArrayList arrayListTrainInstances = Feng.Utils.ReflectionHelper.GetObjectValue(instances, "m_Instances") as java.util.ArrayList;
     foreach (var i in listInstances)
     {
         i.setDataset(instances);
         arrayListTrainInstances.add(i);
     }
 }
 /**
  * Answers an iterator over the list of available charsets.
  *
  * @return available charsets.
  */
 public override java.util.Iterator<java.nio.charset.Charset> charsets()
 {
     java.util.ArrayList<java.nio.charset.Charset> charset = new java.util.ArrayList<java.nio.charset.Charset>();
     EncodingInfo [] ei = Encoding.GetEncodings();
     foreach (EncodingInfo info in ei)
     {
         CharsetImpl ci = new CharsetImpl(info.GetEncoding());
         charset.add(ci);
     }
     return charset.iterator();
 }
示例#36
0
        public static void Invoke()
        {
            var nongeneric = new java.util.ArrayList();

            nongeneric.add(new Class1());

            var generic = new java.util.ArrayList<Class1>();

            generic.add(new Class1());


        }
示例#37
0
		// The RI allows regular expressions beginning with ] or }, but that's probably a bug.
		/// <summary>
		/// Returns a result equivalent to
		/// <code>s.split(separator, limit)</code>
		/// if it's able
		/// to compute it more cheaply than ICU, or null if the caller should fall back to
		/// using ICU.
		/// </summary>
		public static string[] fastSplit(string re, string input, int limit)
		{
			// Can we do it cheaply?
			int len = re.Length;
			if (len == 0)
			{
				return null;
			}
			char ch = re[0];
			if (len == 1 && METACHARACTERS.IndexOf(ch) == -1)
			{
			}
			else
			{
				// We're looking for a single non-metacharacter. Easy.
				if (len == 2 && ch == '\\')
				{
					// We're looking for a quoted character.
					// Quoted metacharacters are effectively single non-metacharacters.
					ch = re[1];
					if (METACHARACTERS.IndexOf(ch) == -1)
					{
						return null;
					}
				}
				else
				{
					return null;
				}
			}
			// We can do this cheaply...
			// Unlike Perl, which considers the result of splitting the empty string to be the empty
			// array, Java returns an array containing the empty string.
			if (string.IsNullOrEmpty(input))
			{
				return new string[] { string.Empty };
			}
			// Collect text preceding each occurrence of the separator, while there's enough space.
			java.util.ArrayList<string> list = new java.util.ArrayList<string>();
			int maxSize = limit <= 0 ? int.MaxValue : limit;
			int begin = 0;
			int end;
			while ((end = input.IndexOf(ch, begin)) != -1 && list.size() + 1 < maxSize)
			{
				list.add(Sharpen.StringHelper.Substring(input, begin, end));
				begin = end + 1;
			}
			return finishSplit(list, input, begin, maxSize, limit);
		}
示例#38
0
文件: Model.cs 项目: nuxleus/saxonica
 /// <summary>
 /// Create a new XdmValue by concatenating the sequences of items in this XdmValue and another XdmValue
 /// </summary>
 /// <remarks>
 /// Neither of the input XdmValue objects is modified by this operation
 /// </remarks>
 /// <param name="otherValue">
 /// The other XdmValue, whose items are to be appended to the items from this XdmValue
 /// </param>
 
 public XdmValue Append(XdmValue otherValue) {
     JArrayList list = new JArrayList();
     foreach (XdmItem item in this) {
         list.add(item.Unwrap());
     }
     foreach (XdmItem item in otherValue) {
         list.add(item.Unwrap());
     }
     return XdmValue.Wrap(new SequenceExtent(list));
 }
        //-----------------------------------------------------------------------
        /**
         * Returns a new list containing all elements that are contained in
         * both given lists.
         *
         * @param list1  the first list
         * @param list2  the second list
         * @return  the intersection of those two lists
         * @throws NullPointerException if either list is null
         */
        public static java.util.List<Object> intersection(java.util.List<Object> list1, java.util.List<Object> list2)
        {
            java.util.ArrayList<Object> result = new java.util.ArrayList<Object>();
            java.util.Iterator<Object> iterator = list2.iterator();

            while (iterator.hasNext())
            {
                Object o = iterator.next();

                if (list1.contains(o))
                {
                    result.add(o);
                }
            }

            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;
 }
示例#41
0
                public override void Init(Variable[] variables)
                {
                    java.util.ArrayList vars = new java.util.ArrayList();
                    foreach (Variable b in variables)
                        if (varMap[b] != null) // because of bad treatment of meta
                            vars.add((SparqlVariable)varMap[b]);

                    bindings = new RdfBindingSetImpl(vars);
                }
 /**
  * Removes the elements in <code>remove</code> from <code>collection</code>. That is, this
  * method returns a list containing all the elements in <code>c</code>
  * that are not in <code>remove</code>. The cardinality of an element <code>e</code>
  * in the returned collection is the same as the cardinality of <code>e</code>
  * in <code>collection</code> unless <code>remove</code> contains <code>e</code>, in which
  * case the cardinality is zero. This method is useful if you do not wish to modify
  * <code>collection</code> and thus cannot call <code>collection.removeAll(remove);</code>.
  *
  * @param collection  the collection from which items are removed (in the returned collection)
  * @param remove  the items to be removed from the returned <code>collection</code>
  * @return a <code>List</code> containing all the elements of <code>c</code> except
  * any elements that also occur in <code>remove</code>.
  * @throws NullPointerException if either parameter is null
  * @since Commons Collections 3.2
  */
 public static java.util.List<Object> removeAll(java.util.Collection<Object> collection, java.util.Collection<Object> remove)
 {
     java.util.List<Object> list = new java.util.ArrayList<Object>();
     for (java.util.Iterator<Object> iter = collection.iterator(); iter.hasNext(); )
     {
         Object obj = iter.next();
         if (remove.contains(obj) == false)
         {
             list.add(obj);
         }
     }
     return list;
 }
示例#43
0
		private void InitClient()
		{
			lock(LOCK_OBJECT)
			{
				if((!_disableHttpConnectionPooling) && (_client == null))
				{
					_client = _sclient;
				}
				if(_client == null)
				{
					mainsoft.apache.commons.httpclient.MultiThreadedHttpConnectionManager manager =
						new mainsoft.apache.commons.httpclient.MultiThreadedHttpConnectionManager();
					manager.setConnectionStaleCheckingEnabled(false);
					manager.setMaxTotalConnections(200);
					//by some reasons RFC something - the default 
					//value will be 2 , so we need to change it ...
					manager.setMaxConnectionsPerHost(20);
					_client = new HttpClient(manager);
					_client.getParams().setIntParameter(HttpClientParams.MAX_REDIRECTS, _defaultMaxRedirectsNum);
					_client.getParams().setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, new java.lang.Boolean(true));
					_client.getParams().setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, new java.lang.Long(30000));
					_client.getParams().setParameter(HttpClientParams.USER_AGENT, 
							"VMW4J HttpClient (based on Jakarta Commons HttpClient)");
					_client.getParams ().setBooleanParameter (HttpClientParams.SINGLE_COOKIE_HEADER, true);
					java.util.ArrayList schemas = new java.util.ArrayList ();
					schemas.add ("Ntlm");
					schemas.add ("Digest");
					schemas.add ("Basic");
					schemas.add ("Negotiate");
					_client.getParams ().setParameter (AuthPolicy.AUTH_SCHEME_PRIORITY, schemas);
					if (!_disableHttpConnectionPooling) {
						_sclient = _client;
					}
				}
			}
		}
示例#44
0
		public static string[] split(java.util.regex.Pattern pattern, string re, string input
			, int limit)
		{
			string[] fastResult = fastSplit(re, input, limit);
			if (fastResult != null)
			{
				return fastResult;
			}
			// Unlike Perl, which considers the result of splitting the empty string to be the empty
			// array, Java returns an array containing the empty string.
			if (string.IsNullOrEmpty(input))
			{
				return new string[] { string.Empty };
			}
			// Collect text preceding each occurrence of the separator, while there's enough space.
			java.util.ArrayList<string> list = new java.util.ArrayList<string>();
			int maxSize = limit <= 0 ? int.MaxValue : limit;
			java.util.regex.Matcher matcher = new java.util.regex.Matcher(pattern, java.lang.CharSequenceProxy.Wrap
				(input));
			int begin = 0;
			while (matcher.find() && list.size() + 1 < maxSize)
			{
				list.add(Sharpen.StringHelper.Substring(input, begin, matcher.start()));
				begin = matcher.end();
			}
			return finishSplit(list, input, begin, maxSize, limit);
		}
        //-----------------------------------------------------------------------
        /**
         * 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;
        }
示例#46
0
			internal override android.widget.Filter.FilterResults performFiltering(java.lang.CharSequence
				 prefix)
			{
				android.widget.Filter.FilterResults results = new android.widget.Filter.FilterResults
					();
				if (this._enclosing.mUnfilteredData == null)
				{
					this._enclosing.mUnfilteredData = new java.util.ArrayList<java.util.Map<string, object
						>>(this._enclosing.mData);
				}
				if (prefix == null || prefix.Length == 0)
				{
					java.util.ArrayList<java.util.Map<string, object>> list = this._enclosing.mUnfilteredData;
					results.values = list;
					results.count = list.size();
				}
				else
				{
					string prefixString = prefix.ToString().ToLower();
					java.util.ArrayList<java.util.Map<string, object>> unfilteredValues = this._enclosing
						.mUnfilteredData;
					int count = unfilteredValues.size();
					java.util.ArrayList<java.util.Map<string, object>> newValues = new java.util.ArrayList
						<java.util.Map<string, object>>(count);
					{
						for (int i = 0; i < count; i++)
						{
							java.util.Map<string, object> h = unfilteredValues.get(i);
							if (h != null)
							{
								int len = this._enclosing.mTo.Length;
								{
									for (int j = 0; j < len; j++)
									{
										string str = (string)h.get(this._enclosing.mFrom[j]);
										string[] words = XobotOS.Runtime.Util.SplitStringRegex(str, " ");
										int wordCount = words.Length;
										{
											for (int k = 0; k < wordCount; k++)
											{
												string word = words[k];
												if (word.ToLower().StartsWith(prefixString))
												{
													newValues.add(h);
													break;
												}
											}
										}
									}
								}
							}
						}
					}
					results.values = newValues;
					results.count = newValues.size();
				}
				return results;
			}
示例#47
0
        public static string[] SplitStringByChar(string e, char p)
        {
            if (null == e)
                throw new InvalidOperationException();

            var a = new java.util.ArrayList();

            int i = -1;
            bool b = true;

            while (b)
            {
                int j = e.IndexOf(p, i + 1);

                if (j == -1)
                {
                    a.add(e.Substring(i + 1));
                    b = false;
                }
                else
                {
                    a.add(e.Substring(i + 1, j - i - 1));
                    i = j;
                }


            }

            return (string[])a.toArray(new string[a.size()]);
        }
示例#48
0
文件: Form1.cs 项目: wushian/MLEA
        private weka.core.Instances CreateEmptyInstances()
        {
            var atts = new java.util.ArrayList();
            atts.add(new weka.core.Attribute("x"));
            atts.add(new weka.core.Attribute("y"));

            if (!ckbClassIsNominal.Checked)
            {
                atts.add(new weka.core.Attribute("v"));
            }
            else
            {
                // - nominal
                var attVals = new java.util.ArrayList();
                //for(int i=0; i<MAXCLASSNUM; ++i)
                //    attVals.add(i.ToString());
                attVals.add("0");
                attVals.add("1");
                atts.add(new weka.core.Attribute("v", attVals));
            }

            weka.core.Instances data = new weka.core.Instances("MyRelation", atts, 0);
            data.setClassIndex(data.numAttributes() - 1);

            return data;
        }
		private imageio.IIOImage GetIIOImageContainer(PlainImage pi) {
			java.util.ArrayList al = null;
			
			// prepare thumbnails list
			if (pi.Thumbnails != null) {
				al = new java.util.ArrayList( pi.Thumbnails.Length );
				for (int i=0; i < pi.Thumbnails.Length; i++)
					al.add(pi.Thumbnails[i]);
			}

			// prepare IIOImage container
			if (pi.NativeImage is image.BufferedImage) {
				imageio.IIOImage iio = new javax.imageio.IIOImage(
					(image.BufferedImage)pi.NativeImage, al, null /*pi.NativeMetadata*/);
				return iio;
			}
			else
				// TBD: This codec is for raster formats only
				throw new NotSupportedException("Only raster formats are supported");
		}
示例#50
0
        public void evaluate(org.openrdf.query.TupleQueryResultHandler tqrh)
        {
            SparqlResultSet rset = this.EvaluateQuery();

            java.util.ArrayList vars = new java.util.ArrayList();
            foreach (String var in rset.Variables)
            {
                vars.add(var);
            }

            tqrh.startQueryResult(vars);
            SesameMapping mapping = new SesameMapping(new Graph(), new dotSesame.impl.GraphImpl());
            foreach (SparqlResult r in rset)
            {
                dotSesameQuery.impl.MapBindingSet binding = new org.openrdf.query.impl.MapBindingSet();
                foreach (String var in r.Variables)
                {
                    binding.addBinding(var, SesameConverter.ToSesameValue(r[var], mapping));
                }
                tqrh.handleSolution(binding);
            }

            tqrh.endQueryResult();
        }
示例#51
0
        // Returns all the public fields of the current System.Type.
        public __FieldInfo[] GetFields()
        {

            var f = this.InternalTypeDescription.getDeclaredFields();
            var a = new java.util.ArrayList<__FieldInfo>();

            for (int i = 0; i < f.Length; i++)
            {
                var fi = f[i];

                // via https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2012/20120-1/20120817-wordpress
                var isPublic = Modifier.isPublic(fi.getModifiers());
                var isFinal = Modifier.isFinal(fi.getModifiers());

                if (isPublic || isFinal)
                {
                    a.add(
                        new __FieldInfo { InternalField = fi }
                       );
                }
            }


            // otherwise, a new array of the same runtime type is allocated 
            return a.toArray(new __FieldInfo[0]);
        }
示例#52
0
		private void InitSPNProviders () {
			if (SPNProviders != null)
				return;
			java.util.ArrayList spnProviders = new java.util.ArrayList ();
			NameValueCollection configAttributes = System.Configuration.ConfigurationSettings.AppSettings;
			string providersList = configAttributes ["SPNProviders"];
			if (providersList == null)
				return;
			string[] tokens = providersList.Split (',');
			foreach (string spnClass in tokens) {
				try {
					spnProviders.add (Activator.CreateInstance (Type.GetType (spnClass)));
				}
				catch (Exception) { }
			}
			SPNProviders = spnProviders;
		}
示例#53
0
		public void sendActivityResult(android.os.IBinder token, string id, int requestCode
			, int resultCode, android.content.Intent data)
		{
			java.util.ArrayList<android.app.ResultInfo> list = new java.util.ArrayList<android.app.ResultInfo
				>();
			list.add(new android.app.ResultInfo(id, requestCode, resultCode, data));
			mAppThread.scheduleSendResult(token, list);
		}
示例#54
0
        /// <summary>
        /// Reads the shapefile and returns a <b>GeometryCollection</b> representing all the records in the shapefile.
        /// </summary>
        /// <returns>A <b>GeometryCollection</b> representing every record in the shapefile.</returns>
        public GeometryCollection ReadAll()
        {
            java.util.ArrayList list = new java.util.ArrayList();
            ShapeHandler handler = Shapefile.GetShapeHandler(_mainHeader.ShapeType);

            if (handler == null)
            {
                throw new NotSupportedException("Unsupported shape type:" + _mainHeader.ShapeType);
            }

            foreach (Geometry geometry in this)
            {
                list.add(geometry);
            }

            Geometry[] geomArray = GeometryFactory.toGeometryArray(list);

            return _geometryFactory.createGeometryCollection(geomArray);
        }
示例#55
0
		/// <summary>Read an ArrayList object from an XmlPullParser.</summary>
		/// <remarks>
		/// Read an ArrayList object from an XmlPullParser.  The XML data could
		/// previously have been generated by writeListXml().  The XmlPullParser
		/// must be positioned <em>after</em> the tag that begins the list.
		/// </remarks>
		/// <param name="parser">The XmlPullParser from which to read the list data.</param>
		/// <param name="endTag">Name of the tag that will end the list, usually "list".</param>
		/// <param name="name">
		/// An array of one string, used to return the name attribute
		/// of the list's tag.
		/// </param>
		/// <returns>HashMap The newly generated list.</returns>
		/// <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 java.util.ArrayList<object> readThisListXml(org.xmlpull.v1.XmlPullParser
			 parser, string endTag, string[] name)
		{
			java.util.ArrayList<object> list = new java.util.ArrayList<object>();
			int eventType = parser.getEventType();
			do
			{
				if (eventType == org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					object val = readThisValueXml(parser, name);
					list.add(val);
				}
				else
				{
					//System.out.println("Adding to list: " + val);
					if (eventType == org.xmlpull.v1.XmlPullParserClass.END_TAG)
					{
						if (parser.getName().Equals(endTag))
						{
							return list;
						}
						throw new org.xmlpull.v1.XmlPullParserException("Expected " + endTag + " end tag at: "
							 + parser.getName());
					}
				}
				eventType = parser.next();
			}
			while (eventType != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT);
			throw new org.xmlpull.v1.XmlPullParserException("Document ended before " + endTag
				 + " end tag");
		}
示例#56
0
		internal java.util.ArrayList<android.content.ComponentCallbacks2> collectComponentCallbacksLocked
			(bool allActivities, android.content.res.Configuration newConfig)
		{
			java.util.ArrayList<android.content.ComponentCallbacks2> callbacks = new java.util.ArrayList
				<android.content.ComponentCallbacks2>();
			if (mActivities.size() > 0)
			{
				java.util.Iterator<android.app.ActivityThread.ActivityClientRecord> it = mActivities
					.values().iterator();
				while (it.hasNext())
				{
					android.app.ActivityThread.ActivityClientRecord ar = it.next();
					android.app.Activity a = ar.activity;
					if (a != null)
					{
						android.content.res.Configuration thisConfig = applyConfigCompatMainThread(newConfig
							, ar.packageInfo.mCompatibilityInfo.getIfNeeded());
						if (!ar.activity.mFinished && (allActivities || (a != null && !ar.paused)))
						{
							// If the activity is currently resumed, its configuration
							// needs to change right now.
							callbacks.add(a);
						}
						else
						{
							if (thisConfig != null)
							{
								// Otherwise, we will tell it about the change
								// the next time it is resumed or shown.  Note that
								// the activity manager may, before then, decide the
								// activity needs to be destroyed to handle its new
								// configuration.
								ar.newConfig = thisConfig;
							}
						}
					}
				}
			}
			if (mServices.size() > 0)
			{
				java.util.Iterator<android.app.Service> it = mServices.values().iterator();
				while (it.hasNext())
				{
					callbacks.add(it.next());
				}
			}
			lock (mProviderMap)
			{
				if (mLocalProviders.size() > 0)
				{
					java.util.Iterator<android.app.ActivityThread.ProviderClientRecord> it = mLocalProviders
						.values().iterator();
					while (it.hasNext())
					{
						callbacks.add(it.next().mLocalProvider);
					}
				}
			}
			int N = mAllApplications.size();
			{
				for (int i = 0; i < N; i++)
				{
					callbacks.add(mAllApplications.get(i));
				}
			}
			return callbacks;
		}
		public override java.util.List<android.content.pm.UserInfo> getUsers()
		{
			// TODO:
			// Dummy code, always returns just the primary user
			java.util.ArrayList<android.content.pm.UserInfo> users = new java.util.ArrayList<
				android.content.pm.UserInfo>();
			android.content.pm.UserInfo primary = new android.content.pm.UserInfo(0, "Root!", 
				android.content.pm.UserInfo.FLAG_ADMIN | android.content.pm.UserInfo.FLAG_PRIMARY
				);
			users.add(primary);
			return users;
		}
示例#58
0
 /**
  * Returns a string containing a concise, human-readable description of this
  * {@code PermissionCollection}.
  *
  * @return a printable representation for this {@code PermissionCollection}.
  */
 public override String ToString()
 {
     java.util.ArrayList<String> elist = new java.util.ArrayList<String>(100);
     java.util.Enumeration<Permission> elenum = elements();
     String superStr = base.ToString();
     int totalLength = superStr.length() + 5;
     if (elenum != null)
     {
         while (elenum.hasMoreElements())
         {
             String el = elenum.nextElement().toString();
             totalLength += el.length();
             elist.add(el);
         }
     }
     int esize = elist.size();
     totalLength += esize * 4;
     java.lang.StringBuilder result = new java.lang.StringBuilder(totalLength).append(superStr)
         .append(" ("); //$NON-NLS-1$
     for (int i = 0; i < esize; i++)
     {
         result.append("\n ").append(elist.get(i).toString()); //$NON-NLS-1$
     }
     return result.append("\n)\n").toString(); //$NON-NLS-1$
 }
示例#59
0
        // Update provider Services if the properties was changed
        private void updatePropertyServiceTable()
        {
            Object _key;
            Object _value;
            Provider.Service s;
            String serviceName;
            String algorithm;
            if (changedProperties == null || changedProperties.isEmpty())
            {
                return;
            }
            java.util.Iterator<java.util.MapNS.Entry<String, String>> it = changedProperties.entrySet().iterator();
            for (; it.hasNext(); )
            {
                java.util.MapNS.Entry<String, String> entry = it.next();
                _key = entry.getKey();
                _value = entry.getValue();
                if (_key == null || _value == null || !(_key is String)
                        || !(_value is String))
                {
                    continue;
                }
                String key = (String)_key;
                String value = (String)_value;
                if (key.startsWith("Provider"))
                { // Provider service type is reserved //$NON-NLS-1$
                    continue;
                }
                int i;
                if (key.startsWith("Alg.Alias."))
                { // Alg.Alias.<crypto_service>.<aliasName>=<stanbdardName> //$NON-NLS-1$
                    String aliasName;
                    String service_alias = key.substring(10);
                    i = service_alias.indexOf('.');
                    serviceName = service_alias.substring(0, i);
                    aliasName = service_alias.substring(i + 1);
                    algorithm = value;
                    String algUp = algorithm.toUpperCase();
                    Object o = null;
                    if (propertyServiceTable == null)
                    {
                        propertyServiceTable = new TwoKeyHashMap<String, String, Service>(128);
                    }
                    else
                    {
                        o = propertyServiceTable.get(serviceName, algUp);
                    }
                    if (o != null)
                    {
                        s = (Provider.Service)o;
                        s.aliases.add(aliasName);
                        if (propertyAliasTable == null)
                        {
                            propertyAliasTable = new TwoKeyHashMap<String, String, Service>(256);
                        }
                        propertyAliasTable.put(serviceName,
                                aliasName.toUpperCase(), s);
                    }
                    else
                    {
                        String className = (String)changedProperties
                                .get(serviceName + "." + algorithm); //$NON-NLS-1$
                        if (className != null)
                        {
                            java.util.ArrayList<String> l = new java.util.ArrayList<String>();
                            l.add(aliasName);
                            s = new Provider.Service(this, serviceName, algorithm,
                                    className, l, new java.util.HashMap<String, String>());
                            propertyServiceTable.put(serviceName, algUp, s);
                            if (propertyAliasTable == null)
                            {
                                propertyAliasTable = new TwoKeyHashMap<String, String, Service>(256);
                            }
                            propertyAliasTable.put(serviceName, aliasName
                                    .toUpperCase(), s);
                        }
                    }
                    continue;
                }
                int j = key.indexOf('.');
                if (j == -1)
                { // unknown format
                    continue;
                }
                i = key.indexOf(' ');
                if (i == -1)
                { // <crypto_service>.<algorithm_or_type>=<className>
                    serviceName = key.substring(0, j);
                    algorithm = key.substring(j + 1);
                    String alg = algorithm.toUpperCase();
                    Object o = null;
                    if (propertyServiceTable != null)
                    {
                        o = propertyServiceTable.get(serviceName, alg);
                    }
                    if (o != null)
                    {
                        s = (Provider.Service)o;
                        s.className = value;
                    }
                    else
                    {
                        s = new Provider.Service(this, serviceName, algorithm,
                                value, new java.util.ArrayList<String>(), new java.util.HashMap<String, String>());
                        if (propertyServiceTable == null)
                        {
                            propertyServiceTable = new TwoKeyHashMap<String, String, Service>(128);
                        }
                        propertyServiceTable.put(serviceName, alg, s);

                    }
                }
                else
                { // <crypto_service>.<algorithm_or_type>
                    // <attribute_name>=<attrValue>
                    serviceName = key.substring(0, j);
                    algorithm = key.substring(j + 1, i);
                    String attribute = key.substring(i + 1);
                    String alg = algorithm.toUpperCase();
                    Object o = null;
                    if (propertyServiceTable != null)
                    {
                        o = propertyServiceTable.get(serviceName, alg);
                    }
                    if (o != null)
                    {
                        s = (Provider.Service)o;
                        s.attributes.put(attribute, value);
                    }
                    else
                    {
                        String className = (String)changedProperties
                                .get(serviceName + "." + algorithm); //$NON-NLS-1$
                        if (className != null)
                        {
                            java.util.HashMap<String, String> m = new java.util.HashMap<String, String>();
                            m.put(attribute, value);
                            s = new Provider.Service(this, serviceName, algorithm,
                                    className, new java.util.ArrayList<String>(), m);
                            if (propertyServiceTable == null)
                            {
                                propertyServiceTable = new TwoKeyHashMap<String, String, Service>(128);
                            }
                            propertyServiceTable.put(serviceName, alg, s);
                        }
                    }
                }
            }
            servicesChanged();
            changedProperties.clear();
        }
 /**
  * Gets a list based on an iterator.
  * <p>
  * As the wrapped Iterator is traversed, an ArrayList of its values is
  * created. At the end, the list is returned.
  *
  * @param iterator  the iterator to use, not null
  * @param estimatedSize  the initial size of the ArrayList
  * @return a list of the iterator contents
  * @throws NullPointerException if iterator parameter is null
  * @throws IllegalArgumentException if the size is less than 1
  */
 public static java.util.List<Object> toList(java.util.Iterator<Object> iterator, int estimatedSize)
 {
     if (iterator == null)
     {
         throw new java.lang.NullPointerException("Iterator must not be null");
     }
     if (estimatedSize < 1)
     {
         throw new java.lang.IllegalArgumentException("Estimated size must be greater than 0");
     }
     java.util.List<Object> list = new java.util.ArrayList<Object>(estimatedSize);
     while (iterator.hasNext())
     {
         list.add(iterator.next());
     }
     return list;
 }