Implement the transmission of arrays between amf3 and Java (dynamic creation of arrays )...

Source: Internet
Author: User

First, amf3 does not seem to support parsing arrays such as list. arraylist... the Java client transfers List objects, and amf3 cannot be parsed as array...

The reason is: amf3 only supports the basic data type...

Therefore, you need to convert data such as list to object []! In this way, amf3 can parse the array passed by Java into array...

Because the array is created, you need to set the length of the array even if no value is assigned at the beginning, for example, string [] mystring = new string [5];

Therefore, you need to dynamically create an object [] array. But often, length is unknown at the beginning, such as the resultset in JDBC...

 

@ Suppresswarnings ("unchecked") <br/> Public seed_warehouse [] findseedwarehousebyuserid (INT userid) <br/> throws sqlexception {<br/> string SQL = "select * From lesogo_seed_warehouse where user_id =? "; <Br/> dB. dopstm (SQL, new object [] {userid}); <br/> resultset rs = dB. getrs (); <br/> If (RS! = NULL) {<br/> int I = 0; // obtain the number of rows in the database table! <Br/> while (RS. next () {<br/> I ++; <br/>}< br/> seed_warehouse [] SWS = new seed_warehouse [I]; <br/> Rs. beforefirst (); // The cursor points to the starting position! <Br/> Int J = 0; <br/> while (RS. next () {<br/> seed_warehouse Sw = new seed_warehouse (); <br/> SW. setid (RS. getint (1); <br/> SW. setcrop_class_name (RS. getstring (2); <br/> SW. setcrop_count (RS. getint (3); <br/> SW. setuser_id (RS. getint (4); <br/> SWS [J ++] = Sw; // assign values to objects in the specific data location! <Br/>}< br/> return SWS; <br/>}< br/> return NULL; <br/>}

 

Summary:

I have to seriously study the amf3 protocol...

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.