Home > Web Front-end > JS Tutorial > jabsorb notes_A few small examples page 1/2_js object-oriented

jabsorb notes_A few small examples page 1/2_js object-oriented

PHP中文网
Release: 2016-05-16 19:00:01
Original
1257 people have browsed it

I studied jabsorb and wrote a few simple examples, hoping to help newbies get started quickly.
First quote jabsorb-1.2.2.jar, slf4j-api-1.4.2.jar, slf4j-jdk14-1.4.2.jar, jsonrpc.js
class files:
package com.test;

import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util .Map;
import java.util.Set;



public class TestJabsorb {
public String getMessage(String s) {
return "Hello: " s ;
}

public String getMessage() {
return "No parameters";
}

public String getMessage(List al) {
String res= "list parameter:";
for(Iterator it = al.iterator();it.hasNext();){
Object next = it.next();
res =next ",";
}
return res;
}

public String getMessage(String[] array) {
String res="Array parameters:";
for(int i= 0;ires =array[i] ",";
}
return res;
}

public String getMessage(Map map ) {
String res="map parameter: ";
Set entrySet = map.entrySet();
for(Iterator it = entrySet.iterator();it.hasNext();){
Object next = it.next();
res =next ",";
}
return res;
}

public String getMessage(Test2 t2) {
String res="Test2(bean) parameters:";
res =t2.p1 ",";
res =t2.p2 ",";
return res;
}

public String getMessage(Test3 t2) {
String res="Test3(bean) parameter: ";
res =t2.p1 ",";
res =t2.p2 ",";
return res;
}

public Test2 getMessage2() {
Test2 res=new Test2();
res.p1="11";
res.p2 ="22";
return res;
}

public Test3 getMessage3() {
Test3 res=new Test3();
res.p1="11";
res.p2="22";
return res;
}

public List getList()
{
List list = new LinkedList();
list .add("China");
list.add(1234);
return list;
}

public Map getMap()
{
Map map = new HashMap();
map.put("bird", "bird");
map.put("human", "human");
return map;
}

}


package com.test;


public class Test2{
public String p1;
public String p2;
public String getP1 () {
return p1;
}
public void setP1(String p1) {
this.p1 = p1;
}
public String getP2() {
return p2;
}
public void setP2(String p2) {
this.p2 = p2;
}

}


Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template