Hashtable- how to retrieve key for a particular value?

I fetched few values from the database and stored all them using hashtable. Then i check for the value entered by the user in a textbox using contains() method of hashtable. Now i want to fetch the key associated to this particular value so that i can pass it to my rest of the program?
Pls help me....

The obvious question is what are you using as your key when you store the value into your hashtable?? The idea behind the key/value system is that you use the key to get the value you want, not the other way around. In your current situation, the contains() method might return true, but that could you mean you have 1, or 1000 instances of that value in your hashtable. Which key do you want? You could, I suppose, parse through the output of Hashtable.toString()... but that still wouldn't resolve the possibility of duplicate values in the hash.
Another possible solution to your problem, depending on how your application works, is to wait until you get that user input before running your database query. Simply append the added info onto your SQL SELECT statement to accurate retrieve only those entries from the database that you will need.

Similar Messages

  • How to retrieve metadata for a particular revision ?

    How do I get a specified revision metadata (information), assuming it has revisions?
    I have found no single word about the subject in the development guide.
    However, Javadoc contains some phrazes about this.
    There's a group of methods that can get a metadata "by given name of by revision ID" :
    getDocumentInformationByName(ISCSContext, ISCSContentID) - Method in interface com.stellent.cis.client.api.scs.document.information.ISCSDocumentInformationAPI
    Retrieve the metadata information for the document identified by the given name or by revision ID.
    I don't have an idea where do i place revision number parameter. Interface for ISCSContentID dosn't have contain methods for revision selection.
    Maybe somebody solved this problem?

    Do you need to do it in Java code? If not, just use the OOTB service "DOC_INFO" and pass in the dDocName and dID. The dID will specify the exact revision of your document. This particular service will redirect to a web page, so it may not be what you need exactly, but you can easily create your own by copying that service in the Component Wizard and removing the redirect at the end.

  • How to get keys of a particular type

    Following are my objects:
    DepartmentKey - primary key is departmentName, a String
    Department
    EmployeeKey - primary key is employeeId, an integer
    Employee
    I have 5 DepartmentKey-Department key-value entries in a cache and 2000 EmployeeKey-Employee key-value entries in the same cache.
    How do I get all the DepartmentKeys from the cache? In general, how to get keys of a particular type (class name)?
    Thanks
    Ghanshyam

    I guess I am deeply off track regarding the general approach towards storing items in the cache.
    Following is my problem domain:
    A Merchant is any establishment that accepts credit cards. (It could be the local Subway down the street or Macy's, etc.). A Transaction is a credit card transaction.
    public class Merchant implements Serializable{
    private String merchantId; // primary key
    private double averageTxnAmount;
    private double totalTxnAmount;
    private long totalTxnCount;
    public class Transaction implements Serializable{
    private String merchantId; // merchant that originated the txn
    private double amount;
    private Timestamp txnTime;
    private String txnType; // sale, return, etc.
    public class MerchantKey implements Serializable, KeyAssociation{
    private String merchantId;
    public Object getAssociatedKey{
    return merchantId;
    public class TransactionKey implements Serializable, KeyAssociation{
    private String merchantId;
    private Timestamp txnTime;
    private double amount;
    public Object getAssociatedKey{
    return merchantId;
    I want to update a merchant's average txn amount as transactions come in.
    Let's say I have a million merchants in a partitioned cache cluster spread across some machines.
    Transactions come into the cluster quite rapidly, say tens in a second. The process that inserts the transaction into the cluster must also update the merchant to which the transaction belongs, as follows:
    Transaction t = ...
    cache.put(tKey, t); // store the transaction into the cache
    MerchantKey mKey = new MerchantKey(txn.getMerchantId());
    Merchant m = (Merchant)cache.get(mKey);
    // update the merchant's avg txn amt
    m.setAverageTxnAmount((txn.getAmount() + m.getTotalTxnAmount())/m.getTotalTxnCount() + 1);
    m.setTotalCount(m.getTotalCount() + 1);
    // store the updated merchant back into cache
    cache.put(mKey, m);
    OR
    Transaction t = ...
    cache.put(tKey, t); // store the transaction into the cache
    MerchantKey mKey = new MerchantKey(txn.getMerchantId());
    Merchant m = (Merchant)cache.get(mKey);
    MerchantUpdater agent = new MerchantUpdater(t);
    cache.invoke(mKey, agent);
    public class MerchantUpdater implements AbstractProcessor{
    public Object process(Entry entry){
    Merchant m = (Merchant)entry.getValue();
    // update m's avg txn amt, total count using t
    entry.setValue(m);
    The basic idea is to store all merchants and all transactions (which could be tens of millions in a day) for a day in memory and to update the merchant objects as transactions come in throughout the day. The above example shows updating just the merchant's average txn amount, but in reality, it could be updating a number of things about the merchant.
    Am I using the api in the right spirit or is my approach seriously whacked? Can you please comment?
    Thanks
    Ghanshyam

  • How to provide hyperlink for a particular field in ALV

    Hi,
      How to provide hyperlink for a particular field in alv report.
    Regards,
    Ramu.

    Yes you can do that. using the fieldcatalog there is an option for that. give HOT_SPOT = 'X'. for the column you want.
    wa_field-hotspot = 'X'.
    REPORT  ztest_alv.
    TYPE-POOLS:slis.
    DATA:it_fieldcat  TYPE  slis_t_fieldcat_alv,
         wa_field LIKE LINE OF it_fieldcat.
    DATA: BEGIN OF it_likp OCCURS 0,
           vbeln TYPE likp-vbeln,
          END OF it_likp.
    DATA: layout TYPE slis_layout_alv.
    wa_field-fieldname = 'VBELN'.
    wa_field-tabname = 'IT_LIKP'.
    wa_field-hotspot = 'X'.
    wa_field-outputlen = 10.
    wa_field-no_zero = 'X'.
    wa_field-seltext_l = 'Sales'.
    APPEND wa_field TO it_fieldcat.
    SELECT vbeln FROM likp
    UP TO 10 ROWS
    INTO TABLE it_likp.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program      = sy-repid
        is_layout               = layout
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat             = it_fieldcat
      TABLES
        t_outtab                = it_likp
      EXCEPTIONS
        program_error           = 1.
    *&      Form  user_Command
    *       text
    *      -->UCOMM      text
    *      -->SELFIELD   text
    FORM user_command USING ucomm TYPE sy-ucomm
                        selfield TYPE slis_selfield.
      CASE ucomm.
        WHEN '&IC1'.
          SET PARAMETER ID 'VL'  FIELD selfield-value.
          CALL TRANSACTION 'VL02N' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "user_Command

  • How to give comments for a particular table

    hi..
    how to give comments for a particular table ..
    select * from user_tab_comments;
    tx in advance..

    Try this.
    SQL> COMMENT ON TABLE EMP IS 'THIS IS SAMPLE EMPLOYEE TABLE' ;
    Comment created.
    SQL> select * from user_tab_comments where table_name = 'EMP'
      2  /
    TABLE_NAME                     TABLE_TYPE
    COMMENTS
    EMP                            TABLE
    THIS IS SAMPLE EMPLOYEE TABLE

  • How to disable cache for a particular Report in obiee 10g?

    HI
    My name is Rani .Learning obiee10g ifaced 1 interview in that they asked me like how u disable cache for a particular report?

    In the advanced tab of the report, under prefix you need to mention:
    SET VARIABLE DISABLE_CACHE_HIT=1;
    Refer below link
    http://tipsonobiee.blogspot.com/2009/06/step-by-step-to-bypass-all-caches.html
    Thanks

  • How to generate keys for the records

    Hi Gurus,
          can anybody explain me how to create keys for the recors while working with keymapping.
    Regards
    Ravikumar

    Hi Yugandher,
    Is your Question pertaining to Key generation in MDM or using the Remote key for importing and syndication in MDM?
    Remote Keys are system specific uniques maintained in MDM while importing source records from different source system.You need to Enable key mapping in Console and then map the <Remote key> field to the unique key in Import manager and do similar mapping in syndicator as well.
    You can view the key mapping for differnt records under the Edit key mapping (context menu) right clicking on any record.
    To know more on this refer the below link:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7051c376-f939-2b10-7da1-c4f8f9eecc8c  (Key mapping) 
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30843106-5539-2b10-75a9-da483911b0d9  (Key mapping)
    For Key generation in MDM you can use the Qualified range property of Remote system in Console for Key genearation.However these keys will be genearted only after syndication and are created and assigned within MDM and not maintained from any source remote system.
    Hope It Helped
    Thanks & Regards
    Simona Pinto

  • How do I search for a particular song on iTunes ?

    How do I search for a particular song on itunes - it used to be easy to go to search but that function seems to have disappeared

    The search function is still very much there, upper right corner of the iTunes Window.

  • How do i search a textfile for a particular value?

    How do i search a textfile for a particular value?
    I have made the records etc, six fields per record, i would like to find a value which is typed into the search textbox, find the record in the textfile and display the record in the boxes used to enter the data.
    SO HOW WOULD I SEARCH A TEXTFILE?
    Thanks very much for your help, Antony (UK)...

    If it were me, I'd use Lucene. Each line could be a separate document, and each field would be a field in Lucene. That would provide you one of the fastest and most flexible ways to do what you want.
    Or did you mean you want someone to complete your homework assignment? :-)

  • Query not executing for one particular value

    Hi
    I have query on multi provider. and this multi provider is combination of Info objects only but not any ODS or cubes. I have one key figure in this multi provider.while executing the query i need to give input for variabl which has 7 different values. Query is executing fine for 6 values but not for one particular value.
    query executed in listcube transaction and it is executed fine here for the same selection. then what might be the reason?
    Please advise as soon as possible.
    Thanks

    Hi Kiran,
    are you maintaining any filters in the query? or is there any logic in the exit for this variable.
    regards.

  • How to retrieve start and end date values from sharepoint 2013

    Hi,
    How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
    Thanks
    Gowri Balaguru

    Hi Srini
    Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
    Thanks
    Tripple k

  • Stop a dimensional drill for a particular value of a column in obiee 11g

    Hi,
    I have dimensional drill been setup for Supervisor Hierarchy Table.I need to stop the dimensional drill for a particular value of the column in obiee 11g.
    Example: I have two columns
    1.Supervisor Level 1 Name
    2.Supervisor Level 2 Name
    Supervisor Level 1 Name Columns have these values.(Ram,Higher,Sam)
    Supervisor Level 2 Name Columns have these values.(Ravi,Higher,Raghul).
    If we pull Supervisor Level 1 Name Column in report which has a dimensional drill(It will navigate to Supervisor Level 2 Name).It will show
    1.Ram
    2.Higher
    3.Sam
    I should not drill on Higher value but the rest of the values(Sam and Ram will drill to Supervisor Level 2 Name) should be drillable.The same should happen for Supervisor Level 2 Name.
    Please Suggest.
    Thanks,
    Azim

    Azim,
    Don't think you can actually get this working

  • How to find Primary Key for a particular SAP Databse Table?

    Hi Guys,
                  How to find Primary Key and foreign key  for Particular SAP Databse table ?for Ex : EKKO , EKPO , EKKN , EKBE , EKBEH  , EKET and EKETH.
    Thanks,
    Srinivas.

    Use transaction SE11 to display the table. Put the cursor on the field you want to display the check table and click 'Foreign key' push button (a key with an bottom point arrow), then it will show the check table of the foreign of a field.
    Or by just simple double click on the field, a pop-up window of all the attribute (including the foreign key and the check table if exists) will show too.
    <i><b>Please reward point for helpful answer.</b></i>
    Minami

  • How to retrieve DELTA for Particular date for FIGL(ECC) into BI

    Hi,
    Model of this ODS is in BW3.5.  (DS --> ODS --> Infocube)
    My loads are daily from 0FI_GL_4 (line Items) into ODS. There was from error in the load, so I deleted the request (manage & and made QM status RED in monitor also) from ODS and also from PSA for a particular date(xx.xx.xxxx).
    Now I tried loading the Infopackage, but the data is not coming for that date (xx.xx.xxxx) into ODS.
    I have set to DELTA REPEAT in RSA7(ECC) , but after saving, it is again coming back to DELTA UPDATE.
    All the Previous and Next day load was fine,but i did not get the data for xx.xx.xxxx.
    In Selection screen for DS and Infopackage does not have 0CALDAY or 0PSTNG_DATE.
    Can you please help me out in telling how to get the data for that particular date (xx.xx.xxxx) into BI.
    DOES REPAIR FULL REQUEST SOLVE MY PROBLEM?
    Full Points will be assigned.
    Regards,
    Bindu.

    Hi Viren,
    Initially I have tried what you have said, but ERROR is coming as AS YOUR PREVIOUS DELTA IS INCORRECT, YOU CANNOT LOAD THIS DELTA. I am not getting any option of REPEAT DELTA.
    "I have set to DELTA REPEAT in RSA7(ECC) , but after saving, it is again coming back to DELTA UPDATE."
    As I am not getting REPEAT DELTA, to get that I tried saving the 0FI_GL_4 as DELTA REPEAT in RSA7 (ECC).
    Please let me know any more information required.
    Thanks,
    Bindu.

  • How can I search for a particular color in an image?

    Hi,
       I am working on images of colored balls.
    I want to search for the particular color (of the ball) and select them .
    How can I do it?
    Your suggestions will be helpful.
    Thanks
    dsk

    Hi Dsk, 
                   you can apply color threshold and extract the required color in the image. Try color threshold in vision assistant.
                  see  here
    Thanks as kudos only

Maybe you are looking for