Return-Path: X-Original-To: apmail-uima-user-archive@www.apache.org Delivered-To: apmail-uima-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A28872B0 for ; Wed, 28 Sep 2011 14:52:33 +0000 (UTC) Received: (qmail 84060 invoked by uid 500); 28 Sep 2011 14:52:33 -0000 Delivered-To: apmail-uima-user-archive@uima.apache.org Received: (qmail 84032 invoked by uid 500); 28 Sep 2011 14:52:33 -0000 Mailing-List: contact user-help@uima.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@uima.apache.org Delivered-To: mailing list user@uima.apache.org Received: (qmail 84024 invoked by uid 99); 28 Sep 2011 14:52:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Sep 2011 14:52:33 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msa@schor.com designates 69.93.179.27 as permitted sender) Received: from [69.93.179.27] (HELO gateway09.websitewelcome.com) (69.93.179.27) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 28 Sep 2011 14:52:24 +0000 Received: (qmail 14009 invoked from network); 28 Sep 2011 14:48:42 -0000 Received: from gator74.hostgator.com (184.173.199.208) by gateway09.websitewelcome.com with SMTP; 28 Sep 2011 14:48:42 -0000 Received: from [129.34.20.19] (port=20913 helo=[9.2.34.128]) by gator74.hostgator.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1R8vUP-0001gF-Sn for user@uima.apache.org; Wed, 28 Sep 2011 09:52:02 -0500 Message-ID: <4E833492.7020802@schor.com> Date: Wed, 28 Sep 2011 10:52:02 -0400 From: Marshall Schor User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: user@uima.apache.org Subject: Re: Java code to add Element to FSList References: <20110928093416.26693.qmail@pro236-138.mxout.rediffmailpro.com> In-Reply-To: X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator74.hostgator.com X-AntiAbuse: Original Domain - uima.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - schor.com X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: yktgi01e0-s5.watson.ibm.com ([9.2.34.128]) [129.34.20.19]:20913 X-Source-Auth: msa+schor.com X-Email-Count: 2 X-Source-Cap: bWlzY2hvcjttaXNjaG9yO2dhdG9yNzQuaG9zdGdhdG9yLmNvbQ== Suggestions welcome for a better / more convenient APIs for lists :-). In general, the advice for lists in the CAS is to recognize that they're not necessarily "efficient" compared to Arrays, unless, of course you are dynamically inserting / removing things. And, as always, only put things into the CAS which you are wanting to share with other components. Within one component, you can use native data structures (e.g., Java lists) as opposed to CAS data. -Marshall On 9/28/2011 6:34 AM, Richard Eckart de Castilho wrote: > Hello, > > the UIMA lists are linked lists and - to my knowledge - offer no convenient API. As an illustration of how to use them, consider the following method which takes a Collection of strings and turns it into an UIMA StringList. This method is part of the uimaFIT FSCollectionFactory class. > > http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT/src/main/java/org/uimafit/util/FSCollectionFactory.java > > public static StringList createStringList(JCas aJCas, Collection aCollection) > { > if (aCollection.size() == 0) { > return new EmptyStringList(aJCas); > } > > NonEmptyStringList head = new NonEmptyStringList(aJCas); > NonEmptyStringList list = head; > Iterator i = aCollection.iterator(); > while (i.hasNext()) { > head.setHead(i.next()); > if (i.hasNext()) { > head.setTail(new NonEmptyStringList(aJCas)); > head = (NonEmptyStringList) head.getTail(); > } > else { > head.setTail(new EmptyStringList(aJCas)); > } > } > > return list; > } > > Cheers, > > -- Richard > > Am 28.09.2011 um 11:34 schrieb abhishek: > >> Hi, >> I have created one Feature in Types. The feature rangeType is FSList and  element Type is another Annotator class(ParagraphAnnotation which extends org.apache.uima.jcas.tcas.Annotation ). >>   >> Now, I am not able to find out a way to set the value of this feature. >>   >> Example: >>   >> List<MyClass>sample= new Arraylist<MyClass>(); >> MyClass c = new MyClass(); >> sample.add(c); >>   >>   >>   >> Is there a way to replicate similar situation mentioned above in UIMA FSList code. >>   >>   >> Kindly help