예제 #1
0
        /// <summary>
        /// Note that currently there seem to be no way for the "yanqi" implementation to actually specify the number
        /// of shortest paths to return, but it seems to find all paths.
        /// However, the implementation of this method instead takes care of reducing the result.
        /// Otherwise, if the semantic of the method is not respected it can not for example be tested
        /// against results from other implementations since then they would return a different number of paths.
        /// </summary>
        /// <param name="startVertex"></param>
        /// <param name="endVertex"></param>
        /// <param name="maxNumberOfPaths"></param>
        /// <returns></returns>
        protected override IList <P> FindShortestPathHook(
            V startVertex,
            V endVertex,
            int maxNumberOfPaths
            )
        {
            IList <P> paths                = new List <P>();
            int       startVertexId        = idMapper.CreateOrRetrieveIntegerId(startVertex.VertexId);
            int       endVertexId          = idMapper.CreateOrRetrieveIntegerId(endVertex.VertexId);
            YenTopKShortestPathsAlg yenAlg = new YenTopKShortestPathsAlg(graphAdaptee, graphAdaptee.GetVertex(startVertexId), graphAdaptee.GetVertex(endVertexId));

            while (yenAlg.HasNext())
            {
                global::edu.asu.emit.algorithm.graph.Path path = yenAlg.Next();
                IList <E> edges = new List <E>();
                java.util.List <BaseVertex> vertexList = path.GetVertexList();
                for (int i = 1; i < vertexList.size(); i++)
                {
                    BaseVertex startVertexForEdge = vertexList.get(i - 1);
                    BaseVertex endVertexForEdge   = vertexList.get(i);
                    E          edge = GetOriginalEdgeInstance(startVertexForEdge, endVertexForEdge);
                    edges.Add(
                        edge
                        );
                }
                W totalWeight = base.CreateInstanceWithTotalWeight(path.GetWeight(), edges);
                paths.Add(base.CreatePath(totalWeight, edges));
                if (maxNumberOfPaths == paths.Count)
                {
                    break;
                }
            }
            return(new ReadOnlyCollection <P>(paths));
        }
예제 #2
0
        public void testStringConstraints()
        {
            //string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.basic_types.test.adl");

            //se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl);
            //attributeList = parser.parse().getDefinition().getAttributes();

            java.util.List list = getConstraints(0);
            assertCString(list.get(0), null, new String[] { "something" }, null);

            assertCString(list.get(1), "this|that|something else", null, null);

            assertCString(list.get(2), "cardio.*", null, null);

            assertCString(list.get(3), "mg|mg/ml|mg/g", null, null);

            assertCString(list.get(4), null, new String[] { "apple", "pear" }, null);

            // with assumed values
            assertCString(list.get(5), null, new String[] { "something" },
                          "nothing");

            assertCString(list.get(6), "this|that|something else", null, "those");

            assertCString(list.get(7), "cardio.*", null, "cardio.txt");

            assertCString(list.get(8), "mg|mg/ml|mg/g", null, "mg");

            assertCString(list.get(9), null, new String[] { "apple", "pear" },
                          "orange");
        }
예제 #3
0
        public void testParseAndVerifySimpleValues()
        {
            string        adl     = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\dadl-parser\src\test\resources\simple_values.dadl");
            DADLParser    parser  = new DADLParser(adl);
            ContentObject content = parser.parse();

            Assert.IsNotNull(content);
            Assert.IsNull(content.getComplexObjectBlock());
            Assert.IsNotNull(content.getAttributeValues());
            Assert.AreEqual(1, content.getAttributeValues().size());
            AttributeValue av = (AttributeValue)content.getAttributeValues().get(0);

            Assert.AreEqual("simple_values", av.getId());
            ObjectBlock ob = av.getValue();

            Assert.IsInstanceOfType(ob, typeof(SingleAttributeObjectBlock));
            SingleAttributeObjectBlock single = (SingleAttributeObjectBlock)ob;

            java.util.List values = single.getAttributeValues();
            Assert.AreEqual(10, values.size());
            assertDateTimeValue((AttributeValue)values.get(0), "2007-10-30T09:22:00");
            assertDateValue((AttributeValue)values.get(1), "2008-04-02");
            assertTimeValue((AttributeValue)values.get(2), "11:09:40");
            assertDurationValue((AttributeValue)values.get(3), "PT10M");
            assertStringValue((AttributeValue)values.get(4), "a string value");
            assertCharacterValue((AttributeValue)values.get(5), 'a');
            assertIntegerValue((AttributeValue)values.get(6), 100);
            assertRealValue((AttributeValue)values.get(7), 9.5);
            assertBooleanValue((AttributeValue)values.get(8), true);
        }
