1 21 24 package org.lobobrowser.html; 25 26 30 public class FormInput { 31 public static final FormInput[] EMPTY_ARRAY = new FormInput[0]; 34 private final String name; 35 private final String textValue; 36 private final java.io.File fileValue; 37 38 44 public FormInput(String name, String value) { 45 super(); 46 this.name = name; 47 this.textValue = value; 48 this.fileValue = null; 49 } 50 51 57 public FormInput(String name, java.io.File value) { 58 this.name = name; 59 this.textValue = null; 60 this.fileValue = value; 61 } 62 63 66 public String getName() { 67 return this.name; 68 } 69 70 public boolean isText() { 71 return this.textValue != null; 72 } 73 74 public boolean isFile() { 75 return this.fileValue != null; 76 } 77 78 public String getTextValue() { 79 return this.textValue; 80 } 81 82 public java.io.File getFileValue() { 83 return this.fileValue; 84 } 85 86 90 public String getCharset() { 91 return "UTF-8"; 92 } 93 94 99 public java.io.InputStream getInputStream() throws java.io.IOException { 100 if(this.isText()) { 101 return new java.io.ByteArrayInputStream (this.getTextValue().getBytes("UTF-8")); 102 } 103 else if(this.isFile()) { 104 return new java.io.FileInputStream (this.getFileValue()); 105 } 106 else { 107 return null; 108 } 109 } 110 111 116 public String toString() { 117 return "FormInput[name=" + this.name + ",textValue=" + this.textValue + "]"; 118 } 119 } 120 | Popular Tags |