Key probelm w. Generic EnumMap -- How to replace a value with unknown key?

Hi, i have a problem that i want to replace an value of an key/value pair, but I dont have the approiate key for that, to avoid passing the key throug all methods, I just implemented
a method in the delegate class.
public K getFirstAssociatedKey(BilanzObjekt bo){
           Set<K> keys = this.container.keySet();
           for(K key: keys){
               V value = this.container.get(key);
               if (bo == value){                    
                    return key;
           return null;
     }It works, but I can't use the retrieved key for a put-statement, cause the satic type comparision seems to fail. Even the key is retrieved from the original, the compilier is unable to validate that the key is in the approiate Enum, so it refuses the operation.
In my special case I can avoid this by returning the value to the calling mehod inside the delegate, but that can't be the solution for all cases. Even If i would pass the key-vaue through all methods, the universial declaraction of ? extends Enum<?> would raise the same problem, that the compiler can't verify if the given key ist part of the Enum of the current EnumMap.
Cause i still not an expert dfor generics, I might have overseen an solution.
So is there any way to retrieve valid keys for the put-method at runtime without declaring a specilized subtype? Using rawtypes would supress compiler-errors, but that isn't the way what Generics intends. I allready have some lager Enums and some subsuets with EnumSet. But this solution isn't absolutly clean, cause you have to use the EnumSet to Iterate over the map and can't use keySet() anymore (Without special preparations for the values not contained in the EnumSet). Also I don't want to limit the code to only one type of Enum. So I my looking for another solution.
Is there hoepfully any easy and gernerally solution to that problem?
Thanks a lot in advance.
Greetings Michael

Hi, I redesigned my programm a little bit by returning the Objeckt which should be replaced to the delegate, but this causes the problem that I know that it is the exact type, cause the previous value had the same type before, but I can't replace it as long I don't except a fixed type for the value-parameter of the EnumMap.
The workaround which worked with keys via Map.Entry, cause I didn't replaced them, don't work here.
I found a solution which works for me (after the redisign mentioned above), even it is quite dirty., cause it moves the error detection form compiletime to runtime. But to gain more flexibilty, i prefer this. The else clause is just to find some programming faults as early as possible. I was quite suprised that the cast to V is legal, but the put -method will throw a ClassCastEcxception if it is not. So its a trade off betwenn flexibility and early error detection. I'm sure that should not used widely, but is a soluion or workaround for my problem.
/* dirty cast */
V new_v = (V) old.getReplacingValue();
                    if ( new_v != null){
                              /* If the both instance are of the same base class, this operation is safe,
                               * Cause if the previous value was ok, then the new value must be also OK!
                               * This should be the default case.*/
                         if(new_v.getClass().getName().equals( old.getClass().getName()) ){                         
                                     this.container.put(key,  new_v);                         
                           }else{
                         /* Otherwise a class-cast exception is most likely,
                          * but should normally not reached, if replacing methods are always returning the most specialized type and are overwritten in all subtypes.  */
                             try{
                              this.container.put(key,  eBoNew);
                              }catch(ClassCastException cce){
                              cce.printStackTrace();
               }Greetings Michael

Similar Messages

  • How to replace NULL values from main table

    Dear all,
    I like to remove the NULL values from a main table field. Or the question is how to replace any part of the string field in MDM repository main table field.
    e.g.   I have a middle name field partly the value is NULL in some hundreds of records, I like to replace NULL values with Space
    any recommendation.
    Regards,
    Naeem

    Hi Naeem,
    You can try using Workflows for automatically replacing NULLs with any specific value.
    What you can do is: Create a workflow and set trigger action as Record Import, Record Create and Record Update. So, that whenever any change will occur in the repository; that workflow will trigger.
    Now create an assignment expression for replacing NULLs with any specific value and use that assignment expression in your workflow by using Assign Step in workflow.
    For exiting records, you will have to replace NULLs manually using the process given by Preethi else you can export those records in an Excel spreadsheet which have NULLs and then replace all NULLs with any string value and then reimport those records in your MDM repository.
    Hope this will solve your problem.
    Regards,
    Varun
    Edited by: Varun Agarwal on Dec 2, 2008 3:12 PM

  • How to Replace Null Value as 0 in an OBIEE11g Pivot Table? it's working 10g

    Hi,
    How to Replace Null Value as 0 in an OBIEE11g Pivot Table? it's working in obiee10g version.
    We have tried below methods
    1) criteria tab and edit the ‘column properties’ associated with your fact measure. Choose the ‘Data Format’ tab, tick to override the default format and choose ‘Custom’.
    It seems that the syntax for this custom format is positive-value-mask (semi colon) negative-value-mask (semi colon) null-mask. So this means we have a few options.
    E.g. if you want zeros (0) instead of null then enter:
    #,##0;-#,##0;0
    2) in that formula columns we have put it below case condition also ,
    Measure Column: Nom_amt --> edit formulas
    CASE WHEN Nom_amt IS NULL THEN 0 ELSE Nom_amt END
    3) we have uncheked IS NULL check box in the admin tool also
    I tried above formats still it's not working for me..kindly help me on this..
    thanks to do the needfull
    Best Regards,
    R.Devarasu

    Hi,
    Null value in database displaying as 0 in report, I need to keep value as in database, and I have one calculated row which is based on null values should also null in report.
    but it showing 0 for null values also so, my calculated row showing wrong result.
    my report is like
    col1 col2
    ABC 0
    BCD 12
    DEF -12 --this is calculated row.
    I require result like:
    col1 col2
    ABC null
    BCD 12
    DEF null --this is calculated row.
    Please let me know how I can achieve this.
    Thanks,
    Rahul

  • How to Replace Null Value as 0 in an OBIEE11g Pivot Table?

    Hi,
    How to Replace Null Value as 0 in an OBIEE11g Pivot Table? it's working in obiee10g version.
    We have tried below methods
    1) criteria tab and edit the ‘column properties’ associated with your fact measure. Choose the ‘Data Format’ tab, tick to override the default format and choose ‘Custom’.
    It seems that the syntax for this custom format is positive-value-mask (semi colon) negative-value-mask (semi colon) null-mask. So this means we have a few options.
    E.g. if you want zeros (0) instead of null then enter:
    #,##0;-#,##0;0
    2) in that formula columns we have put it below case condition also ,
    Measure Column: Nom_amt --> edit formulas
    CASE WHEN Nom_amt IS NULL THEN 0 ELSE Nom_amt END
    3) we have uncheked IS NULL check box in the admin tool also
    I tried above formats still it's not working for me..kindly help me on this..
    thanks in advance...
    Best Regards,
    R.Devarasu

    Hi Amith,
    I have update your suggested one,but it's working few of the rows only..remainings rows some of cells still NULL only
    Measure colmns is : Nom_SGD
    IFNULL(Nom_SGD,0.00)
    Movment : dynamic date calc by using $2-$1 oracle formula's
    Actually i am doing below things only,
    31/12/2011 31/03/2011 Movment
    Country
    India 100 -50 -150
    Singapore 200 200
    UK 1200 -1200
    USA 0.00 0.00 0.00 (here changed null as 0)
    Helpmeon this...

  • How to replace a movieclip with another movieclip

    How to replace a movieclip with another movieclip
    Hi,
    I am having a swf called tchild.swf... in this i got a
    movclip 'child1'. i am loading this tchild.swf into another swf
    tparent.swf within 'mcloader' movie clip.. i got another movclip
    called 'picture1'
    i am loading tchild.swf into mcloader movclip.. and i want to
    load 'child1' moviclip into picture1..
    how to replace a picture1 movieclip with child1 mc..
    PS: i dont want to load picture1 from library.. its on the
    stage.

    AWT or Swing?

  • How to replace double quotes with a single quote in a string ?

    Hi All:
    Can some one tell me how to replace double Quote (") in a string with a single quote (') ? I tried to use REPLACE function, but I couldn;t get it worked.
    My example is SELECT REPLACE('STN. "A"', '"', ''') FROM Dual --This one throws an error
    Thanks,
    Dima.

    Whether it is maybe not the more comfortable way, I like the quoting capabitlity from 10g :
    SQL> SELECT REPLACE('STN. "A"', '"', q'(')') FROM Dual;
    REPLACE(
    STN. 'A'{code}
    Nicoals.                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to replace one variable with another in large number of queries

    Hello guys!
    I have this situation: our company needs to use one variable instead of another for certain amount of queries.
    Is there some way to automatically replace one variable with another for a certain characteristic in big number of queries ( like 150 - 200 ) ? Doing this manually would take lots of time)
    Apreciate your help!

    you could try (at your own risk) the following:
    1. search the technical id (ELTUID) of your variable in table RSZELTDIR
    2. see where this variable is used in table RSZELTXREF (by filling RSZELTDIR-ELTUIID in RSZELTXREF-TELTUID)
    3. add similar entries for your new variable
    4. delete the entries for the old variable (they're part of the key, so you can't simply "change" them)

  • How to replace the '&' character with '&' in xi

    Hi,
    i need to replace the '&' character with ' &amp;'.but i f i am converting it is displaying as '&' because internally '&amp;' = '&'.
    beacuse of this it is not converting.
    is there any possiblity to change the  standard conversion in xi.

    Graphical mapping does not support special character like & , <,> to be mapped.
    You can encode & as and in UTF-8 only.
    if you want the special character to be used, Opt XSLT mapping with ISO-8859-1 encoding
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="ISO-8859-1"/>
    <xsl:template match="/">
    <xsl:copy-of select="*" />
    </xsl:template>
    </xsl:stylesheet>
    How to Work with Character Encodings in Process Integration (NW7.0)
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42

  • How to replace westell 6100 with westell 327w?

    Hi all,
    I am currently using a Westell 6100 and I just inherited a Westell 327W from my brother who switched over to FIOS.
    Can I replace the 6100 with the 327W? And how do I go about doing that?
    Any suggestions or recommendations would be greatly appreciated.
    Cheers!

    If the 327w has newer firmware on it, you can just factory reset it and then connect it up. Once it is online, visit http://192.168.1.1/ and use admin/password respectively as the login information. Then, set a new password for the gateway.
    Once done, visit http://192.168.1.1/verizon/redirect.htm and choose the disable button. Assuming the modem has been able to get a connection at this time, you should be online.
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

  • How to replace SAP logo with customer logo

    Hi Gurus,
    How  to replace or insert a customer logo when creating input schdules EvDRE function.
    Cheers,
    Reddy.

    Reddy,
      You  shld  be  able  to copy and  paste  your  logo (after deleting  the  SAP  logo). ..as you  would  do  in  regular  excel.  If sometimes  it doesn't  work...use the   insert  picture  functionality......regular  excel/MS  way.
    Hope  this  helps.
    Vishal.

  • How can I replace column value with a particular value in SQL

    Hi All,
    Can anyone please tell me how can I format my output with replacing a column value with a specific value which actually depends on the present value of the column
    I am executing the following SQL statement
    select state,count(id) from <table_name> where composite_dn= <composite_dn_name> group by state;
    My Present output is:
    State No.Of Instance
    1 3
    3 28
    I want to replace the value in the column state as follows
    State No.OfInstances
    Completed 3
    Faulted 28
    I want "1" to be reppaced by "Completed" and "3" to be replaced by "Faulted"
    Is is possible with SQL or PL/SQL , if it is then how can I achieve this required result. Please help!!
    Thanks in Advance!!
    Edited by: Roshni Shankar on Oct 27, 2012 12:38 AM

    Hi Roshni,
    I guess this CASE clause can be simulated by a DECODE and also it is very easy to use.
    Refer -- http://www.techonthenet.com/oracle/functions/decode.php
    select decode(t1.state,t2.state_id,t2.state_name), t1.count_id
    from <table_2> t2, (select state,count(id) count_id
    from <table_name>
    where composite_dn= <composite_dn_name>
    group by state) t1
    where t1.state = t2.state_id;HTH
    Ranit B.
    Edited by: ranit B on Oct 27, 2012 2:02 PM
    -- link added
    Edited by: ranit B on Oct 27, 2012 2:19 PM
    -- sample code added

  • How to replace an MDB with a servlet

    I got a situation to replace an MDB with a servlet,How can I do that,more appreciated if u send me some sample code.

    Hi,
    An MDB can be replaced by a normal java class by doing the following.
    Make a jndi lookup for the queue/topic connection factory and then create a javax.jms.QueueConnection. Then create a javax.jms.QueueSession using this connection. Make a JNDI look up for the Queue. Create a javax.jms.QueueReceiver using the created QueueSession. Call start on the QueueConnection and receive a message by calling the receive method on QueueReceiver.
    Thanks,
    marvlex

  • How to replace one char with two chars in email address policy?

    I very much like to replace the 'ß' char in the surname with 'sz'. However, applying filter '%rßsz%[email protected]' on 'Preußig' leaves me with '[email protected]'.
    So, how do I replace one char with two chars in email address policy?

    As far as I know, your only solution is to manually create such addresses instead of using e-mail address policy.
    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

  • How to replace the arrow with a custom graphic on a TitledPane?

    The TitledPane has an arrow that changes state (rotates) to show whether the pane is collapsed or expanded. Is there a way to replace this arrow with a custom graphic for each state?

    Most definitely. Everything in the controls is style-able from CSS. The region you are attempting to style can be addressed via:
    .titled-pane > .title > .arrow-buttonSo you could specify images here for example, or you can just change the arrow path by adding another > .arrow on the end. Below I've posted the entire CSS style that is built in for TitledPane so you can see how the whole thing is styled. You can create your own stylesheet, copy/paste this in there, and then start tweaking things and see how it affects the look of the TitledPane.
    Cheers
    Richard
    * TitledPane                                                                  *
    .titled-pane {
        -fx-skin: "com.sun.javafx.scene.control.skin.TitledPaneSkin";
    .titled-pane > .title {
        -fx-background-color: -fx-box-border, -fx-inner-border, -fx-body-color;
        -fx-background-insets: 0, 1, 2;
        -fx-background-radius: 5 5 0 0, 4 4 0 0, 3 3 0 0;
        -fx-padding: 0.166667em 0.833333em 0.25em 0.833333em; /* 2 10 3 10 */
    .titled-pane > .title > .arrow-button {
        -fx-background-color: null;
        -fx-background-insets: 0;
        -fx-background-radius: 0;
        -fx-padding: 0.0em 0.25em 0.0em 0.0em; /* 0 3 0 0 */
    .titled-pane > .title > .arrow-button .arrow {
        -fx-background-color: -fx-mark-highlight-color, -fx-mark-color;
        -fx-background-insets: 1 0 -1 0, 0;
        -fx-padding: 0.25em 0.3125em 0.25em 0.3125em; /* 3 3.75 3 3.75 */
        -fx-shape: "M 0 0 h 7 l -3.5 4 z";
    .titled-pane:collapsed > .title > .arrow-button .arrow {
        -fx-rotate: -90;
    .titled-pane > *.content {
        -fx-background-color:
            -fx-box-border,
            linear-gradient(to bottom, derive(-fx-color,-02%), derive(-fx-color,65%) 12%, derive(-fx-color,23%) 88%, derive(-fx-color,50%) 99%, -fx-box-border);
        -fx-background-insets: 0, 0 1 1 1;
        -fx-padding: 0.167em;
    .titled-pane:focused > .title {
        -fx-color: -fx-focus-color;
    .titled-pane:focused > .title > .text {
        -fx-text-fill: white;
    .titled-pane:focused > .title > .arrow-button .arrow {
        -fx-background-color: white;
    }

  • How to replace missing fonts with a specific font (and not a suggested font)

    Hello all!
    Looking to replace missing fonts within my document - but the drop-down selection only gives a couple of suggestions, none of which are the font I want to use.
    How can I replace the fonts with a font of my choosing?
    I've attached an image to give more clarity - notice how the drop-down only gives the option to select between 3 fonts without an option to select your own font - many thanks!

    Same problem! The only solution I found is to prepare a textbox in a new file with all the font you need. Copy and past in the file you need to change font. Go to type/risolve missing font. Will open the same window in the pic you pasted. Then you find the font in the dropdown menu. I have to change all the Helvetica family ...it's a long go. If some one could save me. Hope to be usefull to your problem.

Maybe you are looking for

  • Internet hangs/drops after leaving it idle for a few minutes.

    Quick question that I've been pulling my hair out over... I have had a MBP for about 6 months now which I have been connecting to the internet via wireless router (Linksys WRT150N). I'm currently using OS X 10.4.11. For the most part, internet is lig

  • In IPCC express,last 4 month report i;m not getting in historical report. in report it shows blank.

    Hi all, we are using IPCC express 5.0 with high availability and call manager 6.0. Now i;m facing an issue in historical reports.i'm not getting last 4 month reportin the historical report and the report is blank. when i troubleshooted, i checked for

  • Can't debug xilkernel application

    Hello, I have some very strange behaviour when moving from standalobe bsp to xilkernel bsp. I hope someone here will have ideas. I created application+bsp based on standalone and another same application with bsp based on xilkernel. The application i

  • Still showing 1.1.4 as the latest version?

    Just home there after reading a few posts on the discussion forum. Went into iTunes and checked for the update and it still says that 1.1.4 is the latest version. My dad has an iPhone too and he went into iTunes about an hour ago and the 2.0 came up

  • How can one submit suggestions to Adobe.

    It seems that one cannot avoid using Adobe Flash.  It offers frequent updates that are mandatory.  Whenever you select one of those updates, the default is to down load and install a McAfee security program.  I have full blown Norton security program