예제 #4
0
 /*
  * Creates a <code>ExcC14NParameterSpec</code> with the specified list
  * of prefixes. The list is copied to protect against subsequent
  * modification.
  *
  * @param prefixList the inclusive namespace prefix list. Each entry in
  *    the list is a <code>String</code> that represents a namespace prefix.
  * @throws NullPointerException if <code>prefixList</code> is
  *    <code>null</code>
  * @throws ClassCastException if any of the entries in the list are not
  *    of type <code>String</code>
  */
 public ExcC14NParameterSpec(java.util.List <Object> prefixList)
 {
     if (prefixList == null)
     {
         throw new java.lang.NullPointerException("prefixList cannot be null");
     }
     this.preList = unmodifiableCopyOfList(prefixList);
     for (int i = 0, size = preList.size(); i < size; i++)
     {
         if (!(preList.get(i) is String || preList.get(i) is java.lang.StringJ))
         {
             throw new java.lang.ClassCastException("not a String");
         }
     }
 }
        /**
         * Returns the next element from the iterator.
         *
         * @return the next element from the iterator
         * @throws NoSuchElementException if there are no more elements
         */
        public Object next()
        {//throws NoSuchElementException {
            if (currentIndex < wrappedIteratorIndex)
            {
                ++currentIndex;
                return(list.get(currentIndex - 1));
            }

            Object retval = iterator.next();

            list.add(retval);
            ++currentIndex;
            ++wrappedIteratorIndex;
            return(retval);
        }
예제 #6
0
#pragma warning restore 672

        // index "a","b","c" as  pos0="a", pos1="b", pos2="c", pos2="abc"
        private void addCombos(List /*<Token>*/ lst, int start, int end, bool generateSubwords, bool catenateSubwords, int posOffset)
        {
            if (end - start == 1)
            {
                // always generate a word alone, even if generateSubwords=0 because
                // the catenation of all the subwords *is* the subword.
                queue.add(lst.get(start));
                return;
            }

            StringBuilder sb = null;

            if (catenateSubwords)
            {
                sb = new StringBuilder();
            }
            Token firstTok = null;
            Token tok      = null;

            for (int i = start; i < end; i++)
            {
                tok = (Token)lst.get(i);
                if (catenateSubwords)
                {
                    if (i == start)
                    {
                        firstTok = tok;
                    }
                    sb.append(tok.termBuffer(), 0, tok.termLength());
                }
                if (generateSubwords)
                {
                    queue.add(tok);
                }
            }

            if (catenateSubwords)
            {
                Token concatTok = new Token(sb.toString(),
                                            firstTok.startOffset(),
                                            tok.endOffset(),
                                            firstTok.type());
                // if we indexed some other tokens, then overlap concatTok with the last.
                // Otherwise, use the value passed in as the position offset.
                concatTok.setPositionIncrement(generateSubwords == true ? 0 : posOffset);
                queue.add(concatTok);
            }
        }
