Changeset 38850 for main/trunk/greenstone2/build-src/src
- Timestamp:
- 2024-03-19T16:00:34+13:00 (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/build-src/src/java/org/nzdl/gsdl/ApplyXSLT.java
r28973 r38850 101 101 } 102 102 103 /* 104 private boolean isOpen(BufferedReader br) { 105 // The code used to rely on br.ready() to determine whether it should 106 // continue looping to read input (from standard-in). However on 107 // closer read of the JavaDoc, br.ready() can return false even 108 // when the input stream is still open -- it's just that there isn't 109 // any input lines to read in at the moment. 110 111 // If the input stream has been closed (from the external calling Perl code), 112 // then the only sure way to determine that this condition has arise is 113 // to ask br.ready() and catch the Exception that occurs ... because the 114 // input stream is not closed! 115 116 boolean is_open = true; 117 118 try { 119 boolean is_ready = br.ready(); 120 } 121 catch (Exception e) { // Could be more selective and go for IOException ?? 122 //System.err.println("ApplyXSLT::isOpen() encountered an exception => so input is closed"); 123 is_open = false; 124 } 125 126 return is_open; 127 } 128 */ 129 103 130 private boolean process() 104 131 { … … 114 141 115 142 116 while (br.ready()) { 117 118 String this_line = br.readLine(); 143 String this_line; 144 while ((this_line = br.readLine()) != null) { 145 146 //System.err.println("Read in from pipe, line: " + this_line); 147 119 148 if(system_status == BEFORE_READING){ 120 149 if(this_line.compareTo(DOC_START) == 0){ 150 // If this_line is DOC_START then we require the next line of input to be 151 // the filename 121 152 output_file = br.readLine(); // read the next line as the output file name 153 if (output_file == null) { 154 // A problem of some form occurred 155 return false; 156 } 157 //System.err.println("Read in from pipe, next line: " + output_file); 122 158 system_status = IS_READING; 123 159 a_doc = new StringBuffer(); … … 127 163 } 128 164 else{ 129 System.err.println("Undefined process status:" + this_line);130 165 system_status = BEFORE_READING; 131 166 } … … 143 178 144 179 if (!result){ 145 System.err.println("Translation Failed!!");146 180 return false; 147 181 } … … 161 195 } 162 196 197 return true; 198 163 199 //if(br != null) { 164 200 // br.close(); 165 201 // br = null; 166 //} 167 168 }catch (Exception e) 169 { 202 //} 203 } 204 catch (Exception e) { 170 205 System.err.println("Receiving piped data error!" + e.toString()); 171 } 206 e.printStackTrace(); 207 } 172 208 173 209 return false; … … 206 242 }catch (Exception e) { 207 243 System.err.println("Receiving piped data error!" + e.toString()); 244 e.printStackTrace(); 208 245 } 209 246 return false; … … 474 511 public static void main(String[] args) 475 512 { 476 477 513 String xml_file=""; 478 514 String xsl_file=""; … … 636 672 ioe.printStackTrace(); 637 673 } finally { 674 System.err.println("ReadStreamGobbler:run() finished. Closing resource"); 638 675 closeResource(br); 639 676 }
Note:
See TracChangeset
for help on using the changeset viewer.