createJSONError
This commit is contained in:
@ -2,6 +2,11 @@ package tctable;
|
||||
|
||||
//import android.util.Log;
|
||||
|
||||
//import org.ccalm.dbms.AcceptJSON;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
@ -12,14 +17,32 @@ import java.net.InetAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import logging.Logger;
|
||||
|
||||
public class Tools {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Tools.class);
|
||||
|
||||
public static JSONObject createJSONError(int code, String message, String setting, String marker) {
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("error_code", code);
|
||||
json.put("error_message", Arrays.asList(message));
|
||||
json.put("error_setting", Arrays.asList(setting));
|
||||
json.put("error_marker", marker);
|
||||
} catch (JSONException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
public static String readStringFromInputStream(InputStream inputStream) {
|
||||
ByteArrayOutputStream result = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
@ -399,7 +422,7 @@ public class Tools {
|
||||
//Из руского DOC в юникод
|
||||
public static String fromDOStoASCII(byte[] str)
|
||||
{
|
||||
StringBuilder rez = new StringBuilder();
|
||||
StringBuilder rez = new StringBuilder(1024);
|
||||
for(int i=0; i <str.length; i++)
|
||||
{
|
||||
switch ((char)str[i])
|
||||
@ -1013,7 +1036,7 @@ public class Tools {
|
||||
{
|
||||
if(cutInt)
|
||||
{
|
||||
StringBuilder val= new StringBuilder();
|
||||
StringBuilder val= new StringBuilder(1024);
|
||||
for(int i=0;i<str.length();i++)
|
||||
{
|
||||
if((str.charAt(i)=='-' && (val.length()==0 || val.charAt(0)!='-')) || str.charAt(i)=='0' || str.charAt(i)=='1' || str.charAt(i)=='2' || str.charAt(i)=='3' || str.charAt(i)=='4' || str.charAt(i)=='5' || str.charAt(i)=='6' || str.charAt(i)=='7' || str.charAt(i)=='8' || str.charAt(i)=='9')
|
||||
@ -1038,7 +1061,7 @@ public class Tools {
|
||||
//Из казахского ASCII в юникод см: http://foxtools.ru/ASCII#1251
|
||||
public static String fromKAZASCII(byte[] str)
|
||||
{
|
||||
StringBuilder rez = new StringBuilder();
|
||||
StringBuilder rez = new StringBuilder(1024);
|
||||
for (int i = 0; i < str.length; i++)
|
||||
{
|
||||
switch ((char) str[i])
|
||||
|
||||
Reference in New Issue
Block a user