当前位置: 首页>>代码示例>>Java>>正文


Java Source类代码示例

本文整理汇总了Java中net.htmlparser.jericho.Source的典型用法代码示例。如果您正苦于以下问题:Java Source类的具体用法?Java Source怎么用?Java Source使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Source类属于net.htmlparser.jericho包,在下文中一共展示了Source类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: realWrite

import net.htmlparser.jericho.Source; //导入依赖的package包/类
public void realWrite(boolean printHeadBodyTags) throws IOException {
    flush();
    ByteArrayOutputStream stream = (ByteArrayOutputStream) this.out;
    this.out = outputStream;
    if (!printHeadBodyTags) {
        stream.writeTo(outputStream);
        return;
    }
    println("<html>");
    println("<head>");
    println("<style>");
    for (Style style : styles)
        println(style);
    println("</style>");
    println("</head>");

    String htmlText = new String(stream.toByteArray(), "UTF-8");
    Source source = new Source(htmlText);
    source.fullSequentialParse();

    List<StartTag> startTags = source.getAllStartTags("body");
    if (startTags.size() == 0) {
        println("<body>");
        println(htmlText);
        println("</body>");
    } else {
        println(new StringBuffer(startTags.get(0).getElement()));
    }

    println("</html>");
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:32,代码来源:Out.java

示例2: setHTMLText

import net.htmlparser.jericho.Source; //导入依赖的package包/类
public void setHTMLText(String htmlText) {
    try {
        this.text = htmlText;
        if (formatt) {
            Source segment = new Source(text);
            segment.fullSequentialParse();
            SourceFormatter formatter = new SourceFormatter(
                    segment);
            htmlText = formatter.toString();
        }

        editorPane.read(new StringReader(htmlText), null);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:17,代码来源:HTMLView.java

示例3: actionPerformed

import net.htmlparser.jericho.Source; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    if (formatt == ((Boolean) getValue(SELECTED_KEY)))
        return;
    formatt = (Boolean) getValue(SELECTED_KEY);
    putValue(SELECTED_KEY, formatt);
    try {
        String text = HTMLView.this.text;
        if (formatt) {
            SourceFormatter formatter = new SourceFormatter(new Source(
                    text));
            text = formatter.toString();
        }

        editorPane.read(new StringReader(text), null);
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:20,代码来源:HTMLView.java

示例4: processPage

import net.htmlparser.jericho.Source; //导入依赖的package包/类
protected String processPage( PathOrigin baseDir, String pagePath ) throws IOException {

    long start = System.currentTimeMillis();
    InputStream file = null;
    try {
      file = baseDir.getReader( getRepo() ).getFileInputStream( pagePath );
      Source html = new Source( file ); 
      OutputDocument outDoc = new OutputDocument( html );
      // transform
      modifyDocument( html, baseDir, outDoc );
      return outDoc.toString();
    } finally {
      IOUtils.closeQuietly( file );
      if ( log.isDebugEnabled() ) {
        log.debug( String.format( "processPage for %s took %dms", pagePath, System.currentTimeMillis() - start ) );
      }
    }

  }
 
开发者ID:webdetails,项目名称:cte,代码行数:20,代码来源:ProcessedHtmlPage.java

示例5: getContent

import net.htmlparser.jericho.Source; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public String getContent(String eventResource) {
    String reference = getReferenceFromEventResource(eventResource);
    EntityProviderManager entityProviderManager = ComponentManager.get(EntityProviderManager.class);
    EntityReference er= new EntityReference("/sam_item/"+reference);
    ItemEntityProviderImpl qhp= (ItemEntityProviderImpl)entityProviderManager.getProviderByPrefix(er.getPrefix());

    try {
        ItemFacade item = (ItemFacade)qhp.getEntity(er);
        String content = qhp.content(item);
        //We will filter the HTML here just before send to the index
        Source parseContent = new Source(content);
        return parseContent.getTextExtractor().toString();
    } catch (Exception e) {
        throw new RuntimeException(" Failed to get item content ", e);
    }

}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:21,代码来源:ItemContentProducer.java

示例6: getContent

import net.htmlparser.jericho.Source; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public String getContent(String eventResource) {
    String reference = getReferenceFromEventResource(eventResource);
    EntityProviderManager entityProviderManager = ComponentManager.get(EntityProviderManager.class);
    EntityReference er= new EntityReference("/sam_publisheditem/"+reference);
    PublishedItemEntityProviderImpl qhp= (PublishedItemEntityProviderImpl)entityProviderManager.getProviderByPrefix(er.getPrefix());
    try {
        PublishedItemFacade item = (PublishedItemFacade)qhp.getEntity(er);
        String content = qhp.content(item);
        //We will filter the HTML here just before send to the index
        Source parseContent = new Source(content);
        return parseContent.getTextExtractor().toString();
    } catch (Exception e) {
        throw new RuntimeException(" Failed to get item content ", e);
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:PublishedItemContentProducer.java

示例7: strip

import net.htmlparser.jericho.Source; //导入依赖的package包/类
/**
	 * Retira tags indesejadas
	 * 
	 * @param html
	 * @return
	 */
	public String strip(String html) {

		
		if (html == null)
			return "";
		Source source = new Source(html);
		source.fullSequentialParse();
		OutputDocument output = new OutputDocument(source);
		List<Tag> tags = source.getAllTags();

		for (Tag tag : tags) {
			if (processTag(tag, output)) {
				tag.setUserData(VALID_MARKER);
			} else {
				output.remove(tag);
			}
//			reencodeTextSegment(source, output, pos, tag.getBegin());
		}
//		reencodeTextSegment(source, output, pos, source.getEnd());
		return output.toString();
	}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:28,代码来源:HtmlStripperDiscussion.java

示例8: strip

import net.htmlparser.jericho.Source; //导入依赖的package包/类
/**
 * Retira tags indesejadas
 * 
 * @param html
 * @return
 */
public String strip(String html) {
	if (html == null)
		return "";
	Source source = new Source(html);
	source.fullSequentialParse();
	OutputDocument output = new OutputDocument(source);
	List<Tag> tags = source.getAllTags();
	int pos = 0;
	for (Tag tag : tags) {
		if (processTag(tag, output)) {
			tag.setUserData(VALID_MARKER);
		} else {
			output.remove(tag);
		}
		reencodeTextSegment(source, output, pos, tag.getBegin());
		pos = tag.getEnd();
	}
	reencodeTextSegment(source, output, pos, source.getEnd());
	return output.toString();
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:27,代码来源:HtmlStripper.java

示例9: doInBackground

import net.htmlparser.jericho.Source; //导入依赖的package包/类
@Override
protected List<String> doInBackground(Void... params) {
  Source source = new Source(mText);
  String plainText = source.getRenderer().toString();

  Map<String, String> postParams = new HashMap<String, String>(2);
  postParams.put("mod", requestMod);
  postParams.put("text", plainText);
  HttpResponse response = RemoteMessageController.sendPostRequest(postParams);
  if (response != null) {
    String result = RemoteMessageController.responseToString(response);
    if (result != null) {
      return RemoteMessageController.responseStringToArray(result);
    }
  }
  return null;
}
 
开发者ID:k-kojak,项目名称:yako,代码行数:18,代码来源:ThreadDisplayerActivity.java

示例10: tidyHtml

import net.htmlparser.jericho.Source; //导入依赖的package包/类
/**
 * Tidy the HTML source by reformatting the entire HTML. This is
 * particularly useful when the application needs to emit HTML.
 *
 * @param htmlSource
 *            the unformatted HTML source
 *
 * @return the formatted HTML source.
 *
 */
public static String tidyHtml(String htmlSource) {
	if(htmlSource == null) {
		return htmlSource;
	}

	try {
		Source source = new Source(htmlSource) ;
		StringWriter writer = new StringWriter();
		new SourceFormatter(source).setIndentString("  ").setTidyTags(true).writeTo(writer);
		writer.close();

		return writer.toString();
	} catch(Exception e) {
		e.printStackTrace();
	}

	return htmlSource;
}
 
开发者ID:sangupta,项目名称:jerry-core,代码行数:29,代码来源:HtmlUtils.java

示例11: ProcessTextDocument

import net.htmlparser.jericho.Source; //导入依赖的package包/类
/**
 * Processes the text document, extracts the title, and strip the HTML tags
 * @return boolean
 */
public boolean ProcessTextDocument() {
       // The content should be in plain HTML, prefered not to be stripped
       String withoutHTML = this.StripHTML(doc.getRawTextContent());
       withoutHTML = StringEscapeUtils.escapeXml(withoutHTML);
       doc.setStrippedTextContent(withoutHTML);
       String title = ""; //doc.TitleProperty;

       MicrosoftTagTypes.register();
       PHPTagTypes.register();
       PHPTagTypes.PHP_SHORT.deregister(); // remove PHP short tags for this example otherwise they override processing instructions
       MasonTagTypes.register();
       Source source = new Source(doc.getRawTextContent());
       source.fullSequentialParse();

       title = getTitle(source);

       if (title != null) {

           title = StringEscapeUtils.escapeXml(title);
           doc.setTitle(title);

       }

       return true;
   }
 
开发者ID:shiftdirector,项目名称:youseer,代码行数:30,代码来源:Worker.java

示例12: convert

import net.htmlparser.jericho.Source; //导入依赖的package包/类
public String convert() {
    Source source = new Source(code);
    source.fullSequentialParse();

    int from = 0;

    StringBuffer result = new StringBuffer();

    for (StartTag tag : source.getAllStartTags()) {
        if (tag.getName().startsWith("%")) {

            addLines(result, source, from, tag.getBegin());

            from = tag.getEnd();

            String script = tag.toString();
            if (script.length() > 4) {
                if (script.charAt(2) == '=') {
                    result.append("doc.print(");
                    result.append(script.substring(3, script.length() - 2));
                    result.append(");");
                } else {
                    result.append(script.substring(2, script.length() - 2));
                }
            }
        }
    }

    addLines(result, source, from, source.getEnd());

    return result.toString();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:33,代码来源:JSSPToJsConverter.java

示例13: addLines

import net.htmlparser.jericho.Source; //导入依赖的package包/类
private void addLines(StringBuffer result, Source source, int from, int to) {
    CharSequence toAdd = source.subSequence(from, to);
    int length = toAdd.length();
    result.append("doc.print(\"");
    for (int i = 0; i < length; i++) {
        char c = toAdd.charAt(i);
        if (c != '\r') {
            if (c == '\n') {
                result.append("\\n\");\n");
                if (i == length - 1)
                    return;
                result.append("doc.print(\"");
            } else {
                if ((c == '\\') || (c == '\"') || (c == '\'')) {
                    result.append('\\');
                    result.append(c);
                } else {
                    if (c == '\t') {
                        result.append("\\t");
                    } else
                        result.append(c);
                }
            }
        }
    }
    result.append("\");");
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:28,代码来源:JSSPToJsConverter.java

示例14: getReport

import net.htmlparser.jericho.Source; //导入依赖的package包/类
public Source getReport(String name, Query query) {
    Element element = engine.getElement(name, ReportPlugin
            .getReportsQualifier(engine).getId());
    if (element == null)
        throw new DataException("Error.reportNotFound", "Report " + name
                + " not found", name);
    HashMap<String, Object> map = new HashMap<String, Object>();
    if (query != null)
        map.put("query", query);
    String htmlReport = reportQuery.getHTMLReport(element, map);
    Source source = new Source(htmlReport);
    source.fullSequentialParse();
    return source;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:15,代码来源:Data.java

示例15: printHTMLPage

import net.htmlparser.jericho.Source; //导入依赖的package包/类
public void printHTMLPage(HTMLPage page) throws IOException {
    byte[] data = page.getData();
    if (data == null)
        return;
    Source source = new Source(new ByteArrayInputStream(data));
    source.fullSequentialParse();
    printHTMLPage(source);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:9,代码来源:Out.java


注:本文中的net.htmlparser.jericho.Source类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。