Java Doc for HtmlParser.java in  » Mail-Clients » columba-1.4 » org » columba » mail » parser » text » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.mail.parser.text 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.columba.mail.parser.text.HtmlParser

HtmlParser
final public class HtmlParser (Code)
Contains different utility functions for manipulating Html based text. This includes functionality for removing and restoring special entities (such as &, <, >, ...) and functionality for removing html tags from the text.
author:
   Karl Peder Olesen (karlpeder), 20030623




Method Summary
public static  StringgetHtmlBody(String html)
     Extracts the body of a html document, i.e.
public static  CharsetgetHtmlCharset(String htmlSource)
    
public static  StringhtmlToText(String html)
     Strips html tags.
public static  StringremoveComments(String html)
     Parses a html documents and removes all html comments found.
public static  StringrestoreSpecialCharacters(Charset charset, String s)
     Performs in large terms the reverse of substituteSpecialCharacters (though br tags are not converted to newlines, this should be handled separately). More preciesly it changes special entities like amp, nbsp etc.
public static  StringstripHtmlTags(String s)
     Strips html tags and removes extra spaces which occurs due to e.g.
public static  StringstripHtmlTags(String s, boolean breakToNl)
     Strips html tags.
public static  StringsubstituteEmailAddress(String s)
    
public static  StringsubstituteEmailAddress(String s, boolean ignoreLinks)
     Transforms email-addresses into HTML just as substituteEmailAddress(String), but tries to ignore email-addresses, which are already links, if the ignore links flag is set.
This extended functionality is necessary when parsing a text which is already (partly) html.
FIXME: Can this be done smarter, i.e.
public static  StringsubstituteSpecialCharacters(String s)
    
public static  StringsubstituteSpecialCharactersInHeaderfields(String s)
     substitute special characters like: <,>,&,\t,\n with special entities used in html
This is the same as substituteSpecialCharacters, but here an extra newline character is not inserted.
public static  StringsubstituteURL(String s)
    
public static  StringsubstituteURL(String s, boolean ignoreLinks)
     Transforms urls into HTML just as substituteURL(String), but tries to ignore urls, which are already links, if the ignore links flag is set.
This extended functionality is necessary when parsing a text which is already (partly) html.
FIXME: Can this be done smarter, i.e.
public static  StringtextToHtml(String text, String title, String css, String charset)
     Replaces special chars - <,>,&,\t,\n," - with the special entities used in html (amp, nbsp, ...).
public static  StringvalidateHTMLString(String input)
     Tries to fix broken html-strings by inserting html start- and end tags if missing, and by removing content after the html end tag.



Method Detail
getHtmlBody
public static String getHtmlBody(String html)(Code)
Extracts the body of a html document, i.e. the html contents between (and not including) body start and end tags.
Parameters:
  html - The html document to extract the body from The body of the html document
author:
   Karl Peder Olesen (karlpeder)



getHtmlCharset
public static Charset getHtmlCharset(String htmlSource)(Code)



htmlToText
public static String htmlToText(String html)(Code)
Strips html tags. and replaces special entities with their "normal" counter parts, e.g. > => >.
Calling this method is the same as calling first stripHtmlTags and then restoreSpecialCharacters.
Parameters:
  html - input string output without html tags and special entities(null on error)
author:
   karlpeder, 20030623
author:
   (moved from org.columba.mail.parser.text.BodyTextParser)



removeComments
public static String removeComments(String html)(Code)
Parses a html documents and removes all html comments found.
Parameters:
  html - The html document Html document without comments
author:
   Karl Peder Olesen (karlpeder)



restoreSpecialCharacters
public static String restoreSpecialCharacters(Charset charset, String s)(Code)
Performs in large terms the reverse of substituteSpecialCharacters (though br tags are not converted to newlines, this should be handled separately). More preciesly it changes special entities like amp, nbsp etc. to their real counter parts: &, space etc.
This includes transformation of special (language specific) chars such as the Danish ? ? ? ? ? ?.
Parameters:
  s - input string output with special entities replaced with their"real" counter parts (null on error)
author:
   karlpeder, 20030623
author:
   (moved from org.columba.mail.gui.message.util.DocumentParser)



