Retrieve a string in a list?

I have a list and need to parse a positional string out of the iteration of each object in the list.

This is my code that contains the data in the list, but it does not attribute to the string with my expected values. How can it be done?
while (iterator.hasNext())
List groupName = (List) request.getSession().getAttribute("groups");
String groupNameString = null;
Iterator iterator = groupName.iterator();
while (iterator.hasNext())
{
    groupNameString = (groupName.iterator().toString());
    int End = groupName.indexOf(',');
    String groupNameExtract = groupNameString.substring(3, End);
}
Published by: user1251941 on January 27, 2011 18:01

You must call iterator.next () in the loop. Currently, you get a new iterator and call ToString on the iterator.

In addition, you must use the code tags to format your code correctly. Put {code} before your code and post your code, not including spaces.

You also probably call indexOf on groupNameString, instead of on groupName.

The variable 'end' should be 'end' to follow the normal coding standards - starting with a lowercase letter variable names.

Tags: Java

Similar Questions

  • String to number list

    I have separate numbers by- and fate as string. I need numbers in select statements as a list of numbers.

    Can someone please help me to get this done?

    Example of a string: "7001-5001-8001.

    I must use this as

    Select * from table1 where id in ( 7001,5001,8001);

    Any help on this will be greatly appreciated.

    Based on Frank's proposal, Oracle has a blog about it

    How to split string separated by commas and pass to the clause of the select statement

    https://blogs.Oracle.com/aramamoo/entry/how_to_split_comma_separated_string_and_pass_to_in_clause_of_select_statement

    Here's my example

    DROP TABLE t1;
    
    CREATE TABLE t1
    (
    ID NUMBER
    );
    
    INSERT INTO t1 VALUES (7001);
    INSERT INTO t1 VALUES (5001);
    INSERT INTO t1 VALUES (8001);
    INSERT INTO t1 VALUES (9001);
    
    COMMIT;
    
    WITH datum AS
         (SELECT REPLACE('7001-5001-8001', '-', ',') AS token
            FROM dual)
    SELECT *
      FROM t1
     WHERE id IN (SELECT TO_NUMBER(REGEXP_SUBSTR(token, '[^,]+', 1, LEVEL)) AS ids
                    FROM datum
                 CONNECT BY REGEXP_SUBSTR(token, '[^,]+', 1, LEVEL) IS NOT NULL);
    

    The output is:

    Elapsed: 00:00:00.02
    
            ID
    ----------
          7001
          5001
          8001
    
  • Only allow the string to the list

    Hello

    I have an ArrayList.
    ArrayList as = new ArrayList();
    Now, I want to let only the string to add in this list of tables how can I achieve this? Don't want to use generic.

    Please guide.

    Ankur Raiyani wrote:
    I was asked to do not use generic.

    In example you saw generics. It is clearly said if you don't want to use generic drugs, and then use the instanceof keyword.

    I want that list allows me only to add the string if I add another object, then it should throw an error.

    Exactly, I give an idea how to use instanceof and allow that string in the arraylist objects.

    If not clear, please go through the below program:

    import java.util.*;
    import java.lang.*;
    class ArrayListForOnlyString
    {
    
         public static void main(String st[])
         {
              List stringArrayList = new ArrayList(){
    
                   public ArrayList ar = new ArrayList();
    
                   public boolean add(Object ob) throws UnsupportedOperationException
                   {
                        if(ob instanceof String)
                        {
                             ar.add(ob);
                             return true;
                        }
                        else
                        throw new UnsupportedOperationException("Only String Object are accepted");
                   }
    
                   public void add(int index, Object ob)
                   {
                        if(ob instanceof String)
                        {
                             ar.add(index,ob);
                        }
                        else
                        throw new UnsupportedOperationException("Only String Object are accepted");
                   }
    
                   public Object[] toArray()
                   {
                        return ar.toArray();
                   }
    
                   public String toString()
                   {
                        return ar.toString();
                   }
    
              };
    
              try
              {
    
              stringArrayList.add(new String("10"));
              stringArrayList.add(1,new String("10"));
                    // Uncomment the below line and run, it 'll give error , as you are trying to add Integer Object to array list.
              //stringArrayList.add(new Integer("10"));
              System.out.println("The objects of arrayList are : "+stringArrayList);
    
             }catch(Exception e)
                   {
                        e.printStackTrace();
                   }
         }
    
    }
    

    Published by: 833545 on August 31, 2011 15:53

  • Retrieves a string not in a particular model of number

    Hi all

    I want to extract a string for example numbers. 100 to 200 or 1 to 10
    Here, a number may start from any number to a number any and there may be decimal numbers also or it can also be like 100-200. I'm stuck on this.

    I had a link too

    Retrieves the number of string value

    but it shows that extraction of a chain of particular model

    Please help me with this.

    Hello

    Sorry, my mistake. Until you have validated the sample data, I didn't test it.
    In the 2nd argument REGEXP_SUBSTR, all the g-d must have a------right in front of them. I left aside the \ before the 2nd.
    Try this:

    SELECT  REGEXP_SUBSTR ( code
                    , '[+-]?((\d+\.?\d*)|(\.d+))'
    --                          ^
    --                                ^
    --                        need \ here
    

    "\d" (with a backslash) means a number, that is identical to ' [[: digit:]] "or"[0-9]".
    has ' (without a backslash) has no particular meaning; It's just the letter small d.

  • Comparison of a string with a list value

    I have a string that needs to compare it with a list of properties.

    For example: I need to check the 2 H chain exists or not, in a property called Testproplist. Testproplist is a property with a list of all possible values. Test proplist values A1, A2, A3, A4, H3, H5, 2 H.

    Can anyone suggest me how to check this?

    Thank you

    Please try to use PropValue (TESTproplist) instead of TESTproplist that in your formula. Should do the trick.

  • The list of functions: how to remove similar values/strings in a list

    Hello

    I'm stuck with the following: I created several lists and they won't stay to show similar values or strings.
    e.g. my list resembles
    93,97,101,104,105,107,110,111,113,93,111
    each of the 93 and 111 values occur twice in this list. What function (or something?) deletes these two values, even if the list looks like
    93,97,101,104,105,107,110,111,113?

    I would like to do as well with a list containing the names. e.g.
    Tom Jones, kathy winter, daryll hana, steven jobs, hillary Hill, joshua fall, hillary Hill
    where hill hillary occurs twice. should look like to my list
    kathy winter, daryll hana, steven jobs, jones Tom, hillary Hill, joshua graves

    Thank you so much for a short solution!

    One trick is to use the fact that Coldfusion will automatically replace the keys in a struct, avoiding duplicates.

  • Need to retrieve the string after the 2nd comma.

    The input string: "CN = Beard\, of Tracy, OU = operations, OR = HPUsers, DC = HealthPartners, DC = org"

    Output string: OU = operations, OR = HPUsers, DC = HealthPartners, DC = org

    Select substr ("CN = Beard\, of Tracy, OU = operations, OR = HPUsers, DC = HealthPartners, DC = org', instr (" CN = Beard\, of Tracy, OU = operations, OR = HPUsers, DC = HealthPartners, DC = org ',','") + 1") twice;

    I tried this. But it is issued by the 1st comma.

    Select substr (str, instr(str,',',1,2) + 1, instr(str,',',1,3) - instr(str,',',1,2) - 1) third_one,.

    substr (STR, InStr(STR,',',1,2) + 1) third_to_end

    from (select "CN = Beard\, of Tracy, OU = operations, OR = HPUsers, DC = HealthPartners, DC = org" str)

    of the double

    )


    THIRD_ONE THIRD_TO_END
    OU = operations OU = operations, OR = HPUsers, DC = org, DC = HealthPartners

    Concerning

    Etbin

  • Retrieve the string after the symbol @.

    Hello

    I need a suggestion how to extract the string after the symbol ' @' in the string.

    The user will pass the Email that I need to extract the domain name of the string

    > > Eg: [email protected]

    She must return to gmail.com under the domain name, please suggest me


    Thank you
    Sudhir

    Try:

    select substr('[email protected]', instr('[email protected]', '@')+1) from dual
    
  • Retrieves the string number

    Hello world.

    Thank you to everyone who helps everyone. I need your help

    1. Select regexp_replace ('Add freon to a 1/2 ',' [^ [: digit:]]') twice;

    I am trying to execute the query and I make the output voltage

    Output

    ----------

    12

    But I need the output voltage

    Output

    -----------

    1/2

    2. Select regexp_replace (' add 5 * freon ',' [^ [: digit:]]') twice;

    Output

    ------------

    5

    second query is good but for the first query, I need "/" to be displayed in the output.

    Like this?

    Select regexp_replace ('Add freon to a 1/2 ',' [^ [: digit:] /]') twice;

  • How to use a list of strings as a parameter of data service

    Hello.

    I need to create a service that receives a list of string as parameter. I read the thread list of values as param - is possible to bring down the query? but I was unable to make it work.

    In the my namespace, I defined an element:

    < xs: element name = "keyList" >
    < xs:simpleType >
    < xs:list itemType = "XS: String" / >
    < / xs:simpleType >
    < / xs: element >

    In my dataservice, I stated the following function:

    declare function tns:list ($keyList as element (bt: keyList)) as {element(bt:employee) *}

    for $key in $keyList
    for $employee in emp:EMPLOYEES()
    where (fn:upper - eq fn:upper-case(fn:string($key))) case($employee/STR_KEY)
    return
    < bt: employee >
    < bt: name > {fn:data($employee/STR_NAME)} < / bt: name >}
    < / bt: employee >
    };

    When I test this situation, the generated SQL code considers that all the keys as the only parameter:
    (...)
    WHERE (UPPER (t1." STR_NAME") =?)
    (...)

    So, if I try a string of a list, it works:
    (...)
    WHERE (UPPER (t1." THE STR_NAME") ="STRING1")
    (...)

    But with two or more strings...
    (...)
    WHERE (UPPER (t1." THE STR_NAME") ="WORD1 WORD2")
    (...)

    What I am doing wrong?

    Also, on the wire, I mentioned, I would like to know how I could make the reference "for $paramString in $paramStrings / AN_ELEMENT ' using my code.

    Best regards and thanks for your time!

    My answer in list of values as param - is possible to bring down the query? has been

    I think you want:

    for $paramString in $paramStrings / AN_ELEMENT

    and you have:

    for $key in $keyList

    $keyList is a single element that contains a complete list, so $key is the only element that contains a complete list. And that is why it does not work for you.

    Yourself and the other poster are doing more complicated things they should be. You can simply use the following (you need not specify a child of $keyList here). The ' * ' after XS: String means minOccurs = 0 maxOccurs = unlimited.

    declare function tns:list($keyList_as_xs:string*)...

    for $key in $keyList
    ...

  • TestStand 2012 Newbee question: How do I pass a string to a VI to TestStand to control the flow of sequence?

    I want to use a drop-down list box (or a similar control) in a VI to select from a list of strings to direct execution in TestStand.

    • How connect the channel selected in the combo box at the output of the VI Terminal so I can see it in TestStand?

    • What should I use as 'value' in the parameter module TestStand to retrieve the result of that VI?

    I tried "wiring" the result of the drop-down list box directly to a terminal of output without success.

    I tried "wiring" the exit from the drop-down list box to a wire string variable then this variable to an output without success Terminal.

    (see attached files)

    Can someone give me an example of a VI that allows you to select from a list of strings: {'Bob', 'Mary', 'Bill', 'Jennifer',...} using a

    (or similar) drop-down list box control and routing of the string selected to the output terminal?

    Also, how to reference this (result) setting within TestStand?

    It is a simple task and there can be only one solution TestStand, I'm looking for a simple direct execution sequence by the operator to select a string in a list.

    I studied this problem, but could not find instances of the digital comparisons or string canned and did not find a generic model that would return a string to a VI to TestStand result.

    Thank you for suffering through this fundamental question.

    David

    Melbourne, Florida

    Marco beat me but here is my interpretation. TS 2010, LV 2011

    Also, look at the example of demo which comes with TestStand: C:\Documents and Settings\All Users\Documents\National Instruments\TestStand 2010 SP1\Examples\Demo\LabVIEW\Computer Test of the motherboard

    Demonstration should be a version of what you want.

    See you soon,.

  • Pass data to list to the page navigation item

    Hey all, been a problem trying to transmit data to a list item selected to a page which I am pushing by a NavigationPane.

    My list contains a lot of elements, each with a property that contains a url. When an item is selected, I need a new display to be pushed with a component WebView that inherit from that url and display the Web page.

    Here's my list qml file:

    import bb.cascades 1.0
    
    TabbedPane {
        showTabsOnActionBar: true
        Tab {
            title: qsTr("List")
            NavigationPane {
                id: navigationPane
                Page {
                    property string selectedItemUrl
                    id: tab1
                    Container {
                        layout: DockLayout {
                        }
                        //topPadding: 70
                        ListView {
                            objectName: "list"
                            listItemComponents: [
                                ListItemComponent {
                                    type: "item"
                                    FeedListItem {
                                    }
                                }
                            ]
                            onTriggered: {
                                var selectedItem = dataModel.data(indexPath); //get data of selected item
                                var page = webView.createObject();
                                page.webUrl = selectedItem.permalink;
                                navigationPane.push(page);
    
                            }
                            attachedObjects: ComponentDefinition {
                                id: webView
                                source: "PostWebView.qml"
                            }
                        }
                        ActivityIndicator {
                            objectName: "indicator"
                            verticalAlignment: VerticalAlignment.Center
                            horizontalAlignment: HorizontalAlignment.Center
                            preferredWidth: 200
                            preferredHeight: 200
                        }
                    }
                }
            }
        }
    

    And here is my file qml for the page with the Web view:

    import bb.cascades 1.0
    
    Page {
        property string webUrl
            ScrollView {
                 scrollViewProperties.pinchToZoomEnabled: true
                 scrollViewProperties.scrollMode: ScrollMode.Both
                 Container {
                     layout: StackLayout {
                 }
                WebView {
                    id: webView
                    url: webUrl
                }
            }
        }
    }
    

    As you can see I have retrieve the data of the list item selected, create the view, assign a string property in the Web view page to the url property of the data item and push the new view.

    What exactly am I doing wrong? Any help would be appreciated, thanks!

    Thanks for the tip about debugging right through it.

    I found and corrected a small error in my code that does the job, but I also noticed something.

    I noticed that the WebView component has been initialized before I had the chance to assign a value to the property in the chain of the WebView qml file. After executing this line.

    "var page = webView. createObject ();"

    It seemed as if the WebView had already been created, and I had not had the opportunity to give my url.

    But this line then runs

    "page.webUrl = selectedItem.data.permalink;

    and it seemed to reset the component WebView so that he could take my value.

    Hard to explain, but works in all cases.

    Thank you!

  • Array of strings JPA

    Hi all.

    Is just a quick question on JPA - possible to retrieve a single column of type varchar2 from a table as a table or a list of strings using JPA?

    As a brief example, I would like to get the following code would ideally be a String [], or a List < String >.
        ...
        EntityManager em = Persistence.createEntityManagerFactory("MyPersistenceUnit").createEntityManager( );
        
        List result;
        try
        {
            String q = "select distinct mt.textColumn from MyTable mt";
            Query query = em.createNativeQuery(q);
            result = query.getResultList();
        }
        ...
    What happens in practice is however a list of vectors, where each vector contains a single string. A most inconvenient result. I suppose another option would be to define an entity class with a member of the chain, but it isn't really better.

    Thank you!

    Mac.

    I believe that this issue has been raised and has been set for the EclipseLink, version 1.1, which will be available in the next version of Oracle TopLink. Here are two test scenarios that illustrate how you will get a single value or an Object [].

    @Test
    public void readStringUsingNativeQuery() throws Exception {
         EntityManager em = getEntityManager();
    
         List results = em.createNativeQuery("SELECT F_NAME FROM EMPLOYEE").getResultList();
    
         for (String name : results) {
              System.out.println("> " + name);
         }
    }
    
    @Test
    public void readStringsUsingNativeQuery() throws Exception {
         EntityManager em = getEntityManager();
    
         List results = em.createNativeQuery("SELECT F_NAME, L_NAME FROM EMPLOYEE").getResultList();
    
         for (Object[] names : results) {
              System.out.println("> " + names[1] + ", " + names[0]);
         }
    }
    

    Doug

  • CNVString - send strings of a PXI chassis by ethernet to an application of labWindows on another computer

    I have a PXI chassis with a PXI-8101 controller. It is equipped with a system of operating in real time. I connect to it on a PC with a Windows operating system. I am trying to send my PXI system variable length string messages to my PC.

    On the PC, I have a LabWindows application that allows you to send and receive data with the PXI system. I'm trying to send the PXI system error messages to the PC on ethernet. I am able to send digital data between them, but not the string messages. The PXI software meets the CNVCreateArrayDataValue() function call and not to her, but never returns. There only have this problem when the CNVDataType parameter is CNVString; When I change the CNVDataType to CNVBool it doesn't have this problem. I'm new on this time real PXI so would appreciate the help. Here is the code on my PXI system that sends these text messages.

    At the beginning of the RTMain, I create the writer

    CNVCreateBufferedWriter ("\\\localhost\\system\\" REG_CAL_ERROR_STRING, 0, 0, 0, 64, 5000, 0, & gErrorPublisher);

    Then I call a function with a string in the list of parameters:

    void SendRT_ErrorMessage (char * message)

    {

    Data CNVData = 0;

    int error;

    error_str char [256];

    int i;

    char out_str [ERROR_STRN_SIZE * 4];

    strcpy (out_str, message);

    size_t arrayDims = ERROR_STRN_SIZE;

    arrayDims = strlen (message) + 1;

    error = CNVCreateArrayDataValue (& data, CNVString, out_str, 1, & arrayDims);

    If (error<>

    {

    strncpy (error_str, CNVGetErrorDescription (error), 256);

    }

    CNVPutDataInBuffer (gErrorPublisher, data, 1000);

    CNVSetArrayDataValue (data, CNVString, out_str, 1, & arrayDims);

    CNVPutDataInBuffer (gErrorPublisher, data, 1000);

    CNVDisposeData (data);

    }

    Change this:

    public static void CVICALLBACK ErrorMessageCallback(void * handle, CNVData data, void * callbackData)
    {
    char message [ERROR_STRN_SIZE];

    CNVGetScalarDataValue (data, CNVString, & message);
    (void) SetCtrlVal (panelHandle, PANEL_TEXTBOX_DEBUG_MSG, "got something\n");
    (void) SetCtrlVal (panelHandle, PANEL_TEXTBOX_DEBUG_MSG, message);
    (void) SetCtrlVal (panelHandle, PANEL_TEXTBOX_DEBUG_MSG, "\n");

    CNVDisposeData (data);

    }

    To do this:

    public static void CVICALLBACK ErrorMessageCallback(void * handle, CNVData data, void * callbackData)
    {
    char * message;

    CNVGetScalarDataValue (data, CNVString, & message);
    (void) SetCtrlVal (panelHandle, PANEL_TEXTBOX_DEBUG_MSG, "got something\n");
    (void) SetCtrlVal (panelHandle, PANEL_TEXTBOX_DEBUG_MSG, message);
    (void) SetCtrlVal (panelHandle, PANEL_TEXTBOX_DEBUG_MSG, "\n");

    CNVDisposeData (data);

    }

    You also need to add CNVFreeMemory to free the memory allocated for the string.

  • Why flatten data chain not getting past all about TestStand via a local variable of the string?

    I tried to go around a series of data in TestStand as a string using "flattened chain" of LabVIEW. When I create a local variable in TestStand of type 'string' and try to write the cluster flattened at this that he simply not transmitted. If I convert the string flat binary table and then pass it around, I can recover all the data very well.

    Is there something I'm missing here?

    I've attached an example Teststand sequence that illustrates this problem. If you run this sequence that the 1st test will fail, which is the attempt to simply pass the flattened string data structure and the 2nd test will pass as it is the binary table that I generated from the flattened string.

    Thank you

    Pete

    crossrulz is correct.  The Null character affects how TestStand handles the string.  You will need to specify the string to a binary string in the list of settings both the VI.  TestStand then encodes the stringso it can prevent the loss of data.

    If you need work on the binary string in TestStand, you will need to convert it to an array of raw data with PropertyObject.GetValBinary.

Maybe you are looking for

  • HP 2000: HP 2000 lost wireless drivers when has been reinstalled windows 7 Home premium 64

    I reinstalled windows 7 Home premium on this unit and lost the ability to connect to wireless internet.  My network adapter it has the yellow exclamation point.  I pulled the device ID material and listed here in the hope that someone can help me to

  • Physical channel NIO-DAQmx on easytabs

    Hello I am a new user of LabWindows CVI 9.0. I have a problem with the easy tabs and loading of channels on each tab. I get the since the acquisition of data on the first easy tab but I am unable to get them on the rest. I load the Panel and then con

  • the libraries are available in windows vista?

    I am new to windows vista. I have been using windows 7. I like the library function, and I was wondering if it is available to windows vista Home premium?

  • RAM for W700 which we buy

    Hi I would like to buy a 8 GB for my W700, I looked on the Crucial http://www.crucial.com/store/mpartspecs.aspx?mtbpoid=608CDC81A5CA7304 site, but I prefer to order on amazon so I enter the same name and found this http://www.Amazon.com/GP/product/B0

  • problem with my emails

    Dear Sir.I have a problem opening my emailsand I can not also for them deletso in these two subjects, what shall I do?Please can I have an answerconcerning