예제 #7
0
        private IEnumerable <FeedQueueItem> GetExistingQueueItems()
        {
            IList <FeedQueueItem> items = new List <FeedQueueItem>();

            java.util.List jobQueueItems = Client.getFeedJobQueueItems(this.jmxConfiguration.AmqJmxUrl, this.jmxConfiguration.BrokerJmxName, "FeedJobQueue");

            for (int i = 0; i < jobQueueItems.size(); i++)
            {
                var queueItem = jobQueueItems.get(i) as string;

                if (queueItem != null)
                {
                    var boxedVkGroupId     = GroupRegex.Match(queueItem).Groups[1].Value;
                    var boxedQueueItemType = QueueItemTypeRegex.Match(queueItem).Groups[1].Value;

                    var item = new FeedQueueItem
                    {
                        VkGroupId     = int.Parse(boxedVkGroupId),
                        QueueItemType = (QueueItemType)Enum.Parse(typeof(QueueItemType), boxedQueueItemType)
                    };
                    items.Add(item);
                }
            }

            return(items);
        }
예제 #8
0
        public void testConstraintBindingWithMultiTerminologies()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.constraint_binding.test.adl");

            se.acode.openehr.parser.ADLParser  parser    = new se.acode.openehr.parser.ADLParser(adl);
            org.openehr.am.archetype.Archetype archetype = parser.parse();
            java.util.List list = archetype.getOntology().getConstraintBindingList();

            Assert.AreEqual(2, list.size(), "unexpected number of onotology binding");

            // verify the first constraint binding
            org.openehr.am.archetype.ontology.OntologyBinding binding = (org.openehr.am.archetype.ontology.OntologyBinding)list.get(0);
            Assert.AreEqual("SNOMED_CT", binding.getTerminology(), "unexpected binding terminology");

            org.openehr.am.archetype.ontology.QueryBindingItem item = (org.openehr.am.archetype.ontology.QueryBindingItem)binding.getBindingList().get(0);

            Assert.AreEqual("ac0001", item.getCode(), "unexpected local code");
            Assert.AreEqual("http://terminology.org?terminology_id=snomed_ct&&has_relation=102002;with_target=128004", item.getQuery().getUrl(), "exexpected query");

            // verify the second constraint binding
            binding = (org.openehr.am.archetype.ontology.OntologyBinding)list.get(1);
            Assert.AreEqual("ICD10", binding.getTerminology(), "unexpected binding terminology");

            item = (org.openehr.am.archetype.ontology.QueryBindingItem)binding.getBindingList().get(0);

            Assert.AreEqual("ac0001", item.getCode(), "unexpected local code");
            Assert.AreEqual("http://terminology.org?terminology_id=icd10&&has_relation=a2;with_target=b19",
                            item.getQuery().getUrl(), "exexpected query");
        }
예제 #9
0
 public static string RemoteCommandResponse(string Command)
 {
     if (ClientDDM != null && !ClientDDM.isClosed())
     {
         java.util.List lstMessages = ClientDDM.executeReturnMessageList(Command);
         if (lstMessages == null || lstMessages.size() == 0)
         {
             return("");
         }
         else
         {
             for (int msgidx = 0; msgidx < lstMessages.size(); msgidx++)
             {
                 com.ibm.jtopenlite.Message msg = (com.ibm.jtopenlite.Message)lstMessages.get(0);
                 if (msg.getSeverity() > 10)
                 {
                     return(msg.getText());
                 }
             }
         }
         // Get here means no messages with Sev > 10, so ok
         return("");
     }
     else
     {
         return("Not connected.");
     }
 }