stripHtmlTags
public static String stripHtmlTags(String s)(Code)
Strips html tags and removes extra spaces which occurs due to e.g. indentation of the html and the head section, which does not contain any textual information.
The conversion rutine does the following:
1. Removes the header from the html file, i.e. everything from the html tag until and including the starting body tag.
2. Replaces multiple consecutive whitespace characters with a single space (since extra whitespace should be ignored in html).
3. Replaces ending br tags with a single newline character
4. Replaces ending p, div and heading tags with two newlines characters; resulting in a single empty line btw. paragraphs.
5. Strips remaining html tags.

NB: The tag stripping is done using a very simple regular expression, which removes everything between < and >. Therefore too much text could in some (hopefully rare!?) cases be removed.
Parameters:
  s - Input string Input stripped for html tags
author:
   Karl Peder Olesen (karlpeder)



stripHtmlTags
public static String stripHtmlTags(String s, boolean breakToNl)(Code)
Strips html tags. The method used is very simple: Everything between tag-start (<) and tag-end (>) is removed. Optionaly br tags are replaced by newline and ending p tags with double newline.
Parameters:
  s - input string
Parameters:
  breakToNl - if true, newlines are inserted for br and p tags output without html tags (null on error)
author:
   karlpeder, 20030623
author:
   (moved from org.columba.mail.gui.message.util.DocumentParser)
See Also:    stripHtmlTags(String) method



substituteEmailAddress
public static String substituteEmailAddress(String s)(Code)
parse text and transform every email-address in a HTML-conform address
Parameters:
  s - input text text with email-adresses transformed to links(null on error)



substituteEmailAddress
public static String substituteEmailAddress(String s, boolean ignoreLinks)(Code)
Transforms email-addresses into HTML just as substituteEmailAddress(String), but tries to ignore email-addresses, which are already links, if the ignore links flag is set.
This extended functionality is necessary when parsing a text which is already (partly) html.
FIXME: Can this be done smarter, i.e. directly with reg. expr. without manual parsing??
Parameters:
  s - input text
Parameters:
  ignoreLinks - if true link tags are ignored. This gives awrong result if some e-mail adresses arealready links (but uses reg. expr. directly,and is therefore faster) text with email-adresses transformed to links



substituteSpecialCharacters
public static String substituteSpecialCharacters(String s)(Code)
Substitute special characters like: <,>,&,\t,\n," with special entities used in html (amp, nbsp, ...)
Parameters:
  s - input string containing special characters output with special characters substituted(null on error)



substituteSpecialCharactersInHeaderfields
public static String substituteSpecialCharactersInHeaderfields(String s)(Code)
substitute special characters like: <,>,&,\t,\n with special entities used in html
This is the same as substituteSpecialCharacters, but here an extra newline character is not inserted.
Parameters:
  s - input string containing special characters output with special characters substituted(null on error)



substituteURL
public static String substituteURL(String s)(Code)
parse text and transform every url in a HTML-conform url
Parameters:
  s - input text text with urls transformed to links(null on error)



substituteURL
public static String substituteURL(String s, boolean ignoreLinks)(Code)
Transforms urls into HTML just as substituteURL(String), but tries to ignore urls, which are already links, if the ignore links flag is set.
This extended functionality is necessary when parsing a text which is already (partly) html.
FIXME: Can this be done smarter, i.e. directly with reg. expr. without manual parsing??
Parameters:
  s - input text
Parameters:
  ignoreLinks - if true link tags are ignored. This gives awrong result if some urls are already links(but uses reg. expr. directly, and istherefore faster) text with urls



textToHtml
public static String textToHtml(String text, String title, String css, String charset)(Code)
Replaces special chars - <,>,&,\t,\n," - with the special entities used in html (amp, nbsp, ...). Then the complete text is surrounded with proper html tags: Starting- and ending html tag, header section and body section. The complete body section is sorround with p tags.
This is the same as first calling substituteSpecialCharacters and then add starting and ending html tags etc.
Further more urls and email adresses are converted into links Optionally a title and css definition is inserted in the html header.
TODO (@author fdietz): Add support for smilies and coloring of quoted text
Parameters:
  text - Text to convert to html
Parameters:
  title - Title to include in header, not used if null
Parameters:
  css - Style sheet def. to include in header,not used if null.The input shall not include the style tag Text converted to html
author:
   Karl Peder Olesen (karlpeder), 20030916



validateHTMLString
public static String validateHTMLString(String input)(Code)
Tries to fix broken html-strings by inserting html start- and end tags if missing, and by removing content after the html end tag.
Parameters:
  input - html content to be validated content with extra tags inserted if necessary



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.