Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@

/**
* This class represents data that is translated from simple HTML or plain text.
*
*
* This class represents a simple HTML fragment. It allows for user-supplied
* HTML to be translated on the fly into DRI.
*
*
* At the present time it only supports the following tags: h1, h2, h3, h4, h5,
* p, a, b, i, u, ol, li and img. Each are translated into their DRI equivalents, note
* the "h" tags are translated into a paragraph of rend=heading.
*
* If the linkbreaks flag is set then line breaks are treated as paragraphs. This
* allows plain text files to also be included and they will be mapped into DRI as
*
* If the linkbreaks flag is set then line breaks are treated as paragraphs. This
* allows plain text files to also be included and they will be mapped into DRI as
* well.
*
*
* @author Scott Phillips
* @author Jay Paz
*/
Expand All @@ -61,7 +61,7 @@ public class SimpleHTMLFragment extends AbstractWingElement {

/**
* Construct a fragment object for translating into DRI.
*
*
* @param context
* (Required) The context this element is contained in, such as
* where to route SAX events and what i18n catalogue to use.
Expand All @@ -81,7 +81,7 @@ protected SimpleHTMLFragment(WingContext context, boolean blankLines,

/**
* Translate this element into SAX
*
*
* @param contentHandler
* (Required) The registered contentHandler where SAX events
* should be routed too.
Expand All @@ -99,7 +99,7 @@ public void toSAX(ContentHandler contentHandler,
String xml = "<fragment>" + fragment + "</fragment>";

ByteArrayInputStream inputStream = new ByteArrayInputStream(xml
.getBytes());
.getBytes("UTF-8"));

SAXBuilder builder = new SAXBuilder();
Document document = builder.build(inputStream);
Expand Down Expand Up @@ -141,10 +141,10 @@ public void toSAX(ContentHandler contentHandler,

/**
* Remove the given content from the Element.
*
*
* If the content is an element then render it as text and include it's
* children in the parent.
*
*
* @param content
* The DOM Content to be removed.
*/
Expand Down Expand Up @@ -202,10 +202,10 @@ private void removeContent(Content content) {
/**
* Wrap the given set of contents into a paragraph and place it at the
* supplied index.
*
*
* This method will also check for trivial paragraphs, i.e. those that
* contain nothing but white space. If they are found then they are removed.
*
*
* @param parent
* The parent element to attach the wrapped paragraph, too.
* @param index
Expand Down Expand Up @@ -265,7 +265,7 @@ private boolean paragraphWrap(Element parent, int index,
/**
* Ensure that the given element only has the supplied attributes. Also
* remove any possible namespaces on the attributes.
*
*
* @param element
* The element to be checked.
* @param names
Expand All @@ -291,7 +291,7 @@ private void limitAttributes(Element element, String... names) {

/**
* Move the old attribute to a new attribute.
*
*
* @param element
* The element
* @param oldName
Expand All @@ -309,15 +309,15 @@ private void moveAttribute(Element element, String oldName, String newName) {

/**
* Translate the given HTML fragment into a DRI document.
*
*
* The translation is broken up into two steps, 1) recurse through all
* elements and either translate them into their DRI equivalents or remove
* them from the document.
*
*
* The second step, 2) is to iterate over all top level elements and ensure
* that they only consist of paragraphs. Also at this stage if linkBreaks is
* true then \n are treated as paragraph breaks.
*
*
* @param parent
* The Element to translate into DRI.
*/
Expand Down Expand Up @@ -454,7 +454,7 @@ else if ("hi".equals(name)) {
List<Content> removed = new ArrayList<Content>();
for (int i = 0; i < parent.getContentSize(); i++) {
Content current = parent.getContent(i);

if ((current instanceof Element)
&& ("p".equals(((Element) current).getName()))) {
// A paragraph is being open, combine anything up to this
Expand Down Expand Up @@ -517,15 +517,15 @@ else if ("hi".equals(name)) {
* from the originating HTML fragment, 2) to get around a JDOM bug where it
* can not output SAX events for just a document fragment. Since it only
* works with documents this class was created to filter out the events.
*
*
* As far as I can tell, the first time the bug was identified is in the
* following email, point #1:
*
*
* http://www.servlets.com/archive/servlet/ReadMsg?msgId=491592&listName=jdom-interest
*
*
* I, Scott Phillips, checked the JDOM CVS source tree on 3-8-2006 and the
* bug had not been patch at that time.
*
*
*/
public static class SAXFilter implements ContentHandler, LexicalHandler {

Expand All @@ -546,7 +546,7 @@ public SAXFilter(ContentHandler contentHandler,
/**
* Create the qName for the element with the given localName and
* namespace prefix.
*
*
* @param localName
* (Required) The element's local name.
* @return
Expand Down Expand Up @@ -650,4 +650,4 @@ public void comment(char[] ch, int start, int length)
}
}
}