Assigning enum a integer value

hellow, please is there any way to assign items of enum type a integer value.
I have enum SizeOfGrid
9x9,
16x16,
25x25,
and i need to assign an integer value to each items
so i can create new grids like new Grid(9x9.value) or something
and not using switch each time like:
Switch(sizeOfGrid)
case 9x9:
value = 9;
etc.
I need to preserve the type enum, because i need it to be type-safe.
So please is there any way to do that? Thanks a lot.

does your code even compile right now? i thought enum values could not start with a number.
when you declare an enum it gets compiled to a class, and the values that you specify are instances of that class, so you can give it any methods you like, for example:
enum SizeOfGrid {
    SMALL(9),
    MEDIUM(16),
    LARGE(25);
    private int size;
    private SizeOfGrid(int size) {
        this.size = size;
    public int getSize() {
        return size;
}Then to get back the size you can do:
int size = SizeOfGrid.SMALL.getSize();

Similar Messages

  • Integer value in a variable of assing action is no more integer - OSB

    Hi,
    I have seen a strange behavior or I wonder am I missing anything in OSB assing action.
    I am developing a simple proxy service in 11.1.1.6 OSB.Following are the steps involved in my code.
    In first assign action, the value is assigned as xs:integer(1) to a varible varTest
    Next, I've added an if condition as below.
            if( $varTest != xs:integer(0))
            then
            assing "success" to $varResult
    While testing the PS using the test console,  I've got the following error at if condition.
    line 1, column 14: {err}FOTY0012: Items not comparable: types are "{http://www.w3.org/2001/XMLSchema}string" and "{http://www.w3.org/2001/XMLSchema}integer"
    This error is fixed after changing the if condition as below.
      if(xs:integer($varTest) != xs:integer(0))
    Ideally varTest should contain value of type integer right?
    Is it kind of a bug or am I doing any mistake?
    Could you help me out.
    Regards,
    Vasudev Palivela.

    Hi Abhishek, Eric,
    Thanks for your reply.
    It is clear that  OSB's native data format is XML.
    It should also support simple XML types right?
    Even, when we create a new variable structure form OSB console, we can see String as simple type( I could not see other simple types) along with element types based on either schema or WSDL message.
    Can I consider this as a limitation of OSB?
    Regards,
    Vasudev.

  • I need in Formula Node to assign to the variable value 4000000000!!! What kind of variable it should be???

    i've just tryed to write unsigned in32, but it does not understand 'unsogned'... But i need variable to be unsigned, because the max value = 4000000000... So, how can i solve this probleme???

    Hi,
    I don't see exactly what you're trying to do here.
    Where do you want to assign the variable 4000000000 to? If you want it as an
    input, just use a dbl, with only zeros behind the coma.
    Note that an integer is a number without any decimals. An integer in LabVIEW
    is this, but with an extra limitation that it can only be 32 bits... So a
    dbl can be an integer.
    If the input dbl is not an integer, use round, round to -inf or round to
    +inf to make it one. This can also be done if the output needs to be an
    integer.Inside the formula node floor(x), int(x), intrz(x) or ceil(x) can be
    used to make integers.
    I hope this is what you mean... I can't see any problems doing this.
    Regards,
    Wiebe.
    "DrON" wrote in message
    news:506500000008000000E
    [email protected]..
    > I need in Formula Node to assign to the variable value 4000000000!!!
    > What kind of variable it should be???
    >
    > i've just tryed to write unsigned in32, but it does not understand
    > 'unsogned'... But i need variable to be unsigned, because the max
    > value = 4000000000... So, how can i solve this probleme???

  • How to add integer value of two buttons?

    how to add integer value of two buttons (any button) in VI and display it in output text box? i have attached example program, but i know its wrong.. please help
    Solved!
    Go to Solution.
    Attachments:
    add.vi ‏8 KB

    thanks for reply. i am trying to assign an integer value to a button and the button should send the assigned integer value to TCP/IP write, only when the button is pressed. i am able to send data using string control (as shown in the attachment) but i want to replace it with several buttons. for example, if i enter 2 in string control, this data will be sent to a robot (robot has wifi card)  through tcp/ip protocol, it moves front. 3 will make it to move back, 8 is left, 6 is right. this numeric data is already burnt into blackfin processor of the robot. so just by entering numbers in labview can make my robot move in specified direction. can you please help me to create a button with value and convert it into string and send it to tcp/ip write. this should happen only when the button is pressed. because, if i enter numbers in string control, it dosent looks good..... if i have buttons... i think my VI will look good and hitech.
    Attachments:
    robo.vi ‏9 KB

  • Getting integer values from a JTable

    Hello
    The table's cells contain integer values. I would like to save each one of theme them in an array of integers.
    The problem is, I don't know how to do so. I tried to use the getValueAt method, but I always get error messages.
    I tried something like:
    Object o = table.getModel().getValueAt(i, j);
    a[x]=Integer.parseInt(o.toString());Please help.
    Thank you. :)