예제 #10
0
        private void assertKeyedObject(KeyedObject ko, int key,
                                       String attribute, String value)
        {
            SimpleValue keyValue = ko.getKey();

            Assert.IsInstanceOfType(keyValue, typeof(IntegerValue));
            IntegerValue iv = (IntegerValue)keyValue;
            //Assert.AreEqual(iv.getValue(), key);

            ObjectBlock ob = ko.getObject();

            Assert.IsInstanceOfType(ob, typeof(SingleAttributeObjectBlock));
            SingleAttributeObjectBlock saob = (SingleAttributeObjectBlock)ob;

            java.util.List attributes = saob.getAttributeValues();
            Assert.AreEqual(attributes.size(), 1);
            AttributeValue av = (AttributeValue)attributes.get(0);

            Assert.AreEqual(av.getId(), attribute);

            ob = av.getValue();
            Assert.IsInstanceOfType(ob, typeof(PrimitiveObjectBlock));
            SimpleValue sv = ((PrimitiveObjectBlock)ob).getSimpleValue();

            Assert.IsInstanceOfType(sv, typeof(StringValue));
            StringValue str = (StringValue)sv;

            Assert.AreEqual(str.getValue(), value);
        }
예제 #11
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()]));
 }
예제 #12
0
        public static IReadOnlyList <ChemicalWithData> GetSet(Dictionary <string, string> Modelinfo, TbScale ScaleDeclaration, String Set)
        {
            List <ChemicalWithData> SetList = new List <ChemicalWithData>();

            var setup = new BridgeSetup(false);

            //setup.AddAllJarsClassPath(@"B:\ToolboxAddinExamples\lib");

            setup.AddAllJarsClassPath(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
            Bridge.CreateJVM(setup);
            Bridge.RegisterAssembly(typeof(ChemicalinSet).Assembly);
            java.util.List list = ChemicalinSet.getDataset(Modelinfo["tag"], Set);

            if (list.size() == 0)
            {
                return(SetList);
            }

            for (int i = 0; i < list.size(); i++)
            {
                TbData        Mockdescriptordata = new TbData(new TbUnit(TbScale.EmptyRatioScale.FamilyGroup, TbScale.EmptyRatioScale.BaseUnit), new double?());
                ChemicalinSet cur_Chemical       = (ChemicalinSet)list.get(i);
                TbData        cur_exp            = (TbData)Utilities.ConvertData(cur_Chemical.getExperimental(), ScaleDeclaration, Modelinfo);
                SetList.Add(new ChemicalWithData(cur_Chemical.getCAS(), new[] { "N.A." }, cur_Chemical.getSmiles(),
                                                 new TbDescribedData[] { new TbDescribedData(Mockdescriptordata, null) },
                                                 new TbDescribedData(cur_exp, null)));
            }
            return(SetList);
        }
예제 #13
0
        public virtual int addIntentOptions(int groupId, int itemId, int order, android.content.ComponentName
                                            caller, android.content.Intent[] specifics, android.content.Intent intent, int
                                            flags, android.view.MenuItem[] outSpecificItems)
        {
            android.content.pm.PackageManager pm = mContext.getPackageManager();
            java.util.List <android.content.pm.ResolveInfo> lri = pm.queryIntentActivityOptions
                                                                      (caller, specifics, intent, 0);
            int N = lri != null?lri.size() : 0;

            if ((flags & android.view.MenuClass.FLAG_APPEND_TO_GROUP) == 0)
            {
                removeGroup(groupId);
            }
            {
                for (int i = 0; i < N; i++)
                {
                    android.content.pm.ResolveInfo ri      = lri.get(i);
                    android.content.Intent         rintent = new android.content.Intent(ri.specificIndex < 0 ?
                                                                                        intent : specifics[ri.specificIndex]);
                    rintent.setComponent(new android.content.ComponentName(ri.activityInfo.applicationInfo
                                                                           .packageName, ri.activityInfo.name));
                    android.view.MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon
                                                     (ri.loadIcon(pm)).setIntent(rintent);
                    if (outSpecificItems != null && ri.specificIndex >= 0)
                    {
                        outSpecificItems[ri.specificIndex] = item;
                    }
                }
            }
            return(N);
        }
 public void addAll(java.util.List <T> list)
 {
     for (int i = 0; i < list.size(); i++)
     {
         this.add(list.get(i));
     }
 }
예제 #15
0
        public Dictionary <string, TbData> RetrieveAdi(ITbBasket target, Dictionary <string, string> Modelinfo)
        {
            Dictionary <string, TbData> Adidictionary = new Dictionary <string, TbData>();
            string tag   = this.Modelinfo["tag"];
            var    setup = new BridgeSetup(false);

            //setup.AddAllJarsClassPath(@"B:\ToolboxAddinExamples\lib");

            setup.AddAllJarsClassPath(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
            Bridge.CreateJVM(setup);

            Bridge.RegisterAssembly(typeof(AdiArray).Assembly);
            java.util.List list = AdiArray.getADI(tag, target.Chemical.Smiles);
            if (list.size() == 0)
            {
                return(Adidictionary);
            }

            //create the iterator
            for (int i = 0; i < list.size(); i++)
            {
                AdiArray adicomponent = (AdiArray)list.get(i);
                Adidictionary.Add(adicomponent.AdiName, new TbData(new TbUnit(TbScale.EmptyRatioScale.Name, string.Empty), adicomponent.AdiValue));
            }

            return(Adidictionary);
        }
        private void assertVertexList(IList <int> expectedVertices, java.util.List <BaseVertex> actualVertices)
        {
            Assert.AreEqual(expectedVertices.Count, actualVertices.size());
            int count = expectedVertices.Count;

            for (int i = 0; i < count; i++)
            {
                Assert.AreEqual(expectedVertices[i], actualVertices.get(i).GetId());
            }
        }
예제 #17
0
        public void testParseAndVerifySimpleValues()
        {
            string        adl     = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\dadl-parser\src\test\resources\keyed_objects.dadl");
            DADLParser    parser  = new DADLParser(adl);
            ContentObject content = parser.parse();

            Assert.IsNotNull(content);
            Assert.IsNull(content.getComplexObjectBlock());
            Assert.IsNotNull(content.getAttributeValues());
            Assert.AreEqual(1, content.getAttributeValues().size());
            AttributeValue av = (AttributeValue)content.getAttributeValues().get(0);
            ObjectBlock    ob = av.getValue();

            Assert.IsInstanceOfType(ob, typeof(MultipleAttributeObjectBlock));
            MultipleAttributeObjectBlock maob = (MultipleAttributeObjectBlock)ob;

            java.util.List keyedObjects = maob.getKeyObjects();
            assertKeyedObject((KeyedObject)keyedObjects.get(0), 1, "name", "systolic");
            assertKeyedObject((KeyedObject)keyedObjects.get(1), 2, "name", "diastolic");
        }
예제 #18
0
        /// <summary>
        /// Converts a java.util.List of PVectors to a list of Vector3D
        /// </summary>
        /// <param name="arrayList">the java.util.List to convert</param>
        /// <returns>the list of Vectors</returns>
        public static List <Vector3d> ToVec3DList(java.util.List arrayList)
        {
            List <Vector3d> vecList = new List <Vector3d>();

            for (int i = 0; i < arrayList.size(); i++)
            //foreach (PVector p in arrayList)
            {
                vecList.Add(ToVector3d((PVector)arrayList.get(i)));
            }
            return(vecList);
        }
예제 #19
0
        public string[] listOpenPrescriptions()
        {
            java.util.List list = module.listOpenPrescription();
            List <string>  l    = new List <string>();

            for (int i = 0; i < list.size(); i++)
            {
                l.Add(list.get(i).ToString());
            }
            return(l.ToArray());
        }
예제 #20
0
 public ConsumeConcurrentlyStatus consumeMessage(java.util.List list, ConsumeConcurrentlyContext ccc)
 {
     for (int i = 0; i < list.size(); i++)
     {
         var                msg  = list.get(i) as Message;
         byte[]             body = msg.getBody();
         var                str  = Encoding.UTF8.GetString(body);
         MongodbQueryEntity mongodbQueryEntity = JsonConvert.DeserializeObject <MongodbQueryEntity>(str);
         mongodbHelper.Add(mongodbQueryEntity.tablename + DateTime.Now.ToString("yyyyMM"), mongodbQueryEntity);;
     }
     return(ConsumeConcurrentlyStatus.CONSUME_SUCCESS);
 }
예제 #21
0
        public static IEnumerable <T> AsEnumerable <T>(this java.util.List list)
        {
            if (list == null)
            {
                yield break;
            }

            for (int i = 0; i < list.size(); i++)
            {
                yield return((T)list.get(i));
            }
        }
예제 #22
0
 /// <summary>Obtain a JMX connection from a JPPF client</summary>
 /// <param name="client">The client to get the JMX connection from</param>
 /// <returns>An instance of <code>JMXDriverConnectionWrapper</code></returns>
 public static JMXDriverConnectionWrapper GetJMXConnection(JPPFClient client)
 {
     if (jmx == null)
     {
         // wait for a connection pool to be ready
         JPPFConnectionPool pool = client.awaitWorkingConnectionPool();
         // wait until at least one JMX connection is available from the pool
         java.util.List list = pool.awaitJMXConnections(Operator.AT_LEAST, 1, true);
         // return the first available JMX connection
         jmx = (JMXDriverConnectionWrapper)list.get(0);
     }
     return(jmx);
 }
예제 #23
0
        private void _getMinAndInterval(ucar.nc2.Variable var, string minMaxStr, out double interval, out double minVal, out double count)
        {
            ucar.ma2.Array dataArr    = _util.GetAllVariableData(var);
            bool           stepExists = false;

            interval = 1.0; minVal = double.MaxValue; count = 0;
            java.util.List ncVarAtt = var.getAttributes();
            for (int attCount = 0; attCount < ncVarAtt.size(); attCount++)
            {
                ucar.nc2.Attribute varAtt  = (ucar.nc2.Attribute)ncVarAtt.get(attCount);
                string             attName = varAtt.getName();
                if (attName == "step")
                {
                    java.lang.Number attVal = (java.lang.Number)varAtt.getValue(0);
                    interval   = attVal.doubleValue();
                    stepExists = true;
                }
            }

            double prevVal = 0.0;
            int    minCount = 0, maxCount = (int)dataArr.getSize() - 1; count = 0;

            if (!string.IsNullOrEmpty(minMaxStr))
            {
                minCount = Convert.ToInt32(minMaxStr.Split(':')[0]);
                maxCount = Convert.ToInt32(minMaxStr.Split(':')[1]);
                count    = maxCount - minCount + 1;
            }
            else
            {
                count = maxCount + 1;
            }

            for (int dCount = minCount; dCount <= maxCount; dCount++)
            {
                ucar.ma2.Index dIndex = dataArr.getIndex();
                double         data   = dataArr.getDouble(dIndex.set(dCount));
                if (minVal >= data)
                {
                    minVal = data;
                }
                if (!stepExists)
                {
                    if (dCount > 0)
                    {
                        prevVal  = dataArr.getDouble(dIndex.set(dCount - 1));
                        interval = data - prevVal;
                    }
                }
            }
        }
예제 #24
0
        /// <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);
            }
        }
