| 1 |
|
|
| 2 |
|
package org.apache.lucene.demo.html; |
| 3 |
|
|
| 4 |
|
import java.io.*; |
| 5 |
|
import java.util.Properties; |
| 6 |
|
|
|
|
|
| 0% |
Uncovered Elements: 727 (727) |
Complexity: 190 |
Complexity Density: 0.39 |
|
| 7 |
|
public class HTMLParser implements HTMLParserConstants { |
| 8 |
|
public static int SUMMARY_LENGTH = 200; |
| 9 |
|
|
| 10 |
|
StringBuffer title = new StringBuffer(SUMMARY_LENGTH); |
| 11 |
|
StringBuffer summary = new StringBuffer(SUMMARY_LENGTH * 2); |
| 12 |
|
Properties metaTags=new Properties(); |
| 13 |
|
String currentMetaTag=null; |
| 14 |
|
String currentMetaContent=null; |
| 15 |
|
int length = 0; |
| 16 |
|
boolean titleComplete = false; |
| 17 |
|
boolean inTitle = false; |
| 18 |
|
boolean inMetaTag = false; |
| 19 |
|
boolean inStyle = false; |
| 20 |
|
boolean afterTag = false; |
| 21 |
|
boolean afterSpace = false; |
| 22 |
|
String eol = System.getProperty("line.separator"); |
| 23 |
|
Reader pipeIn = null; |
| 24 |
|
Writer pipeOut; |
| 25 |
|
private MyPipedInputStream pipeInStream = null; |
| 26 |
|
private PipedOutputStream pipeOutStream = null; |
| 27 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
| 28 |
|
private class MyPipedInputStream extends PipedInputStream{ |
| 29 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 30 |
0
|
public MyPipedInputStream(){... |
| 31 |
0
|
super(); |
| 32 |
|
} |
| 33 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 34 |
0
|
public MyPipedInputStream(PipedOutputStream src) throws IOException{... |
| 35 |
0
|
super(src); |
| 36 |
|
} |
| 37 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 38 |
0
|
public boolean full() throws IOException{... |
| 39 |
0
|
return this.available() >= PipedInputStream.PIPE_SIZE; |
| 40 |
|
} |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@deprecated |
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
0
|
public HTMLParser(File file) throws FileNotFoundException {... |
| 47 |
0
|
this(new FileInputStream(file)); |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 50 |
0
|
public String getTitle() throws IOException, InterruptedException {... |
| 51 |
0
|
if (pipeIn == null) |
| 52 |
0
|
getReader(); |
| 53 |
0
|
while (true) { |
| 54 |
0
|
synchronized(this) { |
| 55 |
0
|
if (titleComplete || pipeInStream.full()) |
| 56 |
0
|
break; |
| 57 |
0
|
wait(10); |
| 58 |
|
} |
| 59 |
|
} |
| 60 |
0
|
return title.toString().trim(); |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 63 |
0
|
public Properties getMetaTags() throws IOException,... |
| 64 |
|
InterruptedException { |
| 65 |
0
|
if (pipeIn == null) |
| 66 |
0
|
getReader(); |
| 67 |
0
|
while (true) { |
| 68 |
0
|
synchronized(this) { |
| 69 |
0
|
if (titleComplete || pipeInStream.full()) |
| 70 |
0
|
break; |
| 71 |
0
|
wait(10); |
| 72 |
|
} |
| 73 |
|
} |
| 74 |
0
|
return metaTags; |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 8 |
Complexity Density: 0.57 |
|
| 78 |
0
|
public String getSummary() throws IOException, InterruptedException {... |
| 79 |
0
|
if (pipeIn == null) |
| 80 |
0
|
getReader(); |
| 81 |
0
|
while (true) { |
| 82 |
0
|
synchronized(this) { |
| 83 |
0
|
if (summary.length() >= SUMMARY_LENGTH || pipeInStream.full()) |
| 84 |
0
|
break; |
| 85 |
0
|
wait(10); |
| 86 |
|
} |
|