Getter method for Generic type in BinarySearchTree

Hi, I had to write an implementation of a BinarySearchTree for an assignment.
I have the two classes, one 'BinarySearchTree' which basicly just points to the root, and the node that does most of the work:
public class BinaryNode<K extends Comparable<K>,V>
     public K _key;
     public V _val;
     private BinaryNode _left;
     private BinaryNode _right;
     public V getVal() //getter
          return _val;
}In my BinarySearchTree class I use this getter method like so:
V nodeValue;
nodeValue = (V) oldNode.getVal();The thing I don't understand is why I have to cast the value returned? If I don't it won't compile!
It is working fine as is, but my lecturer is always saying to avoid casts.
Thanks,
Austin.

Your BinaryNode class looks OK.
Could you post a small piece of code I can compile and run and results in the compile error you described? (Don't post the entire thing!)
Thanks.

Similar Messages

  • Oracle.jbo.AttrValException: JBO-27019: Get method for attribute

    Hi Guys,
    I am trying to add a new column to Oracle quoting.It has already been customized by some consultant few years back. I followed the note 392728.1 on metalink and also have the documentation by the previous consultant but getting the error oracle.jbo.AttrValException: JBO-27019: Get method for attribute Draft in HeaderVO could not be resolved after adding my column, when I try to print the quote.
    Here are the steps I took
    1) added a column to the query (at the end) in HeaderVO.xml
    2) added the below code in the HeaderVO.xml
    <ViewAttribute
    Name="DRAFT"
    IsQueriable="false"
    IsPersistent="false"
    Precision="100"
    Type="java.lang.String"
    AliasName="DRAFT"
    ColumnType="VARCHAR2"
    Expression="DRAFT"
    SQLType="VARCHAR" >
    <DesignTime>
    <Attr Name="_DisplaySize" Value="100" />
    </DesignTime>
    </ViewAttribute>
    3). Modify HeaderVORowImpl.java file to add setters and getters for the newly added view attribute. For example,
    a) case 67: //
    setDRAFT((String)obj);
    return;
    b) case 67:
    return getDRAFT();
    c) ublic void setDRAFT(String s)
    setAttributeInternal(67, s);
    public String getDRAFT()
    return (String)getAttributeInternal(67);
    d) protected static final int DRAFT = 67;
    Everything is dont exactly as per the manual but not sure why I am getting this issue. Any help will be appreciated.

    a) case 67: //
    setDraft((String)obj);
    return;
    b) case 67:
    return getDraft();
    c)public void setDraft(String s){
    setAttributeInternal(67, s);
    public String getDraft(){
    return (String)getAttributeInternal(67);
    d) protected static final int DRAFT = 67;
    can u change it as explained above.. setDRAFT should be setDraft.. and getDRAFT should be getDraft..
    and make sure that the index.. number is exactly matching with the attribute order in the VO

  • No getter method for property user of bean Problem

    Hi everyone,
    I am new to this struts. I have a samll application to check login. When I run my application I get this message in my server console
    No getter method for property user of bean org.apache.struts.taglib.html.BEAN
    I saw the previous forum for the same topic. I have checked my property names start with appropriate cases. Here is my code
    %@ page language="java" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html>
    <head><title>Login</title></head>
    <body>
    <html:form action="submit.do">
    <table width="100%" border="0" height=75%>
    <tr>
    <td align="right" >UserName: </td>
    <td><html:text property="user"/></td>
    <tr>
    <tr>
    <td align="right" >Password: </td>
    <td><html:text property="password"/></td>
    </tr>
    <tr>
    <td colspan=2 align="center"><html:submit/></td>
    </tr>
    <tr>
    <td colspan=2 align="center"><html:errors/></td>
    </tr>
    </table>
    </html:form>
    </body>
    </html>
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.*;
    import java.util.*;
    * @author skannan
    * To change this generated comment edit the template variable "typecomment":
    * Window>Preferences>Java>Templates.
    * To enable and disable the creation of type comments go to
    * Window>Preferences>Java>Code Generation.
    public class LoginForm extends ActionForm
    private String user = null;
    private String password = null;
    /* user */
    public String getUser()
    return (this.user);
    public void setUser(String user)
    this.user = user;
    /* password */
    public String getPassword()
    return (this.password);
    public void setPassword(String password)
    this.password = password;
    public ActionErrors validate(ActionMapping mapping,
    HttpServletRequest request) {
    // Log the forms data
    servlet.log("Lastname:" + user);
    servlet.log("Address:" + password);
    // Check for mandatory data
    ActionErrors errors = new ActionErrors();
    if (user == null || user.equals("")) {
    errors.add("User", new ActionError("error.user"));
    if (password == null || password.equals("")) {
    errors.add("Password", new ActionError("error.password"));
    return errors;
    I am missing anything in my config files. Please I need help.
    Thanks!

    I did check my struts-config file
    Here is the part of my file
    <!-- ========== Form Bean Definitions ================= -->
    <form-beans>
    <form-bean name="loginForm"
    type="kannan.struts.trailer.checkin.LoginForm"/>
    <form-bean name="checkInForm"
    type="kannan.struts.trailer.checkin.CheckInForm"/>
    </form-beans>
    <!-- ========== Action Mapping Definitions ============ -->
    <action-mappings>
    <action path="/submit"
    type="kannan.struts.trailer.checkin.LoginAction"
    name="loginForm"
    input="/login.jsp"
    scope="request">
    <forward name="success" path="/checkIn.jsp"/>
    <forward name="failure" path="/login.jsp"/>
    </action>
    Still I am getting the error

  • **URGENT** No getter method for property searchText of bean org.apache.stru

    I'm implementing a query page as described in the HowTo ADF_ComplexMasterDetail.zip
    When running the query page, I'm receiving the error:
    javax.servlet.jsp.JspException: No getter method for property searchText of bean org.apache.struts.taglib.html.BEAN
    I have my searchEmployees writen and 'exposed' (at least I can see it in the Data palette). But seems like something is missing, and can't find this searchText beam property specified in the html:text tag.
    Can someone help in this one?
    Here is the Help description inside the HowTo example:
    Section 3
    queryEmployees
    queryEmployeesInDept provides an interface for entering a simple search criteria for querying a list of
    employees. This does not use the Find mode Query By Example functionality that the other query screens
    use, but rather presents a much simpler search interface. The actual search is carried out using a
    function
    searchEmployees that the underlying view object exposes. (See the EmployeesView view object in the
    model project)
    1. Drop a new Data Page onto the page flow diagram call it queryEmployees
    2. In the page flow diagram, drag the searchEmployees operation from the AllEmployeesView
    collection in the Data Control Palette and drop it on top of the new Data Page. This will cause the
    framework to run a search whenever the page is called.
    3. In the Structure pane, locate the queryEmployees node and expand it, select the child node
    paramNames[0], and change it's value attribute to ${param.searchText}. This will pass the URL
    parameter searchText on to the business method to qualify the query.
    4. Drill down into the page and expand the Data Control Palette to select the AllEmployeesView
    collection. Set the Drag and Drop as: list to Read-OnlyTable. Then drag the collection onto the page.
    This will create a tabular containing the query results.
    5. Select the Struts HTML component palette and drag a Form onto the page above the output table. Set
    the handling action to this Data Page (queryEmployees.do)
    6. Drag a text field from the component palette inside of this new form. Set the property attribute of
    the
    <html:text> tag to searchText (the same value you used in the paramNames[0] for the Data Page)
    7. Create a new submit button in the form to submit the search. Set the property attribute of the button
    to
    event_search.
    8. Finally we need to subclass the data page to prevent the search action from being fired when it is not
    appropriate for the page ( for instance when we first display it). To do this we need to Go to Code on
    the Data Page's context menu, and override the invokeCustomMethod() method:
    * We only want to invoke the custom method i.e. the call to change
    * the Where clause on the collection, if the Action has been called with
    * a search event on the page with a search term supplied.
    * If the user got here via a link or another event, we bypass the model call
    * unless a URL parameter event=search is supplied, in which
    * case the method will also be called.
    protected void invokeCustomMethod(DataActionContext actionContext)
    List events = actionContext.getEvents();
    // If the event is "search" do the custom event call
    if ((events != null) && (events.contains("search")))
    String searchTerm = (String)((DynaActionForm)actionContext.getActionForm())
    Get("searchText");
    if (searchTerm != null)
    super.invokeCustomMethod(actionContext);
    }

    Solved with Oracle JDeveloper HowTo:
    Creating Search Pages with Both Fixed and Dynamic Criteria
    Author: Steve Muench, Oracle ADF Development Team
    Date: September 16, 2004
    http://www.oracle.com/technology/products/jdev/howtos/10g/dynamiccrit/index.html

  • [svn:fx-trunk] 10891: Fix for ASDoc throws error when using getter methods for pseudo-inheritance of static constants

    Revision: 10891
    Author:   [email protected]
    Date:     2009-10-06 09:46:47 -0700 (Tue, 06 Oct 2009)
    Log Message:
    Fix for ASDoc throws error when using getter methods for pseudo-inheritance of static constants
    QE notes: None.
    Doc notes: None
    Bugs: SDK-22676
    Tests run: checkintests
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-22676
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocUtil.java

    Have you tried using com.adobe.air.crypto.EncryptionKeyGenerator instead?

  • Visual Mapping for Generic Type

    I have generic message type:
    -Row (Occurences 1..unbounded)
    --Field (Occurences 1..unbounded)
    I want to use this type for all csv files(with different amount of fileds). But how can I map this type on my own type in Visual Mapping? Is it possible?
    For example:
      <row>
        <field>111</field>
        <field>222</field>
      </row>
    Result MT:
       <user>
         <name>111</name>
         <number>222</number>
       </user>
    Message was edited by: Sergey A

    Hi Sergey,
    This is possible in message mapping using user defined functions but needs lot of hardcoding in the code interms of position of the each field i.e
    In your message queues the <field>111</field> will be in  position1 and <field>222</field> in position2. so simply map content of position1  <name>111</name> and content of position2 to <number>222</number>. Simple java code in user defined function can do this.
    But there is risk involved since the mapping is position based all the fields in the source must exist(at least blank value).
    consider input message with 3 fields
    <row>
    <field>111</field>
    <field>222</field>
    <field>333</field>
    </row>
    and target
    <user>
    <name>111</name>
    <number>222</number>
    <number>333</number>
    </user>
    If suppose your second field <field>222</field> does'nt exist then in your message queue <field>333</field> will move to second position henece your mapping might get messed up and fail.
    Regards
    Anand

  • Accounting documents not getting generated for mvt. type 221 Q

    Hi friends,
    When goods are issued for consumption for project accounting documents are not getting generated.
    I have tried with mvt. type 412 Q, 211 Q,
    by mvt type 412 Q, the stock is transfered to project stock, it shows the stock of material in project stock, by movement type 211 Q the project stock gets consumed. So at the time of consumption of consumption account should hit and relevent accounting document should get generated. this is not happenning.
    When i check material document and check for accounting document, message flashses that movement is not rrelevent for accounting.
    Can any one throw more light on this?
    Thanks and regards
    SAP MM

    Hi,
    Please check in PO item details Delivery tab. In that GR Non-valuated checkbox might be checked.Generally for account assignment category asset it is ticked.
    If you tick GR non-valuated check box then at the time of GR accounting document will not be created.Accounting document will be created only at the time of IR.
    or
    Have you mantained Chart of accounts.
    have you mantained Valuation area settings
    Transaction event key
    Valuation class settings.
    Check your material master data in accounting view have mantained Valuation class.
    Check your back ground settings OMWN.

  • Problem referencing to methods with generic type parameters

    Assuming I have an interface like to following:
    public interface Test <T> {
    void test ( T arg0 );
    void test ( T arg0, Object arg1 );
    I would like to reference to both "test"-methods using "{@link #test(T)}" and "{@link #test(T,Object)}".But this generates an error telling me "test(T)" and "test(T,Object)" cannot be found.
    Changing T to Object in the documentation works and has as interesing effect. The generated link text is "test(Object)" but the generated link is "test(T)".
    Am I somehow wrong? Or is this a known issue? And is there a workaround other than using "Object" instead of "T"?

    Hi,
    I bumped into the same problem when documenting a generic.
    After quite a while of search your posting led me to the solution.
    My code goes something like this:
    public class SomeIterator<E> implements Iterator<E> {
      public SomeIterator(E[] structToIterate) {
    }When I tried to use @see or @link with the constructor Javadoc never found it.
    After I changed the documentation code to
    @see #SomeIterator(Object[])it worked.
    Since both taglets offer the use of a label, one can easily use these to produce comments that look correct:
    @see #SomeIterator(Object[]) SomeIterator(E[])CU
    Froestel

  • Problem LSMW + IDOC method for message type : MATMAS

    hi friends,
      I am using LSMW + IDOC method Message : MATMAS , idoc type : MATMAS03 .Setting every thing are fine. Finally Material is not created with error "message have been issued number : <idoc number>".
    data : material, industry type, material type, description, Basic unit of mesure.
    Please  help me.
    Balaji.T.

    Hi,
    I have nothing found regarding your issue. But maybe a look at SAP note 638058 will give you a hint.
    Regards,
    Klaus

  • How get the correct generic type from Class.forName()?

    I have:
    public class Test2 {
        void foo() throws ClassNotFoundException {
            Class<Test2> c = Class.forName("Test2");
    }Of course, this doesn't compile:
    javac -Xlint Test2.java
    Test2.java:4: incompatible types
    found   : java.lang.Class<capture#965 of ?>
    required: java.lang.Class<Test2>
            Class<Test2> c = Class.forName("Test2");Other than casting to Class and suppressing the unchecked warning, how can I get the code to do what I think should be a common use case? I try
    public class Test2 {
        void foo() throws ClassNotFoundException {
            Class<Test2> c = Class.forName("Test2").asSubclass(Test2.class);
    }Which doesn't compile either:
    javac -Xlint Test2.java
    Test2.java:4: incompatible types
    found   : java.lang.Class<capture#400 of ? extends Test2>
    required: java.lang.Class<Test2>
            Class<Test2> c = Class.forName("Test2").asSubclass(Test2.class);Not sure I understand what the javac error is about.
    Help!

    kinmanc wrote:
    This is just a simplified version of what I had. The name of the class being loaded is unknown at compile time, though it is known to implement an interface. Isn't this a common use case?Yes, its' quite common.

  • Query to get summary for two types of row data

    Hi Friends,
    I have tried using aggregate functions and thought of using analytic functions and still trying... But I am sure some analytic function expert can quickly help me out in this.
    With this data.
    BID_ELMT_SEQ_ID     PRF_NO          BID_REQ_DT          BID_ATRB_TYP_CD          BID_ATRB_VAL
    3575758          1          1/24/2011 2:27:32 PM     MINDAYS               1
    3575758          1          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
    3575759          2          1/24/2011 2:27:32 PM     MINDAYS               1
    3575759          2          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
    3575760          3          1/24/2011 2:27:32 PM     MINDAYS               1
    3575760          3          1/24/2011 2:27:32 PM     WRAPDAYS          1-0
    3575761          4          1/24/2011 2:27:32 PM     MINDAYS               1
    3575761          4          1/24/2011 2:27:32 PM     WRAPDAYS          1-0 Is it possible to retrieve an output similar to this ? In short , the row values of BID_ATRB_TYP_CD to be grouped into two columns and values fetched for this
    BID_ELMT_SEQ_ID     PRF_NO          BID_REQ_DT          MIN_DAYS_VAL     WRAP_DAYS_VAL
    3575758          1          1/24/2011 14:27          1          1-0
    3575759          2          1/24/2011 14:27          1          1-0
    3575760          3          1/24/2011 14:27          1          1-0
    3575761          4          1/24/2011 14:27          1          1-0 Regards,
    SSN

    Looks pretty simple to me - I haven't tried it yet.
    Can you share what you have tried so far and what has been the outcome of that effort?

  • Movement Type 261 - Different G/L account to get debited for same Movement

    Hi Friends,
    I need your help to solve the following issue
    We are in the process of implementing ECC 6.00. One of our client requirement is for Movement type 261 , different consumption account to get debited for different types of issues. i.e. incase of MT 261 issue for maintenance order the consumption account should hit to Maintenance G/L and incase of MT 261 issue for production order different  consumption account to get debited.
    I think One way to meet this requirement is by creating new Movement type by copying MT261 and assigning new Account Grouping to that MT and assigning GL in GBB against the new account grouping.
    I would like to know is there any other way to meet this requirement in SAP.
    Request you earliest advise on this issue as we are in the stage of final integration test
    Thanks
    Deva

    Dear
    If the solution works fine please do let me know in detail as we have the same requirement.
    Thanks and Regards
    JS

  • Help with efficiency for insert/get methods?

    I am not an expert when it comes to run times and I am wondering what the most efficient data structures would be for a program I am making. I need to:
    Go through a large document in which each line is formatted as: (String Integer), and add the string & integer to some sort of data structure. The list of string/integers is large and I need to be able to access the information in the data structure efficiently. Right now I am using a scanner to read the doc and a TreeMap<String, Integer> to store the info. The get method for the TreeMap is fine, but processing the document is a little slow.
    What do you think? TreeMap, hashing, balanced search tree? Remember, the insert and get methods are the two that need to be most efficient.

    Why are you using a TreeMap? Is the order of iteration important to you?
    If not, then you can probably get better performance using a HashMap, properly configured. The TreeMap has O(n) performance for get/put. while HashMap has constant-time performance. If you properly configure the initialCapacity and loadFactor for the HashMap you can get very efficient puts by reducing the number of re-hashes that are needed during map-growth. Note that if you retrieve the data from the Map using an iterator (rather than just calling get()) then you have to be more careful with these settings because they affect the total number of buckets - which can affect the speed of iteration.
    You should also run your code through a profiler. Are you sure that the put() operation is the slow step when reading from the file? It may be that your file access is really the slow step, and so modifying the data structure would have little or no effect. You might consider different methods for accessing the file data, perhaps something from thew NIO package would help speed things up (I am not particularly sure though - I am not very familiar with NIO).

  • [ANN] Java IDE with generic type support

    Hello all!
    We are proud to announce that we have just released version 5.0 of our Java IDE CodeGuide.
    CodeGuide 5.0 offers full support for generic types as defined in JSR 14. Features are:
    - Fast incremental on-the-fly compilation
    - On-the-fly error checking of the whole project
    - Code completion
    - Usage search
    - Refactoring (like Renaming, Class moving, etc.)
    - and more...
    A 30-day trial can be downloaded from our web page at
    http://www.omnicore.com
    Any feedback regarding JSR 14 support is much appreciated.
    Best regards,
    Dennis Strein
    Omnicore Software

    I wrote a class MultiMap<K, V> extends Map<K, Set<V>>
        // Various constructors, methods, fields.
        public Set<V> get(K key)
            // Implementation
    } It compiles fine with the Sun reference compiler, but a friend tells me that CodeGuide 5.0 build 504 complains "There already is another method with the same erasure." It could be that CodeGuide is correct and Sun wrong, because I can see that there might be issues with overriding the get(Object) method with a get(K), but I thought I'd mention it.

  • MVC Problem with getter method of table attribute in model class

    Hi,
    I am on 620 SP34. I am writing a bsp application with mvc. One of the model classes has an attribute of type table. I use this attribute in a htmlb-tableview and '//MODEL/ZMY_TAB' for data binding. If I try to activate a getter method for this attribute, the application dumps with exception <i>BSP exception: Structure component with name "ZMY_TAB" does not exist</i>. I find the SAP source, that raising this exception (see below). The source code looks like: <i>"I don't support getter methods for tables in attribute path"</i>! The setter method works fine, so I am at a loss. Has anyone of you wrote a getter method for an table attribute in bsp-mvc? Have I to consider anything special?
    Thanks,
    Carsten
    Main Program CL_BSP_MODEL==================CP
    Source code of CL_BSP_MODEL==================CM00Z
    METHOD IF_BSP_MODEL_BINDING~GET_ATTRIBUTE_DATA_REF
           * check if attribute exists for binding!                                   
             if exists_attribute( l_name ) is initial.                                
               return.                                                                
             endif.                                                                               
    * setter or getter defined? Not supported for DATA REF requests            
             if get_getter( attribute_name = l_name ) is not initial.                 
               raise exception type cx_bsp_inv_component                              
                 exporting name = l_name.                                             
             endif.                                                   

    You have two options:
    1. Make your attributes public. It should work fine.
    2. If you need to process the attribute values before it is used, you can make the attribute private but will need three methods
    GET_T_ZMY_TAB that returns the table
    SET_T_ZMY_TAB that sets the values
    GET_M_T_ZMY_TAB that returns DDIC information about the attribute. The same holds good for structures(Change to GET_S_ and GET_M_S_ ) and simple attributes(Change to GET_ and GET_M_).
    The set and get methods are kind of documented at http://help.sap.com/saphelp_nw04/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/content.htm but there is no mention of the GET_M_ methods. I could not find one single document on the Model part MVC.
    Once I added the GET_M_XYZ methods to my attributes, my BSPs started to work fine.
    Cheers
    Sreekanth

Maybe you are looking for

  • Error while uploading a LOGO into SAP by using SE78

    Hi All we are not able to uplaod a LOGO into DEV200 but the same LOGO is successfully uploaded into DEV215. When we tried in DEV200 it is giving the error "ERROR LOADING FILE <PATH>". As a Basis/ Security consultant I checked: 1) Authorizations 2) Cl

  • MacBook Air 2013 with Windows 8.1 installed with Bootcamp

    Hello , I have a fairly new 2013 MBA 8g , 128ssd, i5 and I installed windows 8.1 with Parallels 9 but it was eating my battery life so so fast and I really didn't like the Parallels experience. I uninstalled and wiped my MBA to factory settings to ge

  • Chinese Character

    I am a new user of Blackberry 8300, actually the handheld was a gift from my colleague which she bought in Europe, I have chosen the mobile/internet service from Hutchison 3 company for both mobile phone and e-mail connection, everything is working p

  • Can't complete setup after setting wi fi

    Hello, I'm new to apple products and we just got a new Ipad2 from the institution. I was setting the thing up but when I got to the wi fi connection part I connected to a wireless network here (our wireless network is not very good but it managed to

  • Possibility of same document number in tables BSAD and BSID

    Hi I want to know the possibility of existence of same document number in the tables BSAD and BSID. If it is possible, in which case the same document number exist both in BSAD and BSID.