本文整理匯總了Java中javax.swing.text.html.parser.ParserDelegator.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java ParserDelegator.parse方法的具體用法?Java ParserDelegator.parse怎麽用?Java ParserDelegator.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.html.parser.ParserDelegator
的用法示例。
在下文中一共展示了ParserDelegator.parse方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionPerformed
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
@Override public void actionPerformed(ActionEvent e) {
textArea.append(String.format("----%n%s%n", getValue(Action.NAME)));
String id = field.getText().trim();
String text = editorPane.getText();
ParserDelegator delegator = new ParserDelegator();
try {
delegator.parse(new StringReader(text), new HTMLEditorKit.ParserCallback() {
@Override public void handleStartTag(HTML.Tag tag, MutableAttributeSet a, int pos) {
Object attrid = a.getAttribute(HTML.Attribute.ID);
textArea.append(String.format("%[email protected]=%s%n", tag, attrid));
if (id.equals(attrid)) {
textArea.append(String.format("found: pos=%d%n", pos));
int endoffs = text.indexOf('>', pos);
textArea.append(String.format("%s%n", text.substring(pos, endoffs + 1)));
}
}
}, Boolean.TRUE);
} catch (IOException ex) {
ex.printStackTrace();
}
}
示例2: verify
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public String verify(String html, String trace)
throws Exception
{
out.setLength(0);
HTMLEditorKit.ParserCallback callback = this;
ParserDelegator delegator = new ParserDelegator();
delegator.parse(new StringReader(html), callback, true);
String ou = out.toString();
if (trace != null)
{
if (!ou.equals(trace))
{
System.err.println("Unable to parse '" + html + "':");
System.err.println(" expected: '" + trace + "',");
System.out.println(" returned: '" + ou + "'.");
throw new Exception("'" + html + "' -> '" + ou + "' expected '" +
trace + "'"
);
}
}
return ou;
}
示例3: getParsedContentOneLine
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
static String getParsedContentOneLine(String path) throws Exception {
File f = new File(path);
FileReader fr = new FileReader(f);
ParserDelegator pd = new ParserDelegator();
SBParserCallback sbcallback = new SBParserCallback();
pd.parse(fr, sbcallback, true);
fr.close();
return sbcallback.getStringOneLine();
}
示例4: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public void parse(Reader in) throws IOException
{
ParserDelegator delegator = new ParserDelegator();
// the third parameter is TRUE to ignore
// charset directive
delegator.parse(in, this, Boolean.TRUE);
}
示例5: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
private void parse() throws ComponentRegistryException {
try {
HttpURLConnection connection = (HttpURLConnection) this.url.openConnection();
connection.setInstanceFollowRedirects(false);
connection.connect();
int count = 0;
// TODO checking 3 is not enough
while (String.valueOf(connection.getResponseCode()).startsWith("3")) {
String location = connection.getHeaderField("Location");
logger.debug("Redirecting to " + location);
connection.disconnect();
this.url = new URL(location);
connection = (HttpURLConnection) this.url.openConnection();
connection.setInstanceFollowRedirects(false);
connection.connect();
count++;
if (count > 10) {
throw new ComponentRegistryException("Too many redirect");
}
}
InputStream inputStream = connection.getInputStream();
InputStreamReader reader = new InputStreamReader(inputStream);
HtmlRegistryParserCallback callback = new HtmlRegistryParserCallback();
ParserDelegator parser = new ParserDelegator();
parser.parse(reader, callback, false);
} catch (IOException e) {
throw new ComponentRegistryException(e);
}
}
示例6: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public List<String> parse(Reader file) throws Exception {
if (file == null) {
return null;
}
ParserDelegator pd = new ParserDelegator();
try {
pd.parse(file, this, true);
} catch (Exception e) {
throw e;
}
return imgs;
}
示例7: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public void parse(Reader in) throws IOException {
s = new StringBuffer();
ParserDelegator delegator = new ParserDelegator();
// the third parameter is TRUE to ignore charset directive
delegator.parse(in, this, Boolean.TRUE);
}
示例8: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
void parse() throws IOException {
ParserDelegator pd = new ParserDelegator();
formParser = new FormHTMLParser();
Reader r = new StringReader(definition);
pd.parse(r, formParser, true);
}
示例9: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public void parse(final Reader in) throws IOException {
s = new StringBuffer();
final ParserDelegator delegator = new ParserDelegator();
delegator.parse(in, this, Boolean.TRUE);
}
示例10: PluginLoader
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public PluginLoader(URL pluginLocation, ClassLoader loader) {
Loader = loader;
//Module = module;
//file = new File
//filePath.
url = pluginLocation;
try{
if(url.toString().substring(0,3).compareTo("http")==0) {
System.out.println("url location is ="+url.toString());
InputStream ips = url.openStream();
Reader r = new InputStreamReader(ips);
ParserDelegator parser = new ParserDelegator();
//HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback();
HTMLEditorKit.ParserCallback callback =
new HTMLEditorKit.ParserCallback () {
public void handleText(char[] dat, int pos) {
String data = new String(dat);
if(accept(new File("."), data))
fileList.addElement(data);
//System.out.println("\nHere is the data at position " +pos+" " + data.toString());
System.out.println("\ngot a file in list"+data);
}
};
parser.parse(r, callback, false);
}else {
file = new File(url.getPath());
System.out.println("File location is ="+file.getPath());
//fileList = file.list(this);
String[] tempList = file.list(this);
for(int i=0;i<tempList.length;i++)
fileList.add(tempList[i]);
}
} catch(Exception e) {e.printStackTrace(); }
//System.out.println("\n filepath and module" +filePath+module);
classLoader = new SimpleClassLoader(url,Loader);
System.out.println(file.getAbsolutePath());
fillVectors();
}
示例11: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public void parse(Reader in) throws IOException {
ParserDelegator delegator = new ParserDelegator();
// the third parameter is TRUE to ignore charset directive
delegator.parse(in, this, Boolean.TRUE);
}
示例12: parse
import javax.swing.text.html.parser.ParserDelegator; //導入方法依賴的package包/類
public void parse(Reader in) throws IOException {
s = new StringBuffer();
ParserDelegator delegator = new ParserDelegator();
delegator.parse(in, this, Boolean.TRUE);
}