예제 #25
0
        /**
         * Updates the current iterator field to ensure that the current Iterator
         * is not exhausted
         */
        protected void updateCurrentIterator()
        {
            if (currentIterator == null)
            {
                if (iteratorChain.isEmpty())
                {
                    currentIterator = EmptyIterator.INSTANCE;
                }
                else
                {
                    currentIterator = (java.util.Iterator <Object>)iteratorChain.get(0);
                }
                // set last used iterator here, in case the user calls remove
                // before calling hasNext() or next() (although they shouldn't)
                lastUsedIterator = currentIterator;
            }

            while (currentIterator.hasNext() == false && currentIteratorIndex < iteratorChain.size() - 1)
            {
                currentIteratorIndex++;
                currentIterator = (java.util.Iterator <Object>)iteratorChain.get(currentIteratorIndex);
            }
        }
예제 #26
0
        private static List <MpTask> GetSubTasks(java.util.List tasks)
        {
            List <MpTask> ChildTasks = new List <MpTask>();

            for (int Idx = 0; Idx < tasks.size(); Idx++)
            {
                var Ct = tasks.get(Idx) as MpTask;
                if (Ct.getName() == null)
                {
                    continue;
                }
                ChildTasks.Add(Ct);
            }
            return(ChildTasks);
        }
