text stringlengths 3 1.18M |
|---|
package cn._2dland.websocket.io;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import cn._2dland.websocket.model.message.Message;
/**
* 报文输入流,封装了对报文的读取
*
* @author deadblue
*/
public abstract class MessageInputStream extends FilterInputStream {
protec... |
package cn._2dland.websocket.io;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import cn._2dland.websocket.model.message.BinaryMessage;
import cn._2dland.websocket.model.message.ControlMessage;
import cn._2dland.websocket.model.message.Message;
import cn._2dlan... |
package cn._2dland.websocket.io;
import java.io.IOException;
import java.io.OutputStream;
import cn._2dland.websocket.model.message.BinaryMessage;
import cn._2dland.websocket.model.message.ControlMessage;
import cn._2dland.websocket.model.message.Message;
import cn._2dland.websocket.model.message.TextMessage;... |
package cn._2dland.websocket.io;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import cn._2dland.websocket.model.message.BinaryMessage;
import cn._2dland.websocket.model.message.ControlMessage;
import cn._2dland.websocket.model.message.Message;
import cn._2dlan... |
package cn._2dland.websocket.io;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import cn._2dland.websocket.model.message.Message;
/**
* 报文输出流,封装了对报文的写入
*
* @author deadblue
*/
public abstract class MessageOutputStream extends FilterOutputStream {
pu... |
package cn._2dland.util;
/**
* 结束标记判断
* 当结束标记为一个字符序列时,可使用此类进行判断
*
* @author deadblue
*/
public class EndChecker {
/** 结束标识的字节序列 */
private byte[] byteSequence = null;
/** 字节序列指针 */
private int pointer = 0;
public EndChecker(byte[] flag) {
// 结束标识的字节序列
byteSequence = flag;
// 初始... |
package cn._2dland.util;
import java.io.ByteArrayOutputStream;
/**
* Base64工具类
*
* @author deadblue
*/
public class Base64 {
/** Base64编码用字符串 */
private static final String BASE64_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
/**
* Base64编码
*
* @param da... |
package test;
import java.math.BigInteger;
public class QQParser {
private static final String QQ_VIDEO_URL = "http://vtop.qqvideo.tc.qq.com/";
public static void main(String[] args) {
String vid = "7tBGpHA4vbP";
System.out.println(getVideoURL(vid));
}
private static String getVideoURL(Strin... |
package test;
import cn._2dland.tools.VideoHelper;
import cn._2dland.utils.HttpUtils;
@SuppressWarnings("unused")
public class FiftySixParser {
public static int[] PARSE_ARRAY = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62... |
package test;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
public class XMLReader {
public static void main(String[] args) {
String xmlFile = "D:\\qqvideo.xml";
try{
DocumentBuilder db = DocumentBu... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.io.StringWriter;
/**
* Test class. This file is not formally a member of the org.json library.
* It is just a casual test tool.
*/
@SuppressWarnings("unchecked")
public class Test {
/**
... |
package org.json;
/**
* The <code>JSONString</code> interface allows a <code>toJSONString()</code>
* method so that a class can change the behavior of
* <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
* and <code>JSONWriter.value(</code>Object<code>)</code>. The
* <code>toJSONString... |
package org.json;
import java.io.IOException;
import java.io.Writer;
/*
Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including witho... |
package org.json;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in... |
package org.json;
/**
* The JSONException is thrown by the JSON.org classes when things are amiss.
* @author JSON.org
* @version 2008-09-18
*/
public class JSONException extends Exception {
/**
*
*/
private static final long serialVersionUID = 0;
private Throwable cause;
/**
* C... |
package org.json;
/*
Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2008 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package cn._2dland.utils;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactor... |
package cn._2dland.tools;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletR... |
package cn._2dland.tools;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Random;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
... |
package cn._2dland.servlet;
import java.io.IOException;
import java.util.Random;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.w3c.dom.Document;
import org.w3c.dom.Elemen... |
package cn._2dland.servlet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Random;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;... |
package cn._2dland.servlet;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Random;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.w3c.dom.Docume... |
package cn._2dland.servlet;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSer... |
package cn._2dland.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import cn._2dland.tools.... |
package cn._2dland.bots;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public final class Utils {
private static String[] STATUS = {"正常", "停用", "出错"};
private static SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.CHINA);
public static ... |
package cn._2dland.bots.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn._2dland.bots.TaskManager;
import cn._2dland.bots.jdo.AccountMana... |
package cn._2dland.bots.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn._2dland.bots.TaskManager;
import cn._2dland.bots.U115Bot;
impor... |
package cn._2dland.bots.servlets;
/**
* <h1>远端服务器异常</h1>
* 发生此异常时,任务应该重试
* @author deadblue
*/
@SuppressWarnings("serial")
public class ServerException extends Exception {
public ServerException(String message) {
super(message);
}
}
|
package cn._2dland.bots.jdo;
import java.util.List;
import javax.jdo.Query;
import cn._2dland.bots.jdo.models.Account;
@SuppressWarnings("unchecked")
public class AccountManager extends EntityManager{
public AccountManager() {
super();
}
/** 获取账户 */
public Account getAccount(Long accoutnId)... |
package cn._2dland.bots.jdo;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;
public final class PMFactory {
private final static PersistenceManagerFactory pmfInstance = JDOHelper.getPersistenceManagerFactory("transactions-optional");
/**
* 获取工厂实例
* @return
*/
public stati... |
package cn._2dland.bots.jdo;
import javax.jdo.PersistenceManager;
/**
* 实体管理器类:提供了连接、关闭持久化管理器的基本功能。
* 所有对实体进行管理的类,都可继承本类。
* @author deadblue
*/
public abstract class EntityManager {
protected PersistenceManager pm = null;
protected boolean bOpened = false;
public EntityManager() {
pm = PMFacto... |
package cn._2dland.bots.jdo.models;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(identityType = IdentityType.AP... |
package cn._2dland.bots.jdo.models;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(identityType = IdentityType.AP... |
package cn._2dland.bots.jdo;
import java.util.List;
import javax.jdo.Query;
import cn._2dland.bots.jdo.models.PickRecord;
@SuppressWarnings("unchecked")
public class PickRecordManager extends EntityManager {
public PickRecordManager() {
super();
}
public void addPickRecord(PickRecord record) {
... |
package cn._2dland.bots;
import javax.servlet.http.HttpServletResponse;
import cn._2dland.bots.jdo.AccountManager;
import cn._2dland.bots.jdo.models.Account;
import cn._2dland.gae.httpclient.HttpClient;
import cn._2dland.gae.httpclient.NameValuePair;
import cn._2dland.gae.httpclient.method.GetMethod;
import ... |
package cn._2dland.bots;
import cn._2dland.bots.servlets.BotServlet;
import com.google.appengine.api.taskqueue.QueueFactory;
import com.google.appengine.api.taskqueue.TaskOptions;
/**
* 任务管理器
*/
public class TaskManager {
private TaskManager() {}
/**
* 创建任务
* @param action - 任务动作
* @param ... |
package cn._2dland.gae.httpclient;
import cn._2dland.gae.httpclient.method.HttpMethod;
/**
* Simple HttpClient For GAE/J
*/
public class HttpClient {
private HttpClientParams params;
private HttpCookie cookie = new HttpCookie();
public HttpClient() {
params = new HttpClientParams();
}
public... |
package cn._2dland.gae.httpclient;
import java.util.ArrayList;
import java.util.List;
public class HttpCookie {
private List<Cookie> cookies = new ArrayList<Cookie>();
public HttpCookie() {
}
public boolean isEmpty() {
return (cookies==null || cookies.isEmpty());
}
/** 添加cookie */
public v... |
package cn._2dland.gae.httpclient.method;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java... |
package cn._2dland.gae.httpclient.method;
import java.util.Iterator;
import java.util.Map.Entry;
public class PostMethod extends HttpMethod {
public PostMethod() {
super();
addRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
public PostMethod(String url) {
super(url);
addRe... |
package cn._2dland.gae.httpclient.method;
import java.util.Iterator;
import java.util.Map.Entry;
public class GetMethod extends HttpMethod {
public GetMethod(String url) {
super(url);
}
public String getMethodName() {
return "GET";
}
public String getURL() {
StringBuffer urlBuf = new Strin... |
package cn._2dland.gae.httpclient;
import java.util.HashMap;
import java.util.Map;
public class HttpClientParams {
public static final String USER_AGENT = "userAgent";
public static final String FOLLOW_REDIRECT = "followRedirect";
public static final String USE_CACHES = "useCaches";
public static final S... |
package cn._2dland.gae.httpclient;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class Cookie {
public String name;
public String value;
public String domain;
public String path;
public long expires;
... |
package cn._2dland.gae.httpclient;
public class NameValuePair {
public String name;
public String value;
public NameValuePair() {}
public NameValuePair(String name, String value) {
this.name = name;
this.value = value;
}
public void set(String name, String value){
this.name = name;
thi... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/**
* The <code>JSONString</code> interface allows a <code>toJSONString()</code>
* method so that a class can change the behavior of
* <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
* and <code>JSONWriter.value(</code>Object<code>)</code>. The
* <code>toJSONString... |
package org.json;
import java.io.IOException;
import java.io.Writer;
/*
Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including witho... |
package org.json;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software a... |
package org.json;
/**
* The JSONException is thrown by the JSON.org classes when things are amiss.
* @author JSON.org
* @version 2010-12-24
*/
public class JSONException extends Exception {
private static final long serialVersionUID = 0;
private Throwable cause;
/**
* Constructs a JSONExcep... |
package org.json;
/*
Copyright (c) 2006 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2008 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish,... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package org.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, ... |
package cn._2dland.sakushi;
import java.util.Collection;
import java.util.HashSet;
/**
* 请求信息类
* @author deadblue
*/
public class Request {
/** 问题 */
private String problem = null;
/** 选项 */
private Collection<String> choices = new HashSet<String>();
/** 是否需要图表 */
private boolean chart = false... |
package cn._2dland.sakushi;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
import java... |
package cn._2dland.sakushi.jdo;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;
public final class PMFactory {
private final static PersistenceManagerFactory pmfInstance = JDOHelper.getPersistenceManagerFactory("transactions-optional");
/**
* 获取工厂实例
* @return
*/
public st... |
package cn._2dland.sakushi.jdo;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class LastQuestion {
@PrimaryKey
... |
package cn._2dland.sakushi.jdo;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Question {
/** 消息ID */
@Pr... |
package cn._2dland.sakushi;
public class SakushiInfo {
/** 饭否API相关设置 */
public static final String FANFOU_API_KEY = "b7074bca27a951cfd0e2b2fbb47bfa12";
public static final String FANFOU_SOURCE = "sakushi";
/** 饭否咎儿的OAuth参数 */
public static final String FANFOU_NAME = "咎儿";
public static final String FAN... |
package cn._2dland.sakushi;
public class NoSuchRequestException extends Exception {
private static final long serialVersionUID = -8950302485727193202L;
public NoSuchRequestException(String message) {
super(message);
}
}
|
package cn._2dland.sakushi.client;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import cn._2dland.http.HttpClient;
import cn._2dland.http.method.GetMethod;
import cn._2dland.http.method.PostMethod... |
package cn._2dland.sakushi.client;
/**
* 消息对象类
*
* @author deadblue
*/
public class Mention {
private String statusId;
private String text;
private String userId;
private String userName;
private String sourceId = null;
public Mention() {}
public Mention(String statusId, String text, Stri... |
package cn._2dland.sakushi.client;
import java.util.ArrayList;
import java.util.List;
//import javax.servlet.http.HttpServletResponse;
import org.json.JSONArray;
import org.json.JSONObject;
import cn._2dland.http.HttpClient;
import cn._2dland.http.HttpStatus;
import cn._2dland.http.method.GetMethod;
im... |
package cn._2dland.sakushi;
public class Policy {
private String content = null;
private byte[] chart = null;
public Policy(String content, byte[] chart) {
super();
this.content = content;
this.chart = chart;
}
public String getContent() {
return content;
}
public byte[] getChart() {
... |
package cn._2dland.sakushi.servlet;
import java.io.IOException;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServle... |
package cn._2dland.sakushi.servlet;
import java.io.IOException;
import java.util.logging.Logger;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
i... |
package cn._2dland.sakushi.servlet;
import java.io.IOException;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn._... |
package cn._2dland.sakushi.servlet;
import java.io.IOException;
import java.util.logging.Logger;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
i... |
package cn._2dland.sakushi.servlet;
import java.io.IOException;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn._... |
package cn._2dland.sakushi;
/**
* 无效请求异常
* 当咎儿收到的消息不符合格式时,抛出此异常
*
* @author deadblue
*/
public class InvalidRequestException extends Exception {
private static final long serialVersionUID = 5665832178384228442L;
public InvalidRequestException(String message) {
super(message);
}
}
|
package cn._2dland.sakushi;
public class Option {
private String label = null;
private double weight = 0;
public Option(String label, double weight) {
super();
this.label = label;
this.weight = weight;
}
public String getLabel() {
return label;
}
public double getWeight() {
return ... |
package cn._2dland.sakushi.util;
/**
* 颜文字集合
*
* @author deadblue
*/
public class JISFace {
private static final String[] FACES = {
"o(*≧▽≦)ツ", "(* ̄︶ ̄)つ", "(/▽\)", "(σ≧︶≦)σ"
};
public static String pickFace() {
int index = (int)(System.currentTimeMillis() % FACES.length);
return FACES[inde... |
package cn._2dland.sakushi.util;
public class JSONUtils {
public static String unicodeToNative(String str) {
int len = str.length();
StringBuffer buf = new StringBuffer(len);
char c;
for(int i=0; i<len; ) {
c = str.charAt(i++);
if(c=='\\' && i!=len) {
c = str.charAt(i++);
if(c == 'u... |
package cn._2dland.http;
/**
* HTTP状态 码
*
* @author deadblue
*/
public final class HttpStatus {
/** HTTP状态:正常 */
public static final int SC_OK = 200;
}
|
package cn._2dland.http;
/**
* HTTP请求/响应头定义
*
* @author deadblue
*/
public final class HttpHeader {
/** HTTP响应头:服务器cookie */
public static final String HEADER_SET_COOKIE = "set-cookie";
/** HTTP响应头:内容编码 */
public static final String HEADER_CONTENT_ENCODING = "content-encoding";
}
|
package cn._2dland.http;
import java.util.HashMap;
import java.util.Map;
import cn._2dland.http.method.HttpMethod;
/**
* Simple HttpClient For GAE/J
*/
public class HttpClient {
private HttpClientParams params;
private HttpCookie cookie = new HttpCookie();
/** 附加请求头 */
private Map<String, Stri... |
package cn._2dland.http;
import java.util.ArrayList;
import java.util.List;
public class HttpCookie {
private List<Cookie> cookies = new ArrayList<Cookie>();
public HttpCookie() {
}
public boolean isEmpty() {
return (cookies==null || cookies.isEmpty());
}
/** 添加cookie */
public void addCoo... |
package cn._2dland.http.method.multiparts;
/**
* 数据块
*
* @author deadblue
*/
abstract public class Part {
public static final String CRLF = "\r\n";
/** 分段名称 */
protected String name = null;
/** 分段字符集,缺省使用utf-8 */
protected String charset = null;
public Part(String name) {
this.name = n... |
package cn._2dland.http.method.multiparts;
import java.io.ByteArrayOutputStream;
/**
* 字符串数据块
*
* @author deadblue
*/
public class StringPart extends Part {
/**参数值 */
private String value = null;
public StringPart(String name, String value) {
super(name);
this.value = value;
}
@Overr... |
package cn._2dland.http.method.multiparts;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
/**
* 文件数据块
*
* @author deadblue
*/
public class FilePart extends Part {
/** 字节组 */
private byte[] buf = null;
/** 文件名 */
private S... |
package cn._2dland.http.method;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry... |
package cn._2dland.http.method;
import java.io.ByteArrayOutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import cn._2dland.http.method.multiparts.Part;
public class PostMethod extends HttpMethod {
/** multipart模式下的分隔符 */
private String boundary = null;
/**... |
package cn._2dland.http.method;
import java.util.Map.Entry;
public class GetMethod extends HttpMethod {
public GetMethod(String url) {
super(url);
}
public String getMethodName() {
return "GET";
}
@Override
protected String getQueryString() {
if(parameters == null || parameters.size() <= ... |
package cn._2dland.http;
import java.util.HashMap;
import java.util.Map;
public class HttpClientParams {
public static final String USER_AGENT = "userAgent";
public static final String FOLLOW_REDIRECT = "followRedirect";
public static final String USE_CACHES = "useCaches";
public static final String CLIE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.