Function to return a list of sub-class elements

Hi all
I'm trying to write a function using templates which takes a list and returns a sub list of a given type.something like shown below:
static <E, T> List<E> get_specific_elements(Collection<T> elements) { //assumes E extends T
          List<E> specific_elements= new ArrayList<E>();
          for (T element : elements)
line 4:               if (element instanceof E)
                    specific_elements.add((E)element);
          return specific_elements;
     }but it gives me at line 4
Cannot perform instanceof check against type parameter E. Use instead its erasure Object
      since generic type information will be erased at runtimeso is there a way to fix it or any other alternative to make it work.
thanks
Sree
Edited by: sreecs on Nov 5, 2008 10:03 PM
Edited by: sreecs on Nov 5, 2008 10:04 PM

In your code, there is no way for the runtime to know what E is. The solution is to tell it.
static <E extends T, T> List<E> get_specific_elements(Class<E> subtype, Collection<T> elements) {
    List<E> specificElements= new ArrayList<E>();
    for (T element : elements) {
        if (subtype.isInstance(element)) {
            specificElements.add(subtype.cast(element));
    return specificElements;
}Bruce

Similar Messages

  • Servicegen for sub-class inside vector variable of Super

    java.lang.NoSuchMethodError
    at com.netsboss.WSBE.model.QueryItemCodec.typedInvokeGetter(QueryItemCod
    ec.java:87)
    at com.netsboss.WSBE.model.QueryItemCodec.invokeGetter(QueryItemCodec.ja
    va:56)
    at weblogic.xml.schema.binding.BeanCodecBase.gatherContents(BeanCodecBas
    e.java:295)
    at weblogic.xml.schema.binding.CodecBase.serializeFill(CodecBase.java:25
    3)
    at weblogic.xml.schema.binding.CodecBase.serialize(CodecBase.java:195)
    at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(RuntimeUti
    ls.java:184)loop
    at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(RuntimeUti
    ls.java:170)
    QueryItem {
    private Vector airItiners;
    public Vector getAirItiners() {
    return airItiners;
    public class AirItinerary implements Serializable{}
    QueryItem is my return class. The return result will include sub class AirItinerary
    in QueryItem's Vector. I notice servicegen will only generate stub and web.xml
    for QueryItem.
    I get above error, when the result return to client. How to generate necessary
    sub-class inside a vector variable of Super class?
    Stephen

    Hi Stephen,
    write my own ser/deser? Any other quick way?Our excellent support group ([email protected]) may be able to help with
    an alternative solution. If you could create a small reproducer, then
    this will help them with a clear picture of your goal.
    One more problem, wls deloy my WSBE.ear as a war correctly. But error show noDouble check the console log for any messages. Also try:
    http://[host]:[port]/[contextURI]/[serviceURI]
    See: http://edocs.bea.com/wls/docs70/webserv/client.html#1051033 and
    also check the console to verify the app is or is not deployed. See:
    http://edocs.bea.com/wls/docs70/programming/deploying.html
    HTHs,
    Bruce
    Stephen Zeng wrote:
    >
    Hi Bruce:
    Our company use wsl7.0. We are not able to update to wls8 in this project. Do
    I have to
    write my own ser/deser? Any other quick way?
    sub class variable:
    public class AirItinerary implements Serializable{
    private String air;
    private Vector flightItem; //sub class of AirItineray
    One more problem, wls deloy my WSBE.ear as a war correctly. But error show no
    deloyment found. web-services.xml has been generated by servicegen under web-inf
    path. Thanks Bruce.
    Stephen
    Bruce Stephens <[email protected]> wrote:
    Hi Stephen,
    The java.util.vector should be converted to a SOAP Array, see:
    http://edocs.bea.com/wls/docs81/webserv/assemble.html#1060696 however
    the issue of the sub-class is most likely the problem. Can you simplify
    the data types? You may just have to write your own ser/deser, see:
    http://edocs.bea.com/wls/docs81/webserv/customdata.html#1060764
    This is with WLS 8.1, right?
    Thanks,
    Bruce
    Stephen Zeng wrote:
    java.lang.NoSuchMethodError
    at com.netsboss.WSBE.model.QueryItemCodec.typedInvokeGetter(QueryItemCod
    ec.java:87)
    at com.netsboss.WSBE.model.QueryItemCodec.invokeGetter(QueryItemCodec.ja
    va:56)
    at weblogic.xml.schema.binding.BeanCodecBase.gatherContents(BeanCodecBas
    e.java:295)
    at weblogic.xml.schema.binding.CodecBase.serializeFill(CodecBase.java:25
    3)
    at weblogic.xml.schema.binding.CodecBase.serialize(CodecBase.java:195)
    at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(RuntimeUti
    ls.java:184)loop
    at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(RuntimeUti
    ls.java:170)
    QueryItem {
    private Vector airItiners;
    public Vector getAirItiners() {
    return airItiners;
    public class AirItinerary implements Serializable{}
    QueryItem is my return class. The return result will include sub classAirItinerary
    in QueryItem's Vector. I notice servicegen will only generate stuband web.xml
    for QueryItem.
    I get above error, when the result return to client. How to generatenecessary
    sub-class inside a vector variable of Super class?
    Stephen

  • How to return a list of class from a package

    Hi,
    I'm trying to create a RPG game with 50 characters. There will be a superclass, and each character is a subclass that extends from the superclass. Each will have unique abilities that will be functions. These classes will be thrown into a package.
    I would like to know the code for returning the list of classes in that package. That way, I can present them as a list for the player to choose just a handful of characters to start out with.
    Thanks in advance         

    Hi u can use the this class
    flash.utils.describeType;
    Regards
    Sumit Agrawal

  • How to use a select list value in a PL/SQL function body returning SQLquery

    Hi Friends,
    I have a select list P6_TEST with values 'nav' anf 'jyo'. I am trying to create a report using "SQL Query (PL/SQL
    function body returning SQL query)". In my report query can i check if P6_TEST='nav' and do something like the
    code shown below.How can i do that.
    DECLARE
    v_sql VARCHAR2(3000);
    BEGIN
    IF :P6_TEST = 'nav' THEN
    v_sql :=
    'SELECT
    * from department';
    ........................Thanks,
    Nav

    Nav:
    What you have should work. Give it a go. Post back if you run into issues.
    Varad

  • Multiple Select List looping thru PL/SQL function body returning SQL query

    Hi,
    I have a Multiple Select List. I want to loop through the values from the Select List and process them in a PL/SQL function body returning a SQL query. Currently, my code only returns the SQL SELECT results of one item in the select list. How do I change my code to make it return the results of all of the items in the select list? (I tested it and it is definitely picking up all the values in the select list).
    <b>
    DECLARE
    selected_items HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    s   VARCHAR2(20);
    q varchar2(32767);
    BEGIN
    selected_items := HTMLDB_UTIL.STRING_TO_TABLE(:P50_SELECTED_INSTRUMENTS);
    -- htp.p('COUNT: '||selected_items.count);
      FOR i in 1..selected_items.count LOOP
      s := TO_CHAR(selected_items(i));
    -- htp.p('First: '||s);
    -- htp.p('Second: '||:s);
    -- htp.p('Third: '||TO_CHAR(selected_items(i)));
      q:= 'SELECT  '||
    'SUBSTR(orig_geo_loc_sys,1,INSTR(orig_geo_loc_sys,''-'')-1) AS INSTRUMENT, '||
    'SUBSTR(orig_geo_loc_sys,INSTR(orig_geo_loc_sys,''-'')+1, LENGTH'||
    ' (orig_geo_loc_sys)) AS ORIG_LINENUM, '||
    'sum(orig_intrl) orig_intrl, '||
    'sum(orig_extrl) orig_extrl, '||
    'sum(recv_intrl) recv_intrl, '||
    'sum(recv_extrl) recv_extrl '||
    'FROM line_usage_sum_view '||
    'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''' || s ||'%'' '||
    --'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''2213003%'' '||
    'AND switch_id = ''' || :P1_SWITCH_ID || ''' ' ||
    'AND call_start_date > TO_DATE(''30-NOV-1999'') ' ||
    'AND call_clear_time > TO_DATE(''30-NOV-1999'') '||
    'AND '||
    :SORTFIELD||' BETWEEN '||
    'TO_DATE(:STARTDATE,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:STOPDATE, ''dd-MON-YYYY HH24:MI'') '||
    'GROUP BY GROUPING SETS (orig_geo_loc_sys)';
    -- htp.p('SQL query: '||q);
      RETURN q;
      END LOOP;
    END;</b>
    Thank you,
    Laura

    Laura,
    First, I would be careful of introducing SQL Injection possibilities. Any time I see
    'Select ... ' || :P123_FOO || ' ... '
    I worry about sql injection. In your case you are converting :P50_SELECTED_INSTRUMENTS into selected_items and then selected_items into s. So when I see
    'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''' || s ||'%'' '||
    I think, "I could use sql Injection and hack this."
    So, I would do some validation on :P50_SELECTED_INSTRUMENTS or some other method to avoid this.
    I'm not certain I understand your query. Do you really intend to allow the user to select the beginning of a string and then find all rows that start with that string? Or, do you just want to let them find when it matches the string. This is one way if you want to do matching:
    DECLARE
    selected_items HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    s VARCHAR2(32767);
    q varchar2(32767);
    BEGIN
    -- Change the : separate string to be comma separated with quoted strings
    s := '''' || replace(:P50_SELECTED_INSTRUMENTS, ',', ''',''')|| '''' ;
    -- htp.p('COUNT: '||selected_items.count);
    q:= 'SELECT '||
    'SUBSTR(orig_geo_loc_sys,1,INSTR(orig_geo_loc_sys,''-'')-1) AS INSTRUMENT, '||
    'SUBSTR(orig_geo_loc_sys,INSTR(orig_geo_loc_sys,''-'')+1, LENGTH'||
    ' (orig_geo_loc_sys)) AS ORIG_LINENUM, '||
    'sum(orig_intrl) orig_intrl, '||
    'sum(orig_extrl) orig_extrl, '||
    'sum(recv_intrl) recv_intrl, '||
    'sum(recv_extrl) recv_extrl '||
    'FROM line_usage_sum_view '||
    'WHERE TO_CHAR(orig_geo_loc_sys) in (' || s ||' ) '||
    --'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''2213003%'' '||
    'AND switch_id = ''' || :P1_SWITCH_ID || ''' ' ||
    'AND call_start_date > TO_DATE(''30-NOV-1999'') ' ||
    'AND call_clear_time > TO_DATE(''30-NOV-1999'') '||
    'AND '||
    :SORTFIELD||' BETWEEN '||
    'TO_DATE(:STARTDATE,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:STOPDATE, ''dd-MON-YYYY HH24:MI'') '||
    'GROUP BY GROUPING SETS (orig_geo_loc_sys)';
    -- htp.p('SQL query: '||q);
    RETURN q;
    END;
    If you want to do something more like you originally stated, try this:
    DECLARE
    selected_items HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
    s VARCHAR2(20);
    q varchar2(32767);
    BEGIN
    selected_items := HTMLDB_UTIL.STRING_TO_TABLE(:P50_SELECTED_INSTRUMENTS);
    -- htp.p('COUNT: '||selected_items.count);
    q:= 'SELECT '||
    'SUBSTR(orig_geo_loc_sys,1,INSTR(orig_geo_loc_sys,''-'')-1) AS INSTRUMENT, '||
    'SUBSTR(orig_geo_loc_sys,INSTR(orig_geo_loc_sys,''-'')+1, LENGTH'||
    ' (orig_geo_loc_sys)) AS ORIG_LINENUM, '||
    'sum(orig_intrl) orig_intrl, '||
    'sum(orig_extrl) orig_extrl, '||
    'sum(recv_intrl) recv_intrl, '||
    'sum(recv_extrl) recv_extrl '||
    'FROM line_usage_sum_view '||
    'WHERE 1=1 ';
    FOR i in 1..selected_items.count LOOP
    s := TO_CHAR(selected_items(i));
    q := q || ' and TO_CHAR(orig_geo_loc_sys) LIKE '''|| s ||'%'' ' ;
    END LOOP;
    q := q || ||'%'' '||
    --'WHERE TO_CHAR(orig_geo_loc_sys) LIKE ''2213003%'' '||
    'AND switch_id = ''' || :P1_SWITCH_ID || ''' ' ||
    'AND call_start_date > TO_DATE(''30-NOV-1999'') ' ||
    'AND call_clear_time > TO_DATE(''30-NOV-1999'') '||
    'AND '||
    :SORTFIELD||' BETWEEN '||
    'TO_DATE(:STARTDATE,''dd-MON-YYYY HH24:MI'') AND '||
    'TO_DATE(:STOPDATE, ''dd-MON-YYYY HH24:MI'') '||
    'GROUP BY GROUPING SETS (orig_geo_loc_sys)';
    -- htp.p('SQL query: '||q);
    RETURN q;
    END;
    Hope this helps...
    Anton

  • Pl/sql web service returning a list of results

    I am able to publish a pl/sql package as a web service that returns a single result. However, when I try to return a list of results, I get an error in jdeveloper when I select the package and invoke publish as web service.
    I use a simple pl/sql package:
    create type longcredit_obj as object (
    credit varchar2(200),
    parlrepid number(6),
    mbrid number(6),
    rdgid number(6))
    create type longcredit_list as table of longcredit_obj
    create or replace package longcredit_pck as
    function get_longcredit (initials in varchar2) return longcredit_list;
    end longcredit_pck;
    create or replace package body longcredit_pck as
    function get_longcredit (
    initials in varchar2) return longcredit_list
    as
    i integer;
    list longcredit_list;
    cursor c_credit is
    select a.credit, a.parlrepid, a.mbrid, a.rdgid
    from member_credits_test_vw a
    where upper(init) = upper(initials);
    begin
    list := longcredit_list();
    for rec in c_credit
    loop
    i:= list.last;
    list(i) := longcredit_obj(null, null, null, null);
    list(i).credit := rec.credit;
    list(i).parlrepid := rec.parlrepid;
    list(i).mbrid := rec.mbrid;
    list(i).rdgid := rec.rdgid;
    end loop;
    return list;
    end get_longcredit;
    end longcredit_pck;
    Is this a feature that is available?
    Any suggestions are appreciated.
    Thank you in advance.
    Carmen.
    I am running jdeveloper 10.1.3.2.0 and database v. 10.1.0.4.0.

    Hi Steffen,
    I did manage to get it to work by doing the following:
    drop type longcredit_list
    drop type longcredit_obj
    create type longcredit_obj as object
    (credit varchar2(200),
    parlrepid number(6),
    mbrid number(6),
    rdgid number(6))
    create type longcredit_list as table of longcredit_obj
    create or replace package longcredit_pck as
    function get_longcredit(initials in varchar2) return longcredit_list;
    end longcredit_pck;
    create or replace package body longcredit_pck as
    function get_longcredit(initials in varchar2) return longcredit_list
    as
    v_longcredit_obj longcredit_obj:=longcredit_obj(null,null,null,null);
    v_longcredit_list longcredit_list:=longcredit_list();
    i number:=1;
    cursor getlist is
    select distinct a.credit, a.parlrepid, a.mbrid, a.rdgid
    from member_credits_test_vw a
    where upper(init) = upper(initials)
    order by a.parlrepid;
    begin
    for rec in getlist loop
    v_longcredit_obj.credit := rec.credit;
    v_longcredit_obj.parlrepid := rec.parlrepid;
    v_longcredit_obj.mbrid := rec.mbrid;
    v_longcredit_obj.rdgid := rec.rdgid;
    v_longcredit_list.extend;
    v_longcredit_list(i):=v_longcredit_obj;
    i:=i+1;
    end loop;
    return v_longcredit_list;
    end get_longcredit;
    end longcredit_pck;
    Also, before deploying, in jdeveloper, in the deploy file, I select the property filters under web-inf\classes and check all the classes that are unchecked (see thread id 505217).
    Also, the database I'm using now is v. 10.2.0.3.0.
    Thanks for your suggestion!
    Carmen.

  • Accessing an Array List from another class

    Hi, I was a member on here before, but I forgot my password and my security question is wrong.
    My question is how do I access a private arraylist from a different class in the same package?
    What I am trying to do is the following (hard to explain).
    Make a picking client for a shop, so that when an order is recieved, the picker can click on the orders button, and view all of the current orders that have not been completed. This Pick client has its own user interface, in a seperate class from where the BoughtList array is created, in the cashier client. The boughtlist is created when the cashier puts in the product number into the cashier client and clicks buy. I seem to be having trouble accessing the list from another class. Once the order is completed the cashier clicks bought and the list is reset. There is another class in a different pagage that processes some of the functions of the order, eg newOrder().
    Yes it is for Uni so I dont need / want the full answers, jist something to get started. Also please dont flame me, I have done many other parts of this project, just having trouble getting started on this one.
    Here is the code for the cashier client. The code for the Pick client is almost the same, I just need to make the code that displays the orders.
    package Clients;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.NumberFormat;
    import java.util.Locale;
    import Catalogue.*;
    import DBAccess.*;
    import Processing.*;
    import Middle.*;
    class CashierGUI 
      class STATE                             // Cashier states
        public static final int PROCESS  = 0;
        public static final int CHECKED  = 1;
      class NAME                             // Names of buttons
        public static final String CHECK  = "Check";
        public static final String BUY    = "Buy";
        public static final String CANCEL = "Cancel";
        public static final String BOUGHT = "Bought";
      private static final int H = 300;       // Height of window pixels
      private static final int W = 400;       // Width  of window pixels
      private JLabel      theAction  = new JLabel();
      private JTextField  theInput   = new JTextField();
      private JTextArea   theOutput  = new JTextArea();
      private JScrollPane theSP      = new JScrollPane();
      private JButton     theBtCheck = new JButton( NAME.CHECK );
      private JButton     theBtBuy   = new JButton( NAME.BUY );
      private JButton     theBtCancel= new JButton( NAME.CANCEL );
      private JButton     theBtBought= new JButton( NAME.BOUGHT );
      private int         theState   = STATE.PROCESS;   // Current state
      private Product     theProduct = null;            // Current product
      private BoughtList  theBought  = null;            // Bought items
      private Transaction     theCB        = new Transaction();
      private StockReadWriter theStock     = null;
      private OrderProcessing theOrder     = null;
      private NumberFormat theMoney  =
              NumberFormat.getCurrencyInstance( Locale.UK );
      public CashierGUI(  RootPaneContainer rpc, MiddleFactory mf  )
        try                                             //
          theStock = mf.getNewStockReadWriter();        // DataBase access
          theOrder = mf.getNewOrderProcessing();        // Process order
        } catch ( Exception e )
          System.out.println("Exception: " + e.getMessage() );
        Container cp         = rpc.getContentPane();    // Content Pane
        Container rootWindow = (Container) rpc;         // Root Window
        cp.setLayout(null);                             // No layout manager
        rootWindow.setSize( W, H );                     // Size of Window
        Font f = new Font("Monospaced",Font.PLAIN,12);  // Font f is
        theBtCheck.setBounds( 16, 25+60*0, 80, 40 );    // Check Button
        theBtCheck.addActionListener( theCB );          // Listener
        cp.add( theBtCheck );                           //  Add to canvas
        theBtBuy.setBounds( 16, 25+60*1, 80, 40 );      // Buy button
        theBtBuy.addActionListener( theCB );            //  Listener
        cp.add( theBtBuy );                             //  Add to canvas
        theBtCancel.setBounds( 16, 25+60*2, 80, 40 );   // Cancel Button
        theBtCancel.addActionListener( theCB );         //  Listener
        cp.add( theBtCancel );                          //  Add to canvas
        theBtBought.setBounds( 16, 25+60*3, 80, 40 );   // Clear Button
        theBtBought.addActionListener( theCB );         //  Listener
        cp.add( theBtBought );                          //  Add to canvas
        theAction.setBounds( 110, 25 , 270, 20 );       // Message area
        theAction.setText( "" );                        // Blank
        cp.add( theAction );                            //  Add to canvas
        theInput.setBounds( 110, 50, 270, 40 );         // Input Area
        theInput.setText("");                           // Blank
        cp.add( theInput );                             //  Add to canvas
        theSP.setBounds( 110, 100, 270, 160 );          // Scrolling pane
        theOutput.setText( "" );                        //  Blank
        theOutput.setFont( f );                         //  Uses font 
        cp.add( theSP );                                //  Add to canvas
        theSP.getViewport().add( theOutput );           //  In TextArea
        rootWindow.setVisible( true );                  // Make visible
      class Transaction implements ActionListener       // Listener
        public void actionPerformed( ActionEvent ae )   // Interaction
          if ( theStock == null )
            theAction.setText("No conection");
            return;                                     // No connection
          String actionIs = ae.getActionCommand();      // Button
          try
            if ( theBought == null )
              int on    = theOrder.uniqueNumber();      // Unique order no.
              theBought = new BoughtList( on );         //  Bought list
            if ( actionIs.equals( NAME.CHECK ) )        // Button CHECK
              theState  = STATE.PROCESS;                // State process
              String pn  = theInput.getText().trim();   // Product no.
              int    amount  = 1;                       //  & quantity
              if ( theStock.exists( pn ) )              // Stock Exists?
              {                                         // T
                Product pr = theStock.getDetails(pn);   //  Get details
                if ( pr.getQuantity() >= amount )       //  In stock?
                {                                       //  T
                  theAction.setText(                    //   Display
                    pr.getDescription() + " : " +       //    description
                    theMoney.format(pr.getPrice()) +    //    price
                    " (" + pr.getQuantity() + ")"       //    quantity
                  );                                    //   of product
                  theProduct = pr;                      //   Remember prod.
                  theProduct.setQuantity( amount );     //    & quantity
                  theState = STATE.CHECKED;             //   OK await BUY
                } else {                                //  F
                  theAction.setText(                    //   Not in Stock
                    pr.getDescription() +" not in stock"
              } else {                                  // F Stock exists
                theAction.setText(                      //  Unknown
                  "Unknown product number " + pn        //  product no.
            if ( actionIs.equals( NAME.BUY ) )          // Button BUY
              if ( theState != STATE.CHECKED )          // Not checked
              {                                         //  with customer
                theAction.setText("Check if OK with customer first");
                return;
              boolean stockBought =                      // Buy
                theStock.buyStock(                       //  however
                  theProduct.getProductNo(),             //  may fail             
                  theProduct.getQuantity() );            //
              if ( stockBought )                         // Stock bought
              {                                          // T
                theBought.add( theProduct );             //  Add to bought
                theOutput.setText( "" );                 //  clear
                theOutput.append( theBought.details());  //  Display
                theAction.setText("Purchased " +         //    details
                           theProduct.getDescription()); //
    //          theInput.setText( "" );
              } else {                                   // F
                theAction.setText("!!! Not in stock");   //  Now no stock
              theState = STATE.PROCESS;                  // All Done
            if ( actionIs.equals( NAME.CANCEL ) )        // Button CANCEL
              if ( theBought.number() >= 1 )             // item to cancel
              {                                          // T
                Product dt =  theBought.remove();        //  Remove from list
                theStock.addStock( dt.getProductNo(),    //  Re-stock
                                   dt.getQuantity()  );  //   as not sold
                theAction.setText("");                   //
                theOutput.setText(theBought.details());  //  display sales
              } else {                                   // F
                theOutput.setText( "" );                 //  Clear
              theState = STATE.PROCESS;
            if ( actionIs.equals( NAME.BOUGHT ) )        // Button Bought
              if ( theBought.number() >= 1 )             // items > 1
              {                                          // T
                theOrder.newOrder( theBought );          //  Process order
                theBought = null;                        //  reset
              theOutput.setText( "" );                   // Clear
              theInput.setText( "" );                    //
              theAction.setText( "Next customer" );      // New Customer
              theState = STATE.PROCESS;                  // All Done
            theInput.requestFocus();                     // theInput has Focus
          catch ( StockException e )                     // Error
          {                                              //  Of course
            theOutput.append( "Fail Stock access:" +     //   Should not
                                e.getMessage() + "\n" ); //  happen
          catch ( OrderException e )                     // Error
          {                                              //  Of course
            theOutput.append( "Fail Order process:" +    //   Should not
                                e.getMessage() + "\n" ); //  happen
    }

    (disclaimer: I did not read through your Swing code, as I find that painful)
    My question is how do I access a private arraylist from a different class in the same
    package?Provide a public accessor method (getMyPrivateArrayList())

  • ADM message TBX buffer: function ThAdmToMys returns RC = -1

    Hello to everyone, I have wrote a program which is loading all our products (aprox. 1300 matnrs) and then in a LOOP at itab is doing the following:
      LOOP AT ITAB.
        CLEAR WMENGE.
        EXPORT WMENGE TO MEMORY ID 'ZGRMENG'.
        SUBMIT ZGRRM07MLBD WITH MATNR = ITAB-MATNR
                           WITH WERKS = ITAB-WERKS
                           WITH DATUM IN SDATUM
                           WITH LGBST      = 'X'
                           WITH XSUM       = 'X'
                           EXPORTING LIST TO MEMORY
                           AND RETURN.
        IMPORT  WMENGE FROM MEMORY ID 'ZGRMENG'.
        IF ITAB-MTART <> 'PACK'.
          IF ITAB-MEINS = 'EA'.
            ITAB-EACH = WMENGE.
            ITAB-KILOS = WMENGE * ITAB-NTGEW.
            ITAB-LITRE = WMENGE * ITAB-VOLUM.
          ELSE.
            IF ITAB-MATNR <> 'WSTE13'.
              ITAB-EACH = 0.
              ITAB-KILOS = WMENGE.
              ITAB-LITRE = WMENGE * ITAB-VOLUM.
            ELSE.
              ITAB-EACH = WMENGE.
              ITAB-KILOS = 0.
              ITAB-LITRE = 0.
            ENDIF.
          ENDIF.
        ELSE.
          ITAB-EACH = WMENGE.
          ITAB-KILOS = 0.
          ITAB-LITRE = 0.
        ENDIF.
        MODIFY ITAB.
      ENDLOOP.
      After 50 minutes I can see the following warning message in the log file:
    18:20:34 Be 020 EKEKAKOS          BBB W ADM message TBX buffer: function ThAdmToMys returns RC = -1
    18:20:39 Be 020 EKEKAKOS          BBB W ADM message TBX buffer: function ThAdmToMys returns RC = -1
       This message is appearing 3 times in a minute. Also in details of this message you can see the followings:
    Time     TA Cl. User         Tcod MNo C Text                  Date : 14.12.06                      
    18:20:34 Be 020 EKEKAKOS          BBB W ADM message TBX buffer: function ThAdmToMys returns RC = -1                                                                               
    Details                                                                               
    Recording at local and central time........................ 14.12.2006 18:20:34                     
    Task................ 17692 Be Background processor No. 14                                           
    User................ EKEKAKOS                                                                       
    Client.............. 020                                                                            
    Terminal............                                                                               
    Session............. 1                                                                               
    Transaction code....                                                                               
    Program name........ ZMMSTOCKS_EK                                                                   
    Problem class....... W    Warning                                                                   
    Development class... SBAC Kernel Objekte                                                                               
    Module name.........                                                                               
    Line................ 1300                                                                           
    Table name.......... ThAdmToMys                                                                     
    Field name..........        -1                                                                               
    Documentation for system log message BB B :                                                         
    During the definition or processing of an ADM message in the                                       
    100%/generic table buffer an unexpected return code has occurred. The C                            
    function is specified in the error text.  In the coding an asynchronous                            
    call for replacement or reorganization is submitted at this point.  The                            
    functions concerned may be functions for packing and unpacking                                     
    parameters and for sending the ADM message.             ,                                                                               
    Technical details                                                                               
    File................ 000378                                                                         
    Position............ 0000494820                                                                     
    Entry type.......... h      ( Database error (non SQL)       )                                      
    Message ID.......... BB B                                                                           
    Variable parts...... ThAdmToMys       -1                                         1300                                                                               
    The version of our SAP is 4.0B and is running in UNIX Solaris and our database is Oracle 8.1.7.
      Can anyone suspects what is causing this message?
      Thanks in advance.

    It seems that this is a difficult problem. I think that the problem is in the SUBMIT statement which I use in order to take the stock of each material of each plant. I do not know I am still searching in the internet.
      Thanks

  • How do i Index on a Sub class

    Hi,
    Please let me know if there is a way to index on the vairable in a sub class.
    Thanks & regards,
    Ebe

    Hi Cameron,
    The design of the Object is as follows.
    Object
    --- getSubObjectList() - Returns SubObjectList
    ----- Contains the list of SubObject
    ---- SubObject Contains attributes which i query upon.
    Please let me know a way how to index on these attributs. Please find the code am using below
    Below is the extract method of my Extractor Class
    public final class ObjectGraphNavigationValueExtractor extends
    AbstractExtractor implements ValueExtractor, ExternalizableLite
    public Object extract(Object object) {
    if(this.path.equals("attr1") || this.path.equals("attr2")){
    MyObject obj =
    (MyObject)object;
    SubObjectList subList = (SubObjectList) obj.getSubObjectList();
    Object aoExtracted[] = subList.toArray();
    for(int i=0;i<aoExtracted.length;i++){
    SubObject objSubObject =
    (SubObject) aoExtracted;
    return new BeanWrapperImpl(SubObject).getPropertyValue(this.path);
    return new BeanWrapperImpl(object).getPropertyValue(this.path);
    I have applied index as follows.
    cache.addIndex(new ObjectGraphNavigationValueExtractor("attr1"),true,null);
    cache.addIndex(new ObjectGraphNavigationValueExtractor("attr2"),true,null);
    Regards,
    Ebe

  • Defining return values of the same class in interface implementations

    hello,
    i'm trying to update older code to java 1.5 using generics. i'm new to generics and i have a problem i cannot solve: assuming the interface
    public interface Stake
         public Stake makeACopyAndShift( long delta );
    }and the class
    public class BasicStake
          private final long pos;
          public BasicStake( long pos )
                 this.pos = pos;
          public Stake makeACopyAndShift( long delta )
                  return new BasicStake( pos + delta );
    }... and a container class Trail:
    public class Trail<S> {
           private final List<S> stakes = new ArrayList<S>();
           public Trail() {}
           public void add( S stake ) { stakes.add( stake ); }
           public S get( int index ) { return stakes.get( index ); }
           public void shiftAll( long delta )
                  final List<S> stakesNew = new ArrayList<S>( stakes.size() );
                  S orig, copy;
                  for( int i = 0; i < stakes.size(); i++ ) {
                          orig = stakes.get( i );
                          copy = (S) orig.makeCopyAndShift( delta );
                          stakesNew.add( copy );
                  stakes.clear();
                  stakes.addAll( stakesNew );
    so that i could do:
    Trail<BasicStake> t = new Trail<BasicStake>();etc.
    how do i manage to get rid of the warning
    "Type safety: The cast from Stake to S is actually checking against the erased type Stake"
    with casting to (S) in the for-loop in the shiftAll function? Obviously the problem is that in interface Stake the return type of makeCopyAndShift should not be Stake but "<SameClassAsMe>", so that in BasicStake the method would be
    public BasicStake makeCopyAndShift( long delta ) { ... }. how do i accomplish that?
    thanks a lot!
    ciao, -sciss-

    This seems to work just fine for me:
    public class Foo {
        public static void main(String[] args) {
            Trail<Stake> trail = new Trail<Stake>();
            trail.add(new BasicStake(1L));
            trail.add(new AnotherStake(1L));
            trail.shiftAll(10L);
    interface Stake {
         public Stake makeACopyAndShift(long delta);
    class BasicStake implements Stake {
        private final long pos;
        public BasicStake(long pos) {
            this.pos = pos;
        public Stake makeACopyAndShift(long delta) {
            return new BasicStake(pos+delta);
    class AnotherStake implements Stake {
        private final long pos;
        public AnotherStake(long pos) {
            this.pos = pos;
        public Stake makeACopyAndShift(long delta) {
            return new AnotherStake(pos*delta);
    class Trail<S extends Stake> {
        private final List<Stake> stakes;
        public Trail() { stakes = new ArrayList<Stake>(); }
        public void add(S stake) { stakes.add(stake); }
        public Stake get(int index) { return stakes.get(index); }
        public void shiftAll(long delta) {
            final List<Stake> stakesNew = new ArrayList<Stake>(stakes.size());
            for(int i = 0; i < stakes.size(); i++ ) {
                Stake orig = stakes.get(i);
                Stake copy = orig.makeACopyAndShift(delta);
                stakesNew.add(copy);
            stakes.clear();
            stakes.addAll(stakesNew);
    }

  • How can a sub class access exisiting stage item?

    i have a button on the stage. the document class loads two
    sub classes. how do you get the sub class to access/work with a
    stage item that is already on the display list?
    as3.0 is killing me!!! grrrr...
    thanks!

    The document class mapDC:
    package com.main{
    // this is the main document class for the rextag map
    appllication
    // import movie clip to extend to use on stage
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import com.main.tools.mapTools;
    public class mapDC extends MovieClip {
    // instance of class
    public function mapDC() {
    trace("MainMap initialized");
    new mapTools(stage);
    public function test() {
    trace("here at test");
    The mapTools Class:
    package com.main.tools{
    // import
    import flash.events.MouseEvent;
    import flash.display.*;
    // this class will contain all the move methods and
    functions
    public class mapTools {
    private var stage:Stage;
    function mapTools(targetStage) {
    trace("Map tools initialized");
    stage = targetStage;
    stage.root.mapSection.eastArrow.addEventListener(MouseEvent.ROLL_OVER,testOutput);
    //---------- test output function
    public function testOutput(evt:MouseEvent) {
    trace("worked");
    }

  • Pl/sql function body returning SQL query - Print function

    Hello all,
    I have pl/sql function body returning SQL query for my reports for my new project that I am developing. We dont have any BI tool or anything for APEX so we use Oracle reports to get the same reports to be printed in PDF format. I had been using SQL function for Reports all these days and grabbing the data using SQL query was easy in Oracle reports. But this time we had atleast 8 fields in search criteria and hence I thouhgt PL/sql function body returning SQL query could be something easy to handle that scenario. We have 11 such reports in our project. Now when we tried to use the same PL/sql function to oracle reports , I was told by one of our Oracle reports expert, that we have to write it into functions and use it in SQL query to get the Reports in Oracle reports. Is there any Easy way to convert the same Pl/SQL function or get a PDF format of the same report in APEX without going thru the much pains of rewriting the whole SQL Query.
    thank you
    Devisri

    Hi,
    give this a go.
    I can't test it as I don't have the tables in my schema.
    create or replace package MK_TEST_PF is
    -- Author  : MK
    -- Created : 21/06/2010 16:30:19
    -- Purpose : FOR LUCY_DISCOVER
    -- Public type declarations
    /*     -- just guess the table row types.....
         -- otherwise it won't compile
         type test_rec is record
              (INV REP.inv%type
              ,cNUMBER REP.cNUMBER%type
              ,OPENDATE REP.OPENDATE%type
              ,TARGETDATE REP.ESTCOMPLETE%type
              ,DATECLOSED REP.COMPLETED%type
              ,STATUS REP.STATUS%type
              ,cCODE REP.cCODE%type
              ,line varchar2(4000)
              ,SIGc varchar2(4000)
              ,CLASS REP.CLASS%type
              ,SUMM REP.SUMM%type
              ,AREA REP.AREA%type
         type test_rec is record
              (INV varchar2(4000)
              ,cNUMBER varchar2(4000)
              ,OPENDATE varchar2(4000)
              ,TARGETDATE varchar2(4000)
              ,DATECLOSED varchar2(4000)
              ,STATUS varchar2(4000)
              ,cCODE varchar2(4000)
              ,line varchar2(4000)
              ,SIGc varchar2(4000)
              ,CLASS varchar2(4000)
              ,SUMM varchar2(4000)
              ,AREA varchar2(4000)
         type test_tab is table of test_rec;
    -- Public constant declarations
    -- Public variable declarations
    -- Public function and procedure declarations
    end MK_TEST_PF;
    create or replace package body MK_TEST_PF is
    -- Private type declarations
    -- Private constant declarations
    -- Private variable declarations
    -- Function and procedure implementations
         function get_query_f
              (p_inv VARCHAR2 := UPPER(v('P44_INV'))
              ,p_reg VARCHAR2 := UPPER(v('P44_CLASS'))
              ,p_proarea VARCHAR2 := UPPER(v('P44_PROGRAM_AREA'))
              ,p_disp VARCHAR2 := UPPER(v('P44_DISPOSITION'))
              ,p_coding VARCHAR2 := UPPER(v('P44_CODING'))
              ,p_status VARCHAR2 := UPPER(v('P44_STATUS'))
              ,p_SIG VARCHAR2 := UPPER(v('P44_SIG_c'))
              ,p_inc_sum VARCHAR2 := UPPER(v('P44_INCLUDE_SUMM_FIELD'))
              ,p_word VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_timeframe VARCHAR2 := UPPER(v('P44_TIME_FRAME'))
              ,p_rec VARCHAR2 := UPPER(v('P44_RECORD_KEEPING'))
              ,p_WORD_IN_SUMM VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_ON_AFTER VARCHAR2 := UPPER(v('P44_ON_AFTER'))
              ,p_ON_BEFORE VARCHAR2 := UPPER(v('P44_ON_BEFORE'))
              return varchar2
         is
              v_sql VARCHAR2(5000);
         --     v_inv VARCHAR2(100);
         --     v_reg VARCHAR2(100);
         --     v_proarea VARCHAR2(100);
         --     v_status VARCHAR2(100);
         --     v_SIG VARCHAR2(100);
         --     v_disp VARCHAR2(100);
         --     v_coding VARCHAR2(100);
         --     v_inc_sum VARCHAR2(4);
         --     v_word VARCHAR2(4000);
              v_wildcard VARCHAR2(2000);
         --     v_timeframe VARCHAR2(100);
         --     v_rec VARCHAR2(5);
              v_record VARCHAR2(5);
              v_open VARCHAR2(100);
              v_closed VARCHAR2(100);
              v_PEND VARCHAR2(100);
              v_refSIG VARCHAR2(100);
              v_refreg VARCHAR2(100);
              v_refother VARCHAR2(100);
              v_y varchar2(100);
         BEGIN
              --v_inv := UPPER(v('P44_INV')) ;
              v_record := 'R%';
              v_wildcard := '%';
              v_open := 'OPEN';
              v_closed := 'CLOSED';
              v_PEND := 'PEND';
              v_refSIG := 'REF - SIG';
              v_refreg := 'REF - CLASS';
              v_refother := 'REF - OTHER';
              v_y := 'Y';
              v_sql := 'SELECT REP.INV as INV, REP.cNUMBER as cNUMBER, REP.OPENDATE as OPENDATE,
              REP.ESTCOMPLETE as TARGETDATE, REP.COMPLETED as DATECLOSED, REP.STATUS as STATUS,
              REP.cCODE as cCODE, apex_item.checkbox(1,REP.line,null,'''||v_y||''') line , apex_item.checkbox(1,REP.SIG,null,'''||v_y||''') SIGc ,
              REP.CLASS as CLASS, REP.SUMM as SUMM, REP.AREA as AREA from REP where 1=1';
              IF p_rec is not null then
                   IF p_rec = 'E' then
                        v_sql := v_sql|| ' and upper(REP.cnumber) not like '''||v_record||'''';
                   ELSIF p_rec = 'D' then
                        v_sql := v_sql|| ' and upper(REP.cnumber) like '''||v_record||'''';
                   ELSIF p_rec = 'I' then
                        v_sql := v_sql|| ' and REP.cnumber = REP.cnumber ';
                   end if ;
              end if ;
              IF upper(p_status) not like '%NULL%' then
                   IF upper(p_status) like '%OPEN%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_open||'''';
                   ELSIF upper(p_status) like '%CLOSED%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_closed||'''';
                   ELSIF upper(v_PEND) like '%PEND%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_PEND||'''';
                   ELSIF upper(v_refSIG) like '%REF - SIG%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_refSIG||'''';
                   ELSIF upper(v_refreg) like '%REF - CLASS%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_refreg||'''';
                   ELSIF upper(v_refother) like '%REF - OTHER%' then
                   v_sql := v_sql||' AND upper(REP.status) like '''||v_refother||'''';
                   END IF ;
              END IF ;
              IF p_inv = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.INV),'''||p_inv||''') > 0';
              END IF ;
              IF p_reg = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.CLASS),'''||p_reg||''') > 0';
              END IF ;
              IF p_proarea = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.AREA),'''||p_proarea||''') > 0';
              END IF ;
              IF p_disp = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.disposition),'''||p_disp||''') > 0';
              END IF ;
              IF p_coding = 'NULL' THEN
                   v_sql := v_sql||' AND instr(upper(REP.ccode),'''||p_coding||''') > 0';
              END IF ;
              IF p_SIG = ' ' THEN
                   v_sql := v_sql||' AND instr(upper(REP.SIG),'''||p_SIG||''') > 0';
              END IF ;
              IF p_word is not null then
                   v_sql := v_sql|| ' and
                   instr(upper(REP.SUMM),
                   upper(nvl('''||p_WORD_IN_SUMM||''',REP.SUMM))) > 0';
              end if ;
              If p_timeframe is not null then
                   if upper(p_timeframe) = 'OPEN' then
                   v_sql := v_sql|| ' and to_date(REP.opendate) between to_date ('''||p_ON_AFTER||''') and to_date('''||p_ON_BEFORE||''')';
                   elsif upper(p_timeframe) = 'CLOSED' then
                   v_sql := v_sql|| ' and to_date(REP.completed) between to_date ('''||p_ON_AFTER||''') and to_date('''||p_ON_BEFORE||''')';
                   elsif upper(p_timeframe) = 'EST' then
                   v_sql := v_sql|| ' and to_date(REP.estcomplete) between to_date ('''||p_ON_AFTER||''') and to_date('''||p_ON_BEFORE||''')';
                   end if;
              end if;
              v_sql := v_sql ||' order by REP.INV ';
              return v_sql;
         end get_query_f;
         function test_pf
              (p_inv VARCHAR2 := UPPER(v('P44_INV'))
              ,p_reg VARCHAR2 := UPPER(v('P44_CLASS'))
              ,p_proarea VARCHAR2 := UPPER(v('P44_PROGRAM_AREA'))
              ,p_disp VARCHAR2 := UPPER(v('P44_DISPOSITION'))
              ,p_coding VARCHAR2 := UPPER(v('P44_CODING'))
              ,p_status VARCHAR2 := UPPER(v('P44_STATUS'))
              ,p_SIG VARCHAR2 := UPPER(v('P44_SIG_c'))
              ,p_inc_sum VARCHAR2 := UPPER(v('P44_INCLUDE_SUMM_FIELD'))
              ,p_word VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_timeframe VARCHAR2 := UPPER(v('P44_TIME_FRAME'))
              ,p_rec VARCHAR2 := UPPER(v('P44_RECORD_KEEPING'))
              ,p_WORD_IN_SUMM VARCHAR2 := UPPER(v('P44_WORD_IN_SUMM'))
              ,p_ON_AFTER VARCHAR2 := UPPER(v('P44_ON_AFTER'))
              ,p_ON_BEFORE VARCHAR2 := UPPER(v('P44_ON_BEFORE'))
              RETURN test_tab PIPELINED
         is
              type test_c is ref cursor;
              v_row test_tab;
              v_sql varchar2(4000);
              v_cursor test_c;
         begin
              v_sql := get_query_f
                   (p_inv
                   ,p_reg
                   ,p_proarea
                   ,p_disp
                   ,p_coding
                   ,p_status
                   ,p_SIG
                   ,p_inc_sum
                   ,p_word
                   ,p_timeframe
                   ,p_rec
                   ,p_WORD_IN_SUMM
                   ,p_ON_AFTER
                   ,p_ON_BEFORE
              open v_cursor for v_sql;
              fetch v_cursor bulk collect into v_row;
              close v_cursor;
              for i in 1 .. v_row.count loop
                   pipe row (v_row(i));
              end loop;
              return;
         end test_pf;
    end MK_TEST_PF;
    /Regards
    Michael

  • Sub-class objects changing lovu2019s in XI 3.0

    Hello all,
    I have a XI 3.0 universe where I have several classes and sub-classes like this;
    Class1
    ....Subclass1
    .............Object 1
    .............Object 2
    .............Object 3
    ....Subclass2
    .............Object 4
    .............Object 5
    .............Object 6
    ...Subclass3
    .............Object 7
    .............Object 8
    .............Object 9
    Class2
    ....Subclass1b
    .............Object 10
    .............Object 11
    .............Object 12
    While updating the objects lovu2019s (for sorting) in the properties window, Iu2019ve noticed that beginning with Object 4 that the lovu2019s are changing back to that of Object 1, this is also the case for Object 5 (changes to Object 2u2019s lov) all the way through Object 12. It seems that no mater how often I set and apply the sorted lov for all objects, they take on the settings of the objects in the first sub-class in my universe. When querys are ran from WebIntelligence, they display the correct SQL (and return no results as there is no data in my dev database as yet). Objects in other classes (not sub-classes) seem to be fine. Has anyone seen this type of behavior before?
    Iu2019m thinking that I will need to go to 3.1 and suspect this may be a bug, any thoughts or comments are appreciated....

    Hi Didier,
    I did copy some some of the objects from a subclass to another, and to make sure this was not the issue, I re-created new ones and had the same issue.  I was not aware that previous BOE versions (LOVs) had the issue though, which makes some sense. 
    At the moment, I'm suspecting this is a bug so I am asking the client to upgrade to 3.1 to see if the issue persist (I suspect it may), if so I will then open up a tech support case.
    Thanks, Joe Szabo

  • Is there a function to check a list of characters in a string?

    is there a function to check a list of characters in a string?

    You need to create a vi. Find attached a vi that you can use. In the vi, if the number of match occurrence is zero, that indicates no match otherwise it will return the number of matches in the supply string. The vi is a modified version of Search String and Replace - General
    Attachments:
    Search_String_and_Count_Match.vi ‏17 KB

  • Conditional display using Pl/SQL function body returning a boolean

    I am having issues with conditional display of a report.
    I have to select lists: p50_facility and p50_supervisor.
    I have entered the below pl/sql function body returning a boolean
    Begin
    if (:p50_facility is null or
    :p50_supervisor is null) THEN
    Return False;
    Else
    Return True;
    End if;
    End;
    No matter what values my items are set to (null, not null), the report shows.
    What am I doing wrong?

    Hi,
    The values for the lists will be null only until the first time the page is submitted. Thereafter, the value is likely to be '%null%'
    You will need to do something like:
    BEGIN
    IF (:P50_FACILITY IS NULL OR :P50_FACILITY = '%' || 'null%' OR :P50_SUPERVISOR IS NULL OR :P50_SUPERVISOR = '%' || 'null%') THEN
      RETURN FALSE;
    ELSE
      RETURN TRUE;
    END IF;
    END;Andy

Maybe you are looking for