예제 #27
0
 /// <summary>
 /// 消费功能,消费失败返回ConsumeConcurrentlyStatus.RECONSUME_LATER,成功返回CONSUME_SUCCESS
 /// </summary>
 /// <param name="list">虽然是个list,但是list的size是一个</param>
 /// <param name="ccc">上下文,对一些参数做设置,例如</param>
 /// <returns>结果</returns>
 public ConsumeConcurrentlyStatus consumeMessage(java.util.List list, ConsumeConcurrentlyContext ccc)
 {
     for (int i = 0; i < list.size(); i++)
     {
         var    msg  = list.get(i) as Message;
         byte[] body = msg.getBody();
         var    str  = Encoding.UTF8.GetString(body);
         if (body.Length == 2 && body[0] == 0 && body[1] == 0)
         {
             //System.out.println("Got the end signal");
             continue;
         }
     }
     return(ConsumeConcurrentlyStatus.CONSUME_SUCCESS);
 }
예제 #28
0
        /// <summary>
        /// Save specifical page to file
        /// </summary>
        /// <param name="PageNumbers"></param>
        /// <param name="sourceFilePath"></param>
        /// <param name="outputFilePath"></param>
        public static void ExtractToSingleFile(int[] PageNumbers, string sourceFilePath, string outputFilePath)
        {
            var originalDocument = PDDocument.load(sourceFilePath);
            var originalCatalog  = originalDocument.getDocumentCatalog();

            java.util.List sourceDocumentPages = originalCatalog.getAllPages();
            var            newDocument         = new PDDocument();

            foreach (var pageNumber in PageNumbers)
            {
                // Page numbers are 1-based, but PDPages are contained in a zero-based array:
                int pageIndex = pageNumber - 1;
                newDocument.addPage((PDPage)sourceDocumentPages.get(pageIndex));
            }
            newDocument.save(outputFilePath);
        }
