How to use methods when objects stored in a linked list?

Hi friend:
I stored a series of objects of certain class inside a linked list. When I get one of them out of the list, I want to use the instance method associated with this object. However, the complier only allow me to treat this object as general object, ( of Object Class), as a result I can't use instance methods which are associated with this object. Can someone tell me how to use the methods associated with the objects which are stored inside a linked list?
Here is my code:
import java.util.*;
public class QueueW
     LinkedList qList;
     public QueueW(Collection s) //Constructor of QuequW Class
          qList = new LinkedList(s); //Declare an object linked list
     public void addWaiting(WaitingList w)
     boolean result = qList.isEmpty(); //true if list contains no elements
          if (result)
          qList.addFirst(w);
          else
          qList.add(w);
     public int printCid()
     Object d = qList.getFirst(); // the complier doesn't allow me to treat d as a object of waitingList class
          int n = d.getCid(); // so I use "Object d"
     return n; // yet object can't use getCid() method, so I got error in "int n = d.getCid()"
     public void removeWaiting(WaitingList w)
     qList.removeFirst();
class WaitingList
int cusmNo;
String cusmName;
int cid;
private static int id_count = 0;
     /* constructor */
     public WaitingList(int c, String cN)
     cusmNo = c;
     cusmName = cN;
     cid = ++id_count;
     public int getCid() //this is the method I want to use
     return cid;

