How do I count objects of a specific type in a Vector? Java 1.3 source.

How do I count the objects of a specific type in a Vector?

isInstance may allow too much for your needs as it allows any object which can be typecast to 'type' while you seem to want to limit to objects which are exactly of the type 'type'. In such a case you could do this:
for (Enumeration e = attachmentTypes.elements(); e.hasMoreElements();)
  Object check = e.nextElement();
  if (check.getClass().equals(type)) {
    counter++;
}Javadoc of the isInstance() method:
http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Class.html#isInstance%28java.lang.Object%29
(I link to the old Javadoc given you mentioned Java 1.3 compatible source)

Similar Messages

  • How to cast an Object into a specific type (Integer/String) at runtime

    Problem:
    How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
    Example:
    public class TestCode {
         public static Object func1()
    Integer i = new Integer(10); //or String str = new String("abc");
    Object temp= i; //or Object temp= str;
    return temp;
         public static void func2(Integer param1)
              //Performing some stuff
         public static void main(String args[])
         Object obj = func1();
    //cast obj into Integer at run time
         func2(Integer);
    Description:
    In example, func1() will be called first which will return an object. Returned object refer to an Integer object or an String object. Now at run time, I want to cast this object to the class its referring to (Integer or String).
    For e.g., if returned object is referring to Integer then cast that object into Integer and call func2() by passing Integer object.

    GDS123 wrote:
    Problem:
    How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
    There is only one way to have an object of an unknown type at compile time. That is to create the object's class at runtime using a classloader. Typically a URLClassloader.
    Look into
    Class.ForName(String)

  • How to block accounting by MIRO for specific type of documents.

    Hello
    Is there any possibility to block accounting by MIRO for specific type of document? So you could only account specific type of documents by FBV* or FB*.
    Regards
    Marcin Obukowicz

    Hi,
    You can try to make a validation (OB28) which will check the document type based on transaction code prerequisites.
    Regards,
    Eli

  • How do I count numbers within a specific range in a column?

    I'm creating a spreadsheet for my college courses where I enter each score from each class as I get them back and it continues to recalculate my grades in each course.  Now I'm on the part where I want to make a box that calculates the current GPA for the semester.  I know how I'm going to do it already but I need to figure one thing out first.  Say my scores are as follows:
    85.50%
    82.00%
    92.35%
    94.25%
    78.00%
    I need a working code that counts the amount of scores within a certain range, say for example, tell me how many scores are between 80.00 and 89.99.  I can figure out how many are above/below a certain value (80.00 again for example) with a code like this [scores being the column with the grades]:
    =COUNTIF(Scores,">=80.00") ---- this gives me "4" correctly
    BUT when I add another value and want it to limit scores to not just being equal to/above 80.00 but also below 90.00 it freaks out.  I tried the two following codes:
    =COUNTIF(Scores,">=80.00","<90.00")
    =COUNTIF(Scores,">=80.00",Scores,"<90.00")
    Neither work, i'm sure i'm just wording it wrong.  It should obviously spit out the number "2" with there being two B's.  Any help would be appreciated!

    Jeremy.Osborne wrote:
    I have set up a chart just like yours with the intervals (60-100) on the left and on the right I have no idea what to do.  Do I enter that code into each box? Right now it looks like:
    =INDEX(FREQUENCY(Scores, I have no idea what to put here)
    Jeremy,
    in my response, I gave you the expression I used to build the frequency table. It was:
    =INDEX(FREQUENCY(Data :: A,A),ROW()-1)
    If you build a document exactly as the one I illustrated, the same expression will work for you. If you use a different table name, you will have to adjust the reference.
    Regarding the COUNTIFS function, you must read carefully the syntax defined in the Function Browser or the Formulas and Functions user guide and follow it to the letter.
    Jerry

  • How to get count of records for each type from internal table

    Hi Guys,
    I want to implement a logic to find out the count of records in a internal table.
    Assume my internal table have one field having the entries as shown below.
    Internal table Entries
    10
    10
    10
    11
    11
    12
    12
    12
    12
    13
    14
    14
    15
    15
    15
    15
    15
    16
    16
    17
    18
    19
    20
    20
    20
    ....... etc....
    I should get an output as below
    10's - 3
    11's -2 ,
    12's - 4.... etc..
    Could any one help me how to do this.
    Thanx,
    Kumar

    REPORT  zzz.
    DATA: i(100),
          t(100),
          j TYPE n.
    TYPES: BEGIN OF gt_int_type,
            linex(100) TYPE c,
           END OF gt_int_type.
    DATA: gt_int TYPE STANDARD TABLE OF gt_int_type,
          wa_int LIKE LINE OF gt_int.
    START-OF-SELECTION.
      wa_int-linex = '10'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '10'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '10'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '11'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '11'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '13'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '14'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '14'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '16'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '16'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '17'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '18'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '19'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '20'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '20'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '20'.
      APPEND wa_int TO gt_int.
      LOOP AT gt_int INTO wa_int.
        WRITE:/ wa_int-linex.
      ENDLOOP.
      ULINE.
      SKIP 3.
      SORT gt_int BY linex.
      READ TABLE gt_int INDEX 1 INTO i.
      j = 0.
      LOOP AT gt_int INTO wa_int.
        IF wa_int-linex EQ i.
          j = j + 1.
        ELSE.
          WRITE:/ i,'''s = ', j.
          j = 1.
          i = wa_int-linex.
        ENDIF.
      ENDLOOP.
      WRITE:/ i,'''s = ', j.
    consider clearing leading/trainling spaces...

  • Counting Rows of a Specific Type

    I have the following dataset and I was wondering if someone
    could help me out with the following problem:
    <data>
    <row type="A">item1</row>
    <row type="B">item1</row>
    <row type="B">item2</row>
    <row type="C">item1</row>
    <row type="C">item2</row>
    <row type="C">item3</row>
    </data>
    How would I set up the code to get the number of rows in the
    data set with the 'type' column being C for example? Any help is
    appreciated. Thanks!

    quote:
    if (ds.getDataWasLoaded())
    var rows = ds.getData();
    for (var loop = 0; loop < rows.length; loop++)
    if (rows[loop]["@type"] == "A")
    return rows[loop]["ds_RowID"];
    alert("Found " + rows.length + "match(es).");
    found somethinig like that @
    http://labs.adobe.com/technologies/spry/articles/data_api/apis/dataset.html#dataset
    im not a java expert, but its probly somethinig like that, it
    would probly get u started, i hope

  • How to check/count whether child records with specific type exist?

    Hi
    We need to create a BIP report based on data from Siebel.
    In Siebel we have two entities:
    Entity <Mandate> = Parent Business Componet
    Entity <Attachment> = Child Business Component
    (An attachment has a specific type attribute (e.g. “contract”, “appendix” and lot of others…)
    Relationship between Mandate and Attachments is 1-m.
    We need to create a BIP report which displays all Mandates records which do not have at least two Attachments child records (there must be one attachment child record with type=”contract’ and another with type “appendix”). How can we check in BIP whether these child records with a specific Attachment type exist? And if not, display the Mandate in a list....
    Many thanks
    Alen

    Thanks for your help
    Well I'm not sure about the syatax I have to use in order to filter on the field *<GAMDocumentType>*
    The structure of the xml we use is as follows:
    <ListOfBipJbAmlMandateAttachmentReport>
    <JbAmlMandate>
    <ListOfJbAmlAttachment>
    <JbAmlAttachment>
                   <AccntFileName>DocumentPage_713328</AccntFileName>
                   <GAMDocumentType>*contract</GAMDocumentType>
                   <MandateId>1-4C79B</MandateId>
                   <Status>Active</Status>
    </JbAmlAttachment>
    I tried <?for-each:JbAmlMandate[count(./JbAmlAttachment[GAMDocumentType='contract']) > 1 and count(./Attachment[type='appendix']) > 1]?>
    But this returns nothing.
    Many thanks for your help
    Saggittarius

  • BW 3.5 - How can I select TADIR objects in a specific date range?

    Hi everybody,
    I have the necessity to obtain a list of BW objects in a specific date range. I have observed that using TADIR table it is impossible because a timestamp is not present. I have also the necessity to group the BW objects using the object type of the TADIR table (e.g. PROG for Program).
    Any idea?
    Many thanks in advance for your kind support.
    Regards,
       Giovanni

    Hi Giovanni
    I would suggest you try put table TADIR in SE11 and generating a "Where-Used List (CtrlShiftF5)" Also you should try double click on data element SOBJ_NAME in the database view of TADIR and generate a Where-Used List on that field, then you can see the relationships of the table/field.
    I hope this works for you
    Good Luck
    Ben
    Please Assign Points if Useful

  • How do I count the number of records returned in the CMIS query

    How do I count the number of records returned in the query CMIS?
    SELECT COUNT(*) FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition = \'RD_PROJETOS_EXCLUSIVOS\''}
    Euler Homero

    Hi Euler,
    interestingly enough, the reference guide for CMIS ( http://wiki.alfresco.com/wiki/CMIS_Query_Language ) that I found does not mention the COUNT function at all. On the other hand it states that: "The SELECT clause identifies which virtual columns to return in the result set. It can be either a comma-separated list of one or more queryNames of properties that are defined by queryable object types or * for all virtual columns."
    There are, however, some other posts like e.g. http://alfrescoshare.wordpress.com/2010/01/20/count-the-total-number-of-documents-in-alfresco-using-sql/ which state that they could make it working.
    Having asked in the WebCenter Portal forum, I assume that your content repository is WebCenter Content. The CMIS doc for the Content is available here: http://docs.oracle.com/cd/E23943_01/doc.1111/e15813.pdf (no COUNT there either). It does, however, mention explicitly that "CMIS queries return a Result Set where each Entry object will contain only the properties that were specified in the query.". This means your could rather investigate the Result Set. Note that there are also other means than CMIS how to get the requested result set (e.g. calling a search service directly via so-called RIDC).
    In the given context I am also interested what your use case is. OOTB CMIS in WebCenter Portal is used, for instance, in Content Presenter, where it is content rather than "parameters" what's displayed.

  • How to set a Object value by JDI

    How to set a Object value using JDI?
    For example:
    class User{
      private String name;
      private String id;
    set and get method;
    public static void main(String[] args) throws Exception {
            VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
            List<AttachingConnector> connectors = vmm.attachingConnectors();
            SocketAttachingConnector sac = null;
            for (AttachingConnector ac : connectors) {
                if (ac instanceof SocketAttachingConnector) {
                    sac = (SocketAttachingConnector) ac;
                    break;
            if (sac == null) {
                System.out.println("JDI error");
                return;
            Map<String, Connector.Argument> arguments = sac.defaultArguments();
            Connector.Argument hostArg = arguments.get("hostname");
            Connector.Argument portArg = arguments.get("port");
            hostArg.setValue(HOST);
            portArg.setValue(String.valueOf(PORT));
            vmMachine = sac.attach(arguments);
            List<ReferenceType> classesByName = vmMachine.classesByName(CLSNAME);
            if (classesByName == null || classesByName.size() == 0) {
                System.out.println("No class found");
                return;
            ReferenceType rt = classesByName.get(0);
            List<Method> methodsByName = rt.methodsByName(METHODNAME);
            if (methodsByName == null || methodsByName.size() == 0) {
                System.out.println("No method found");
                return;
            Method method = methodsByName.get(0);
    I will connect to server and monitor the remote server JVM , There is a object of User, I want to change its value by the Java Debugger Interface by client.
    so how to set its value by the client, and I can not got the User bean at client.
    I know the basic type filed value changed as follows:
    Value newValue = vmMachine.mirrorOf("change var value");// this field is a string.
    stackFrame.thisObject().setValue(field, newValue);
    But a Object , how can I change its value.
    Thanks Advanced.

    ObjectReference.setValue() is the method for chaining the value of an Object's field. First you need to find the specific Object you want to change, though.
    /Staffan

  • In InDesign, how does one determine the pixel size of a text box? Specifically, we need to write text to specifications of 600 pixel width, and have no idea a) how to scale a text box to specific pixel width, b) how to

    This may be a basic question... but in InDesign, how does one determine the pixel size of a text box? Specifically, we need to write text to specifications of 600 pixel width, and have no idea a) how to scale a text box to specific pixel width, b) how to determine what word count we can fit in, and c) how to do it in a table? Thanks!

    Set your ruler increments to pixels Preferences>Units & Increments. You can fill the text box with placeholder text Type>Fill with Placeholder text and get a word count from the Info panel with Show Options turned on from the flyout.
    From the Transform panel you can set a text box's width and height

  • How to integrate customer objects in CC02 / change management?

    Hello everybody,
    I want to integrate a new customer object (for customer-specific master data) into the standard change management of ECC 6.0.
    I already read that there is a BAdI, which can undo changes made with the standard change management.
    "In the BAdI ECM_UNDO Undo Changes, SAP provides separate classes as BAdI implementations for each of these objects. If you want to implement undo changes for more SAP master data and for customer-specific master data, you can use these classes as templates for your own implementations."
    But how can I integrate new objects for customer-specific master data?
    Thanks in advance,
    Lars

    Hello Lars,
    i´ve the same requirement. For a customer specific development we´ve developed our own business objects. The customer wants the change these objects with change management. You´ve already got a solution for this?
    Regards,
    Andy

  • Some performance counter objects are not available for a 32-bit process on 64-bit versions of Windows Server 2012 standard

    When we try to gather performance counter information for a 32-bit process on a 64-bit computer that is running Microsoft Windows Server 2012, all our performance counter objects are not available with 32 bit perfmon application (C:\Windows\SysWOW64\perfmon.exe)
    I didn't notified any errors while registering our counter objects or while running Perfmon.exe
    Note: Same counter objects are available and working fine with Windows Server 2008 R2.
    for diagnostic our counters on WIN2012, ran command as follows:
     cd c:\windows\sysWOW64
     lodctr /Q
    I am able to see all our counter objects on response and infact all were shown as enabled, as shown below
    Appreciate quiclk response with solution or clues to diagnose it more details.
    Thanks & Regards,
    Sudhakar Rudra

    Hi,
    Thanks for your reply.
    I hope you understood our problem.
    same our system counter objects (ver x), we able to browse from Perfmon 32 bit app on Windows 7, Windows 2008 R2 (64bit) OS but not on Windows 2012.
    I am able to see all counter objects registered as follows (same at HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\HMI Alarm Class\Performance,
    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\HMI Alarm Class\Performance
    and
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HMI Alarm Class\Performance)
    Only difference I observed that "Disable Performance Counters" were set to 4 in Windows 2012 OS unlike other windows 7 64bit OS and there is no differnece for remaining all entires.
    I tried setting that "Disable Performance Counters" value to "0", but some how they get reset to "4", no luck..
    I think "Disable Performance Counters" value either "0", or "4", should not matter for browsing our counters with 32bit bit perfmon applicaiton.
    Do you see any issues of registry entries. ?
    On what basis perfomance monitor list few enabled counters?
    How can we add our counters manually to perfomance monitor?

  • How to organize Data Objects and other Objects in SWCV

    Hi,
    I am looking for Best Practices on how to organize data objects in SWCV as well as other objects such as a Distribution Rules.
    We are planning to develop three occasionally connected applications with NW Mobile 7.1 this year and maybe additional one the following year. We will create multiple Standard Data Objects (e.g. Plant, Company Code, Reservations, ...) which are shared in the first set of transactions and in the future transactions.
    I have heard before to separate out Standard Data Objects from Distribution Models and have two different SWCV.
    Should I have a) one SWCV for all current and future Standard Data Objects and one for the distribution rtules or b) should I separate out common data objects into one SWCV, and all transaction-specific data object each into separate SWCV?
    Just wondering if there are any best practices available for this so that I won't run into problems in the future when we want to add more transactions/data objects?
    Any advise is appreciated.
    Thanks,
    W. Berger

    Hi Siva,
    Thanks for quick reply!!
    I have created say SWCV1 for Dataobjects.
    Now i want to create seperate SWCV2 for defining distribution model.
    How i should proceed..I cannot see the uses option while creating new SWCV2  ( Only option i see is  'backward compatibility checkbox : uses NW04/NW04s MI Application')
    where to check the following which you have mentioned?
    SWCV2 was created and inherited SWCV1 in uses tab of SWCV2.
    Thanks in advance!!
    Regards
    Devendra

  • How to attach an object back to its source in a master page?

    Hello,
    on a content page I can access objects from the assigned master page using the Ctrl+Shift+LeftClick combination. By doing so I detach many attributes of this object from the master page specifications. How to reset an object and attach it back to the source object of the master page?
    If you are a PowerPoint user, the option reapply slide layout may be familiar to you (this function resets all format overrides to the master settings). I am looking for a similar function in InDesign.

    I really looking for a way to change the position of the second and third text boxes relative to other items on the page.
    An overriden master page item will still respond to its master's position if its position on the page after overriding hasn't been changed. So, you can have the "directions" box on the master page, override it, add text, and as long as you don't move its x, y position in the process of adding text, it can be moved via the master page in the future. The key is not to move it in the editing process.
    Same goes for other attributes. If the fill color is red, you can change it to gray from its master later, as long as you don't change the page item's fill to pink in between.
    It's also possible to match a changed page item's attributes to its master via scripting.
    So for example if you had a 3" text box on the master and there was 100 pages with the text box, and in the editing process 50 had their width changed to varying widths and later you decided you needed a 4"width— a simple script could loop through all the pages and reset the changed widths to match the master's new 4" width.

Maybe you are looking for

  • How do I change the behaviour of an update button.

    I have a variable - $UpdateFlag, which contains a string and updates a table with it on the click of the update button. The problem I have is that if the string is blank, I don't want to update, and I want the button to exit instead. here's the code.

  • OPENING PDF IN FIREFOX, CHOSE "DO THIS AUTOMATICALLY..." POPUP ALWAYS COMES UP ASKING TO SAVE OR OPEN ETC.

    I'm clicking to open a pdf invoice so I can then print it. The windows box which is headed "YOu have chosen to open " "What should firefox do with this file?" 3 ck box lines 1) Save... 2) Open.... 3) Do this automatically PROBLEM is this box always k

  • Mac OSX 10.7.4 not recognising file types.

    .dmg files are coming up as a plain "document". I have changed the "open with" to diskimagemounter and clicked change all. This works until the computer is restarted, then reverting back to unkown file type or document. Any suggestions? Thanks.

  • Verify custom plugin signature with Adobe Default Security

    Hi, I have a few questions using Adobe Default Security when verifying a signature. I've created my own signing plugin which works well. When I verify my signature it states that it is a valid signature, that the document has not been altered and tha

  • My brother stole my laptop, how to prove its mine?

    As the title says, My greedy, lowlife brother came into my apartment (it was open, stupid me, i know) and took my laptop among other things. Its a basic Toshiba satellite i purchased from Best Buy maybe 2 years ago. I registerd the product, but I can