Specifying which Objects to pull out of a Vector

I'm pulling certain objects out of a vector to play with them. My problem is that I only want certain ones. Inside the vector "neighborList when I getMooreNeighbors are objects other than Soldiers (there are Democrats, Monarchs, etc, etc). I only want to fiddle with the Soldiers. I'm getting an NPE when I get to the "get" method because I'm casting the objects as Soldiers when it's possible some aren't. What do I do? How do I only get the Soldiers out of the Vector?
{code}
     public void getMyNeighbor () {
          neighborList = new Vector();
          soldierNeighbors = new Vector();
          neighborList = world.getMooreNeighbors(x, y, false);
          for (int i = 0; i < neighborList.size(); i++){
               Soldier otherSoldier = (Soldier) neighborList.get (i);//NPE here
               otherSoldier.getMyColor();
               otherSoldier.getStrength();
          if (otherSoldier.getMyColor()!=this.getMyColor()){
               fight();
{code}

So I think I tracked down that NPE, but another one seems to have cropped up. Is there a better way to write this? I'm asking my soldier to compare his color with the other guy and fight him if they don't match.
     public void getMyNeighbor () {
          neighborList = new Vector();
          soldierNeighbors = new Vector();
          neighborList = world.getMooreNeighbors(x, y, false);
          for (int i = 0; i < neighborList.size(); i++){
               Object o = neighborList.get (i);
               if (o instanceof Soldier) {
                    Soldier otherSoldier = (Soldier)o;
                    otherSoldier.getMyColor();
                    otherSoldier.getStrength();
          if (otherSoldier.getMyColor()!=this.getMyColor()){//NPE here
               fight();
          }

Similar Messages

  • Detect which object is clicked out of several objects.

    I want to make a game where it randomly generates a map, and players can click objects of the map. I want something to happen to that object, and I want the game to detect which object has been clicked, and temporarily assign that object a name so that I can do things to that object, I want the name to overwrite when I click a new object, and want to be able to retreive what I have done to the other objects. Any help would be appreciated.

    Thanks, you pointed me in the right direction, here was my result:
    public var target
            public function DirtBlock() { //dirt block spawned
                trace("SPAWNED")
                this.addEventListener(MouseEvent.CLICK,fl_click)
             function fl_click(event:MouseEvent):void { //dirt block clicked
                var dirtblock:DirtBlock = new DirtBlock();
                trace("CLICKED")
                trace(event.currentTarget) //traces which object was clicked(Object, dirtblock)
                target = event.currentTarget// sets the object to "target" so it can be manipulated
                target.visible = false

  • Query to pull out Tables from Workbooks/Folders

    Hi,
    Do anybody have a query which helps to pull out tables which are used in the Workbook or folders, without opening the workbook or a folder ? Your earliest help is Appreciated.
    Thanks,
    Ashok

    Hi Farheen......
    Please try this........
    SELECT T0.HousBnkAct, T1.CardName, T0.PymCode, T0.DflAccount,
    T0.DflBranch, T0.BankCtlKey, T1.DocNum,T1.NumAtCard, T2.LineTotal, T2.Dscription,
    T3.Branch, T3.Street FROM OCRD T0 LEFT JOIN OPCH T1 ON T0.CardCode = T1.CardCode
    LEFT JOIN PCH1 T2 ON T1.DocEntry = T2.DocEntry LEFT JOIN DSC1 T3 ON
    T0.HousActKey = T3.AbsEntry WHERE T1.DocDate >='[%0]' AND T1.DocDate <='[%1]' AND T1.DocStatus = 'o' AND T0.PymCode = 'EFT'
    Regards,
    Rahul

  • Full page pull out tray, pull only object workaround

    Hi,
    Is there any way yet, when creating a pull out tray/slider using the scrollable frame, to only have a object within the container pull the content, rather then being able to pull from anywhere within the container?
    Basically what I am trying to do is have a pull out that when pulled out, covers the entire page, therefore the container needs to cover the entire page which disables the ability to navigate horizontally between articles, I can still navigate vertically, but not horizontally..
    Does anyone know of a workaround that would enable me to have a full page pull out (container) and still be able to navigate horizontally. i.e. having only an object (the pull tab) pull the content rather then anywhere within the container.
    Thanks for you help
    Quinn

    Thanks everyone for your help, however I am yet to solve this problem...
    On top of the horizontally scrolling content I have created a MSO consisting of two invisible rectangle frames. Tried to see if it would work as just a MSO, nothing, turned those into a one time Auto Play Slideshow, still nothing. No matter where I pull, the content still scrolls yet I can not navigate horizontally to the next article. (Made sure I left space for the tab area, yet I can still pull from anywhere). Any other solutions/workarounds to this problem? Or if this has worked for others, possibly tell me if I am doing something incorrectly?
    Thanks again for your help.
    Quinn
    PS. I am using V20 on ID 5.5

  • How to find out which objects are at the end of the datafiles

    My Scenario is having a tablespace of 65G but the data is 5G and that is at the end of datafile for that we are not able to resize the datafile our though is to find out what are the objects at that end of datafiles and will either alter move <owner.tablename> move or alter index <owner.index> rebuld online.
    For that how to find out which objects are at the end of the datafiles.

    >
    My Scenario is having a tablespace of 65G but the data is 5G and that is at the end of datafile for that we are not able to resize the datafile our though is to find out what are the objects at that end of datafiles and will either alter move <owner.tablename> move or alter index <owner.index> rebuld online.
    For that how to find out which objects are at the end of the datafiles.
    >
    You may want to copy this and add it to your toolkit
    See 'What's at the End of the File?' in this Tom Kyte article from the Sept 2004 Oracle Magazine
    http://www.oracle.com/technetwork/issue-archive/o54asktom-086284.html
    And this AskTom blog shows you how to generate a script containing ALTER statements toresize your datafiles to the smallest possible. You can 'pick and choose' from the ALTER statements to do what you want.
    Then of course, you can use techniques from this article by Oracle ACE, and noted author, Jonathan Lewis
    http://jonathanlewis.wordpress.com/2010/02/06/shrink-tablespace/

  • Pulling Objects out of a Vector

    Hi, all:
    I am trying to pull Objects out of this vector, and the given method only wants to let me get integers. How do I go about getting Objects out of a vector like this one? The problem comes in with the last line, where the "get" method complains that it wants an integer. The API says the same; I just can't find a method that lets me pull an Object out of a vector instead of an integer. Any ideas?
              neighborList = new Vector();
              soldierNeighbors = new Vector();
              neighborList = world.getMooreNeighbors(x, y, false);
              for (int i = 0; i < neighborList.size(); i++){
              Soldier soldier = neighborList.get (soldier);

    Soldier soldier = neighborList.get (soldier);You'll want to use "i" as your index, not "soldier", since you presumably want to get the soldier reference at element 'i'. Note that since you're not using generics, the get() method returns an Object reference. You'll need to cast it to Soldier. Example:
    Soldier soldier = (Soldier) neighborList.get(i);Read more here: http://java.sun.com/docs/books/tutorial/collections/
    ~

  • How to find out which object has a specific attribute value

    Hi all,
    which is the easiest way to check in a collection of objects which object has an attribute with a specific value?
    i.e. I have n objects of classA and they all have an attribute "String value;".
    How can I check which object has that attribute set to "myvalue"?
    Thanks,
    A.

    hi,
    i don't know if this would be the best way to do it, but i would add all the instances of the objects to a hashtable with the key as the attribute with which you want to search them. You would then retrieve the object using the value.
    Cath

  • Pull out a report of all cop orders

    Hello,
    I need to pull out a report of all COP orders for one month which have to include cop1 and cop2 delivery numbers.
    Any help would be appreciated.
    Thank you!

    Hello Allison
    Try using standard sales reports like VA05 (Sales Orders), VA45 (Sales Contracts), they should reasonably cover your requirements because they have quantities and net value figures.
    Also if your system is enabled with Sales Infosystem (SIS) functionality, you many run standard analysis reports like MCTE  (for a Sales Org) to get summary figures and get into lists from there.
    The perceived weak point of SAP is reporting and many companies use Business Objects, formerly Business warehouse, for specific reports and analytics.
    Hope this helps.

  • Scroll the document window to a specified graphic object

    Hi,
    anyone knows  a way to scroll the document window to a specified graphic object?
    I've tried with F_ApiScrollToText() function, but it works only with object containing text, and a graphic object ( like a line) doesn't contain text...
    Thanks in advance.

    Hi Stemen82,
    I have dealt with this in the past and found it to be a bit complex. I've pasted below the functions I came up with to do it. Note that:
    - I'm not sure that it works in all cases. Because there is no direct FDK function to do this, you really have to monkey around with things to get it done.
    - The code I've pasted should handle both anchored frames and graphic objects, including "floating" graphics. Anchored frames are actually a bit more straightforward because you can get the text location of the anchor.
    - All the comments in the code are "notes to self." That is, I didn't write them for you   However, they should be of some use to you.
    - There may be plenty of other, better ways to do this... this is just what I slapped together to get the basic functionality to work.
    Russ
    //THIS IS REALLY ONLY GOOD FOR ONE LEVEL OF NESTING,
    // ie, one graphic in one anchored frame, in a text frame.
    // No testing or implementation for anything else at this point.
    //If you don't know whether the object is a graphic or an anchored
    //frame, you can send it as the graphic ID and the function will
    //figure it out.
    // So, either send a graphic ID as graphicId,
    // a frame ID as graphicId, or both graphic and frame IDs.
    // Don't sent just a frame ID as frameID.
    VoidT ws_SelectAndScrollToGraphic(F_ObjHandleT docId,
                                      F_ObjHandleT graphicId,
                                      F_ObjHandleT frameId)
      F_ObjHandleT aFrameId = 0,
        textFrameId,
        graphicPageId,
        currentPageId,
        tempGraphicId;
      IntT objectType,
        alreadySelected = False;
      F_TextRangeT tr;
      if(!docId || (!graphicId && !frameId)) return;
      //let's get the page. We might need it for scrolling and
      //maybe to switch to the correct page type
      graphicPageId = ws_GetPageForGraphic(docId, graphicId);
      //So far, two possibilities here, either an anchored frame somewhere in the object hierarchy or not.
      //If there is no anchored frame, we have to guess based on pages and paragraps.  If there is one,
      //we can jump to the anchor.
      //let's start by looking for an anchored frame if one was not sent
      if(graphicId && !frameId)
        objectType = F_ApiGetObjectType(docId, graphicId);
        //if we actually got an anchored frame, we will store the ID.
        if(objectType == FO_AFrame)
          aFrameId = graphicId;
        //otherwise, let's look above to see if there is an anchored frame
        else
          aFrameId = F_ApiGetId(docId, graphicId, FP_FrameParent);
          objectType = F_ApiGetObjectType(docId, aFrameId);
          if(objectType != FO_AFrame)
            aFrameId = 0;
      //at this point, if we have an anchored frame, scroll to it
      if(aFrameId)
        //let's switch to the appropriate page type, only if necessary
        //we'll do that by simply switching to the first page of that
        //type in the doc before the scroll action
        currentPageId = F_ApiGetId(FV_SessionId, docId, FP_CurrentPage);
        if(F_ApiGetObjectType(docId, graphicPageId) != F_ApiGetObjectType(docId, currentPageId))
          if(F_ApiGetObjectType(docId, graphicPageId) == FO_MasterPage)
            currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstMasterPageInDoc);
          else if(F_ApiGetObjectType(docId, graphicPageId) == FO_RefPage)
            currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstRefPageInDoc);
          else
            currentPageId = F_ApiGetId(FV_SessionId, docId, FP_FirstBodyPageInDoc);
          F_ApiSetId(FV_SessionId, docId, FP_CurrentPage, currentPageId);
        tr.beg = tr.end = F_ApiGetTextLoc(docId, aFrameId, FP_TextLoc);
        F_ApiScrollToText(docId, &tr);
      //if no anchored frame (ie, just a floating graphic),
      //let's finangle with some paragraphs and pages and try our
      //best. There might be a better way.
      else
        // We have the page that the graphic is on, let's at least jump
        // to that page, maybe we can get a little closer later
        F_ApiSetId(FV_SessionId, docId, FP_CurrentPage, graphicPageId);
        //get the parent frame of the graphic which is hopefully a text frame
        textFrameId = F_ApiGetId(docId, graphicId, FP_FrameParent);
        //let's see if we can find a paragraph and scroll to it.
        tr.beg.objId = tr.end.objId =
          F_ApiGetId(docId, textFrameId, FP_FirstPgf);
        F_ApiScrollToText(docId, &tr);
      //now, let's do the selection. We'll unselect everything
      //that is selected, unless our graphic is already selected.
      tempGraphicId = F_ApiGetId(FV_SessionId, docId, FP_FirstSelectedGraphicInDoc);
      while(tempGraphicId)
        if(tempGraphicId == graphicId || tempGraphicId == frameId)
          alreadySelected = True;
        else
          F_ApiSetInt(docId, tempGraphicId, FP_GraphicIsSelected, False);
        tempGraphicId = F_ApiGetId(docId, tempGraphicId, FP_NextSelectedGraphicInDoc);
      if(!alreadySelected)
        if(graphicId)
          F_ApiSetInt(docId, graphicId, FP_GraphicIsSelected, True);
        else
          F_ApiSetInt(docId, frameId, FP_GraphicIsSelected, True);
    //Returns the ID of the page that the graphic is on.
    F_ObjHandleT ws_GetPageForGraphic(F_ObjHandleT docId,
                                      F_ObjHandleT graphicId)
      F_ObjHandleT tempGraphicId = 0,
        pageId = 0;
      while(graphicId)
        tempGraphicId = graphicId;
        graphicId = F_ApiGetId(docId, graphicId, FP_FrameParent);
      if(tempGraphicId)
        pageId = F_ApiGetId(docId, tempGraphicId, FP_PageFramePage);
      return pageId;

  • Pull out tab - two way to scroll

    Hello!
    I wanted to reproduce the 'two way scroll pull out tab' I saw on the DPS tips app (Advanced Overlays).
    I was able to make the the pull out tab and to include another scrolling frame inside But I have problems with the buttons. They just don't work.
    I'd like to do the same as in the example with a clicable list that change a multistate object.
    Is there some tips to include buttons in scrolling frame?
    Thanks for your help!
    Best
    j.

    When you paste the content frame into the container frame in the nested overlay, the buttons lose their actions. Use the Layers panel to select each button and specify the action. It helps if you give your buttons logical names like "Asparagus Button."

  • Report for pulling out data of Pricing Ref. Material

    Hi All,
    I want to know the transaction or report which can pull out the data of pricing ref. material used for any material in Sales Org .2 view. I mean to say that, if there are 100 materials created and 50 of them have a pricing material field populated by some xyz material then how can I pull out those 50 material numbers for which the pricing ref. material is populated along with the pricing ref. material number?
    Await your quick response.
    Hrishikesh

    Hi
    These are  the standard reports for the material related.
    Material Analysis-Incoming orders - MC(E
    Material Analysis- Invoiced Sales - MC+Q
    Material Returns-Analysis - MC+M
    But i think you need to go for LIS , by creating a user defined report where in you need to take the character sics as pricing reference material (MATNR) as one of them
    Regards
    Srinath

  • How do I show multiple rollover images on a page inserted dynamically (pulled out of a sql database

    How do I show multiple rollover images on a page inserted dynamically (pulled out of a sql database table) using Dreamweaver’s Repeat Region. Example: I have different products each one associated (through their productID) with two images (one that’s showing in the page and one for the rollover effect) that are pulled from a database using Dreamweaver’s Recordset. So I want to end up with a page containing row after row of images(one for every product).When moused over each image will reveal the second (rollover) image for the same product which in turn can be a link(the image itself ) that when clicked leads to a detailed page with more information about the product the image is associated with. To show row after row with images for the different products in the database table I am using Dreamweaver’s Insert Rollover Image command and then the  Repeat Region – I have no problem to complete the steps, to insert the image and the rollover one at once and set the paths so they are pulled dynamically depending on the productID they are associated with .I have also no problem to apply the Repeat Region so not only the first image associated with the first product in the table is shown but all of them-a routine and standard procedure when using the Repeat Region to dynamically generate and display multiple rows of data. However, when I preview the page the rollover effect is lost –the images are shown but when moused over the second  image does not  show. The problem is caused when the Repeat Region is applied-once again I am allowed to apply it but the rollover stops working, a kind of interference. ANY SOLLUTION PLEASE, ANY WORK AROUND.

    I gotta tell you, using multiple images for rollover effects is going to be a big challenge in your dynamic scenario. 
    If this were my product page, I would use thumbnails with a bit of CSS opacity or filters to desaturate and make them full opacity/color on mouse over.  Nice effect with much less bandwidth. Easily done globally with CSS code.
    Two examples:
    http://alt-web.com/GALLERY/GalleryTest.php
    http://alt-web.com/TEMPLATES/CSS-Semi-liq-photo-sheet.shtml
    Nancy O.

  • Pulling out two records at a time

    I have a TABLE with multiple records in it, of which i want to pull out two records at a time (as if they were one record), of those records that meet the WHERE criteria. Order is not important. Basically, i have a TABLE of things that wither need processing or have been processed already. I can process two at a time. (In a related search, that i am not up to yet, i can do 20 at a time.) How would i go about doing that?
    My first thought was a CTE with ROW_NUMBER() RN, using CONNECT BY RN = PRIOR RN + 2, and have a sub-query (or joined TABLE) pull out the second record:
    WITH Moo (SELECT ... ROW_NUMBER RN FROM Table WHERE ...)
    SELECT ..., (SELECT ... FROM FROM Moo Moo2 WHERE Moo2.Id = Moo.Id + 1)
    FROM Moo CONNECT BY Id = PRIOR Id + 2;
    Or a join. Is there a better way to approach it?

    Pretty much everything you just said is wrong.
    >
    I generally keep away from CURSORs, as i want the DB to handle the set processing for me, as opposed to a CURSOR which tells the DB how to do it's job.
    >
    If you do any DB queries then you are using cursors. You have the wrong idea about them. All result sets are obtained using a cursor. A cursor does NOT tell a DB how to do a job; that is what the query and execution plan do.
    >
    (And, Tom Kyt's mantra of "You should do it in a single SQL statement if at all possible") But that's just a rule of thumb.
    >
    No - that isn't a rule of thumb. That is exactly what you should do if possible which is what I said. But I also said
    >
    Well the general use is to use SQL instead of PL/SQL but since you already need to use a function you might as well make that function as efficient as possible.
    >
    If you are already using a function then you should get the most bang for the buck from it and make it as efficient as possible.
    >
    If the CURSOR is the most efficient, so be it. But as you point out, if i'm already going to use a CURSOR, i might as well do all the work in the CURSOR LOOP. Why bother switching contexts.
    >
    All queries are done using cursors. It isn't a question of whether they are more efficient; it is the only way possible. I think you are referring to a user creating an explicit cursor and performing explicit manipulation of that cursor. That isn't normally what you want to do.
    A cursor loop is the slowest way to process results especially if all you are doing is row-by-row processing to perform essentially SQL-related work. PL/SQL should be used for the transactional part of the processing. In your case that transactional use is consolidating two records together for specialized processing.
    As for context switches if you perform any PL/SQL you are going to have a context switch: functions, procedures, triggers. The function you already planned to use would have caused a context switch. What I am saying is that if you are going to perform a context switch then you want to maximize the amount of work (transactional work) done in the PL/SQL engine so that you minimize the context switching.
    You still haven't explained exactly why 2 records at a time is any more ideal than 1 or if you could also process 50, 100, or 10000 at a time. Is the limit what needs to be passed somewhere else? What is the reason for a max of two? What exactly are you doing with the data to prepare it before you have to pass it on?
    Bulk collect processing is more efficient, with fewer context switches, if you process 20, 50, or 100 records in the loop at a time.
    See Chap 13 Using Pipelined and parallel Table Functions in the Data Cartridge Dev Guide
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28425/pipe_paral_tbl.htm

  • I have a brand new macbook pro that i was doing a data transfer from an old macbook, it got stopped/cable pulled out, now have spinning wheel of death that wont stop, how do i reboot/stop the wheel of death and start again?

    i have a brand new macbook pro that i was doing a data transfer via firewire from an old macbook, it got stopped/cable pulled out, now have spinning wheel of death that wont stop, how do i reboot/stop the wheel of death and start again? (this time il use time machine transfer)

    Just power off the machine(s). Shut them down. Migration Assistant gets 'stuck' sometimes - best way to migrate really isn't over Firewire, though it will certainly work, but with both machines hardwired via Ethernet to the same router. You can use a TM backup, too, of course, provided that it's recent. Which is the best? Your choice. I've done it both ways and have a preference for MA, but TM restore can be a bit faster and less quarrelsome.
    Clinton

  • How to increase the number of data Business Object can pull for a report?

    Hi,
    I would like to ask around how to increase the number of data Business Object can pull for a report. I have a report which pulls data depending on the date range (ex. From 01/01/2007 - 01/10/2007). But, when the data that is pulled exceeds 5000, the report fails. Is there anyway to increase the number of data that BO can pull?
    Thanks

    Bobby,
       to my knowledge we can't change that. Let me explain this, we have setting in the source system for DS default Data Transfer. there we will assign the processes. if you want to assign 4 you need to change the setting in the source system. For flat files we can change in BW System. We can maintain the setting in the Infopackage level(wht we are assigned in the Source System), but we can't change the process.
    in order to check the setting in source system  SBIW--> General Settings --> Control Parameters for Data Transfer.
    we need to change here, this will effect to all the Data Sources. Before making changes check with your basis.
    All the best.
    Regards,
    Nagesh Ganisetti.

Maybe you are looking for