Use casting. In other words, cat the object taken from the collection to the correct type and call your method.
   HashMap map = /* ... */;
   map.put(someKey, myObject);
   ((MyClass)(map.get(someKey)).myMethod();Chuck

Similar Messages

  • How to use method find(Object pk) in java EE 5

    I've just started programming in java ee and netbeans and I do have some startup problems. I'm going to access a database using persistence entity classes. My task is to fetch the lastname of a user in a table called User and present it in the webbrowser.
    Can anyone see any errors? It always presents Fetch from database: John
    Seems like it won't get anything from the UserTestFacade find method. Is this the right way to use it?
    Here is the code for the servlet that is going to present the info:
    public class RegisterServlet extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String str = initDB();
    String title = "Fetch from database: ";
    out.println("<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1>" + title + str + "</H1>\n" +
    "</BODY></HTML>");
    out.close();
    public String initDB()
         String str = "John";
         try { 
    UserTestFacade u = new UserTestFacade();
    UserTest us = u.find(new String("Tom"));
    str = us.getLastname();
    } // end try
    catch ( Exception e ) {
         e.printStackTrace();
    finally {
         return str;
    Here is some of the code for the sessionbean UserTestFacade:
    @Stateless
    public class UserTestFacade implements UserTestFacadeLocal, UserTestFacadeRemote {
    @PersistenceContext
    private EntityManager em;
    /** Creates a new instance of UserTestFacade */
    public UserTestFacade() {
    public void create(UserTest userTest) {
    em.persist(userTest);
    public UserTest find(String username) {
    return (UserTest) em.find(UserTest.class, username);
    Here is the code for the entityclass UserTest
    public class UserTest implements Serializable {
    @Id
    @Column(name = "Username", nullable = false)
    private String username;
    @Column(name = "Firstname", nullable = false)
    private String firstname;
    @Column(name = "Lastname", nullable = false)
    private String lastname;
    public UserTest(String username) {
    this.username = username;
    public UserTest(String username, String firstname, String lastname) {
    this.username = username;
    this.firstname = firstname;
    this.lastname = lastname;
    public String getUsername() {
    return this.username;
    }

    Hi,
    Till now this question is not answered.........
    Any Answer around this deeply apprciated.
    Edited by: DoraiRaj on Sep 29, 2009 3:55 AM

  • How to Use Transient View Objects to Store Session-level Global Variables

    hi
    Please consider section "40.8.5 How to Use Transient View Objects to Store Session-level Global Variables"
    at http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcstatemgmt.htm#ADFFD19610
    Based on this documentation I created the example application
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.01.zip
    It behaves as show in the screencast at http://screencast.com/t/qDvSQCgpvYdd
    Its Application Module has a Transient View Object instance "MyEmployeesContextVOVI", as master for the child View Object instance "EmpInCtxJobVI".
    On rollback the Transient View Object instance keeps its row and attribute values.
    Also when passivation and activation is forced (using jbo.ampool.doampooling=false ) the Transient View Object instance seems to keep its row and attribute values.
    questions:
    - (q1) Why does the expression #{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty} evaluate as true when a Transient View Object instance attribute value is changed (as shown in screencast at http://screencast.com/t/qDvSQCgpvYdd )?
    - (q2) What would be a robust approach to make a Transient View Object instance more self-contained, and manage itself to have only one single row (per instance) at all times (and as such removing the dependency on the Application Module prepareSession() as documented in "5. Create an empty row in the view object when a new user begins using the application module.")?
    many thanks
    Jan Vervecken

    Thanks for your reply Frank.
    q1) Does sample 90 help ? http://blogs.oracle.com/smuenchadf/examples/
    Yes, the sample from Steve Muench does help, "90. Avoiding Dirtying the ADF Model Transaction When Transient Attributes are Set [10.1.3] "
    at http://blogs.oracle.com/smuenchadf/examples/#90
    It does point out a difference in marking transactions dirty by different layers of the framework, "... When any attribute's value is changed through an ADFM binding, the ADFM-layer transaction is marked as dirty. ...".
    This can be illustrate with a small change in the example application
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.02.zip
    It now shows the result of both these expressions on the page ...
    #{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty}
    #{bindings.MyEmployeesContextVOVIIterator.dataControl.dataProvider.transaction.dirty}... where one can be true and the other false respectively.
    See also the screencast at http://screencast.com/t/k8vgNqdKgD
    Similar to the sample from Steve Muench, another modification to the example application introduces MyCustomADFBCDataControl
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.03.zip
    public class MyCustomADFBCDataControl
      extends JUApplication
      @Override
      public void setTransactionModified()
        ApplicationModule vApplicationModule = (ApplicationModule)getDataProvider();
        Transaction vTransaction = vApplicationModule.getTransaction();
        if (vTransaction.isDirty())
          super.setTransactionModified();
    }Resulting in what seems to be more consistent/expected transaction (dirty) information,
    see also the screencast at http://screencast.com/t/756yCs1L1
    Any feedback on why the ADF Model layer is so eager to mark a transaction dirty is always welcome.
    Currently, question (q2) remains.
    regards
    Jan

  • What is the use for lock object and how to use the lock objects

    Hi Guru's,
    I am new to ABAP .Can you please clarify the that what is the use of lock object and how to use the loct object .what is use of the Deque & Enque  function modules .

    hi ,
    below are some minfo about lock objects :
      Lock Objects
    These types of objects are used for locking the access to database records in table. This mechanism is used to enforce data integrity that is two users cannot update the same data at the same time. With lock objects you can lock table-field or whole table.
    In a system where many users can access the same data, it becomes necessary to control the access to the data. In R/3 system this access control is built-in on database tables. Developers can also lock objects over table records.
    To lock an object you need to call standard functions, which are automatically generated while defining the lock object in ABAP/4 dictionary. This locking system is independent of the locking mechanism used by the R/3 system. This mechanism also defines LUW i.e. Logical Unit of Work. Whenever an object is locked, either by in built locking mechanism or by function modules, it creates corresponding entry in global system table i.e. table is locked. The system automatically releases the lock at the end of transaction. The LUW starts when a lock entry is created in the system table and ends when the lock is released.
    Creating Lock Objects
    Lock object is an aggregated dictionary object and can be defined by using the following steps:
    o From initial data dictionary screen, enter the name for the object, Click Lock object radiobutton and then click on Create. The system displays a dialog box for Maintain Lock Objects screen
    o Enter short text as usual and the name for primary table.
    -Save
    -Select Tables option
    From this screen you can:
    Select secondary tables, if any, linked by foreign key relationship.
    Fields for the lock objects. This option allows you to select fields for objects (R/3 system allows locking up to record level). Lock object argument are not selected by user but are imposed by the system and includes all the primary keys for the table.
    1) Exclusive lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.
    2) Shared lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.
    3) Exclusive but not cumulative: Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.
    Also, last but not the least, locking the object is logical (locking with any enqueue ) .so, you have to use the lock object while trying to access from second program .
    reward if helpful ,
    Regards,
    Ranjita

  • How to use order by in stored procedure base block?

    How to use order by in stored procedure base block? I need to change order by dynamically

    Use SET_BLOCK_PROPERTY('BLOCK_NAME',ORDER_BY,'COLUMN_NAME1, COLUMN_NAME2');

  • How to use case when function to calculate time ?

    Dear All,
    May i know how to use case when function to calculate the time ?
    for the example , if the First_EP_scan_time is 12.30,  then must minus 30 min.  
    CASE WHEN FIRSTSCAN.EP_SHIFT <> 'R1' AND FIRSTSCAN.EP_SHIFT <> 'R2'
    THEN ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF((CASE WHEN SHIFTCAL.EP_SHIFT = 'N1'
    THEN CONVERT(VARCHAR(8),DATEADD(DAY,+1,LEFT(FIRSTSCAN.EP_SCAN_DATE ,8)),112) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','')
    ELSE LEFT(FIRSTSCAN.EP_SCAN_DATE ,8) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','') END),12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0 - 0.25) AS FLOAT),2)
    ELSE ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF(FIRSTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0) AS FLOAT),2) END AS OTWORK_HOUR

    Do not use computations in a declarative language.  This is SQL and not COBOL.
    Use a table of time slots set to one more decimal second of precision than your data. You can now use temporal math to add it to a DATE to TIME(1) get a full DATETIME2(0). Here is the basic skeleton. 
    CREATE TABLE Timeslots
    (slot_start_time TIME(1) NOT NULL PRIMARY KEY,
     slot_end_time TIME(1) NOT NULL,
     CHECK (start_time < end_time));
    INSERT INTO Timeslots  --15 min intervals 
    VALUES ('00:00:00.0', '00:14:59.9'),
    ('00:15:00.0', '00:29:59.9'),
    ('00:30:00.0', '00:44:59.9'),
    ('00:45:00.0', '01:00:59.9'), 
    ('23:45:00.0', '23:59:59.9'); 
    Here is the basic query for rounding down to a time slot. 
    SELECT CAST (@in_timestamp AS DATE), T.start_time
      FROM Timeslots AS T
     WHERE CAST (@in_timestamp AS TIME)
           BETWEEN T.slot_start_time 
               AND T.slot_end_time;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to use C:when test... inside column in ADF table

    I am using ADF table with below two columns
    in First column i have to check the Type of document if it is doc type then i have to use commondlink to download that file ,Otherwise i need to show only text.
    for that i added
    *<c:when test="{boolean($favoriteType eq 'doc')}">*
    which is not working .
    please let me know how to use <C:when test... inside column in ADF table
    <tr:column sortProperty="favoriteName" sortable="true"
    headerText="#{res['favorite.favoritename']}"
    width="500" noWrap="false">
    <c:choose>
    *<c:when test="{boolean($favoriteType eq 'doc')}">*
    <tr:commandLink actionListener="#{bindings.downloadFile.execute}"
    text="#{row.favoriteName}"
    disabled="#{!bindings.downloadFile.enabled}"/>
    </c:when>
    <c:otherwise>
    <af:outputText value="#{row.favoriteName}"/>
    </c:otherwise>
    </c:choose>
    </tr:column>
    <tr:column sortProperty="favoriteType" sortable="true"
    headerText="#{res['favorite.favoriteType']}" rendered="true">
    <af:outputText value="#{row.favoriteType}" id="favoriteType"/>
    </tr:column>

    Hi Frank,
    Thanks it is working like cham..
    related to same page i am facing new problem which i posted at below thread
    How to get row data runtime @ trinidad table , set rowSelection="multiple"
    can u reply on same.
    Thanks for all help.
    Jaydeep

  • ** How to use TO_DATE function in Stored Proc. for JDBC in ABAP-XSL mapping

    Hi friends,
    I use ABAP-XSL mapping to insert records in Oracle table. My Sender is File and receiver is JDBC. We use Oracle 10g database. All fields in table are VARCHAR2 except one field; this is having type 'DATE'.
    I use Stored procedure to update the records in table. I have converted my string into date using the Oracle TO_DATE function. But, when I use this format, it throws an error in the Receiver CC. (But, the message is processed successfully in SXMB_MONI).
    The input format I formed like below:
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">
    Value in Payload is like below.
    <X_EMP_START_DT hasQuot="No" isInput="1" type="DATE">TO_DATE('18-11-1991','DD-MM-YYYY')</X_EMP_START_DT>
    Error in CC comes as below:
    Error processing request in sax parser: Error when executing statement for table/stored proc. 'SP_EMP_DETAILS' (structure 'STATEMENT'): java.lang.NumberFormatException: For input string: "TO_DATE('18"
    Friends, I have tried, but unable to find the correct solution to insert.
    Kindly help me to solve this issue.
    Kind Regards,
    Jegathees P.
    (But, the same is working fine if we use direct method in ABAP-XSL ie. not thru Stored Procedure)

    Hi Sinha,
    Thanks for your reply.
    I used the syntax
    <xsl:call-template name="date:format-date">
       <xsl:with-param name="date-time" select="string" />
       <xsl:with-param name="pattern" select="string" />
    </xsl:call-template>
    in my Abap XSL.  But, its not working correctly. The problem is 'href' function to import "date.xsl" in my XSLT is not able to do that. The system throws an error. Moreover, it is not able to write the command 'extension-element-prefixes' in my <xsl:stylesheet namespace>
    May be I am not able to understand how to use this.
    Anyway, I solved this problem by handling date conversion inside Oracle Stored Procedure. Now, its working fine.
    Thank you.

  • How to use @jws:sql call Stored Procedure from Workshop

    Is there anyone know how to use @jws tag call Sybase stored procedure within
    Workshop,
    Thanks,

    Anurag,
    Do you know is there any plan to add this feature in future release? and
    when?
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    In the current release, we do not support calling stored procedures from a
    database control. You will have to write JDBC code in the JWS file to call
    stored procedures.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Anurag,
    I know how to use DB connection pool and create a db control with it. In
    fact, we have created a Web Service with the db control using plain SQL
    in
    @jws:sql. However, my question here is how to use @jws tag in Weblogic
    Workshop to create a Web Services based on Sybase stored procedure orany
    Stored Proc not plain SQL.
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    You can use a database control to obtain a connection from any JDBC
    Connection Pool configured in the config.xml file. The JDBC Connectionpool
    could be connecting to any database, the database control is
    independent
    of
    that.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Is there anyone know how to use @jws tag call Sybase stored
    procedure
    within
    Workshop,
    Thanks,

  • How to use method setXSLT

    Hi All!
    how I can use method setXSLT from OracleXMLQuery class
    when I try:
    java.lang.NoClassDefFoundError: oracle/xdb/XMLType
         oracle.xml.sql.query.OracleXMLQuery.setXSLT(OracleXMLQuery.java:747)
    code:
    xmlQuery = new OracleXMLQuery(this.mainDbConn.getConn(),sql);
    xmlQuery.setXSLT("/[path]/[name].xsl","");

    Specify stylesheet as a URI.
    xmlQuery.setXSLT("file://c:/util.xslt");this don't work :(

  • Could someone explain how to use of the object Thermometer?

    Hi to all,
    please, could someone write a real example explaining how to use the thermometer in order to indicate the progress of a process like to submit a document?
    I need to do it exactly to indicate this process in Adobe Reader.
    Thanks.
    Dan

    Sorry but I surely have explained my problem badly. I understand how to use the object thermometer perfectly.
    I need to use this object in order to determine the progress of the document's transference when I submit a PDF form from Adobe Reader.
    I'm having problems when I try to do this, and I would like to know if there exists some way to do it.
    b I have tried the following:
    var t = app.thermometer;
    t.duration = 1000;
    // How can I know this value?
    t.begin();
    t.text = "Please wait";
    // Is this a madness?
    while( event.target.submitForm( { cURL: [...], cSubmitAs: [...] } ) )
       t.value++;
    t.end();
    Thank you for your time
    Dan

  • How to use method of Standard Class

    Hi all,
                  I want to call a pop up in pcui screen in some standard application with some text. I have made Zclass of  standard SAP class which i am using (cl_bsp_accmod_contact in CRM system).
    I think i have to call 'PRINT_STRING' method of  standard class CL_BSP_ELEMENT.
    <i>I am trying to use this code: </i>
    <b>
    data: lr_data type ref to cl_bsp_element.
      concatenate html 'rohit' into html.  (html is a string)
      lr_data->print_string( html ).</b>
    <u>but it gives a dump:</u>
    You attempted to use a 'NULL' object reference (points to 'noth
    access a component (variable: "lr_data").
    An object reference must point to an object (an instance of a class)
    before it can be used to access components.
    I dont know how to assign object reference to an object???
    Plz help me in this regard,
    Thanks in advance,
    Rohit

    Hi ,
    try and use :
    data: lr_data type ref to cl_bsp_element.
    concatenate html 'rohit' into html. (html is a string)
    lr_data->print_string( html = html ).
    You are creating a variable...but not passing the value to the parameter...it is exactly like callin get_data or get_cell_value...!!
    Hope this helps.
    <i><b>Do reward each useful answer.</b></i>
    Thanks,
    Tatvagna.

  • How to use CRM authorization object.

    Hi All,
    I have a specific requirement to restrict user while he/she tries to save a record. It appears that if that restrictions are implemented the save logic for an entity has to be changed because there are some validation regarding relationship management in SAP system. SO I need to bypass that validation to allow some users of specific(Marketting) role to save the entity record bypassing that validation. here I am planning to use the CRM authorization objects. But dont know how to use these and which authorization object to refer.
    Please let me know if you guys have any idea.
    Regards,
    Bikramjit.

    Hi Bikramjit.,
    You might need to create a Custom authorization object and then use it. Else you can create one Z table and maintain the User ID of all users. The mainatin one field with flag and set it to X for the user that are aloowed to save the transaction.
    Also once you maintain the table, generate the table maintenance so that it becomes easier for future use.
    Hope this helps

  • How to use the ViewRowImpl objects in JSP?

    Is there anyway for me to use the ViewRowImpl objects in the JSP (so I could call the set<attribute> methods and get<attribute> methods to retrieve the attributes? Right now I am retrieving all the information I need in the application tier from the database, marshal them myself, and then return the marshaled data back to the JSP side in the presentation tier, then demarshal the data, and finally interpret the demarshaled data. I did this because I want to return everything in one single remote method call, and I know this is really ugly, but I do not know of any other way for me to retrieve all information needed by a JSP page in one single method call. Any suggestions?

    I've done this in servlets.
    I created an application module (with an ic.lookup() call, see the documentation) and then used the appModule to create my view.
    Once you've got that you can iterate through rows and use the accessor methods.
    You might need a wrapper method to get the ViewObjectImpl in your jsp...

  • How to use a Graphics Object in a JSP?

    Hello, I do not know if this is a good or a silly question. Can anyone tell me if we can use a Graphics object in a JSP. For example to draw a line or other graphics, i am planning to use the JSP. Any help is much appreciated.
    Regards,
    Navin Pathuru.

    Hi Rob or Jennifer, could you pour some light here.
    I have not done a lot of research for this, but what i want to do is below the polygon i would like to display another image object like a chart... is it possible? If so how to do it? Any help is much appreciated.
    here is the code:
    <%
    // Create image
    int width=200, height=200;
    BufferedImage image = new BufferedImage(width,
    height, BufferedImage.TYPE_INT_RGB);
    // Get drawing context
    Graphics g = image.getGraphics();
    // Fill background
    g.setColor(Color.white);
    g.fillRect(0, 0, width, height);
    // Create random polygon
    Polygon poly = new Polygon();
    Random random = new Random();
    for (int i=0; i < 5; i++) {
    poly.addPoint(random.nextInt(width),
    random.nextInt(height));
    // Fill polygon
    g.setColor(Color.cyan);
    g.fillPolygon(poly);
    // Dispose context
    g.dispose();
    // Send back image
    ServletOutputStream sos = response.getOutputStream();
    JPEGImageEncoder encoder =
    JPEGCodec.createJPEGEncoder(sos);
    encoder.encode(image);
    %>
    Regards,
    Navin Pathuru

Maybe you are looking for