id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
2c5f6afd-b12c-40e8-8738-391b6d26dd38 | @Override
public void mouseClicked(MouseEvent e) {
} |
cbd2c265-583d-489f-951e-56eaaedd7080 | @Override
public void mouseDragged(MouseEvent e) {
U.CurMouse = e.getPoint();
} |
b3ed6d83-7c50-4ab1-84eb-d2c22b21b2e9 | @Override
public void mouseEntered(MouseEvent arg0) {
} |
bbe6df77-7516-4ba9-9a70-820f1ac4b961 | @Override
public void mouseExited(MouseEvent arg0) {
} |
7f71d133-bc4f-46cd-a391-a10f077d1025 | @Override
public void mouseMoved(MouseEvent e) {
U.CurMouse = e.getPoint();
} |
1dcf14c6-49f7-4d85-a48d-96cbcc31bc73 | @Override
public void mousePressed(MouseEvent e) {
U.CurMouse = e.getPoint();
U.mouseClick = true;
U.ticks_with_mouse_down = -200;
} |
65f154b0-3559-4493-8304-0aa57eb51f69 | @Override
public void mouseReleased(MouseEvent e) {
U.mouseClick = false;
if (U.ticks_with_mouse_down < 0) {
B.ProcessMouseClick();
}
} |
91ed96cd-bc27-4436-9b26-ee32916753e2 | public void NewCreative() {
Clear();
U.setC(1f);
U.setV(0.5f);
U.show_all_locations = false;
U.show_light_cones = false;
U.player = new PlayerShip(0 - U.world_x_pixels2, 0 - U.world_y_pixels2);
} |
499819e3-c9b3-4c43-adf0-9bbf520c437d | public void NewGame() {
Clear();
for (int n = 1; n <= U.nEnemies; ++n) {
int rx = 0, ry = 0;
while (rx < 200 && rx > -200) {
rx = (int) (U.R.nextFloat() * (U.world_x_pixels - 10) - U.world_x_pixels2);
}
while (ry < 200 && ry > -200) {
ry = (int) (U.R.nextFloat() * (U.world_y_pixels - 10 - U.UI)... |
b543fa84-dfa4-478d-8ee1-98180c807a2f | @Override
public void paint(Graphics g) {
// System.out.println("RecSize:"+U.list_of_rectangles.size()+" DebSize:"+U.list_of_debris.size()+" ShellSize:"+P.list_of_shells.size());
final Graphics2D g2 = (Graphics2D) g;
if (U.af_none == null) {
U.af_none = g2.getTransform();
U.af_none.translate(U.world_x_off... |
bc32e0f4-4c5d-4ac6-b0eb-3576a2544a93 | @Override
public void run() {
// lower ThreadPriority
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
// run a long while (true) this means in our case "always"
while (true) {
if (_TIME_OF_NEXT_TICK > System.currentTimeMillis()) {
// too soon to repaint, wait...
try {
Thread.sleep(Math... |
2a8a68e7-a5b9-44fc-95d5-391b34c92f8f | @Override
public void start() {
th = new Thread(this);
th.start();
} |
6b6eaa8e-6026-41bd-841f-9cdf2222f9d6 | @Override
public void stop() {
} |
5b9464a4-9419-46f9-bf04-d87fc2dcbed9 | private void Tick() {
if (U.mouseClick == true) {
if (++U.ticks_with_mouse_down > 0
&& U.ticks_with_mouse_down % 30 == 0) {
B.ProcessMouseClick();
}
}
if (U.currentMode == GameMode.Creative
&& U.CurMouse != null
&& (U.mouseClick || U.mouseDrag)
&& U.CurMouse.y > U.UI + U.world_y_offset
... |
14e1a70f-45d4-40a8-beb1-1abbdfeaec2f | @Override
public void update(Graphics g) {
final Graphics2D g2 = (Graphics2D) g;
// initialize buffer
if (dbImage == null) {
dbImage = createImage(this.getSize().width, this.getSize().height);
dbg = dbImage.getGraphics();
}
// clear screen in background
dbg.setColor(getBackground());
dbg.fillRec... |
68169f1c-0553-4af6-aef4-b172e2bfa1ae | @BeforeClass
public static void setUpBeforeClass() throws Exception {
serverThread = new Thread(new Runnable() {
@Override
public void run() {
try {
server = new WebServer();
server.runServer();
} catch (Exception e) {
}
}
});
serverThread.start();
Thread.sleep(3000);
} |
e412a017-db7f-4ff1-a83e-5023352149d6 | @Override
public void run() {
try {
server = new WebServer();
server.runServer();
} catch (Exception e) {
}
} |
40fccc6f-3923-46dc-bb76-c0108a1a4dd9 | @AfterClass
public static void tearDownAfterClass() throws Exception {
server.shutdown();
serverThread.join();
} |
c415540f-04e5-4dac-bffe-e59abd7f9505 | @Test
public void testGreenPath() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("http://127.0.0.1:5555/");
CloseableHttpResponse response1 = httpclient.execute(httpGet);
assertTrue(EntityUtils.toString(response1.getEntity()).indexOf(
"Meant... |
667fc844-9ac4-4e13-a3cc-ef16c217833b | @Test
public void testError500() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("http://127.0.0.1:5555/api/golan/error");
CloseableHttpResponse response1 = httpclient.execute(httpGet);
assertTrue(response1.getStatusLine().getStatusCode()==500);
... |
035f99c8-6fb0-4dbb-93b4-af1a57ee86f1 | @Test
public void testRedirect() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("http://127.0.0.1:5555/api/golan/redirect?destination=http://ynet.co.il");
CloseableHttpResponse response1 = httpclient.execute(httpGet);
System.out.println(response... |
19a621cd-650d-4aef-866c-b4e19df2befb | @Test
public void testBadRequest() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("http://127.0.0.1:5555/api/golan/badrequest");
CloseableHttpResponse response1 = httpclient.execute(httpGet);
System.out.println(response1.getStatusLine().getStatu... |
e6760089-3957-40b6-91d9-c3d887330fee | @Test
public void testGreenPathWithPost() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("http://127.0.0.1:5555/api/golan/post");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair(... |
efa29404-4473-4923-acc6-615058535b0a | @Test
public void testCorrupted() throws Exception {
int sessionsBefore = server.getSessionsCount();
Socket clientSocket = new Socket("127.0.0.1", 5555);
DataOutputStream outToServer = new DataOutputStream(
clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamRea... |
8ce0de6a-74fb-48ed-a8ac-ec158f7390a5 | @Test
public void loadTest() throws Exception {
int sessionsBefore = server.getSessionsCount();
ArrayList<Thread> threadList = new ArrayList<>();
for (int i= 0;i<10;i++){
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
for (int z=0;z<30;z++){
testGreenPath(... |
3f10dce7-1112-40f1-b522-527a1670d1eb | @Override
public void run() {
try {
for (int z=0;z<30;z++){
testGreenPath();
}
}catch (Exception e){
errorHappened = true;
}
} |
8cb10a90-ea05-4592-ba34-d7b5cb346a6b | @Override
public HTTPResponse handleRequest(HTTPRequest request) throws Exception {
// TODO Auto-generated method stub
HTTPResponse resp = new HTTPResponse();
resp.setContent("{'name':asaf}".getBytes());
return resp;
} |
4b5fda8c-bc4d-40ce-844b-b13cf308dec8 | @Override
public HTTPResponse handleRequest(HTTPRequest request) throws Exception {
if (request.getUri().endsWith("/get")){
String getParams = request.getParameters().toString();
return new HTTPResponse(getParams);
}
if (request.getUri().endsWith("/post")){
String postParams = request.postParameters().t... |
cbfffef5-7f82-410d-af20-6f00b108c954 | public HTTPRequest(String raw) {
this.raw = raw;
parse();
} |
6c3a26ec-c977-42c3-9c96-919beed2ee8a | public String getMethod() {
return method;
} |
a0c56e15-fba8-4450-a204-8ba4ca05e54d | public String getLocation() {
return location;
} |
a5fdfc17-8521-473a-9576-d0119940afbd | public String getHead(String key) {
return headers.get(key);
} |
5a5489c0-316f-4ed2-88b8-d868ed64e424 | public String getVersion(){
return version;
} |
033b65b5-6b55-4943-b000-1e620a96ac82 | public String getUri(){
return uri;
} |
76dc0239-c3aa-4901-90f0-4a00e0387afe | public Map<String, List<String>> getParameters(){
return parameters;
} |
ce70952a-b403-497e-9810-b5221758918b | public Map<String, List<String>> postParameters(){
return postParameters;
} |
559aa1a0-72c2-4b1f-b7db-5f276a72b6e4 | private void parse() {
// parse the first line
StringTokenizer tokenizer = new StringTokenizer(raw);
method = tokenizer.nextToken().toUpperCase();
location = tokenizer.nextToken();
version = tokenizer.nextToken();
// parse the headers
String[] lines = raw.split("\... |
d37bd748-465e-4488-a4d0-d4b3c7388c32 | private String decodePercent(String str) {
String decoded = null;
try {
decoded = URLDecoder.decode(str, "UTF8");
} catch (UnsupportedEncodingException ignored) {
return str;
}
return decoded;
} |
0fba2f72-3069-4f03-858d-0380f04e5538 | private Map<String, List<String>> decodeParameters(String queryString) {
Map<String, List<String>> parms = new HashMap<String, List<String>>();
if (queryString != null) {
StringTokenizer st = new StringTokenizer(queryString, "&");
while (st.hasMoreTokens()) {
Str... |
0010de52-b0e2-4b8a-8db1-20c7a60704e9 | public void loadConfiguration() throws Exception {
YamlReader reader = new YamlReader(new FileReader("server.yml"));
Object object = reader.read();
Map map = (Map)object;
serverSettings = (Map)map.get("basic_conf");
ArrayList<Map<String,String>> obj = (ArrayList<Map<String,String>>)map.get("ur... |
e391a796-b2b0-41c9-b399-fca42412ad74 | public String getAddress() {
return (String)serverSettings.get("address");
} |
a17e0ccd-9bd6-4bf9-a411-8766dec25db8 | public int getPort() {
return Integer.parseInt((String)serverSettings.get("port"));
} |
559c44f7-4746-491d-8f02-3cde54f77f92 | public String getRootDocument() {
return (String)serverSettings.get("root_doc");
} |
b48b932d-1771-42d7-9793-0dcd81529ffc | public HttpHandler getHandlerForLocation(String uri){
for (Pattern p:urlMappingCompiled.keySet()){
Matcher matcher = p.matcher(uri);
if (matcher.find()){
return urlMappingCompiled.get(p);
}
}
return null;
} |
8852744b-0b48-4e31-8592-f91adf1f0b45 | public HTTPSession(SocketChannel channel) {
this.channel = channel;
} |
03921f14-232c-4611-88ef-2a72770a9e27 | public boolean readData() throws IOException {
buffer.clear();
buffer.limit(buffer.capacity());
int read = channel.read(buffer);
if (read < 0) {
return false;
}
byte[] res = new byte[read];
buffer.flip();
buffer.get(res);
requestData = new String(res);
return true;
} |
76c3fcc9-14fb-4fff-8e70-79fca4ee6b4a | public void sendResponse(HTTPResponse response) {
response.addDefaultHeaders();
try {
writeLine(response.getVersion() + " " + response.getResponseCode()
+ " " + response.getResponseReason());
for (Map.Entry<String, String> header : response.getHeaders()
.entrySet()) {
writeLine(header.getKey() +... |
59572031-7df9-4a82-827b-094430760b2f | public String getRequestData() {
return requestData;
} |
41aadb43-92ed-4ebb-88b9-6d5ce63a24c9 | public void close() {
try {
channel.close();
} catch (IOException ex) {
logger.log(Level.FINE, "Error closing connection.", ex);
}
} |
915020a3-6150-41d8-abd2-7493ff7ebf2c | private void writeLine(String line) throws IOException {
channel.write(encoder.encode(CharBuffer.wrap(line + "\r\n")));
} |
4088513d-8dc0-40b5-a06a-d0a04f3557e1 | protected WebServer() throws IOException{
} |
287e9fc0-f0aa-497f-8948-74ba3becc4d4 | protected void initServer() throws Exception {
serverConf= new ServerConf();
serverConf.loadConfiguration();
server.socket().bind(new InetSocketAddress(serverConf.getAddress(),serverConf.getPort()));
server.configureBlocking(false);
server.register(selector, SelectionKey.OP_ACCEPT);
... |
bef57bbc-4a28-4f0c-9476-339d7e52f363 | public void runServer() throws Exception {
initServer();
logger.info("Meantesh server started and waiting for requests.");
while (isRunning) {
run();
Thread.sleep(10);
}
} |
2e9c9056-b292-47ef-b11b-30c4921950b5 | public final void run() {
try {
selector.selectNow();
Iterator<SelectionKey> i = selector.selectedKeys().iterator();
while (i.hasNext()) {
SelectionKey key = i.next();
i.remove();
if (!key.isValid()) {
contin... |
5b86b0fd-da18-45ea-a2f8-76f780bb16b2 | protected HTTPResponse handle(HTTPSession session, HTTPRequest request) {
try {
HttpHandler handler = serverConf.getHandlerForLocation(request.getUri());
if (handler != null) {
return handler.handleRequest(request);
}
return staticContentHandler.handleRequest(request);
}catch (T... |
c5ad5d24-24ad-43a5-b0b1-6e5f2ded5d6d | public final void shutdown() {
isRunning = false;
try {
selector.close();
server.close();
} catch (IOException ex) {
// do nothing, its game over
logger.finest("Error closing connection");
}
} |
d785860f-5ed5-4240-b11c-4b6a772e1fa4 | public int getSessionsCount(){
return sessionsCount;
} |
437b83d6-8381-415d-a248-ef539b84e743 | public static void main(String[] args) throws Exception {
WebServer server = new WebServer();
server.runServer();
} |
2a3c107f-8915-477d-b559-312f1155c581 | public HTTPResponse() {
} |
7befe1f7-cb8b-42d8-b952-b69f6e79d1ed | public HTTPResponse(String content) {
this();
setContent(content);
} |
56e2cc22-ae62-4226-9f73-e7fed43419bd | public HTTPResponse(int responseCode,String responseReason) {
this();
this.responseCode = responseCode;
this.responseReason = responseReason;
} |
285a6701-91c5-4b93-9e6f-851ebbea4e95 | public void addDefaultHeaders() {
headers.put("Date", new Date().toString());
headers.put("Server", "Java NIO Webserver by Golan D inspired by md_5");
headers.put("Connection", "close");
headers.put("Content-Length", Integer.toString(content.length));
} |
25803914-f272-48de-8b45-ebb284fd581f | public String getVersion(){
return version;
} |
17d342a9-102e-4abb-8f4e-b16888381f0d | public int getResponseCode() {
return responseCode;
} |
e489e5c9-9746-4260-80b4-86a1b70ca683 | public String getResponseReason() {
return responseReason;
} |
c4114446-38a3-4276-9863-012e40126023 | public String getHeader(String header) {
return headers.get(header);
} |
a4fefc08-a1e7-4c16-a7d3-ac23f9c361a7 | public byte[] getContent() {
return content;
} |
216cd666-e07e-4cc0-a46a-773d99a4ecdc | public void setResponseCode(int responseCode) {
this.responseCode = responseCode;
} |
42424b48-c6b1-403b-88bb-57ed3be262c8 | public void setResponseReason(String responseReason) {
this.responseReason = responseReason;
} |
533e71db-9dec-42ec-851b-c1d97661eec8 | public void setContent(String content) {
setContent(content.getBytes());
} |
eaff1bc5-178c-427f-86b5-bedd3f6cd219 | public void setContent(byte[] content) {
this.content = content;
} |
fd429758-a878-40b8-8635-3312ff1448ce | public void setHeader(String key, String value) {
headers.put(key, value);
} |
2461ae4f-851d-42f2-9848-4b989de20591 | public Map<String,String> getHeaders(){
return headers;
} |
411b50b1-88b8-4ba8-bca9-f45d2b0e26e5 | public HttpResponseRedirect(){
super(302,"Redirect");
} |
48729840-645d-46c6-87f1-757cbd2d16f4 | public HttpResponseRedirect(String redirectTo){
this();
this.setHeader("Location",redirectTo);
} |
042bded0-cd39-490b-b3cd-99bca91056c6 | public HttpResponseNotFound(String resource){
super(404,"NOT FOUND");
setContent(String.format("Resource %s not found!",resource).getBytes());
} |
ef3c49b7-52c2-44d3-8dd9-b76d00365f8e | public HttpResponseBadRequest(String resource){
super(400,"BAD Request");
setContent("Bad Request sent by client");
} |
ef0f0c87-ba20-4425-896d-85735ddf0f68 | public HttpResponseInternalServerError(){
super(500,"INTERNAL SERVER ERROR");
} |
91bd53e0-41aa-4f30-a320-7308e1759127 | public HttpResponseInternalServerError(Throwable t){
this();
setContent(String.format("Internal Server Error: %s ",t.getLocalizedMessage()));
} |
2777b622-c836-4a70-8716-d42bfedafb27 | public HttpResponseInternalServerError(String message){
this();
setContent(String.format("Internal Server Error: %s ",message));
} |
d682ba95-9727-4488-91e7-0510bf8d53bf | public StaticContentHandler(ServerConf configuration){
this.serverConf = configuration;
} |
9940152e-dc75-4a46-bd1b-e1bbafccc869 | public HTTPResponse handleRequest(HTTPRequest request) throws Exception{
HTTPResponse response = new HTTPResponse();
File f = null;
if ("/".equals(request.getLocation()) || "".equals(request.getLocation())){
f = new File(serverConf.getRootDocument(),"server_default.html");
} els... |
b111a216-e5f3-494a-806b-6c722371d25d | public HTTPResponse handleRequest(HTTPRequest request) throws Exception; |
c97fd6a0-5142-4092-9dbf-321a5b0950f8 | public Comment() {} |
00f330bc-5735-4626-a4db-9799fe1ee0c8 | public Comment(int commentId, String content, Date createdDateTime,
Project project, User user) {
super();
this.commentId = commentId;
this.content = content;
this.createdDateTime = createdDateTime;
this.project = project;
this.user = user;
} |
c31cc09b-1c6c-49fa-be6f-f0866e902383 | public int getCommentId() {
return commentId;
} |
45fdb3b3-66ea-4741-8923-003a2b88512d | public void setCommentId(int commentId) {
this.commentId = commentId;
} |
5f207617-2c77-4c9b-b88d-5ed2bf5db174 | public String getContent() {
return content;
} |
86973e42-55fa-42b4-b606-f4e8b7dac105 | public void setContent(String content) {
this.content = content;
} |
8ea428ec-cf69-4592-9714-0699c785bf07 | public Date getCreatedDateTime() {
return createdDateTime;
} |
4a0d5b1d-4229-4ddd-916c-1568fe466378 | public void setCreatedDateTime(Date createdDateTime) {
this.createdDateTime = createdDateTime;
} |
76686511-6635-43bf-8b2c-e577963f307d | public Project getProject() {
return project;
} |
b78b8147-4c63-40f6-b9d0-e3d0038c6c98 | public void setProject(Project project) {
this.project = project;
} |
b50cf795-58ec-40ce-acbb-d4b6f98741b8 | public User getUser() {
return user;
} |
4d8b964e-bcea-428b-b262-6eb79c1183c3 | public void setUser(User user) {
this.user = user;
} |
669b70ed-0451-4ed1-904b-70d8d02ab02c | public Category() {} |
2d26ddc6-1133-48ed-8c82-725b1a760589 | public Category(int categoryId, String name) {
super();
this.categoryId = categoryId;
this.name = name;
} |
84fd0aef-5591-4174-ac06-ed928d3931bc | public int getCategoryId() {
return categoryId;
} |
473a0abb-2efd-477b-b64d-678d73fc6a61 | public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
} |
acc7211b-0e64-44cc-a549-ed8090534662 | public String getName() {
return name;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.