Iterate through a treemap object

how can 'iterate' through treemap object like you can with an ArrayLIst
like:
Iterator it = arraylist.iterator();

Here is an example:
TreeMap users = (TreeMap)session.getAttribute("users");
Iterator i = users.entrySet().iterator();
while (i.hasNext()) {
Map.Entry e = (Map.Entry)i.next();
if (e != null) {
String key = (String)e.getKey();
if (key != null && key.length() > 0) {
String value = (String)e.getValue();
} // end if key not null
} // end if entry not null
} // end while

Similar Messages

  • Iterate through the child Objects in a components

    I have a custom component named myComp that has three TextInputs. And in the main application there is a button that adds this component dynamically to the VBox named myVBox, I would like to know how to iterate through the added components and show the text inside each of the TextInputs in an Alret box. I am pretty new to flex and I couldn't find any examples for it.
    Thanks,

    Sample code,
    Custom Component
    MyComp1.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">
         <mx:TextInput id="txt1" width="100" />
         <mx:TextInput id="txt2" width="100" />
         <mx:TextInput id="txt3" width="100" />
    </mx:HBox>
    Application
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
         xmlns:mx="http://www.adobe.com/2006/mxml"
         layout="absolute"
         creationComplete="init()">
         <mx:Script>
              <![CDATA[
                   import mx.controls.Alert;
                   import com.MyComp1;
                   private function addComponent(event: MouseEvent): void {
                        var myComp1: MyComp1 = new MyComp1();
                        myVBox.addChild(myComp1);
                   private function getText(event: MouseEvent): void {
                        var alertMsg: String = "";
                        for (var i: int = 0; i < myVBox.getChildren().length; i++) {
                             if (myVBox.getChildAt(i) is MyComp1) {
                                  var myComp: MyComp1 = myVBox.getChildAt(i) as MyComp1;
                                  alertMsg += myComp.txt1.text + "\t" +
                                                 myComp.txt2.text + "\t" +
                                                 myComp.txt3.text + " \n"
                        Alert.show(alertMsg);
              ]]>
         </mx:Script>
         <mx:VBox width="100%" height="100%">
              <mx:Button label="Add Comp" click="addComponent(event)" />
              <mx:Button label="Get Value" click="getText(event)" />
              <mx:VBox id="myVBox" width="100%" height="95%">
              </mx:VBox>
         </mx:VBox>
    </mx:Application>
    Hope this helps you

  • How to iterate through a treemap in alphabetical order

    This is with a servlet. I will have a button for next and previous. When next is pressed, I go to the next record in alphabetical order.
    I know how to use a comparator and set it up. I also know how to use an iterator with 'hasNext' function. The problem is that the servlet(or jsp, etc...) will display this to the web. Then a doPost will get called and I have to go to the 'next' or previous record from the last time the form was called.
    I don't care about concurrency yet(let me get this part down first). How do i 'track' where I was last and then go to the next record. Or is there an easier way that a treemap. I don't care about performance.

    I'm assuming you want to sort on keys, not values, since that's what SortedMaps do.
    Let's say you're using elements of class C as the keys in the map. Either have C implement Comparable, or create a Comparator that compares to C instances.
    Whether you go the Comparable or Comparator route, the body of the compare or compareTo method will be almost the same. You'll just compare whatever fields are relevant on this/obj (Comparable) or obj1/obj2 (Comparator).
    The only other difference is it's more important for Comparable's compareTo to be compatible with equals, which means you have to override equals and hashCode. You don't have to do so for Comparator, but it can make some subtle issues a bit cleaner.
    Then you could do something like the following: for (Iterator iter = <something>.iterator(); iter.hasNext();) {
        <SomeClass>sc = iter.next();
        // process this element
    } where <something> can be keySet() or entrySet(). Maybe even values(). I think values() will give the sorted order for a SortedMap, but not 100% sure.Check the docs. <SomeClass> will either be the class or the keys (for keySet()), Map.Entry (for entrySet()) or the class of the values (for values()).
    You might want to check out this tutorial, if you haven't already.
    http://java.sun.com/docs/books/tutorial/collections/

  • Iterate through AS3 object

    Can anybody help me iterate through an Actionscript object in C
    The equivalant AS3 code would be:
    For (var key:String in someObject) {
    Thanks

    Hi,
    see this: https://blogs.oracle.com/groundside/entry/refresh_problems_using_adaptive_bindings
    Also, please read this:
    SQL injection - Wikipedia, the free encyclopedia
    Because this is what you will have to implement protection for to defend your database from damage.
    Frank

  • Iterate through HashMap ?

    Hello,
    is it possible to iterate through a Java HashMap somehow?
    Or is there any other iterable data structure i could use (I need to get objects from the data structure by using an integer value as key ) ?
    thanks!

    It depends...
    Simple answer: you can use keySet() or values() to get respectively a Set or a Collection, then you iterate on them (using iterator()).
    But you have no guarantee on the order of iteration.
    Now, a data structure using an integer as key is commonly called... an array! Half joking, it works well if these integers are consecutive or of limited range.
    If you need to iterate in increasing key values, use a TreeMap.

  • Iterating through master view objects and child view objects in same page

    I am working on a project using ADF UIX and Business Components.
    I have an application module with two view objects one the master view object and the second the detail object. They are related via a view link.
    I would like to iterate through the master view objects displaying a customer name as bold text and then below each customer name I'd like to display the detail records in a table via the detail view object i.e. a seprate table for each customer.
    Is this possible - I haven't had much luck!?
    Thanks in advance.

    That's because
    $(".ms-vb2 a").
    is bringing back all the pieces that have that class with an anchor on the whole page, not just the ones in the .ms-wpContentDivSpace
    I don't know the exact syntax, but I think you need to iterate through all the '.ms_vb2 a' items as well - there are multiple ones, and do something like this inside your other grouping
    $(".ms-vb2 a").each(function(index) {
        var val=$(this).html();
       var val2=val.replace(/_/g," ")
       $(this).html(val2);
    That's not quite right but maybe that will help.
    Robin

  • Iterate through all the records in a table using Java API

    Hi All,
    What is the easiest way to iterate through all the records in a given table using Java API? I cannot find any methods that will return all records in a table and the only way I can use is to perform a free form search with a condition that is always true. The code works but is pretty ugly. Is there an alternative to this approach?
    Thanks!
    Kenny

    Hi Kenny,
    You can construct a new Search object with your table's code name, a new ResultSetDefinition object for your table and just execute this search using the GetResultSet method of CatalogData.
    Please look at the following code:
    Search search = new Search(<code name of your table>);
    ResultSetDefinition rsd = new ResultSetDefinition(<code name of your table>);
    rsd.AddField<code name of a field>);
    rsd.AddField(<code name of a field>);
    String sortField = <code name of your sort field>;
    boolean sortAscending = true;
    int page = 0; //page number
    A2iResultSet rs = <your CatalogData object>.GetResultSet(search, rsd, sortField, sortAscending, page);
    for (int i = 0; i < rs.GetRecordCount(); i++)
        Value fieldValue = rs.GetValueAt(i, <code name of a field>);
    Hope this helps,
    Nir
    PS - I really recommend you to start using the new API, as it is much more efficient and straight-forward.

  • Iterate Through Lists Instead of Document Libraries, Or both

    System Info: SharePoint 2010 Enterprise w DEC 2013 CU. 2 WFEs (load balanced), App Server, SSRS Server, Dedicated CA Server (All running Win 2k8 R2).
    Background:I have a large (5,000 user) application that is completely customized on top of SP2010. I am the admin, and have been on the team for many years. Previously, we had a development team,
    but client has scaled costs back, and now its just me on the technical side. We have a Web app that houses multiple Site Collections, and each site collection has various subsites.
    My Problem: We have increased the LVT to 10k items (system has plenty of HP, although we do see performance degradation). Each subsite in the Site Collection holds data specific to an organization
    wtihin the Line of Business. There are two lists that frequently approach the 10k mark, and we have mitigation steps in place (essentially, we just create a new SubSite for them once they reach 10k). What I need is a single script that will traverse ALL subsites
    and return a count of their lists, perhaps I can work a couple of if statements in there to have specific data written to a SP List (if count is greater than 5000), and other wise everything gets written to the output file.
    I am trying to iterate through all lists and return a count of folders + items ... The script below works just fine, but it goes through Document Libraries only (per the baseType eq tag).
    I've tried changing baseType from DocumentLibrary to GenericList, but I continually get an error.
    I've also removed the where baseType = DocLib clause completely, and this has the desired results (all lists and doclibs are listed), except the 'WebUrl' field in the csv output is blank.
    Any thoughts on how I can make a small tweak to this script to get my desired results?
    Start-SPAssignment -Global
    $OutputFile ="D:\folder\DocCount3.csv"
    $results = @()
    $webApps = Get-SPWebApplication http://WebAppURL
    foreach($webApp in $webApps)
    foreach($siteColl in $webApp.Sites)
    foreach($web in $siteColl.AllWebs)
    $webUrl = $web.url
    $docLibs = $web.Lists | Where-Object {$_.baseType -eq "DocumentLibrary"}
    $docLibs | Add-Member -MemberType ScriptProperty -Name WebUrl -Value {$webUrl}
    $results += ($docLibs | Select-Object -Property WebUrl, Title, ItemCount)
    $results | Export-Csv -Path $OutputFile -NoTypeInformation
    Stop-SPAssignment –Global

    You guys won't believe this ... But, the script actually works as intended if I change the baseType tag to "GenericList"... I had been getting errors (about 14 of them) through PowerShell and
    assuming the script didn't process, but after looking at the output CSV, it seems that everything worked properly. I think the 14 errors MAY have been corrupted sites (or something?) as it gives me NullValueNotAllowed when trying to "Add-Member" and points
    to $WebUrl as being null.
    Next up -- working on getting this script to write specific objects to a SP list!

  • Iterate through all documents

    Hi,
    We have a container which contains *1 million* documents, each of which has size 5K. Container type is wholedocument. We need to iterate through all document regualrly using container.getAllDocuments(containerTxn, DBXML_LAZY_DOCS | DBXML_NO_INDEX_NODES). For each document, we will perform a xpath query in xml document in memory.
    The problem here is about whether we should use transaction. If transaction is used, getAllDocuments will report "Lock table is out of available lock entries" error when it scan about 9383 ducuments. Here are lock setting:
    envp->set_lk_max_lockers(6000);
    envp->set_lk_max_locks(6000);
    envp->set_lk_max_objects(8000);
    We have 1 million documents, it is impossible to set lock object to 1 million.
    My questions:
    (1) Is this normal? If so, why performing a dbxml query on the container doesn't cause such an error. I believe dbxml query has to iterate all of documents too.
    (2) Is it possible to use a seek position for getAllDocuments? Thus we can commit transaction every iterating 1000 documents, and then continue the iteration from the last seek position.
    (3) if we don't use transaction to call getAllDocuments, what possible problems will happen? Other threads are using transaction to read/update the documents.
    Thanks.
    -Yuan

    Yuan,
    The quickest thing to try is to add the flag DB_READ_COMMITTED to getAllDocuments(). That may reduce the number of locks you need. While you may not be able to set the various lock parameters to 1 million, you should set them much larger than you have now (e.g. 50k - 100k) for this sort of operation.
    Not using transactions at all can lead to inconsistent data mostly related to index consistency with document content. Depending on the nature of your updates it may be safe. You could get stray exceptions but nothing should crash. E.g. if you are only adding/removing documents you are probably safe without transactions; although you might iterate to a document that's been removed so you'll see an exception which would have to be ignored. I'm not 100% certain this will work well but if you can test it in a high-update environment and see no issues that will tell you. The read side will not interfere with the updates.
    As for "seeking" if you look under the covers getAllDocuments() is really just a wrapper for an index lookup on the name index. The XmlIndexLookup API is quite flexible in terms of returning ranges. If you want to look into returning ranges of documents, do this:
    1. look at the code in XmlContainer.cpp in the function "getDocs()". It uses XmlIndexLookup to perform the operation.
    2. look at the XmlIndexLookup API to figure out how to turn the lookup into a range lookup vs looking up ALL items in the index
    Using XmlIndexLookup and tracking the name of your last-used document you can easily ask for all documents "higher" than that one. Further, if you know how your documents are named lexicographically you can give it a maximum as well if you wanted, but given that you can set your XmlQueryContext to be lazy you can simply iterate N times to get the next N documents without paying a penalty retrieving any documents you don't need.
    For the sort of thing you are doing I highly recommend using XmlIndexLookup directly (with or without transactions) to get the flexibility you need. XmlContainer::getAllDocuments() is merely a "convenience" layer on that class.
    Regards,
    George

  • Iterate through RichTable with custom cells

    Hi.
    I create a RichTable by drag and drop a view in DataControls. View is from table xxx and table contains only one column, binding description field in the table.
    This description is shown in an OutputText UI component.
    Then, I add a column with a SelectOneRadio component (to check Yes/No).
    Finally, I add another column with an Input Text to write comments.
    So, when I click one button, I capture the action event and want to process table content. But, how can I iterate through this table?
    How can I get each row, and each cell in its row (each radio, each text)?
    My JDeveloper version is 11.1.1.7.0
    Thanks in advance. Best regards
    EDIT: _________Final solution_________
    Add two transient attributes and iterate the VO object is very easy.
    For the specific issue about radio button, add a switcher and bind the radio group with the transient attribute.

    Hi,
    You could do something like
                   <af:switcher id="s1" defaultFacet="input" facetName="#{row.type eq 0?'radio':'input'"}>
                    <f:facet name="input">
                        <af:inputText id="it2" value="#{row.answer.inputValue"}/>
                    </f:facet>
                    <f:facet name="radio">
                        <af:selectBooleanRadio id="sbr1" value="#[row.answer.inputValue"}/>
                    </f:facet>
                    </af:switcher>
    -Arun

  • Iterate through selected characters

    Hi guys and girls!
    Has anybody a code snippet to show me how to iterate through the selected text (not the frame!, not the words, only the selected chars) and make any change on the characterAttributes (size, color, etc.)?
    Deeper into it:
    In the property "app.activeDocument.selection" usually the selected objects are stored as an array. Now when I select characters in a textframe (or TextPath, whatever) there is a [Textrange] in it.
    I already tried some combinations like this snippet underneath but I still get errors, that selectedChars[i] is undefined.
    FYI: I'm on Illustrator CS4, Mac OS X, Javascript
    var selectedChars = app.activeDocument.selection.characters;
    for (i = 0; i < selectedChars.length; i++ ){                           
         selectedChars[i].characterAttributes.fillColor = myNewCMYKColor;
    I hope I have gathered all relevant information. If not, please do not kill me and just ask back
    So has anybody a smart hint for me?
    Thanks a lot in advance!

    Here's a Change Size script that I found in my collection that somebody posted severat years ago. I'm sorry I don't remember who it was to give proper credit.
    #target illustrator
    // change size of paragraph text
    //$.bp();
    ChangeSize();
    function ChangeSize()
        selectedItems = selection;
        // check to make sure something is selected.
        if (selectedItems.length == 0)
            alert("Nothing is selected");
            return;
        endIndex = selectedItems.length;
        for (index = 0; index < endIndex; index++)
            pageObject = selectedItems[index];
            pageItemType = pageObject.typename;
            if (pageItemType == "TextFrame")
                // get the paragraphs from the selection.
                theTextRange = pageObject.textRange;
                paraTextRange = theTextRange.paragraphs;           
                numParagraphs = paraTextRange.length;
                for (i = 0 ; i < numParagraphs ; i++)
                    aParagraph = paraTextRange[i];
                    charTextRange = aParagraph.characters;
                    charCount = charTextRange.length;
                    if (charCount > 1)
                        end = charCount;
                        fontSizeChanger = 14/end;
                        currentFontSize = 18;
                        for (j = 0 ; j < end; j++)
                            theChar = charTextRange[j];
                            theChar.size = currentFontSize;  
                            currentFontSize = currentFontSize - fontSizeChanger;
    and here's the output.
    You should be able to go from there.

  • Iterate through all dynamic text variables

    Hello,
    I'd like to be able to iterate through all of the dynamic
    text variables in my flash movie, and I'd like it so that if I add
    new text to this movie, it will show up in the iteration.
    Essentially, I want to do something like this:
    for (i in _root) {
    trace(i);
    While this seems to print out all the variables in root, it
    prints more than just the dynamic text variables, and also doesn't
    iterate down through various objects to find the dynamic text
    variable.
    Is there any way I can accomplish this in action script?
    Thanks!

    Great! That code helps me a lot.
    There are still two weird issues.
    1) the test for tl[obj].text seems to always turn out to be
    false. However, if I trace the value of text, I'll see the text.
    Example:
    trace(tl[obj].text); // This will display the value in the
    text field
    if (tl[obj].text) // This is always returning false.
    Any ideas?
    The 2nd issue might be more difficult - some of my text
    objects don't appear until later in the movie (i.e. frame 10). It
    sort of looks like this looping doesn't see objects that appear in
    the future. Do I need to advance the frame 1 by 1 and repeat this
    looping process until the text appears? Maybe instead I can always
    have the text in the first frame, but have it be invisible or
    something?

  • Iterating through fields in object

    Is there a way for me to iterate through the fields in an object?
    I have a helper class that basically contains several variables with assigned values.
    How can I iterate through the variables in this class?
    I basically want to check the contents and re-assign a value as I loop through.
    Thanks

    Here is what I am really trying to accomplish.
    I have a jsp that is get back values from the database.
    Before I attempt an update, I retrieve the record from the database.
    The fields that are showing up blank in Oracle. Nulls are allowed.
    When the record is retrieved, my jsp shows null in the text box after I do a setAttribute.
    The problem is that the "null" is text. So now when I actually update to the database,
    I end up with a text string that says "null" instead of actually having a null value in the database for that field.
    So I need some sort of null check before I populate my jsp, so that I can just have a blank field and I think that would solve my problem.
    Thanks

  • Iterate through list

    i have a list and i want to iterate through the list and get the names of the classes present in that..
    i have the following code
    Iterator it= list.iterator();
    String value;
    while(it.hasNext())
         Object obj= it.next();
         Class cls= obj.getClass();
         value = cls.getName();
    now if i want to check whether a class called test is present in that list how to do that...pls help

    mgv wrote:
    i have a list and i want to iterate through the list and get the names of the classes present in that..
    i have the following code
    Iterator it= list.iterator();
    String value;
    while(it.hasNext())
         Object obj= it.next();
         Class cls= obj.getClass();
         value = cls.getName();
    now if i want to check whether a class called test is present in that list how to do that...pls help
    while(it.hasNext()){
    Object obj = it.next();
    if(obj instanceof test){
        //do something
    }

  • Iterate through CR on BOE

    I am a .NET developer given the task to extract all table values from all reports on our BOE server - could you please point me in the right direction as to which portion of your BOE API will allow me to:
    1. Iterate through all reports on a BOE server
    2. Iterate through all table values in a CR Report
    If you have any other suggestions or samples on the best way to do this please let me know.
    Thank you!

    Thank you for the references.  I can see now how to iterate through the infoobjects:
    InfoStore infoStore = (InfoStore) enterpriseSession.GetService("InfoStore");
    string queryString = "SELECT SI_NAME, SI_DESCRIPTION "
         + "FROM          CI_INFOOBJECTS "
         + "WHERE      SI_KIND = 'CrystalReport'";
    InfoObjects infoObjects = infoStore.Query( queryString );
    IEnumerator infoObjectsEnumer = infoObjects.GetEnumerator();
    while(infoObjectsEnumer.MoveNext())
        InfoObject crReport = (InfoObject) infoObjectsEnumer.Current;
        // iterate through object and extract values
       Report report = (Report)crReport;
    Can you please tell me what object I will need to cast the info object to in order to access it's table fields?

Maybe you are looking for

  • Function Module for GL open Itmes

    Could any body from forum tell me that "there is any Function Module for General Ledge open Items". Rgds, Raju

  • Journal Entry Preview before adding any transactions

    Hi experts Is there any way to see the preview of Journal Entry before adding any transactions. for ex ' AR Invoice '. Just like Simulate functionality in R/3 . Thanks Ashish Ranjan

  • Active Content - Flash - fix for Contribute Users

    Greetings, I have a group of users that use Contribute. Many of these users create Flash Paper forms and embed them in a standard template. These individuals do not work with HTML or JavaScript. Recently a security patch for IE has been applied to th

  • Syncing iPhone (how to not loose data?)

    I have just reinitialized my disk I was using to sync to my iphone, and completely reinstalled a fresh system. Now I'm trying to get my iphone data off my phone (like contacts) and onto my computer, how do I do this without loosing them? Can I sync m

  • Synchro does not work between Ipad, Iphone and Mac

    Good evening, I have an IMAC, iPhone 5s and an Ipad all with the last IOS version and synchro does not work at all. My iCloud address is not with iCloud but with hotmail. I dod not get any suitable answer from the retailers in Budapest. Does anybody