How to keep track of all the classes/methods/properties created in a long script

Hi,
I'm curious to know what method people use to keep track of all the classes, methods, and properties you've created when writing a longer script.
For quick scripts, this isn't a problem. But for long scripts it can get quite difficult to keep track of all the objects one has created, and all their methods and properties, and overloaded constructors, etc.
ESTK is great, and it's the IDE I use for InDesign scripting, if only because of it's powerful debugging options.
But it doesn't provide any way of keeping track of this stuff. No proper Intellisense as in Visual Studio.
I'd be interested to hear how people solve this issue.

Hi Ariel,
Not sure it is relevant to your question but I have an old snippet that collects and displays ExtendScript references using $.list(). This may help to track some object relationships.
// WARNING: this is just a WIP -- Not tested in all platforms and versions
$.scanRefs = function scanRefs(/*0|1*/showAll)
    var s = $.list(),
        p = (!showAll) && s.indexOf('[toplevel]'),
        a = ((!showAll) ? s.substr(0,10+p) : s).split(/[\r\n]+/),
        n = a.length,
        // --- Address:1     L:2  Rf:3   Pp:4  Type:5  Name:6
        re = /^([0-9a-z]{8}) (.) +(\d+) +(\d+) (.{10}) (.{1,17})/,
        reTrim = / +$/,
        i, t, k, m,
        refBy, type, name, tag, rest, rfCount, props, j,
        o = {},
        TYPES = {'Function':"FCT", 'Object':"OBJ", 'Array':"ARR", 'RegExp':"REG"};
    for( i=2, refBy=0 ; i < n ; ++i )
        s=a[i];
        while( s && m=s.match(re) )
            k = '&'+m[1].toUpperCase();
            rfCount = parseInt(m[4],10);
            rest = s.substr(m[0].length);
            type = m[5].replace(reTrim,'');
            name = m[6].replace(reTrim,'');
            if( 0x5B==rest.charCodeAt(0) )
                p = rest.indexOf(']');
                tag = rest.substr(0,1+p);
                rest = rest.substr(1+p);
            else
                tag = '';
            if( 0x20==rest.charCodeAt(0) )
                rest=rest.substr(1);
            if( p=!(rest.indexOf("referenced by:")) )
                rest = rest.substr(14);
            o[k] || (o[k] = {
                locked:        +('L'==m[2]),
                rfCount:    parseInt(m[3],10),
                ppCount:    rfCount,
                type:        TYPES[type]||type,
                name:        name,
                tag:        tag,
                from:        [],
                order:        -1,
            if( 0 < refBy )
                if( p || !rest ){ throw "Unable to parse references." }
                props = rest.split(' ');
                refBy -= (j=props.length);
                while( j-- ) t.from.push([k,props[j]]);
                (props.length=0)||(props=null);
                rest = '';
            else
                refBy = rfCount;
                if( p != !!refBy )
                    if( p ){ throw "Unable to parse references."; }
                    refBy = 0;
                (t = o[k]).order = n - i;
            (m.length=0)||(m=null);
            s = rest;
    a.length=i=0;
    for( k in o )
        if( !o.hasOwnProperty(k) ) continue;
        a[i++] = k;
    a.sort( function(x,y){return o[x].order-o[y].order;} );
    //a.sort( function(x,y){return parseInt(x.substr(1),16)-parseInt(y.substr(1),16);} );
    var u,
        pngLock = "\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\x0E\x00\x00\x00\x0E\b\x06\x00\x00\x00\x1FH-\xD1\x00\x00\x00\tpHYs\x00\x00\x0B\x13\x00\x00\x0B\x13\x01\x00\x9A\x9C\x18\x00\x00\x01VIDAT(\xCF\xA5\x91\xB1j\xC2P\x14\x86\x93\xD6\x94\x98\xA4\xB5\xA5\x85\x0E-R\xAF\xA5\xB8\xF4\x1D\xAA\xEF\x10_B\x9C\xDD\x0B]\xA4o`C\xE9$B\x1C\xCD\x10\x10C6\x05q\td\xA9%\x83d2\x83O\xF0\xF7\xDCp#i\xB5\x1D\xDA\xC0\xC7\xB97\xE7|\xF7\xDC\xCB\x91\x00H\x7FA\xFA\xB7\x98\xFF\xAA\xD5\xEA\x0B\x855\xC1\x13k\xDA\xBF\xEA\x9A\xA6\x9C\x18\xC6\xC1\xB6\xE8\xBBHE\x16\x85w\xC6\xD8\xE3\x91\xA2\xDCQ|\xA2\xFD\x07\xC57\xADXT\x8B\xAAz\xB8#\x8A\x13\xD7\xBC\xD8\xD0\xB4kC\xD7\x19q\xCB*\x95g\xFA\x9FP\xD7\x0B\x8A\n!oE.\xB5Z-\xEC\xA3\xD9l\xA2\xFEP\x07\x1D\xC8;\x18D!/\x16x\x91\xEF\xFBX.\x97\xD8l6H\x92$]O\xA7S\x8CF#\x887\x9F\x13j^T\xB9\xD8\xE9t0\x99L\x10\xC71V\xAB\x15\x82 \xC0\xD0\x1E\xA2\xDDng\xE2\x15q\x9C\x175.:\x8E\x83\xC5b\x81(\x8A \xCB2\xE6\xF39\\\u00D7E\xBF\xDF\xCF\xC4\x1B\xE24/\x1A\\\u00ECv\xBB\xF0<\x0Fa\x18\xA2\xD1h`<\x1E\xC3\xB2,\x98\xA6\x99\x89\x8C8\xDB\x11\x07\x83AzU\xDEu6\x9B\xA5\xA2m\xDB\xE8\xF5z?\x8B4\xC3,\xF9\x1B_E1\x9F\x12Q&j\xC4\xFD\x1Ej\"_\xCA\x8B\x051\xA3K\x91d{(\x8B\xBC\xFE\t\xC1TI!\xE3L\x03\x7F\x00\x00\x00\x00IEND\xAEB`\x82",
        pngNop = "\x89PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x00\x0E\x00\x00\x00\x0E\b\x03\x00\x00\x00(\x96\xDD\xE3\x00\x00\x00\x03PLTE\x00\x00\x00\xA7z=\xDA\x00\x00\x00\x01tRNS\x00@\xE6\xD8f\x00\x00\x00\x15IDATx\xDA\xDD\xC1\x01\x01\x00\x00\x00\x80\x90\xFE\xAF\xF6#\xDA\x01\x00\xD2\x00\x01\xCC \x10\x14\x00\x00\x00\x00IEND\xAEB`\x82",
        w = new Window('dialog', " ExtendScript Memory"),
        p1 = w.add('panel', u, "References"),
        lRefs = p1.add('listbox', u, "",
            numberOfColumns: 4,
            showHeaders: true,
            columnTitles: ["Address", "Type", "Name", "Refs"],
            columnWidths: [90,60,120,36],
        g = w.add('group'),
        pFrom = g.add('panel', u, "From"),
        lFrom = pFrom.add('listbox', u, "",
            numberOfColumns: 4,
            showHeaders: true,
            columnTitles: ["Address", "Type", "Name", "Property"],
            columnWidths: [90,60,120, 120],
        pTo = g.add('panel', u, "To"),
        lTo = pTo.add('listbox', u, "",
            numberOfColumns: 4,
            showHeaders: true,
            columnTitles: ["Property", "Address", "Type", "Name"],
            columnWidths: [120,90,60, 120],
    g.orientation = 'column';
    w.orientation = 'row';
    w.alignChildren = ['left','top'];
    lRefs.maximumSize = lRefs.minimumSize = [330,450];
    lFrom.maximumSize = lFrom.minimumSize = [420,120];
    lTo.maximumSize = lTo.minimumSize = [420,220];
    lRefs.onChange = function()
        lFrom.removeAll();
        lTo.removeAll();
        lFrom.parent.text = "From";
        lTo.parent.text = "To";
        if( !this.selection ) return;
        var key = '&'+this.selection.text,
            t = o[key],
            from = t.from,
            i = from.length,
            k;
        lFrom.parent.text = "["+key.substr(1)+"] is reachable from " + t.ppCount + (1<t.ppCount ? " properties" : " property");
        if( t.ppCount && !i )
            with( lFrom.add('item', '--------') )
                image = pngNop;
                subItems[0].text = '';
                subItems[1].text = '<UNKNOWN REFERRER>';
                subItems[2].text = '';
        while( i-- )
            k = from[i][0];
            t = o[k];
            with( lFrom.add('item', k.substr(1)) )
                image = t.locked ? pngLock : pngNop;
                subItems[0].text = t.type;
                subItems[1].text = t.name + ' ' + t.tag;
                subItems[2].text = from[i][1];
        for( k in o )
            if( !o.hasOwnProperty(k) ) continue;
            t = o[k];
            from = o[k].from;
            i = from.length;
            while( i-- )
                if( from[i][0]!=key ) continue;
                with( lTo.add('item', from[i][1]) )
                    image = pngNop;
                    subItems[0].text = k.substr(1);
                    subItems[1].text = t.type;
                    subItems[2].text = t.name + ' ' + t.tag;
        lTo.parent.text = "["+key.substr(1)+"]'s properties had access to " + lTo.items.length + " addr.";
        from = t = null;
    for( i=0, n=a.length ; i < n ; ++i )
        t = o[k=a[i]];
        with( lRefs.add('item', k.substr(1)) )
            image = t.locked ? pngLock : pngNop;
            subItems[0].text = t.type;
            subItems[1].text = t.name + ' ' + t.tag;
            subItems[2].text = t.ppCount + '/' + t.rfCount;
    w.show ();
// TEST
var t;
var f = function MyFunc()
    (function MyInnerFunc(){})();
$.scanRefs(1);
@+
Marc

Similar Messages

  • How to keep track of all errors occured during package execution

    Hi all,
    I want to keep track of all exceptions raised in my package execution .I am following this approach .
    Please correct me ,if i am wrong .
    DECLARE
       v_empno_is_null      EXCEPTION;
       PRAGMA EXCEPTION_INIT (v_empno_is_null, -01400);
       v_deptno_not_found   EXCEPTION;
       PRAGMA EXCEPTION_INIT (v_deptno_not_found, -02291);
       v_sal_is_zero        EXCEPTION;
       PRAGMA EXCEPTION_INIT (v_sal_is_zero, -02290);
    BEGIN
       INSERT INTO emp
                   (empno, deptno, sal
            VALUES (1245, 60, 0
    EXCEPTION
       WHEN v_empno_is_null
       THEN
          DBMS_OUTPUT.put_line ('Empno should not be null ');
       ---Insert into Error table to keep track of errors
       WHEN v_deptno_not_found
       THEN
          DBMS_OUTPUT.put_line ('This dept does not exist ');
       ---Insert into Error table to keep track of errors
       WHEN v_sal_is_zero
       THEN
          DBMS_OUTPUT.put_line ('Sal should not be less than zero');
       ---Insert into Error table to keep track of errors
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (SQLCODE || SQLERRM);
       ---Insert into Error table to keep track of errors with oracle error message
    END;Thanks,
    P Prakash
    Edited by: prakash on Jul 31, 2011 9:56 PM
    Edited by: prakash on Jul 31, 2011 10:14 PM

    Ugly. Uses all uppercase.
    Do you not know the de facto naming standards in use today?
    Suggest that you familiarise yourself with Guidelines for Names (MSDN) for .Net and Code Conventions for the Java Programming Language for Java.

  • WD MyBook - how to keep it on all the time?

    Hello,
    I have 2 hard drives by WesternDigital (the MyBook series), and when they aren't in use, they turn off after some time. Is there a way to stop that and keep them on all the time?
    My problem is that, when they are turned off (or in sleep mode - who knows, what it is), and I want to use Finder or open a dialog "Add photos" in for example Facebook, I have to wait pretty long until they turn on again.
    Cheers,

    Erase and reformat them. That should remove the WD SmartWare crapola which isn't and let you control the HDs via the EnergySaver prefPane. If erasing and reformatting them doesn't do the trick, see http://wdc.custhelp.com/app/answers/detail/a_id/1376. FYI, I never sleep HDs.
    27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10.2), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2

  • Wi-Fi app that keeps track of all the joined networks?

    I'm trying to look for an app in iTunes that allows me to look at all the joined networks I have been on and also allows me to delete the saved information for the networks I don't want to join any longer. Is there an app for that?

    This function is kind of "build in". Go to Settings/WiFi, choose the network you don't want and hit "forget network"
    Use "Forget this Network" to reset settings for this particular Wi-Fi network, including the password. This is also useful if you identify a network issue and want to prevent the device from automatically using this network in the future.
    copied from http://support.apple.com/kb/TS1398

  • Adding all the classes and external jars in webservice WAR using servicegen

    Hi,
    Can someone please tell me how do I include all the classes and my external jar files to the ear/war file that is created using servicegen. I don't see any option in servicegen tag where I can include my classes and jar files to the ear/war file. The war it creates only contains the web service implementation class but I want to all the classes in the service code and jars in the same war. Any ideas on how to do that instead of putting in the classpath.
    here is the snippet of my build file
    <servicegen
           destEar="${deploy}/myservice.ear"
           warName="myservice.war">
           <service
             javaClassComponents="com.ws.service.TestService"
             targetNamespace="http://xmlns.test.com/tool/myservice"
             serviceName="myservice"
             serviceURI="/myservice"
             style="document"
             protocol="http"
             expandMethods="True">
           </service>
          <classpath>
            <pathelement path="${classes}"/>
            <pathelement path="${lib}/*.jar"/>
         <pathelement path="C:/bea/weblogic92/server/lib/webserviceclient.jar"/>
          </classpath>      
    </servicegen>
    ..........................Thanks

    Hi,
    The work around I am using to overcome this problem is Unzipping th ear/war file created by servicegen task and including all the classes. Then creating the ear file again by creating a new ant target.
    I know this is not a neater way, but this works for me.

  • Collection available to all the classes

    Hello,
    I am just wondering if I can have a collection of an object and that collection is made available to all the classes rather than creating that collection again and again. For example I am deserializing an object from the file in one of the class, how can I make that object available to all the classes, I don’t want to read it again and again. This can be done easily when using java servlet, but my application is standalone, so is there any way of achieving this?
    Any idea will be appreciated.
    Many Thanks,

    JoachimSauer wrote:
    veer2go wrote:
    Yeah Thanks mate, do u think, this approach is better or passing the collection through the parameters is better?That question is opening a huge can of worms.
    Normally I'd say avoid the static version as much as possible. Pass the Set to all objects that need it.
    This could lead to the Set being passed through many levels of calls, 'though. This usually means that your classes are not isolated enough and need to be refactored.
    So both solutions can become quite ugly and writing a clean one takes some experience.+1
    The assumption that all classes need to see this collection is to be challenged. It's usually made in order to avoid working out exactly what needs the object in question

  • How To Keep Track of Component Location Within JTextPane

    I'm inserting JComboBox's into a JTextPane (to allow the user to construct paragraphs), and using the insertComponent(Component) method. After the user selects the JComboBox's, I can't find any way to find the JComboBox's current location. I need to be able to convert the current text plus the selected strings within the JComboBox plus store the last configuration so I can pull it up in the future.
    The JComboBox's can easily be shifted around by additional text added or deleted via the keyboard. I know I can at least use a ComponentListener to find out if the user deleted the JComboBox. The only thing I can think of is to use a KeyListener on the JTextPane to keep track of all the Component locations. This seems a bit tedious as they'd all (could be 10 or more in one JTextPane) need to be updated with each keystroke rather than just getting their location at the end.
    Does anyone have any ideas on a better way to track the location?
    Thanks

    So that's exactly what I did but Position has a problem when the component is located at an index of 0. I created a test program and posted it here: http://forums.sun.com/thread.jspa?threadID=5444569 . If you have any advice camickr (or anyone else), I'd greatly appreciate it. I started capturing all the exceptions to write special cases to track when the component is moved to 0 but there's a ton of possibilities (backspace, cut, delete, etc).

  • Linking Equipments to all the classes and characteristics

    Hello Everyone,
    I need a list of all the equipments for a specific technical object type in a given plant with their classes ,characteristics and values.
    I tried to do it with standard list editing IH08, but it restricts me to max of 20 characteristics.
    Can some one help me with an alternative or a query to pull up all the classification info ( classes, characteristics, and characteristic values)
    Thanks in advance
    Sumit

    Hi,
    The work around I am using to overcome this problem is Unzipping th ear/war file created by servicegen task and including all the classes. Then creating the ear file again by creating a new ant target.
    I know this is not a neater way, but this works for me.

  • How to keep track of the users who are all currently logged in

    Hi All,
    I have basic knowledge of Session and Servlets. I am wondering how to keep track of the users who are all currently logged in. There should be some way of achieving it.
    I thought of it and come up with having an Application variable that hold it when ever a user successfully logged in.
    Thanks in advance for any reply.

    You can do this by keeping data in a static veriable in a some class of yours. The variable will need to be a collection.
    Whenever a user loogs in to the site a servlet/jsp should put the users information in to the collection and when logs off or when the session expires the entry should be take off.
    You can achive this by storing the velues in a some sort of a week collection where the entries are automaticaly removed when all the other refferences to the entry goes out of scope.
    You might need to read bit about java.lang.ref package and WeekReference
    Or you can make the entry in the collection contain the last time that the user visited any of the pages and a thread can run time to time and clean up the older entries which have timed out

  • How to keep track of the changes done in ALV GRID Report

    Hi Experts,
    how to keep track of the changed record in ALV GRID Report. how to set the field to be editable even for the entire row also. Can anybody guide along with code also?...
    Valuable answers will be rewarded.
    Thanks,
    Satish.

    Hi,
    Access the table through SM30. It comes blank as standard. Click "New Entries" and make entries for changes to be tracked. For example, whenever an org. unit changes 002 and 003 relationship, you will make entries like:
    01 O 1001 B002 Activate box checked
    01 O 1001 B003 Activate box checked
    Here, 01 is your active plan version, O is org. unit, 1001 is infotype and B002 and B003 are the subtypes. You can also use * for infotype and subtype which means every change will be logged.
    If you then run the report RHCDOC_DISPLAY through SA38, it will pick up all the changes pertaining to B002 and B003 relationship for org. units (in the above example).
    Similarly, you can set up this table for other object types.
    For more information, follow SPRO>Personnel Management>OM>Basic Settings>Activate change documents and go through the documentation for that node. Also, read up the documentation for the report.
    Hope this helps.
    Donnie

  • How to keep Track of the wagetype Changes

    Hi Experts,
    How to keep Track of the Changes after changing the wagetype values.If any body has made changes to the existing wagetype, how do we keep a track of what changes has done, is there any standard Tcode through  which we can get the information.
    Thanks in advance,
    Regards,
    Magesh.S

    Hi,
    Access the table through SM30. It comes blank as standard. Click "New Entries" and make entries for changes to be tracked. For example, whenever an org. unit changes 002 and 003 relationship, you will make entries like:
    01 O 1001 B002 Activate box checked
    01 O 1001 B003 Activate box checked
    Here, 01 is your active plan version, O is org. unit, 1001 is infotype and B002 and B003 are the subtypes. You can also use * for infotype and subtype which means every change will be logged.
    If you then run the report RHCDOC_DISPLAY through SA38, it will pick up all the changes pertaining to B002 and B003 relationship for org. units (in the above example).
    Similarly, you can set up this table for other object types.
    For more information, follow SPRO>Personnel Management>OM>Basic Settings>Activate change documents and go through the documentation for that node. Also, read up the documentation for the report.
    Hope this helps.
    Donnie

  • How to load all the classes in a JAR file at runtime?

    Any clues o:
    "How can I force JVM to load all the classes in a specified JAR at once?"
    Thanx!
    -Rajeev

    Well I was thinking may be there exists an option with "java", when I
    am starting an application from a jar file, I could force it to load all
    the classes in the JAR. I don't want to do it programically. Is there such
    an option available?? Or in other words can I ask JVM to not do the dynamic
    loading for the JAR??
    Thanx.
    List all JarEntries and convert the paths to fully
    qualified class files
    e.g file in jar
    [1] /com/mycompany/proj/X.class
    should become
    [2] com.mycompany.proj.X
    then for each entry issue
    Class.forName( [2] );

  • How to keep track of the sequence of the BSP Pages being invoked.

    Hi,
    How to keep track of the sequence of the BSP Pages being invoked.
    I have a BSP Page A.htm. There are two other pages B.HTM and C.HTM in the same BSP Application.
    The page B.HTM has a link A.HTM. The page C.HTM also has a link A.HTM. On clicking  these links the Page A.HTM would be invoked. Is there any way to keep track which BSP Page  (i.e B.HTM or C.HTM) invoked the page A.HTM.
    Any input on this Regard would be of great help.
    Thanks and Regards,
    Pavithra

    Hi Pavithra,
    Declare in page attributes:
    appl_url type string
    In the onClick event of the link that calls the A.htm page , use:
    call method runtime->get_url
    receiving
    URL = appl_url.
    Now appl_url contains the url (also name) of the page that invoked A.htm .
    Hope it helps.
    Anubhav.

  • How do I download the previos software iOS 6? I have the iOS 7 and my iPhone 5S gold keeps turning off all the time!

    How do I download the previos software iOS 6? I have the iOS 7 and my iPhone 5S gold keeps turning off all the time!

    Sorry, downgrading isn't supported by Apple.
    what troubleshootings steps have you done to try to resolve your issue?

  • How to keep track of an iterator?

    Hi everyone.
    I'm having an issue trying to keep track of an interator in a tree map.
    Basically my application is an address book, and it has the following button:
    First Prev Next Last
    So if they press the first button it will run the following code:
      Collection c = treeMap.values();
            //obtain iterator for tree map
            Iterator iter = c.iterator();
            //get first item in the list
            Contact temp = (Contact)iter.next();This works fine.
    But now I'm trying to get the Last element in the tree and then assign a "global" iterator to it, infact all the buttons should have an iterator that will keep track of where the current element is...and thats where I'm having problems with.
    So if I get the first element when someone presses the first button, I would like to now assign an iterator to that position, so if someone presses the Next button, I would just do iter.next(); and then display the information .
    The problem is though, I also need to go back 1 element if the user presses the Previous button...is there a way to go forward and backward with an iterator?
    I have an internal iterator keeping track of things but I get an error, like for example:
      Collection c = treeMap.values();
             int count = 0;
            //obtain iterator for tree map
            Iterator iter = c.iterator();
            while(iter.hasNext() && count < treeMap.size()-1)
                count++;
                iter.next();
            trackIter = iter.next();trackIter = iter.next();
    I want trackIter to point to whatever iter.next() is pointing at, which in this case, is the last element in the list but I get an error here saying:
    found : java.lang.Object
    required: java.util.Iterator
    trackIter = iter.next();
    Any ideas?
    Thanks

    First of all your bug.
    Iterators return Objects.
    What kind of object it returns depends on what you were shoving into the Map. If you shoved a Dog into the map, then the iterator returns the Dog, but the Iterator and the Collection only knows that it is an Object, not that it is a Dog. Your code that needed to get a Dog back, needs to cast the result returned by the iterator as a Dog
    trackItem = (Dog) iter.next();
    However, before you haul off and fix your code, twould be best to fix your design. Your question, "is there a way to go forward and backward with an iterator?" is a good question. Before I tell you the answer, let me ask you a question? What are you going to do if the answer is "NO - you can't go forward and backward"
    I mean, it's OK to hack and slash around, trying this and that, but generally it would be good to know the answer to that question BEFORE you write a bunch of code involving iterators, because when you find out that you CAN'T go both forward and backwards with an iterator, what are you gonna do. Are you going to leave part of the design working one way, using iterators for going next and then some totally different mechanism to go the other way? Of course you could do that, but that is not really how one arrives at good design, by first hacking out one feature until you can get it working and then turning you attention to the next and hacking out a different bunch of code.
    Observe that Collections can be converted to Arrays and that Arrays have indicies and moving forward and backward in an array is a simple matter of incrementing or decrementing an integer and testing if you fell of the end. Also arrays, having no particular order restrictions can be sorted, or re-ordered any way that you like. How much easier your problem would be if only you had an array instead of a Collection.
    Don't take the criticism of your design the wrong way. I actually like the idea of using something like an iterator for your buttons, but the thing you are using is not really an iterator. As you said it must go both ways. It is really more like a text cursor where you can advance forward and backwards over a list. So build a Cursor class that you can hand an array. Give it routines like, first(), last(), mid(), stepForward(), stepBack(), getCurrent(), getIndex(), setIndex().
    And then you ask yourself, "before I write this code - let me see if someone has already written it." you look up Cursor in the API. Nope, there is a cursor class, but it is for crossHair cursors and the like. Then you ask yourself, "What else could they have called this?" How about ListIterator. Bingo - there you are, an interface class that has hasNext, hasPrevious, ... But it is only an interface. It doesn't do anything. What kind of class would implement this interface? Maybe List, so you look up List. Drat, it is some disgusting awt component. Oh wait, there's another interface, List, and there on the "All known Implementing Classes" you see LinkedList, ArrayList and others.
    Cool. You can reduce a collection to an array, if you could get an array into one of these list types, you could have your interface all built for you and everything, or if it isn't exactly what you want, no big deal, you already know the interface you need, you can just build it, whatever reduces your effort.
    See how it works? And just for the record, I didn't know about ListIterators, when I started typing this. But I know a design principle that helped me find it. I don't grab a component that I know and see if I can make the system work with the thing that I know. Instead I think of what I want it to do, try to design the interface for what I want it to do and then, once I know what I want from a structural standpoint, I start groveling around to see if that thing already exists.
    You were almost there. When you asked if an Iterator goes both forwards and backwards. And the answer is, "No"
    I see that others have posted before I finished writing this tome. Reversing the array and creating an iterator for that list will not get you the behavior that you are in some state, at some place in the list, from which you can go either forward or backwards. It just gets you a way to go backwards through the list.
    On the assumption that you are a student attempting to learn something, I would suggest that you actually do both approaches. Using the ListIterator approach is what you would do in a production environment (I just need this one behavior and it already exists over here) but you will probably learn more if you implement your own cursor class as I described above. The point is that you have a chunk of functionality, knowing where you are in a list and being able to step either forward or backward, that you want to achieve. The way that you get some chunk of functionality is that you design and build a class that lets you get that functionality. Iterator is NOT that class.

Maybe you are looking for

  • How to create Protein or Chemical structures in .pdb or .mol format for use with iBooks Author. Please help.

    Dear Community,        There are a large variety of software packages used by Chemists and Biologists to view and manipulate Protein and Chemical structures in 3D. They typically have formats such as .pdb, or .mol. I have looked around and none of th

  • Aperture 2.1.4 crashes using Lion 10.7.2

    I am not sure if it is just because I am now using Lion, but my editing software keeps crashing about ever 10 to 30 photos I go through. Its really frustrating especially when Im on a roll and I have to stop and wait for the program to reload. I have

  • What is 's' stands for?

    ..can't figure out what exactly the 's' stands for iPhone 4s..could it be 's=steve'?

  • Safari print style sheet problem

    I've been working on a new site design and for the first time I'm trying to use a different style sheet for printing a page (via the link media="print" tag).  So far I've had success with this technique except when printing with Safari  The printed p

  • Pop up message help for 'POPUP_TO_DISPLAY_VALUE'

    Hi friends, I want to display a pop up message in the screen with my input variables. Which function module can assign for this.... i.e., just wants to display the information,i passed thru var/field.PLs reply. ******If it can be done thru error mess