/*
* Copyright 2005 Joe Walker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.getahead.dwrdemo.people;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import org.directwebremoting.util.Logger;
/**
* A container for a set of people
* @author Joe Walker [joe at getahead dot ltd dot uk]
*/
public class People
{
/**
* Pre-populate with random people
*/
public People()
{
log.debug("Generating a new set of random people");
for (int i = 0; i < 5; i++)
{
people.add(getRandomPerson());
}
}
/**
* Accessor for the current list of people
* @return the current list of people
*/
public Set getAllPeople()
{
return people;
}
/**
* Insert a person into the set of people
* @param person The person to add or update
*/
public void setPerson(Person person)
{
log.debug("Adding person: " + person);
if (person.getId() == -1)
{
person.setId(getNextId());
}
people.remove(person);
people.add(person);
}
/**
* Delete a person from the set of people
* @param person The person to delete
*/
public void deletePerson(Person person)
{
log.debug("Removing person: " + person);
people.remove(person);
debug();
}
/**
* the current list of people
*/
private Set people = new HashSet();
/**
* Create a random person
* @return a random person
*/
private Person getRandomPerson()
{
Person person = new Person();
person.setId(getNextId());
String firstname = FIRSTNAMES[random.nextInt(FIRSTNAMES.length)];
String surname = SURNAMES[random.nextInt(SURNAMES.length)];
person.setName(firstname + " " + surname);
String housenum = (random.nextInt(99) + 1) + " ";
String road1 = ROADS1[random.nextInt(ROADS1.length)];
String road2 = ROADS2[random.nextInt(ROADS2.length)];
String town = TOWNS[random.nextInt(TOWNS.length)];
String address = housenum + road1 + " " + road2 + ", " + town;
person.setAddress(address);
float salary = Math.round(10 + 90 * random.nextFloat()) * 1000;
person.setSalary(salary);
return person;
}
/**
* List the current people so we know what is going on
*/
protected void debug()
{
for (Iterator it = people.iterator(); it.hasNext();)
{
Person person = (Person) it.next();
log.debug(person.toString());
}
}
/**
* Get the next unique ID in a thread safe way
* @return a unique id
*/
private static synchronized int getNextId()
{
return nextId++;
}
/**
* The next ID, to get around serialization issues
*/
private static int nextId = 1;
private Random random = new Random();
private static final String[] FIRSTNAMES =
{
"Fred", "Jim", "Shiela", "Jack", "Betty", "Jacob", "Martha", "Kelly",
"Luke", "Matt", "Gemma", "Joe", "Ben", "Jessie", "Leanne", "Becky",
};
private static final String[] SURNAMES =
{
"Sutcliffe", "MacDonald", "Duckworth", "Smith", "Wisner", "Iversen",
"Nield", "Turton", "Trelfer", "Wilson", "Johnson", "Cowan", "Daniels",
};
private static final String[] ROADS1 =
{
"Green", "Red", "Yellow", "Brown", "Blue", "Black", "White",
};
private static final String[] ROADS2 =
{
"Close", "Drive", "Street", "Avenue", "Crescent", "Road", "Place",
};
private static final String[] TOWNS =
{
"Birmingham", "Kettering", "Paris", "San Francisco", "New York",
"San Mateo", "Barcelona",
};
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(People.class);
}
没有合适的资源?快使用搜索试试~ 我知道了~
ajax技术dwr.jar
共368个文件
gif:114个
js:89个
xml:79个
需积分: 9 1 下载量 193 浏览量
2008-10-30
22:04:01
上传
评论
收藏 2.14MB ZIP 举报
温馨提示
ajax异步提交技术的关键jar包.目前大于50%的公司在用,因为写javaScript太烦了,而且容易出错.
资源详情
资源评论
资源推荐
收起资源包目录
ajax技术dwr.jar (368个子文件)
People.class 5KB
Publisher.class 3KB
LiveHelp.class 3KB
Clock.class 3KB
JavascriptChat.class 3KB
JavaChat.class 2KB
AuthenticationAjaxFilter.class 2KB
Corporation.class 2KB
LoggingAjaxFilter.class 2KB
Person.class 2KB
Generator.class 2KB
AddressLookup.class 2KB
PublisherServletContextListener.class 1KB
Corporations.class 1KB
RandomSecurityAjaxFilter.class 1KB
JettyLauncher.class 1KB
Demo.class 1KB
Message.class 790B
Intro.class 707B
JSX.css 20KB
JSX_strict.css 20KB
JSX.css 19KB
generic.css 2KB
tabs.css 751B
logo.gif 7KB
select_a.gif 6KB
select.gif 6KB
select.gif 6KB
select.gif 6KB
header.gif 3KB
logo_234_18.gif 3KB
over.gif 2KB
selectover.gif 2KB
selectover.gif 2KB
over.gif 2KB
select.gif 2KB
doughnut.gif 2KB
focus.gif 1KB
on.gif 1KB
down.gif 1KB
file.gif 1KB
over_menu.gif 927B
down_menu.gif 927B
on_menu.gif 927B
fade_h.gif 888B
linearLine.gif 876B
arrow.gif 876B
pie.gif 871B
stackedLine.gif 869B
overlayLine.gif 841B
pieSeries.gif 839B
gridlines.gif 833B
stacked100Line.gif 832B
off.gif 831B
on.gif 831B
spc.gif 807B
selected.gif 683B
over.gif 628B
down.gif 628B
previous.gif 596B
on.gif 591B
next.gif 590B
off.gif 580B
default.gif 578B
folder.gif 577B
plotPoint.gif 570B
categoryAxis.gif 533B
plotBubble.gif 528B
linearAxis.gif 514B
overlayArea.gif 489B
linearArea.gif 483B
lineSeries.gif 480B
bubbleSeries.gif 410B
areaSeries.gif 399B
logarithmicAxis.gif 399B
scatterSeries.gif 398B
logo_16.gif 395B
legend.gif 389B
arrow.gif 368B
file.gif 366B
window.gif 366B
stacked100Area.gif 364B
open.gif 363B
disabled.gif 359B
stacked100Bar.gif 346B
chartLabel.gif 343B
linearColumn.gif 338B
stackedArea.gif 331B
bg.gif 319B
linearBar.gif 318B
bevel.gif 287B
stacked100Column.gif 283B
stackedBar.gif 282B
clusteredColumn.gif 281B
clusteredBar.gif 280B
stackedColumn.gif 260B
bottom.gif 243B
left.gif 241B
right.gif 240B
top.gif 235B
共 368 条
- 1
- 2
- 3
- 4
guntongnanmo
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0