    WalterLaan wrote:
    The next line in the exception stacktrace contains a class name and a line number. So go to that class source file and that line number and fix the problem there.Yes, guenouni, we're not mind readers. You need to be clearer and give precise details. The single best way to get the most useful possible help is to take a few minutes and write and post a SSCCE . If you do that, it will show your serious.

  • Passing multiple integer values as parameter in SSRS

    Hello,
    I am trying to pass a comma separated multiple integer value parameter in SSRS report and it errors out complaining that it is not able to convert the nvarchar value to datatype int. But it works fine when I pass a single value. Here is the code I am using
    for the report and I am stuck at passing multiple values.
    SELECT
    id,count(*) as cnt
    from table
    and ID in (@id) group by id
    eg: if I pass 10,20,30 then I would get error however if I pass 10 then it works fine
    Is there a different method to pass multiple integer values?
    Thanks for your help.

    A comma is, of course, a textual character and not an integer, thus the error you are getting. Multi-value parameters can be used for this.
    Select "Allow multiple values"and set data type to Integer. Multi-value parameters deliver the values as an array. The query interface is smart enough to convert them to the proper syntax (comma-delimited) automatically so a statement like:
    WHERE Field IN (@id)
    where the parameter has an array of values {1, 2, and 3} is interpreted as:
    WHERE Field IN (1,2,3)
    You do not need to manually convert it in a transact SQL query. That is not the case for displaying the value array in your report. If you wish to display the array (described above) in your report as "1, 2, 3", you will need to use a join expression:
    =Join(@id, ", ")
    As DJ described, the other part to a multivalue parameter is the Available values. These can be set explicitly but given your example, I think it would be best to create a new dataset that retrieves a distinct list of the IDs that can be retrieved, perhaps
    something like:
    SELECT DISTINCT GroupName, GroupID
    FROM table
    WHERE [criteria]
    Set the available values to use this query with GroupName (or whatever user-friendly field you choose for your dataset) as the label and the id as the value. The label field should be something the the target report user can easily identify the correct group
    using.
    If you don't want to or can't use a multivalue parameter for some reason then you will need to manipulate your parameter value prior to consuming it in your query. When you add the parameter to the TSql query and save the dataset, SSRS adds it to the Parameters
    property of the dataset. Open the dataset properties and select the parameters tab. You should see your parameter in the list. click the expression builder (fx) button next to the value and enter this expression:
    =Split(@id,",")
    Note that the second element of the expression is the delimiter. If your text input has comma-space as a delimiter (1, 2, 3 vs 1,2,3) then that element must include ", ". My example just has comma so if you use that with a string "1, 2, 3"then
    the resulting array will still have 3 elements but the 2nd and 3rd elements of the array will have a preceding space which will cause your dataset to error with the same error. As long as there are no non-numeric characters in any of the elements, the split6
    will create the text array, SSRS will dynamically generate the correct "IN"syntax (comma separated) and SQL will convert the elements from VARCHAR to INT on the fly.
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • How can I assign a hard coded value to a variable of type OBJECT.

