diff --git a/NiHao/src/nihao/WebCall.java b/NiHao/src/nihao/WebCall.java index 0a53229..f35298d 100644 --- a/NiHao/src/nihao/WebCall.java +++ b/NiHao/src/nihao/WebCall.java @@ -154,7 +154,7 @@ * @param name * String clave del valor, 4 tipos:
* · si se antepone "@" se retorna un valor de contexto
- * · si se antepone "$" se retorna un valor se desión
+ * · si se antepone "$" se retorna un valor se sesión
* · si se antepone "%" se retorna un valor de atributo * del request
* en cualquier otro caso, el campo hace referencia a un valor en diff --git a/NiHao/src/nihao/types/TextEncoding.java b/NiHao/src/nihao/types/TextEncoding.java new file mode 100644 index 0000000..4c7bb25 --- /dev/null +++ b/NiHao/src/nihao/types/TextEncoding.java @@ -0,0 +1,38 @@ +package nihao.types; + +public enum TextEncoding { + /** + * Desconocido + */ + Unknown, + + /** + * ASCII (usado tambi�n para ANSI) + */ + ASCII, + + /** + * UTF-8 + */ + UTF8, + + /** + * UTF-16 (UNICODE) Little Endian + */ + UTF16LE, + + /** + * UTF-16 (UNICODE) Big Endian + */ + UTF16BE, + + /** + * UTF-32 (UNICODE) Little Endian + */ + UTF32LE, + + /** + * UTF-32 (UNICODE) Big Endian + */ + UTF32BE, +} diff --git a/NiHao/src/nihao/util/Base64Codec.java b/NiHao/src/nihao/util/Base64Codec.java deleted file mode 100644 index b20166e..0000000 --- a/NiHao/src/nihao/util/Base64Codec.java +++ /dev/null @@ -1,183 +0,0 @@ -package nihao.util; - -/** - * A Base64 encoder/decoder. - * - *

- * This class is used to encode and decode data in Base64 format as described in - * RFC 1521. - * - *

- * Project home page: www. - * source-code.biz/base64coder/java
- * Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
- * Multi-licensed: EPL / LGPL / GPL / AL / BSD / MIT. - */ -public class Base64Codec { - // Mapping table from 6-bit nibbles to Base64 characters. - private static final byte[] map1 = new byte[64]; - static { - int i = 0; - for (char c = 'A'; c <= 'Z'; c++) - map1[i++] = (byte) c; - for (char c = 'a'; c <= 'z'; c++) - map1[i++] = (byte) c; - for (char c = '0'; c <= '9'; c++) - map1[i++] = (byte) c; - map1[i++] = '+'; - map1[i++] = '/'; - } - - // Mapping table from Base64 characters to 6-bit nibbles. - private static final byte[] map2 = new byte[128]; - static { - for (int i = 0; i < map2.length; i++) - map2[i] = -1; - for (int i = 0; i < 64; i++) - map2[map1[i]] = (byte) i; - } - - /** - * Encodes a byte array into Base64 format. No blanks or line breaks are - * inserted in the output. - * - * @param in - * An array containing the data bytes to be encoded. - * @return A character array containing the Base64 encoded data. - */ - public static byte[] encode(byte[] in) { - return encode(in, 0, in.length); - } - - /** - * Encodes a byte array into Base64 format. No blanks or line breaks are - * inserted in the output. - * - * @param in - * An array containing the data bytes to be encoded. - * @param iOff - * Offset of the first byte in in to be processed. - * @param iLen - * Number of bytes to process in in, starting at - * iOff. - * @return A character array containing the Base64 encoded data. - */ - public static byte[] encode(byte[] in, int iOff, int iLen) { - int oDataLen = (iLen * 4 + 2) / 3; // output length without padding - int oLen = ((iLen + 2) / 3) * 4; // output length including padding - byte[] out = new byte[oLen]; - int ip = iOff; - int iEnd = iOff + iLen; - int op = 0; - while (ip < iEnd) { - int i0 = in[ip++] & 0xff; - int i1 = ip < iEnd ? in[ip++] & 0xff : 0; - int i2 = ip < iEnd ? in[ip++] & 0xff : 0; - int o0 = i0 >>> 2; - int o1 = ((i0 & 3) << 4) | (i1 >>> 4); - int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6); - int o3 = i2 & 0x3F; - out[op++] = map1[o0]; - out[op++] = map1[o1]; - out[op] = (byte) (op < oDataLen ? map1[o2] : '='); - op++; - out[op] = (byte) (op < oDataLen ? map1[o3] : '='); - op++; - } - return out; - } - - /** - * Decodes a byte array from Base64 format. No blanks or line breaks are - * allowed within the Base64 encoded input data. - * - * @param in - * A character array containing the Base64 encoded data. - * @return An array containing the decoded data bytes. - * @throws IllegalArgumentException - * If the input is not valid Base64 encoded data. - */ - public static byte[] decode(byte[] in) { - return decode(in, 0, in.length); - } - - /** - * Decodes a byte array from Base64 format. - * - * @param in - * A character array containing the Base64 encoded data. - * @param iOff - * Offset of the first character in in to be - * processed. - * @param iLen - * Number of characters to process in in, starting - * at iOff. - * @return An array containing the decoded data bytes. - * @throws IllegalArgumentException - * If the input is not valid Base64 encoded data. - */ - public static byte[] decode(byte[] in, int iOff, int iLen) { - int ip=0; - for (int i=0;iin to be - * processed. - * @param iLen - * Number of characters to process in in, starting - * at iOff. - * @return An array containing the decoded data bytes. - * @throws IllegalArgumentException - * If the input is not valid Base64 encoded data. - */ - private static byte[] idecode(byte[] in, int iOff, int iLen) { - if (iLen % 4 != 0) - throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4."); - while (iLen > 0 && in[iOff + iLen - 1] == '=') - iLen--; - int oLen = (iLen * 3) / 4; - byte[] out = new byte[oLen]; - int ip = iOff; - int iEnd = iOff + iLen; - int op = 0; - while (ip < iEnd) { - int i0 = in[ip++]; - int i1 = in[ip++]; - int i2 = ip < iEnd ? in[ip++] : 'A'; - int i3 = ip < iEnd ? in[ip++] : 'A'; - if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) - throw new IllegalArgumentException("Illegal character in Base64 encoded data."); - int b0 = map2[i0]; - int b1 = map2[i1]; - int b2 = map2[i2]; - int b3 = map2[i3]; - if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) - throw new IllegalArgumentException("Illegal character in Base64 encoded data."); - int o0 = (b0 << 2) | (b1 >>> 4); - int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2); - int o2 = ((b2 & 3) << 6) | b3; - out[op++] = (byte) o0; - if (op < oLen) - out[op++] = (byte) o1; - if (op < oLen) - out[op++] = (byte) o2; - } - return out; - } - - private Base64Codec() { - } -} \ No newline at end of file diff --git a/NiHao/src/nihao/util/Conversor.java b/NiHao/src/nihao/util/Conversor.java index 636cd66..5ad178d 100644 --- a/NiHao/src/nihao/util/Conversor.java +++ b/NiHao/src/nihao/util/Conversor.java @@ -18,7 +18,10 @@ import java.util.ArrayList; import java.util.Collection; +import javax.xml.bind.DatatypeConverter; + import nihao.NiHaoException; +import nihao.types.TextEncoding; public class Conversor { static final String ASCIICharset = "ISO-8859-1"; @@ -137,8 +140,7 @@ * @return String */ public static String bytesToBase64(byte[] data) { - byte[] result = Base64Codec.encode(data); - return bytesToASCII(result); + return DatatypeConverter.printBase64Binary(data); } /** @@ -149,7 +151,7 @@ * @return Array de bytes */ public static byte[] base64ToBytes(String data64) { - return Base64Codec.decode(asciiToBytes(data64)); + return DatatypeConverter.parseBase64Binary(data64); } /** @@ -160,7 +162,7 @@ * @return Array de bytes */ public static byte[] base64ToBytes(byte[] data64) { - return Base64Codec.decode(data64); + return DatatypeConverter.parseBase64Binary(bytesToASCII(data64)); } /** @@ -521,7 +523,7 @@ * @return String */ public static String nvl(Object o, String nval) { - return o==null?nval:o.toString(); + return o == null ? nval : o.toString(); } /** diff --git a/NiHao/src/nihao/util/FileUtil.java b/NiHao/src/nihao/util/FileUtil.java index e5e8419..b5ff2f3 100644 --- a/NiHao/src/nihao/util/FileUtil.java +++ b/NiHao/src/nihao/util/FileUtil.java @@ -1,30 +1,22 @@ package nihao.util; -import java.io.BufferedInputStream; import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.ByteArrayInputStream; -import java.io.CharArrayReader; -import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.Reader; -import java.util.ArrayList; -import java.util.List; public class FileUtil { private static String tempDirPropertyName = "java.io.tmpdir"; private static String NOT_FOUND = "NOT_FOUND"; - private static final String LINE_SEPARATOR = System.getProperty("line.separator"); + + // private static final String LINE_SEPARATOR = + // System.getProperty("line.separator"); /** * Escribe en un fichero un array de bytes @@ -106,579 +98,6 @@ return; } - // Writers - // ------------------------------------------------------------------------------------ - - /** - * Write byte array to file. If file already exists, it will be overwritten. - * - * @param file - * The file where the given byte array have to be written to. - * @param bytes - * The byte array which have to be written to the given file. - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, byte[] bytes) throws IOException { - write(file, new ByteArrayInputStream(bytes), false); - } - - /** - * Write byte array to file with option to append to file or not. If not, - * then any existing file will be overwritten. - * - * @param file - * The file where the given byte array have to be written to. - * @param bytes - * The byte array which have to be written to the given file. - * @param append - * Append to file? - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, byte[] bytes, boolean append) throws IOException { - write(file, new ByteArrayInputStream(bytes), append); - } - - /** - * Write byte inputstream to file. If file already exists, it will be - * overwritten.It's highly recommended to feed the inputstream as - * BufferedInputStream or ByteArrayInputStream as those are been - * automatically buffered. - * - * @param file - * The file where the given byte inputstream have to be written - * to. - * @param input - * The byte inputstream which have to be written to the given - * file. - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, InputStream input) throws IOException { - write(file, input, false); - } - - /** - * Write byte inputstream to file with option to append to file or not. If - * not, then any existing file will be overwritten. It's highly recommended - * to feed the inputstream as BufferedInputStream or ByteArrayInputStream as - * those are been automatically buffered. - * - * @param file - * The file where the given byte inputstream have to be written - * to. - * @param input - * The byte inputstream which have to be written to the given - * file. - * @param append - * Append to file? - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, InputStream input, boolean append) throws IOException { - mkdirs(file); - BufferedOutputStream output = null; - try { - output = new BufferedOutputStream(new FileOutputStream(file, append)); - int data = -1; - while ((data = input.read()) != -1) { - output.write(data); - } - } finally { - close(input, file); - close(output, file); - } - } - - /** - * Write character array to file. If file already exists, it will be - * overwritten. - * - * @param file - * The file where the given character array have to be written - * to. - * @param chars - * The character array which have to be written to the given - * file. - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, char[] chars) throws IOException { - write(file, new CharArrayReader(chars), false); - } - - /** - * Write character array to file with option to append to file or not. If - * not, then any existing file will be overwritten. - * - * @param file - * The file where the given character array have to be written - * to. - * @param chars - * The character array which have to be written to the given - * file. - * @param append - * Append to file? - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, char[] chars, boolean append) throws IOException { - write(file, new CharArrayReader(chars), append); - } - - /** - * Write string value to file. If file already exists, it will be - * overwritten. - * - * @param file - * The file where the given string value have to be written to. - * @param string - * The string value which have to be written to the given file. - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, String string) throws IOException { - write(file, new CharArrayReader(string.toCharArray()), false); - } - - /** - * Write string value to file with option to append to file or not. If not, - * then any existing file will be overwritten. - * - * @param file - * The file where the given string value have to be written to. - * @param string - * The string value which have to be written to the given file. - * @param append - * Append to file? - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, String string, boolean append) throws IOException { - write(file, new CharArrayReader(string.toCharArray()), append); - } - - /** - * Write character reader to file. If file already exists, it will be - * overwritten. It's highly recommended to feed the reader as BufferedReader - * or CharArrayReader as those are been automatically buffered. - * - * @param file - * The file where the given character reader have to be written - * to. - * @param reader - * The character reader which have to be written to the given - * file. - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, Reader reader) throws IOException { - write(file, reader, false); - } - - /** - * Write character reader to file with option to append to file or not. If - * not, then any existing file will be overwritten. It's highly recommended - * to feed the reader as BufferedReader or CharArrayReader as those are been - * automatically buffered. - * - * @param file - * The file where the given character reader have to be written - * to. - * @param reader - * The character reader which have to be written to the given - * file. - * @param append - * Append to file? - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, Reader reader, boolean append) throws IOException { - mkdirs(file); - BufferedWriter writer = null; - try { - writer = new BufferedWriter(new FileWriter(file, append)); - int data = -1; - while ((data = reader.read()) != -1) { - writer.write(data); - } - } finally { - close(reader, file); - close(writer, file); - } - } - - /** - * Write list of String records to file. If file already exists, it will be - * overwritten. - * - * @param file - * The file where the given character reader have to be written - * to. - * @param records - * The list of String records which have to be written to the - * given file. - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, List records) throws IOException { - write(file, records, false); - } - - /** - * Write list of String records to file with option to append to file or - * not. If not, then any existing file will be overwritten. - * - * @param file - * The file where the given character reader have to be written - * to. - * @param records - * The list of String records which have to be written to the - * given file. - * @param append - * Append to file? - * @throws IOException - * If writing file fails. - */ - public static void write(java.io.File file, List records, boolean append) throws IOException { - mkdirs(file); - BufferedWriter writer = null; - try { - writer = new BufferedWriter(new FileWriter(file, append)); - for (String record : records) { - writer.write(record); - writer.write(LINE_SEPARATOR); - } - } finally { - close(writer, file); - } - } - - // Readers - // ------------------------------------------------------------------------------------ - - /** - * Read byte array from file. Take care with big files, this would be memory - * hogging, rather use readStream() instead. - * - * @param file - * The file to read the byte array from. - * @return The byte array with the file contents. - * @throws IOException - * If reading file fails. - */ - public static byte[] readBytes(java.io.File file) throws IOException { - BufferedInputStream stream = (BufferedInputStream) readStream(file); - byte[] bytes = new byte[stream.available()]; - stream.read(bytes); - return bytes; - } - - /** - * Read byte stream from file. - * - * @param file - * The file to read the byte stream from. - * @return The byte stream with the file contents (actually: - * BufferedInputStream). - * @throws IOException - * If reading file fails. - */ - public static InputStream readStream(java.io.File file) throws IOException { - return new BufferedInputStream(new FileInputStream(file)); - } - - /** - * Read character array from file. Take care with big files, this would be - * memory hogging, rather use readReader() instead. - * - * @param file - * The file to read the character array from. - * @return The character array with the file contents. - * @throws IOException - * If reading file fails. - */ - public static char[] readChars(java.io.File file) throws IOException { - BufferedReader reader = (BufferedReader) readReader(file); - char[] chars = new char[(int) file.length()]; - reader.read(chars); - return chars; - } - - /** - * Read string value from file. Take care with big files, this would be - * memory hogging, rather use readReader() instead. - * - * @param file - * The file to read the string value from. - * @return The string value with the file contents. - * @throws IOException - * If reading file fails. - */ - public static String readString(java.io.File file) throws IOException { - return new String(readChars(file)); - } - - /** - * Read character reader from file. - * - * @param file - * The file to read the character reader from. - * @return The character reader with the file contents (actually: - * BufferedReader). - * @throws IOException - * If reading file fails. - */ - public static Reader readReader(java.io.File file) throws IOException { - return new BufferedReader(new FileReader(file)); - } - - /** - * Read list of String records from file. - * - * @param file - * The file to read the character writer from. - * @return A list of String records which represents lines of the file - * contents. - * @throws IOException - * If reading file fails. - */ - public static List readRecords(java.io.File file) throws IOException { - BufferedReader reader = (BufferedReader) readReader(file); - List records = new ArrayList(); - String record = null; - try { - while ((record = reader.readLine()) != null) - records.add(record); - } finally { - close(reader, file); - } - return records; - } - - // Copiers - // ------------------------------------------------------------------------------------ - - /** - * Copy file. Any existing file at the destination will be overwritten. - * - * @param source - * The file to read the contents from. - * @param destination - * The file to write the contents to. - * @throws IOException - * If copying file fails. - */ - public static void copy(java.io.File source, java.io.File destination) throws IOException { - copy(source, destination, true); - } - - /** - * Copy file with the option to overwrite any existing file at the - * destination. - * - * @param source - * The file to read the contents from. - * @param destination - * The file to write the contents to. - * @param overwrite - * Set whether to overwrite any existing file at the destination. - * @throws IOException - * If the destination file already exists while - * overwrite is set to false, or if copying file fails. - */ - public static void copy(java.io.File source, java.io.File destination, boolean overwrite) { - if (destination.exists() && !overwrite) - throw new RuntimeException("Copying file " + source.getPath() + " to " + destination.getPath() + " failed." + " The destination file already exists."); - try { - mkdirs(destination); - BufferedInputStream input = null; - BufferedOutputStream output = null; - - try { - input = new BufferedInputStream(new FileInputStream(source)); - output = new BufferedOutputStream(new FileOutputStream(destination)); - int data = -1; - while ((data = input.read()) != -1) { - output.write(data); - } - } finally { - close(input, source); - close(output, destination); - } - } catch (RuntimeException e) { - throw e; - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - - // Movers - // ------------------------------------------------------------------------------------- - - /** - * Move (rename) file. Any existing file at the destination will be - * overwritten. - * - * @param source - * The file to be moved. - * @param destination - * The new destination of the file. - * @throws IOException - * If moving file fails. - */ - public static void move(java.io.File source, java.io.File destination) throws IOException { - move(source, destination, true); - } - - /** - * Move (rename) file with the option to overwrite any existing file at the - * destination. - * - * @param source - * The file to be moved. - * @param destination - * The new destination of the file. - * @param overwrite - * Set whether to overwrite any existing file at the destination. - * @throws IOException - * If the destination file already exists while - * overwrite is set to false, or if moving file fails. - */ - public static void move(java.io.File source, java.io.File destination, boolean overwrite) { - if (destination.exists()) { - if (overwrite) { - destination.delete(); - } else { - throw new RuntimeException("Moving file " + source.getPath() + " to " + destination.getPath() + " failed." + " The destination file already exists."); - } - } - try { - mkdirs(destination); - } catch (RuntimeException e) { - throw e; - } catch (Throwable e) { - throw new RuntimeException(e); - } - if (!source.renameTo(destination)) { - throw new RuntimeException("Moving file " + source.getPath() + " to " + destination.getPath() + " failed."); - } - } - - // Filenames - // ---------------------------------------------------------------------------------- - - /** - * Trim the eventual file path from the given file name. Anything before the - * last occurred "/" and "\" will be trimmed, including the slash. - * - * @param fileName - * The file name to trim the file path from. - * @return The file name with the file path trimmed. - */ - public static String trimFilePath(String fileName) { - return fileName.substring(fileName.lastIndexOf("/") + 1).substring(fileName.lastIndexOf("\\") + 1); - } - - /** - * Generate unique file based on the given path and name. If the file - * exists, then it will add "[i]" to the file name as long as the file - * exists. The value of i can be between 0 and 2147483647 (the value of - * Integer.MAX_VALUE). - * - * @param filePath - * The path of the unique file. - * @param fileName - * The name of the unique file. - * @return The unique file. - * @throws IOException - * If unique file cannot be generated, this can be caused if all - * file names are already in use. You may consider another - * filename instead. - */ - public static java.io.File uniqueFile(java.io.File filePath, String fileName) throws IOException { - java.io.File file = new java.io.File(filePath, fileName); - - if (file.exists()) { - - // Split filename and add braces, e.g. "name.ext" --> "name[", - // "].ext". - String prefix; - String suffix; - int dotIndex = fileName.lastIndexOf("."); - - if (dotIndex > -1) { - prefix = fileName.substring(0, dotIndex) + "["; - suffix = "]" + fileName.substring(dotIndex); - } else { - prefix = fileName + "["; - suffix = "]"; - } - - int count = 0; - - // Add counter to filename as long as file exists. - while (file.exists()) { - if (count < 0) { // int++ restarts at -2147483648 after - // 2147483647. - throw new IOException("No unique filename available for " + fileName + " in path " + filePath.getPath() + "."); - } - - // Glue counter between prefix and suffix, e.g. "name[" + count - // + "].ext". - file = new java.io.File(filePath, prefix + (count++) + suffix); - } - } - - return file; - } - - // Helpers - // ------------------------------------------------------------------------------------ - - /** - * Check and create missing parent directories for the given file. - * - * @param file - * The file to check and create the missing parent directories - * for. - * @throws IOException - * If the given file is actually not a file or if creating - * parent directories fails. - */ - private static void mkdirs(java.io.File file) throws IOException { - if (file.exists() && !file.isFile()) { - throw new IOException("File " + file.getPath() + " is actually not a file."); - } - java.io.File parentFile = file.getParentFile(); - if (!parentFile.exists() && !parentFile.mkdirs()) { - throw new IOException("Creating directories " + parentFile.getPath() + " failed."); - } - } - - /** - * Close the given I/O resource of the given file. - * - * @param resource - * The I/O resource to be closed. - * @param file - * The I/O resource's subject. - */ - private static void close(Closeable resource, java.io.File file) { - if (resource != null) { - try { - resource.close(); - } catch (IOException e) { - String message = "Closing file " + file.getPath() + " failed."; - // Do your thing with the exception and the message. Print it, - // log it or mail it. - System.err.println(message); - e.printStackTrace(); - } - } - } - /** * Crea una estructura de directorios con la ruta que le entra * diff --git a/NiHao/src/nihao/util/TextEncoding.java b/NiHao/src/nihao/util/TextEncoding.java deleted file mode 100644 index 014583f..0000000 --- a/NiHao/src/nihao/util/TextEncoding.java +++ /dev/null @@ -1,38 +0,0 @@ -package nihao.util; - -public enum TextEncoding { - /** - * Desconocido - */ - Unknown, - - /** - * ASCII (usado tambi�n para ANSI) - */ - ASCII, - - /** - * UTF-8 - */ - UTF8, - - /** - * UTF-16 (UNICODE) Little Endian - */ - UTF16LE, - - /** - * UTF-16 (UNICODE) Big Endian - */ - UTF16BE, - - /** - * UTF-32 (UNICODE) Little Endian - */ - UTF32LE, - - /** - * UTF-32 (UNICODE) Big Endian - */ - UTF32BE, -} diff --git a/NiHao/src/nihao/util/net/NetConnection.java b/NiHao/src/nihao/util/net/NetConnection.java index 3d93e98..1579a97 100644 --- a/NiHao/src/nihao/util/net/NetConnection.java +++ b/NiHao/src/nihao/util/net/NetConnection.java @@ -112,7 +112,7 @@ sended = true; return connection.getInputStream(); } catch (IOException e) { - throw new QCoreNetException(getHttpCode(), e.getMessage(), connection.getErrorStream()); + throw new NiHaoNetException(getHttpCode(), e.getMessage(), connection.getErrorStream()); } } diff --git a/NiHao/src/nihao/util/net/NiHaoNetException.java b/NiHao/src/nihao/util/net/NiHaoNetException.java new file mode 100644 index 0000000..e671521 --- /dev/null +++ b/NiHao/src/nihao/util/net/NiHaoNetException.java @@ -0,0 +1,30 @@ +package nihao.util.net; + +import java.io.InputStream; + +import nihao.NiHaoException; + +public class NiHaoNetException extends NiHaoException { + private static final long serialVersionUID = 1L; + + private int code; + private InputStream errstream; + + public NiHaoNetException(int code, String msg, InputStream errstream) { + super(msg); + this.code = code; + this.errstream = errstream; + } + + public int getHttpCode() { + return code; + } + + public String getCodeDescription(){ + return null; + } + + public InputStream getErrorResponse() { + return errstream; + } +} diff --git a/NiHao/src/nihao/util/net/QCoreNetException.java b/NiHao/src/nihao/util/net/QCoreNetException.java deleted file mode 100644 index 0d68abf..0000000 --- a/NiHao/src/nihao/util/net/QCoreNetException.java +++ /dev/null @@ -1,30 +0,0 @@ -package nihao.util.net; - -import java.io.InputStream; - -import nihao.NiHaoException; - -public class QCoreNetException extends NiHaoException { - private static final long serialVersionUID = 1L; - - private int code; - private InputStream errstream; - - public QCoreNetException(int code, String msg, InputStream errstream) { - super(msg); - this.code = code; - this.errstream = errstream; - } - - public int getHttpCode() { - return code; - } - - public String getCodeDescription(){ - return null; - } - - public InputStream getErrorResponse() { - return errstream; - } -}