예제 #29
0
        public static List <T> ToList <T>(this java.util.List list)
        {
            if (list == null)
            {
                return(null);
            }

            var newList = new List <T>();

            for (int i = 0; i < list.size(); i++)
            {
                newList.Add((T)list.get(i));
            }

            return(newList);
        }
예제 #30
0
 public ConsumeConcurrentlyStatus consumeMessage(java.util.List list, ConsumeConcurrentlyContext ccc)
 {
     for (int i = 0; i < list.size(); i++)
     {
         var    msg  = list.get(i) as Message;
         byte[] body = msg.getBody();
         var    str  = Encoding.UTF8.GetString(body);
         MongodbUpdateVersion mongodbUpdateVersion = JsonConvert.DeserializeObject <MongodbUpdateVersion>(str);
         if (!string.IsNullOrEmpty(mongodbUpdateVersion.item))
         {
             mongodbUpdateVersion.item = mongodbUpdateVersion.item.Remove(0, 1);
             mongodbUpdateVersion.item = mongodbUpdateVersion.item.Remove(mongodbUpdateVersion.item.Length - 1, 1);
         }
         mongodbHelper.AddForJson(mongodbUpdateVersion.tablename, mongodbUpdateVersion.item);
     }
     return(ConsumeConcurrentlyStatus.CONSUME_SUCCESS);
 }
예제 #31
0
 public void testParseEscapedBackslash()
 {
     list = getConstraints(0);
     assertCString(list.get(1), null, new String[] { "any\\thing" }, null);
 }
예제 #32
0
 public void testParseEscapedDoubleQuote()
 {
     list = getConstraints(0);
     assertCString(list.get(0), null, new String[] { "some\"thing" }, null);
 }