Mercurial Hosting > luan
comparison core/src/luan/modules/IoLuan.java @ 725:a741a3a33423
add url support for multipart/form-data
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 08 Jun 2016 23:13:10 -0600 |
parents | 647602e8291a |
children | e44e98fe9de8 |
comparison
equal
deleted
inserted
replaced
724:4f8e30a3ffd0 | 725:a741a3a33423 |
---|---|
34 import luan.LuanState; | 34 import luan.LuanState; |
35 import luan.LuanTable; | 35 import luan.LuanTable; |
36 import luan.LuanFunction; | 36 import luan.LuanFunction; |
37 import luan.LuanJavaFunction; | 37 import luan.LuanJavaFunction; |
38 import luan.LuanException; | 38 import luan.LuanException; |
39 import luan.modules.url.LuanUrl; | |
39 | 40 |
40 | 41 |
41 public final class IoLuan { | 42 public final class IoLuan { |
42 | 43 |
43 private static void add(LuanTable t,String method,Class... parameterTypes) throws NoSuchMethodException { | 44 private static void add(LuanTable t,String method,Class... parameterTypes) throws NoSuchMethodException { |
165 } | 166 } |
166 | 167 |
167 | 168 |
168 | 169 |
169 public static abstract class LuanIn { | 170 public static abstract class LuanIn { |
170 abstract InputStream inputStream() throws IOException, LuanException; | 171 public abstract InputStream inputStream() throws IOException, LuanException; |
171 public abstract String to_string(); | 172 public abstract String to_string(); |
172 public abstract String to_uri_string(); | 173 public abstract String to_uri_string(); |
173 | 174 |
174 public Reader reader() throws IOException, LuanException { | 175 public Reader reader() throws IOException, LuanException { |
175 return new InputStreamReader(inputStream()); | 176 return new InputStreamReader(inputStream()); |
239 } | 240 } |
240 } | 241 } |
241 | 242 |
242 public static final LuanIn defaultStdin = new LuanIn() { | 243 public static final LuanIn defaultStdin = new LuanIn() { |
243 | 244 |
244 @Override InputStream inputStream() { | 245 @Override public InputStream inputStream() { |
245 return System.in; | 246 return System.in; |
246 } | 247 } |
247 | 248 |
248 @Override public String to_string() { | 249 @Override public String to_string() { |
249 return "<stdin>"; | 250 return "<stdin>"; |
322 }; | 323 }; |
323 private final OutputStream out = new OutputStream() { | 324 private final OutputStream out = new OutputStream() { |
324 @Override public void write(int b) {} | 325 @Override public void write(int b) {} |
325 }; | 326 }; |
326 | 327 |
327 @Override InputStream inputStream() { | 328 @Override public InputStream inputStream() { |
328 return in; | 329 return in; |
329 } | 330 } |
330 | 331 |
331 @Override OutputStream outputStream() { | 332 @Override OutputStream outputStream() { |
332 return out; | 333 return out; |
347 | 348 |
348 private LuanString(String s) { | 349 private LuanString(String s) { |
349 this.s = s; | 350 this.s = s; |
350 } | 351 } |
351 | 352 |
352 @Override InputStream inputStream() { | 353 @Override public InputStream inputStream() { |
353 throw new UnsupportedOperationException(); | 354 throw new UnsupportedOperationException(); |
354 } | 355 } |
355 | 356 |
356 @Override OutputStream outputStream() { | 357 @Override OutputStream outputStream() { |
357 throw new UnsupportedOperationException(); | 358 throw new UnsupportedOperationException(); |
405 | 406 |
406 private LuanFile(File file) { | 407 private LuanFile(File file) { |
407 this.file = file; | 408 this.file = file; |
408 } | 409 } |
409 | 410 |
410 @Override InputStream inputStream() throws IOException { | 411 @Override public InputStream inputStream() throws IOException { |
411 return new FileInputStream(file); | 412 return new FileInputStream(file); |
412 } | 413 } |
413 | 414 |
414 @Override OutputStream outputStream() throws IOException { | 415 @Override OutputStream outputStream() throws IOException { |
415 return new FileOutputStream(file); | 416 return new FileOutputStream(file); |
619 | 620 |
620 private LuanSocket(Socket socket) throws IOException { | 621 private LuanSocket(Socket socket) throws IOException { |
621 this.socket = socket; | 622 this.socket = socket; |
622 } | 623 } |
623 | 624 |
624 @Override InputStream inputStream() throws IOException { | 625 @Override public InputStream inputStream() throws IOException { |
625 return socket.getInputStream(); | 626 return socket.getInputStream(); |
626 } | 627 } |
627 | 628 |
628 @Override OutputStream outputStream() throws IOException { | 629 @Override OutputStream outputStream() throws IOException { |
629 return socket.getOutputStream(); | 630 return socket.getOutputStream(); |