    Hi,
       I have to call the following method
                                      lc_action_execute->get_ref_object(
                                                            exporting
                                                                  io_appl_object = io_appl_object
                                                            importing
                                                                   ev_guid_ref    = lv_guid_ref.
    Now I have to hard code the io_appl_object variable (of type OBJECT) to test my application for the time being. How can I assign a value to the variable? Is there any way to do that?

    I wouldn't use WDR_CONTEXT_ATTR_VALUE_LISTGEN.  Use wdr_context_attr_value_list instead:
    data l_topics type zpm_main_topic_tbl.
      l_topics = wd_assist->read_all_topics( ).
      data lt_valueset type wdr_context_attr_value_list.
      field-symbols <wa_topic> like line of l_topics.
      field-symbols <wa_vs>  like line of lt_valueset.
      loop at l_topics assigning <wa_topic>.
        append initial line to lt_valueset assigning <wa_vs>.
        <wa_vs>-value = <wa_topic>-main_topic.
        <wa_vs>-text  = <wa_topic>-main_topic_desc.
      endloop.
      data lo_nd_meeting type ref to if_wd_context_node.
    * navigate from <CONTEXT> to <MEETING> via lead selection
      lo_nd_meeting = wd_context->get_child_node( name = wd_this->wdctx_meeting ).
      data lo_node_info type ref to if_wd_context_node_info.
      lo_node_info = lo_nd_meeting->get_node_info( ).
      lo_node_info->set_attribute_value_set(
         name = 'MAIN_TOPIC'
         value_set = lt_valueset ).

  • Assigning a DataProvider filter value with JavaScript

    I have a "Fiscal Yr/Period" filter characteristic in my web application that I am assigning the value of the current month and year when the web application is loaded.  In other words, this filter is applied to the DataProvider when the application loads (code below):
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="SET_DATA_PROVIDER"/>
             <param name="NAME" value="C_LPR_Q018"/>
             <param name="QUERY" value="C_LPR_Q018"/>
             <param name="INFOCUBE" value="ZPP_C01"/>
             <param name='FILTER_IOBJNM' value='0FISCPER'/>
             <param name='FILTER_VALUE' value='H12004010'/>
             DATA_PROVIDER:             C_LPR_Q018
    </object>
    As you can see above, the value for the '0FISCPER' object is hardcoded and thus requires me to change this monthly.  I have written some JavaScript code to calculate the current mo. and yr. however I can't get my JavaScript variable that holds the value I need assigned to the FILTER VALUE.  Can I even assign a JavaScript variable as the filter value?  Is there another way?  Any help would be greatly appreciated.

    Hi Allen,
    if you want to change any param of an object, try the function SAPBWOpenURL, which should be sent against the object you want to change. Documentation is at :
    http://help.sap.com/saphelp_bw33/helpdata/en/f1/0a5a2ee09411d2acb90000e829fbfe/frameset.htm -> Business Explorer ->
    Web Application ... -> Befehl URLs
    Concat the date in JavaScript and call
    SAPBWOpenURL(SAP_BW_URL_Get()+'&item=...&FILTER_IOBJNM="0FISCPER"&FILTER_VALUE="TheDateYouWant"') (I hope I set the " and ' correctly, better you should check).
    For example you can insert :
    <HEAD>
    <script>
        function callTheTableWithTheDate()
            SAPBWOpenURL(like above);
    </script>
    </HEAD>
    <BODY onload="JavaScript:callTheTableWithTheDate()">
    It's only a hint, adjust it for your requirements. You can save the date in a cookie too and reuse it whenever you want. You know how to handle cookies ?
        Bye
        Ralf

  • Assign a Javascript variable value to a ABAP variable

    Hi,
       I wish to assign a javascript variable value to  a ABAP variable. Any ideas how to do that?
        Many thanks.
    Rgds,
    Bernice

    Here's another suggestion for you.
    BSP Application: SBSPEXT_HTMLB
    Check out the radionbuttongroup.bsp
    So then instead of using a standard HTML radio buttons you can use the HTMLB element with the parameter for onClick set then in your DO_HANDLE_EVENT you can read the value.
    VIEW
    <htmlb:radioButtonGroup id="radio">
      <htmlb:radioButton id="id_link"
                       text="Link"
                    onClick="myClickHandler"/>
      <htmlb:radioButton id="id_unlink"
                       text="Unlink"
                    onClick="myClickHandler"/>
    </htmlb:radioButtonGroup>
    DO_HANDLE_EVENT
      DATA:   lt_event        TYPE REF TO if_htmlb_data.
      lt_event = cl_htmlb_manager=>get_event_ex( request ).
      if lt_event IS NOT INITIAL.
        if  lt_event->event_name = htmlb_events=>radiobutton.
           case lt_event->event_id.
            when 'control_id_link'.
              schalter = ' '..
            when 'control_id_unlink'.
              schalter = '1'.
           endcase.
        endif.
      endif.
    There is an example of how to use it and read it in the DO_HANDLE_EVENT you then just have to pass the variable around (in this example the variable name is schalter and is defined as char1 in the class)

  • Help with passing integer value in A.S.S

    I get an NSinternal script error while trying to pass this value can anyone help?
    Also I wonder if it is possible to pass the value to a matrix
    on clicked theObject
    tell button "checkbox" of window 1
    if integer value = 1 then
    set button "checkbox2" of window 1 to integer value = 1
    else
    set integer value to 0
    end if
    end tell
    end clicked
    I also tried:
    if state of button "checkbox" of window1 is 1 then
    set the state of button "checkbox2" of window1 to 1
    end if
    Message was edited by: Doug Bassett

    I've been following this thread and trying to figure out how to make this work. I was getting inconsistent results or errors with most of the code that has been posted. But I finally got it working... at least on a Leopard machine (not sure if this could have changed between Tiger and Leopard so your mileage may vary).
    What I found was that a checkbox button that's located directly in a window seems to have a state that's equal to 0 when it's unchecked and 1 when it's checked. But a checkbox cell that's contained within a matrix seems to have a state that's set to either _off state_ or _on state_. Trying to set a cell's state to 0 or 1 simply wasn't working right for me. So I get the state of the "selectall" checkbox button (which is a 0/1) and transform it to either "off state" or "on state" before setting the states of the checkbox cells in the matrix.
    Here's my code:
    on clicked theObject
    set n to name of theObject
    if n = "selectall" then
    set s to state of theObject
    log "state: " & s
    if s = 0 then
    set newState to off state
    else
    set newState to on state
    end if
    repeat with i from 1 to count of cells of matrix "directories" of window "main"
    tell cell i of matrix "directories" of window "main"
    set state to newState
    end tell
    end repeat
    return
    end if
    if n = "logStatesBtn" then
    logStates()
    return
    end if
    end clicked
    on logStates()
    log "Logging states:"
    set s to state of button "selectall" of window "main"
    log "selectall checkbox: " & s
    repeat with i from 1 to count of cells of matrix "directories" of window "main"
    tell cell i of matrix "directories" of window "main"
    set s to state
    end tell
    log "Cell " & i & ": " & s
    end repeat
    end logStates
    Note the "logStates" handler is just something I connected up to a "logStatesBtn" button in my window that lets me spit out the states of all the checkboxes into the console log. This is how I actually discovered that the cells were set to "off state" or "on state".
    Steve

  • How to set a default integer value in a form

    I have a form defined as follows:
    =================================================
    public static class ProjectForm extends FormData
    private int idx;
    private String name;
    private String projectNumber;
    private String description;
    public void setIdx(int index)
    this.idx = idx;
    public int getIdx(){
    return this.idx;
    public void setName(String name)
    this.name = name;
    public String getName()
    return this.name;
    public void setDescription(String description)
    this.description = description;
    public String getDescription()
    return this.description;
    public void setProjectNumber(String projectNumber)
    this.projectNumber = projectNumber;
    public String getProjectNumber()
    return this.projectNumber;
    ======================================================
    When I add a new entry into the database, I have no issues. However, when I want to modify an entry I run into some issues with the idx entry. For some reason, I cannot set a default value into the netui:label tag. My jsp code is as follows:
    ===================================================
    <tr valign="top">
    <td>
    Index:
    </td>
    <td>
    <netui:label value="{actionForm.idx}"
    defaultValue="{pageFlow.project.idx}"/>
    </td>
    </tr>
    <tr valign="top">
    <td>
    Name:
    </td>
    <td>
    <netui:textBox dataSource="{actionForm.name}"
    defaultValue="{pageFlow.project.name}"/>
    </td>
    </tr>
    <tr valign="top">
    <td>
    ProjectNumber:
    </td>
    <td>
    <netui:textBox dataSource="{actionForm.projectNumber}"
    defaultValue="{pageFlow.project.projNum}"/>
    </td>
    <tr valign="top">
    <td>
    Description:
    </td>
    <td>
    <netui:textBox dataSource="{actionForm.description}"
    defaultValue="{pageFlow.project.description}"/>
    </td>
    </tr>
    ======================================================
    The the project class is passes into the page and has the appropriate values. The name, project number and description fields work as I would expect. However, the idx value is alway '0'. If I print out pageFlow.project.idx it has the correct value.
    How do I fix this? My feeling is that it is related to the form field being an int and not a string. The default parameter indicates that is only works with null values, and ints default to zero. Do I need to use an Integer value instead in the form, or just stay away from non-string form fields.
    Thank for the help!!
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    In the action which displays the edit page just set the form idx value before displaying the jsp.

  • Read integer values from spreadsheet and display the values in a table

    Hi all,
    I have integer values to read from a spreadsheet and display them in a table. I am using 'Read from spreadsheet file' in 'integer' mode. I would like to display these values in a table. The problem is that the table takes only 2d-array of string as input but not integer.  
    It works fine if I change the mode of 'Read from spreadsheet file' from 'integer' to 'string' but I want to read integers and have to use the integer values for further calculations. Please give any suggestions on displaying integers to a table.
    Thank you. 
    Solved!
    Go to Solution.

    No don't take element by element just convert as a whole. See the attached example
    Good luck
    The best solution is the one you find it by yourself

  • How to assign a query retrived value to a user defined  object in a table

    how to assign a query retrived value to a user defined  object in a table

    Rajeshwar,
    If you use the "Search" feature in this forum, you should be able to find helpful links to similar questions.  You could also look at the RecordSet and DoQuery documentation in the SAP Business One SDK Help Center documentation to assist you with your question.
    HTH,
    Eddy

  • Why do i get integer values instead of decimals when selecting a mysql table through an oracle xe DB?

    Hi
    My company just started a new project that implies migrating every hour operational data from a mysql database located at another company to our main DB (oracle10gR2). Between these two DB, we have an oracle XE DB which contains the database links to both DB and a procedure to get (from mysql) and insert (oracle10g) the values. What happens is that in the mysql DB, the values have decimals and, when i select the table in oracle, i only see integer values (no decimals). Here is an example of the select i use:
    SELECT "v_hour", "v_date", "v_type", "v_tabstamp","v_value"
    FROM "tab1"@mysql;
    How can i work around this problem?
    Many thanks!

    Maybe just a HS_LANGUAGE setting issue.
    You could try that:
    1a) in the gateway init file, please set HS_LANGUAGE=GERMAN_GERMANY.WE8ISO8859P1
    2a) now open a new SQL*Plus session ans select from your table using the gateway based database link
    => if the values are now including the decimal part then your foreign database is set up to use a comma as the decimal separator and you have to make sure that the HS_LANGUAGE contains a territory that uses as decimal separator a comma.
    If you still do not get the decimal values, then change it to:
    1b) HS_LANGUAGE=american_america.we8iso8859P1
    2b) Make sure you start again a new SQL*Plus session (the gateway init file is only read when you use the database link in your session for the first time (or explicit closed it before). Select again from your table.
    => is the decimal part now visible?
    More details can be found in the gateway note: Gateway and Decimal Digits(Doc ID 1453148.1) available from My Oracle Support portal.
    - Klaus

  • Convert an integer value that was created with the Excel DATEVALUE formula to a valid date?

    Hello everyone,
    How can I convert an integer value that was created with the Excel DATEVALUE formula to a valid date in SSIS?
    Is this even possible?
    For example:
    =DATEVALUE("8/22/2008") will format the cell to display 39682.
    Reading the column as a string to get the int value (39682) - how can I turn this into a valid date using SSIS and then importing the real date to sql server?
    Thank you!

    You can use Script component for this and convert your integer values to Date. An example here is following:
    CultureInfo provider = CultureInfo.InvariantCulture;
    string dateString = "08082010";
    string format = "MMddyyyy";
    DateTime result = DateTime.ParseExact(dateString, format, provider);
    Source: http://stackoverflow.com/questions/2441405/converting-8-digit-number-to-datetime-type
    Vikash Kumar Singh || www.singhvikash.in

Maybe you are looking for