Getting a netative value from InetAddress...
I have an IP address that I am trying to convert to an InetAddress so I can pick out pieces of it. Unfortunately, when I use the following code, the first region of the IP address is a negative number... Am I doing something incorrectly? (I put in a dummy IP just for the sake of this post, BTW)
InetAddress address = null;
try {
address = InetAddress.getByName("131.255.255.255");
} catch (UnknownHostException uhe) {
System.out.println("Unknown Host " + ip);
System.out.println("address: " + address);
System.out.println("address.getAddress()[0]: " + (address.getAddress()[0]));
System.out.println("address.getAddress()[1]: " + (address.getAddress()[1]));
System.out.println("address.getAddress()[2]: " + (address.getAddress()[2]));
System.out.println("address.getAddress()[3]: " + (address.getAddress()[3]));
This is the output:
address: 131.255.255.255/131.255.255.255
address.getAddress()[0]: -125
address.getAddress()[1]: 255
address.getAddress()[2]: 255
address.getAddress()[3]: 255
Why is this showing up as -125 and not 131?
0000 .... 1000 0011 = 131 int
cut to byte
1000 0011 = -125
prolly recast to int to get the right value...sorry, you know what I mean, not cast, since that'd keep the sign, put the 0's back
Similar Messages
-
How can i get the all values from the Property file to Hashtable?
how can i get the all values from the Property file to Hashtable?
ok,consider my property file name is pro.PROPERTIES
and it contain
8326=sun developer
4306=sun java developer
3943=java developer
how can i get the all keys & values from the pro.PROPERTIES to hashtable
plz help guys..............The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
InputStream is = new FileInputStream("tivoli.properties");
props.load(is); -
Get all the values from a multiple select in a multipart form
Hi there!
I am using a form with enctype="multipart/form-data" in order to upload files from the form.
I have read this page: http://commons.apache.org/fileupload/using.html and everything works well for my form.
The only problem is that I can't get all the values from a "multiple select" html object. I get only one value.
Using servlets I have used this method:
public java.lang.String[] getParameterValues(java.lang.String name) But now I have enctype="multipart/form-data" in my form and I can't use this way...
Is there a way to get all the values of a multi-valued parameter?
Thanks a lot!
StefanoHi
I have got solution for this problem so, I am listing here logic
assume tag name of html
<select name="moption" multiple="multiple">
iterate it in as
String moption="";
boolean cnt=true;
while(itr.hasNext())
FileItem fi=(FileItem)itr.next();
if(fi.isFormField())
if(fi.getFieldName().equals("moption"))
if(cnt==true)
moption=fi.getString();
cnt=false;
else
moption=moption+","+fi.getString();
If wants more help then mail me your problem
at [email protected]
Thanks!
Anand Shankar
Edited by: AnandShankar on 6 Nov, 2009 12:54 PM -
How to get all the values from the dropdown menu
How to get all the values from the dropdown menu
I need to be able to extract all values from the dropdown menu; I know how to get all those values as a string, but I need to be able to access each item; (the value in a dropdown menu will change dynamically)
How do I get number of item is selection dropdown?
How do I extract a ?name? for each value, one by one?
How do I change a selection by referring to particular index of the item in a dropdown menu?
Here is the Path to dropdown menu that I'm trying to access (form contains number of similar dropdowns)
RSWApp.om.GetElementByPath "window(index=0).form(id=""aspnetForm"" | action=""advancedsearch.aspx"" | index=0).formelement[SELECT](name=""ctl00$MainContent$hardwareBrand"" | id=""ctl00_MainContent_hardwareBrand"" | index=16)", element
Message was edited by: testtestThe findElement method allows various attributes to be used to search. Take the following two examples for the element below:
<Select Name=ProdType ID=testProd>
</Select>
I can find the element based on its name or any other attribute, I just need to specify what I am looking for. To find it by name I would do the following:
Set x = RSWApp.om.FindElement("ProdType","SELECT","Name")
If I want to search by id I could do the following:
Set x = RSWApp.om.FindElement("testProd","SELECT","ID")
Usually you will use whatever is available. Since the select element has no name or ID on the Empirix home page, I used the onChange attribute. You can use any attribute as long as you specify which one you are using (last argument in these examples)
You can use the FindElement to grab links, text boxes, etc.
The next example grabs from a link on a page
Home
Set x = RSWApp.om.FindElement("Home","A","innerText")
I hope this helps clear it up. -
How to get edited row values from ADF table?
JDev 11.
I have a table which is populated with data from Bean.
I need to save changes after user make changes in any table cell. InputText is defined for table column component.
I have defined ValueChangeListener for inputText field and AutoSubmit=true. So when user change value in inputText field, method is called:
public void SaveMaterial(ValueChangeEvent valueChangeEvent) {
getSelectedRow();
SaveMaterial(material);
This method should call getSelectedRow which take values from selected table row and save them into object:
private Row getSelectedRow(){
RichTable table = this.getMaterialTable();
Iterator selection = table.getSelectedRowKeys().iterator();
while (selection.hasNext())
Object key = selection.next();
table.setRowKey(key);
Object o = table.getRowData();
material = (MATERIAL) o;
System.out.println("Selected Material Desc = "+material.getEnumb());
return null;
Problem is that getSelectedRow method doesnt get new (edited) values, old values are still used.
I have tried to use ActiveButton with same method and it works fine in that case. New values are selected from active row and inserted into object.
JSF:
<af:table var="row" rowSelection="single" columnSelection="single"
value="#{ManageWO.material}" binding="#{ManageWO.materialTable}">
<af:column sortable="false" headerText="E-number">
<af:inputText value="#{row.enumb}" valueChangeListener="#{ManageWO.SaveMaterial}" autoSubmit="true"/>
</af:column>
<af:column sortable="false" headerText="Description">
<af:inputText value="#{row.desc}" valueChangeListener="#{ManageWO.SaveMaterial}" autoSubmit="true"/>
</af:column>
</af:table>
<af:activeCommandToolbarButton text="Save" action="#{ManageWO.EditData}"/>
What is a correct place from where save method should be called to get new (edited) values from ADF table?
Thanks.Did you look into the valueChangeEvent?
It has oldValue and newValue attributes.
public void SaveMaterial(ValueChangeEvent valueChangeEvent) {
Object oldVal = valueChangeEvent.getOldValue();
Object newVal = valueChangeEvent.getNewValue();
// check if you see what you are looking for.....
getSelectedRow();
SaveMaterial(material);
}Timo -
How to get the return values from a web page
Hi all :
how to get the return values from a web page ? I mean how pass values betwen webflow and web page ?
thank you very much
Edited by: jingying Sony on Apr 15, 2010 6:15 AM
Edited by: jingying Sony on Apr 15, 2010 6:18 AMHi,
What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
Regards,
Karri -
Getting all the values from a JList
Hi,
I want to get all the values from a JList and store it into an array. Any method is available to perform this task? Pls help me out with this task.Use getModel() on the list to get the ListModel and then call getSize() and getElementAt(int) to loop over the elements
HTH
Mike -
How Can I get multi column values from dynamic search help?
Hi Gurus;
I'm using dynamic search help in my program.
I want to get multi column values from search help. But I dont know solution for this issue.
I'm using F4IF_INT_TABLE_VALUE_REQUEST FM.
How Can I get multi column values from dynamic search help?
Thanks.Believe it or not, the same FM worked for me in a dynpro. I will try to explain here how it works in custom screen and then you can do your work for other screens or program types. I am not going to write my actual work but will explain in general.
I have 4 fields (FLD1, FLD2, FLD3, FLD4) and i made the search based on FLD2 and when user click on a line (could be any field), then this would bring the line on to the screens.
There are like 3 steps.
You have your value_tab for my fields FLD1, FLD2, FLD3 and FLD4. This is just the data that we pass into the FM. (data: IT_VALTAB type table of ZVAL_TABLE)
Next map the screen fields into an internal table (data: It_dynpfld type table of dselc ). I also have other internal tables defined (just to keep it straight, i will be putting here) data: It_return type standard table of ddshretval.
Next step is to call the function module. Make sure you have values in IT_VALTAB.
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'FLD2'
value_org = 'S'
tables
value_tab = It_VALTAB
return_tab = It_return
dynpfld_mapping = It_dynpfld
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
perform get_selected_fields tables It_return.
endif.
The code within the perform GET_SELECTED_FIELDS - We need to map the result fields after user selects it. The code goes like this. This is step is to update the dynpro fields.
I need a internal table as well as a work area here. like,
data: lt_fields type table of dynpread,
la_fields type dynpread.
field-symbols: <fs_return> type ddshretval.
so fill out LT_FIELDS from the IT_RETURN table
loop at lt_return assigning <fs_return>.
la_fields-fieldname = <fs_return>-retfield.
la_fields-fieldvalue = <fs_return>-fieldval.
append la_fields to lt_fields.
clear: la_fields.
endloop.
Call the FM to update the dynpro
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-repid
dynumb = '1002' "This is my screen number. You could use 1000 for selection screen (hope so)
tables
dynpfields = lt_fields
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
others = 8.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
good luck -
How to get the Node Value from XmlValue result?
Hi ,
I am not able to get the Node Value from the result. In my XQuery im selecting till a Node, if i change my query as
collection('PhoneBook')/phone_book/contact_person/address/string()", qc);
im getting the node value, but here the problem is its not a Node so i cannot get the Node name.
So how can i get the Node Name and Node value together?
any help please ????
XML :
<?xml version="1.0" encoding="UTF-8"?>
<phone_book>
<contact_person>
<name>
<first_name>Michael</first_name>
<second_name>Harrison</second_name>
</name>
<address city="yyyyy" pincode="600017" state="xxxxx">
176 Ganesan street, Janakinagar, alwarthirunagar
</address>
</contact_person>
<phone_number type="mobile">9881952233</phone_number>
<phone_number type="home">044-24861311</phone_number>
<phone_number type="office">080-12651174</phone_number>
</phone_book>
Code:
XmlQueryContext qc = manager.createQueryContext();
XmlResults rs = manager.query
("collection('PhoneBook')/phone_book/contact_person/address", qc);
while(rs.hasNext()){
XmlValue val = rs.next();
System.out.println(val.getNodeName() + " = [ " + val.getNodeValue() + " ] ");
Output
address = [ ]You are right, this seemed un-intuitive to me too, but I finally understood how it's done.
The "value" of a node is actually the total amount of text that is not contained in any of the node's child nodes (if any). So a node with child nodes can still have text value.
To get the 'value' of an element node, you must therefore concatenate the values of all children of type "XmlValue::TEXT_NODE", of that node. Try it.
In your example, the <address> node has no child elements, my guess is that BDB XML stores the address string "176 Ganesan street, Janakinagar, alwarthirunagar" inside a child node of <address> node (of type XmlValue::TEXT_NODE) because you wrote the string on a separate line. -
Bonjour,
Suite au passage à la version CVI 2013, il faut passer par un fichier .obj au lieu du .c quand on veut utiiser la LoadExternalModule.
Le pb qui en résulte impossibilité de récupérer la valeur des control dans l'uir géré par le .obj qui est appelé par une dll.
Autrement, il m'est impossible de faire parvenir à la dll les valeur des control ( dll qui appelle le .obj).
Quelqu'un a eu le même soucis amigos?
Merci
Hi,
When using the LoadExternalModule function in CVI 2013, we can no longer use a .c file. Instead we have to use an .obj file.
My issue is that' impossible for me to get a control value from an .iur managed by the .obj witchi is called by a dll.
Otherwise it's impossible for me to get the control vale when calling the .obj from a dll.
Any suggestions Amigos
ThanksFor people who could be interested in, here the code I provided to the customer. This code demonstrates that calling a function defined in a .obj file from a DLL which is called itself by a program can be realized without throwing any error.
In order to use this example, you will have to :
1) Open "main.cws"
2) Define "Madll" as Active Project (right clic on the project and click on "Set Active Project")
3) Build the DLL (CTRL+M)
4) Define "Main" as Active Project
5) Click on "Debug Project" in order to build the executable and run it
This example has been built with CVI 2013.
Jérémy C.
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
Travaux Pratiques d'initiation à LabVIEW et à la mesure
Du 2 au 23 octobre, partout en France
Attachments:
main.zip 70 KB -
Getting 2nd Least Value from Different Column
Hi there All,
I have one odd requirement.
I hava table which has diffrent columns of numeric Datatype.
The task is to get the least values from the table.
I can take the least value by least(col1,col2,col3 ...) function.Until this stage it is fine.
But also I have take 2nd least value and 3rd least value, which I am quite unsure how to get it.
Looking forward for suggestions.
Thanks in Advance.
Regards,
AjeetThe following is a generic solution that will allow you to select the nth least and allow you to pass as many column names as you like and will return null if the nth least requested exceeds the number of distinct values. The nleast function that I wrote uses the str2tbl function by Tom Kyte. I have included a demonstration of its usage below. The value returned for the 1st least is the same as that returned by the least function.
This should have been posted on the SQL and PL/SQL discussion group of these forums, rather than the general database. I also posted the same response in the SQL discussion group of the Orafaq forums.
scott@ORA92> -- test data:
scott@ORA92> SELECT * FROM your_table
2 /
COL1 COL2 COL3
1 2 3
4 6 5
8 7 9
11 12 10
15 13 14
18 17 16
6 rows selected.
scott@ORA92> -- type and functions:
scott@ORA92> create or replace type myTableType as table of number;
2 /
Type created.
scott@ORA92> create or replace function str2tbl( p_str in varchar2 )
2 return myTableType
3 as
4 l_str long default p_str || ',';
5 l_n number;
6 l_data myTableType := myTabletype();
7 begin
8 loop
9 l_n := instr( l_str, ',' );
10 exit when (nvl(l_n,0) = 0);
11 l_data.extend;
12 l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
13 l_str := substr( l_str, l_n+1 );
14 end loop;
15 return l_data;
16 end;
17 /
Function created.
scott@ORA92> CREATE OR REPLACE FUNCTION nleast
2 (p_n IN NUMBER,
3 p_nums IN VARCHAR2)
4 RETURN NUMBER
5 AS
6 v_nleast NUMBER;
7 BEGIN
8 SELECT DISTINCT column_value
9 INTO v_nleast
10 FROM (SELECT column_value,
11 DENSE_RANK () OVER (ORDER BY column_value) AS num_rk
12 FROM (select *
13 from table (CAST (str2tbl (p_nums) AS mytabletype)))
14 WHERE column_value IS NOT NULL)
15 WHERE num_rk = p_n;
16 RETURN v_nleast;
17 EXCEPTION
18 WHEN OTHERS THEN RETURN NULL;
19 END nleast;
20 /
Function created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> -- query:
scott@ORA92> SELECT col1, col2, col3,
2 LEAST (col1, col2, col3) AS the_least,
3 nleast (1, col1 || ',' || col2 || ',' || col3) AS first_least,
4 nleast (2, col1 || ',' || col2 || ',' || col3) AS second_least,
5 nleast (3, col1 || ',' || col2 || ',' || col3) AS third_least,
6 nleast (4, col1 || ',' || col2 || ',' || col3) AS fourth_least
7 FROM your_table
8 /
COL1 COL2 COL3 THE_LEAST FIRST_LEAST SECOND_LEAST THIRD_LEAST FOURTH_LEAST
1 2 3 1 1 2 3
4 6 5 4 4 5 6
8 7 9 7 7 8 9
11 12 10 10 10 11 12
15 13 14 13 13 14 15
18 17 16 16 16 17 18
6 rows selected. -
How to get updated table values from objectlistdataproviders
how to get updated table values from objectlistdataproviders
Hi,
Here is a sample code
start-of-selection.
*Select the data you need into an internal table
loop at it_mara into wa_mara.
data that needs to be displayed in the output list
write:/ box as checkbox,
wa_mara-matnr under text-001,
wa_mara-maktx under text-002,
wa_mara-lgort under text-003.
Hide the data that needs to moved to internal table
hide:wa_mara-matnr, wa_mara-maktx, wa_mara-lgort.
endloop.
clear wa_mara.
end-of-selection.
lines = sy-linno.
at line-selection.
clear:it_matnr.
do lines times.
check sy-index > 1.
box = space.
read line sy-index field value box.
if box = 'X'.
*data selected using check box is moved to internal table
append wa_mara to it_matnr.
endif.
enddo.
Regards,
Jisha. -
Get the Cookie Value from Different Application Servers
Hi All,
I am using the two applications with different application servers. How to get the cookie values from one to another application. Shall i know any sample codes?
Thanks
MaalanA cookie carries a domain name. The browser will only return cookies whose domain matches to domain to which the request is made, however although you can use a partial domain name providing it's not too generic. So, when you add a cookie you need to explicitly set the domain name on the cookie to, for example, your company suffix like ".acme.com", then the cookie should be returned to all the servers under that domain e.g. server1.acme.com and server2.acme.com.
-
Get a return value from a stored procedure.
hi all ,
i need to know where i am going wrong with the below code. I am trying to get a value from a stored procedure. the return type is int. The stored procedure works fine as i've debugged it. The variable have been declared correctly.
int n = 0;
proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
proc.registerOutParameter(1, java.sql.Types.INTEGER);
proc.setString(1, locationCode);
proc.setString(2, itemCode);
proc.execute();
n = proc.getInt(1);thanksHi ayub_a,
According the [ *setString*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html#setString(java.lang.String,%20java.lang.String)] method of the [*CallableStatement*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html] interface, the first parameter must be a parameter name and not an ordinal position index !!!
Edit : I've just found out the solution, it must be :
int n = 0;
proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
proc.registerOutParameter(1, java.sql.Types.INTEGER);
proc.setString(2, locationCode);
proc.setString(3, itemCode);
proc.execute();
n = proc.getInt(1);Edited by: Chicon on Jul 5, 2009 7:48 PM -
Get selected row values from Table view control
Hi ,
I am using transaction ME23N, would like to access row values from item table for selected row. I have written a script as in screen shot and its giving me error at java script step two. I want to get the PR number from item table for selected row.
With Regards
Vishal LokapurH Vishal,
Can you please share how you were able to resolve the issue regarding the selected row
in case of a table control .
Regards
Maybe you are looking for
-
How to load Test data from a Text file in ECATT
Hi, I have created a test configuration with a test script, system data container, and test data container. I have done the recording of a transaction and created the script. Parameterization is done for the script and have imported those parameters
-
i am on iTunes 11.4.04. My iphone iOs is 6.1.3 and has 14 GB. I am trying to backup on my iMac iOs 10.6.8 and it has 113 GB free, But I am getting error messgae that computer doesnt have enough free space
-
iChat use to work perfectly but now for about 3 weeks nearly everytime I open ichat it only displays connecting for about a minuete and then says connection timed out. It must be an application error because my other apple imac works perfectly to con
-
Setting the layer color property with javascript
Is it possible to set a layer's color in the layers palette using javascript? By default everything shows up with no layer color but if you right click (ctrl-click) on a layer you have the option to change the color to Red, Orange, Yellow, etc. My qu
-
Hi, I have a macbook air os x 10.9.5 and I have problems with the app store. It doesn't open anyway. so, how can I install it again or update. I have problems with preview too, the same, doesn't open the application