Convert a value into an enum

I'm using enums that have assigned values, like so:enum Alphabet {
       a(101), b(135), c(22), d(5);
       private final int value;
       Alphabet(int i) { value = i; }
}OK, so I can get a value from an Alphabet object by Alphabet item;
item = Alphabet.c;
int i = c.value;Cool. But how do I go the other way, where I have an int value and I need to get the corresponding Alphabet object? Is that what EnumMap is for? If so it seems kind of inefficient, since my values can be all over the map, so to speak.

What's wrong with this?
enum Alphabet {
a(101), b(135), c(22), d(5);}
I can't get that to compile. You have to provide a constructor in the enum to tell it what the values in the ()s means.
Is there some reason the alphabet isn't a character
array instead?My example of Alphabet was just generic. My real application is using enum to describe possible values within a protocol structure.

Similar Messages

  • Convert given value into words

    i want convert given value into words
    such as
    amount 54300
    in words fifty four thousand three hundred only
    thanking you
    aamir

    number value in words

  • IPhone SDK: How to convert Pixel values into Point values

    UIScrollView has a property called contentSize. This takes values in points. How do i convert Pixel values into Point Vales?
    -TRS

    As far as I can tell, they're the same - I know they are in Photoshop at least. My 57x57 point Tab Bar icon is also 57x57 pixels.
    Hope that helps

  • Converting arrayCollection values into String

    Hi,
    In my application, the dataprovider of a datagrid which is an arraycollection receives values of objects. I need to get them as string variable so as to convert a particular column in the arraycollection as a string variable of comma seperated values.
    I am not too good with flex. Can someone please help me..?
    I have three AS classes :
    First Class
    package script.vo
    public class SectorsVO
    public function SectorsVO()
    public var sectorId:Number;
    public var sectorName:String;
    public var fromStation:StationsVO;
    public var toStation:StationsVO;
    Second class
    package script.vo
    public class StationsVO
    public function StationsVO()
    public var stationCode:String;
    public var stationName:String;
    public var countryCode:CountryVO;
    Third class
    package script.vo
    public class CountryVO
    public function CountryVO()
    public var countryCode:String;
    public var countryName:String;
    My mxml page is :
    <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid- controls/ -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            layout="horizontal"
            verticalAlign="middle"
            backgroundColor="white">
    <mx:Script>
    <![CDATA[
    import script.vo.SectorsVO;
    import mx.controls.Alert;
    import mx.collections.ArrayCollection;
    [Bindable]
    public var sectors:ArrayCollection = new ArrayCollection([{sectorId:101,fromStation:"Calicut",toStation:"Muscat"},
      {sectorId:102,fromStation:"Kochi",toStation:"Sharjah"},
      {sectorId:103,fromStation:"Bangalore",toStation:"Dubai"},
      {sectorId:104,fromStation:"Dubai",toStation:"Amman"},
      {sectorId:105,fromStation:"Amman",toStation:"Frankfurt"}]);
    [Bindable]
    public var draggedSectors:ArrayCollection = new ArrayCollection();
    public var mySectors:SectorsVO = new SectorsVO;
    public var myString:String = "";
    private function getValuesAsCSV():void{
    for(var i:int = 0; i < draggedSectors.length; ++i){
    mySectors = SectorsVO(draggedSectors.getItemAt(i));
    Alert.show("Value is : "+mySectors.sectorId);
    myString = String(mySectors.fromStation.stationName);
    Alert.show("Sector name :"+myString);
    ]]>
    </mx:Script>
        <mx:VBox width="50%">
            <mx:Label text="Stations" />
            <mx:DataGrid id="dataGrid1" width="100%" rowHeight="22" dataProvider="{sectors}" dragEnabled="true" dragMoveEnabled="true"
                    dropEnabled="true" verticalScrollPolicy="on">
                <mx:columns>
                    <mx:DataGridColumn dataField="fromStation" headerText="From Station" />
                    <mx:DataGridColumn dataField="toStation" headerText="To Station" />
                </mx:columns>
            </mx:DataGrid>
            <mx:Label text="{dataGrid1.dataProvider.length} items" />
        </mx:VBox>
        <mx:VBox width="50%">
            <mx:Label text="DataGrid #2" />
            <mx:DataGrid id="dataGrid2" width="100%" rowHeight="22" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true"
                    verticalScrollPolicy="on" dataProvider="{draggedSectors}" >
                <mx:columns>
                    <mx:DataGridColumn dataField="fromStation" headerText="From Station" />
                    <mx:DataGridColumn dataField="toStation" headerText="To Station" />
                </mx:columns>
            </mx:DataGrid>
            <mx:Label text="{dataGrid2.dataProvider.length} items" />
            <mx:Button id="getValues" click="getValuesAsCSV()" label="Get Sectors" enabled="{dataGrid2.dataProvider.length>0}"/>
        </mx:VBox>
    </mx:Application>
    My prime issue is to convert the values in the arraycollection into String variables.
    Please help me on the ablve matter..! Thanks in advance..!

    fromStation and toStation are already Strings, but you are attempting to cast an ArrayCollection entry to a SectorsVO object. The problem is that SectorsVO has a no-arg constructor and the entry that you are attemping to cast is not of type SectorsVO. You need to modify the constructor to accept an Object and manually assign values to the properties.
    It sounds like you are trying to build a CSV string out of all of the values of one of the fields. What you can do is loop through the draggedSectors and pull out the desired property, placing it into a temporary Array. After the loop, simply use Array.join(",") to produce a CSV string.

  • Convert column values into a row with a delimiter

    Hi Gurus,
    This may be a trivial question to you. I have an internal table itab with a column called plant, internal table has 'n' records, by the end of loop, I need to convert the column into a row delimited by comma into one row (one field). This needs to be dynamic without hard-coding.
    Plant
    1000
    2000
    3000
    4000
    5000 ....
    n....
    Expected result of the field:
    field1 value: 1000,2000,3000,4000,5000,...n
    Let's set a limit to the field say it can hold upto 500 chars.
    Thanks,
    GP.

    Hi,
    I've already tried this:
      ELSEIF <fs_dms_cv>-zca_cv_attr_ind = c_multiple.
      w_plant = <fs_plant_ele>-werks.
      concatenate w_string w_plant
                    into w_string separated by c_delimiter.
          IF w_end_fl = c_on.
          w_tabname = <fs_dms_cv>-dbtabname.
           ASSIGN (w_tabname) TO <fs_tabname>.
            IF sy-subrc = 0.
             ASSIGN COMPONENT <fs_dms_cv>-name_komp OF 
                STRUCTURE <fs_tabname> TO <fs_destination>.
                        IF sy-subrc = 0.
                          <fs_destination> = w_string.
                        ENDIF.
            ENDIF.
    There are 2 issues here: One is that after first plant there will be two commas inserted, after that it's consistent. Secondly the key word concatenate is against our code standards.
    Please let me know if there is any other way of doing this.
    Thanks.

  • How do you convert numeric values into english words?

    I am interested in creating a field in adobe acrobat that references a total dollar amount field. I want the java script to convert the numeric number into a written word, such as $59.59 as Fifty Nine and 59/100. I have no experience writing java script code and would really like some help on how this can get done. Its also important to embed in the programming that if their is no numeric value to reference, then nothing get referenced. This means an empty text box. Thanks for any help.

    Im using the below script...... I'm a complete novice at this and helping a friend out with it.
    Any info is appreciated.
    aTens = [ "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
    aOnes = [ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
      "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",
      "Nineteen" ];
    function ConvertToHundreds(num)
       var cNum, nNum;
       var cWords = "";
       num %= 1000;
       if (num > 99) {
          /* Hundreds. */
          cNum = String(num);
          nNum = Number(cNum.charAt(0));
          cWords += aOnes[nNum] + " Hundred";
          num %= 100;
          if (num > 0)
             cWords += " and "
       if (num > 19) {
          /* Tens. */
          cNum = String(num);
          nNum = Number(cNum.charAt(0));
          cWords += aTens[nNum - 2];
          num %= 10;
          if (num > 0)
             cWords += "-";
       if (num > 0) {
          /* Ones and teens. */
          nNum = Math.floor(num);
          cWords += aOnes[nNum];
       return cWords;
    function ConvertToWords(num)
       var aUnits = [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ];
       var cWords = (num >= 1 && num < 2) ? "Dollar and " : "Dollars and ";
       var nLeft = Math.floor(num);
       for (var i = 0; nLeft > 0; i++) {
           if (nLeft % 1000 > 0) {
              if (i != 0)
                 cWords = ConvertToHundreds(nLeft) + " " + aUnits[i - 1] + " " + cWords;
              else
                 cWords = ConvertToHundreds(nLeft) + " " + cWords;
           nLeft = Math.floor(nLeft / 1000);
       num = Math.round(num * 100) % 100;
       if (num > 0)
          cWords += ConvertToHundreds(num) + " Cents";
       else
          cWords += "Zero Cents";
       return cWords;
    You can use the following script for the custom calculation for the words field when the number field is named "Number":
    event.value = "";
    var f = this.getField("Number");
    if(f.valueAsString != "") {
    event.value = ConvertToWords(f.value);

  • How to convert ascii value into character and vice versa

    Hello the java world people,
    I want to convert each characters from my array into their corespondent ascii value and vice versa, how can I do that ?

    The term "ASCII" is often used very loosely.
    Java char values are UNICODE and the ASCII codes are indentical to UNICODE characters in the range 0 .. 127. UNICODE values 128 and above don't have coresponding ASCII values, though 128-255 corespond to ISO-8859-1 which is one of the encodings often called "extended ASCII".
    As shown above you can covert between chars and coresponding int value simply with a cast, but you should be aware that the more exotic characters will not give you sensible values.

  • In BO 4.0,how to convert field values into column heading.

    Currently Product Codes are represented in "Code" and "Value" fields.
    Please retain the code and value fields, so that if the user adds another code and immediately needs to report on them they can through this functionality.
    Current:
    Fund Code
    Code
    Value
    ABC1
    Embassy Series
    XYZ123
    ABC1
    FMI
    19837
    ABC1
    Gladis Short Name
    FUJHAT
    Required:
    Fund Code
    Embassy Series
    FMI
    Gladis Short Name
    ABC1
    XYZ123
    19837
    FUJHAT

    Hi Archana,
    I think you need to use a Cross Tab on your report but also you will need to apply Sections on the Fund Code dimension.
    ie
    Section 1 - ABC1
    Crosstab
    Section 2 - ABC2
    Crosstab
    Section 3 - ABC3
    Crosstab
    With regards
    Gill

  • Converting a value into decimals in smart form.

    i have a variable(amt) in a smartform in which i have a value '600000.00' . When i display it, i do like this..
    &amt(1.0)&  // cuz i want 60,000
    but it displays '6' ..
    why ? plz help... Thanks !!

    &amt(n)& will tell the number of digits is n.
    &amt(.n)& will tell us the number of digits after decimal point.
    We can combine both these two like
    &amt(n.n)& . So problem solved.

  • Convert Exponential value into float value

    Exponential format example 005.0000E-02 Result 0.05
    public static double convertExp(String slice)
    int i=0,j=0;
    int symbolpos=0;
    int sign=0;
    int power=0;
    StringBuffer PowValue=new StringBuffer();
    StringBuffer ExpValue=new StringBuffer();
    while(i<slice.length())
    if(slice.charAt(i)=='-') {sign=-1;}               
    if(slice.charAt(i)=='+' || slice.charAt(i)=='-') {
    symbolpos=i+1;
    PowValue.append(slice.charAt(symbolpos));
    PowValue.append(slice.charAt(symbolpos+1));                    
    if(slice.charAt(i)!=('e') || slice.charAt(i)!=('E'))
    if(j<=(slice.length()-5))
    ExpValue.append(slice.charAt(j));               
    j++;
    i++;          
    int powInt=Integer.parseInt(PowValue.toString());
    Double expFot=Double.parseDouble(ExpValue.toString());
    if(sign==0)
    return (expFot * Math.pow(10,powInt));
    else if(sign==-1)
    return (expFot/(Math.pow(10,powInt)));
    else
    return 1;
    Function return double value
    double tummy=convertExp(imageviewerdisplay.Slicethick);
    float convertslicevalue=(float)tummy; //double to float......

    Best 3rd post ever?:-) Except that this was the 1st post .. #2 & #3 are in the resurrected zombie.
    {color:0000ff}http://forum.java.sun.com/thread.jspa?threadID=583688{color}
    And, um, I've heard of a double chin, but what's this?double tummy=convertExp(imageviewerdisplay.Slicethick);db

  • How to convert from value to word ?

    Hi all,
    I intend to convert from value into words such as 234.50 will be two hundred and thirty four and cents fifty. How should I code or any function will able to produce this ?
    Please advise.
    Rgds
    Lim

    Lim
    The SP format modifier spells out part of a date - so does YEAR:
    SQL> select to_char(sysdate,'YEAR') from dual
      2  /
    TO_CHAR(SYSDATE,'YEAR')
    TWO THOUSAND EIGHT
    SQL> To spell out a money amount, you have to take a decimal number and break it into dollars and cents (both integers):
    SQL> r
      1  declare
      2    amount number(10,2) := 12345.67;
      3    dollars integer;
      4    cents integer;
      5  begin
      6    dollars := floor(amount);
      7    cents := (amount - dollars) * 100;
      8    dbms_output.put_line(to_char(to_date(dollars,'J'), 'JSP') ||  ' dollars a
    nd ' ||
      9        to_char(to_date(cents,'J'),'JSP') || ' cents');
    10* end;
    TWELVE THOUSAND THREE HUNDRED FORTY-FIVE dollars and SIXTY-SEVEN cents
    PL/SQL procedure successfully completed.
    SQL>Note that the spelling out is rather american (in UK we wouldn't add the hyphen and we would say twelve thousand three hundred AND forty five).
    Using JSP means we are spelling out a Julian date (ie a number of days, which is allowed to get pretty large. But watch out - there is a limit (somwhere between 1 and 10 million) - ie the number of days between minimum date (4172 BC) and max date (around 31/12/9999).
    HTH
    Regards Nigel

  • Converting seconds values

    Hi All,
    I have values in fields KAKO-BEGZT (Start time in seconds (internal)) and KAKO-ENDZT (Finish time in seconds (internal)) which I want to convert into HH:MM:SS format.
    Is there any FM existing. Or if anyone can tell me the logic of converting this value into HH:MM:SS format.
    Problem is I don't know in which format data is stored in fields KAKO-BEGZT and KAKO-ENDZT.
    Regards,
    Pawan

    Hi pawan,
    1. try this code (just copy paste)
    2.  On selection screen enter number of seconds.
        it will give output in HH:MM:SS
    REPORT abc.
    DATA :  mytime(8) TYPE c.
    PARAMETERS : begzt LIKE kako-begzt DEFAULT '45000'.
    PERFORM gettime USING begzt CHANGING mytime.
    WRITE :/ mytime.
    FORM gettime USING sec CHANGING tm.
      DATA : hh(2) TYPE n.
      DATA : mm(2) TYPE n.
      DATA : ss(2) TYPE n.
      DATA :remsec(10) TYPE n.
      hh = sec / 3600.
      remsec = sec - ( 3600 * hh ).
      mm = remsec / 60 .
      remsec = sec - ( 60 * mm ).
      ss = remsec.
      CONCATENATE hh ':' mm ':' ss INTO tm.
    ENDFORM.                    "gettime
    regards,
    amit m.

  • Need to convert values into coma separated

    Need to convert values into coma separated
    I have a string value that stores data like 'NYK,IND,SGP,GER'
    FOR EXAMPLE
    V_CITY_CODE = 'NYK,IND,SGP,GER'
    When I query
    select * from city where city_code = V_CITY_CODE;I get no rows, this is because V_CITY_CODE has all city code as single code.
    I need a function to search , and replace with ','.
    I tried using instr and replace but was unable to convert it.
    could some one pls assist me.
    thanks in advance
    Saz

    Looking for this?
    SQL> select * from emp
      2  /
         EMPNO     DEPTNO ENAME                                 SAL DOJ       JOB
             1          1 Karthick                               80 03-DEC-11
             2          1 Karthick_1                             90 23-NOV-11
             3          2 Ram                                    80 03-DEC-11
             4          2 Ram_1                                  90 23-NOV-11
    SQL> var v_ename varchar2(1000)
    SQL> exec :v_ename := 'Karthick,Karthick_1'
    PL/SQL procedure successfully completed.
    SQL> select *
      2    from emp
      3   where ename in (
      4                     select regexp_substr(val, '[^,]+', 1, level)
      5                        from (select :v_ename val from dual)
      6                    connect by level <= length(val) - length(replace(val, ','))+1
      7                  ) 
      8  /
         EMPNO     DEPTNO ENAME                                 SAL DOJ       JOB
             1          1 Karthick                               80 03-DEC-11
             2          1 Karthick_1                             90 23-NOV-11

  • Converting rotatation value from flash into svg

    hi,
    Advance thankx for helping me
    Here i am taking the rotation value from flash and
    transfering into svg by the forumlae and getting varibale fdeg then
    also it is not coming in the position seen in flash window which is
    not in svg file.
    And also check the formulae is right to convert the value
    from angle to degree.
    if We scale the object it comes in right scaled and right x
    and y position. only if We rotate the rotated object is in correct
    angle but not in correct x,y axis position
    Regards,
    R.Denesh Kumar
    [email protected]

    post as2 questions in the as1/as2 forum. and if you use code
    in a message avoid using [ i ] or your code will be difficult to
    read.

  • How to convert PM Module Breakdown Duration (AUSZT) floating point value into Minutes

    Hi Frnds,
    My requirement is to display a normal alv report. Out of which one of the filed is from VIQMEL-AUSZT (Breakdown Duration).
    Which is of Data type FLTP.
    Details:
    AUZTV
    AUZTV
    TIMS
    6
    Start of Malfunction (Time)
    12:39:19
    AUZTB
    AUZTB
    TIMS
    6
    End of Malfunction (Time)
    12:42:00
    AUSZT
    AUSZT
    FLTP
    16
    Breakdown Duration
    1.6100000000000000E+02
    Now I want to convert the value '1.6100000000000000E+02' into Minutes.
    Kindly let me know the solution.
    Note: I tried with standard FM 'PM_TIME_CONVERSION' and converted the break down value into hours.
    For example: 1.6100000000000000E+02 to 4,472222222222222E-02.
    But i want to convert the break down duration value into perfect minutes.
    With Regards,
    Sudhir.

    Simply equate to a variable of type P decimals zero. It should give you value in seconds. Divide it by 60 to have it in minutes.

Maybe you are looking for

  • How to use multiple models in one Function module?

    Hi, In my FM i am using 2 models and if i dont completely exit the Function and use the same fm for another query based on another model it is giving error saying invalid type. if iv_type_of_search = 'A'. start the application BT     lv_bol_core = cl

  • Media Coder Failing with MPEG2-DVD and H.264 Blu-Ray Encode

    I am useing Adobe Media Encoder CC 2014 8.0.0.173 build. I am a CC subscriber. I am importing a Premiere Pro CC 2014 timeline. I also have Premiere Pro CS6, Photoshop CC and CS6, Encore CS6, Lightroom 5, Indesign CC and CS6 installed.  Just updated a

  • Read attachment content in Mapping

    Hi, In PI 7.1 there is one option to read attachment content inside mapping using the api: "com.sap.aii.mapping.api". To do that in operation mapping we have to check the option "ReadAttachments", to get the attachments in addition to the payload. If

  • Unable to Connect to Apex

    Hi All, I have installed apex 4.1.1 on linux. When I tried to connect apex from my laptop I couldn't Its says "Internet Explorer cannot display the webpage". Where would I gone wrong? Thanks in Advance

  • SD - EDI - Drop Ship - Difficult Scenario - Question

    Hi EDI & SD Experts, I have a very difficult scenario. Whenever a Drop-to Ship order comes through EDI, the customer won't send ship-to code instead they will send just the Drop-To Address of that 1 time customer. The Subsystem maps the Sold-to code