當前位置: 首頁>>代碼示例>>Java>>正文


Java ParserDelegator.parse方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:aterai,項目名稱:java-swing-tips,代碼行數:22,代碼來源:MainPanel.java

示例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;
}
 
開發者ID:cfriedt,項目名稱:classpath,代碼行數:25,代碼來源:Parser_Test.java

示例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();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:bug7165725.java

示例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);
}
 
開發者ID:TOMIGalway,項目名稱:cmoct-sourcecode,代碼行數:8,代碼來源:HTML2Text.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:airavata,代碼行數:34,代碼來源:WebComponentRegistry.java

示例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;
}
 
開發者ID:howsun,項目名稱:howsun-javaee-framework,代碼行數:15,代碼來源:AnalizeWebParse.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:RefactoringPanel.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:ButtonsHTMLParser.java

示例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);
}
 
開發者ID:friedlwo,項目名稱:AppWoksUtils,代碼行數:6,代碼來源:HTML2PlainConverter.java

示例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();
  
 }
 
開發者ID:SOCR,項目名稱:HTML5_WebSite,代碼行數:55,代碼來源:PluginLoader.java

示例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);
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:6,代碼來源:IMDBTableConverter.java

示例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);
}
 
開發者ID:pdf4j,項目名稱:icepdf,代碼行數:6,代碼來源:FreeTextAnnotationComponent.java


注:本文中的javax.swing.text.html.parser.ParserDelegator.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。