- java.lang.Object
-
- javax.swing.text.AbstractWriter
-
- javax.swing.text.html.HTMLWriter
-
public class HTMLWriter extends AbstractWriter
This is a writer for HTMLDocuments.
-
-
Field Summary
-
Fields inherited from class javax.swing.text.AbstractWriter
NEWLINE
-
-
Constructor Summary
Constructors Constructor and Description HTMLWriter(Writer w, HTMLDocument doc)
Creates a new HTMLWriter.HTMLWriter(Writer w, HTMLDocument doc, int pos, int len)
Creates a new HTMLWriter.
-
Method Summary
Methods Modifier and Type Method and Description protected void
closeOutUnwantedEmbeddedTags(AttributeSet attr)
Searches the attribute set and for each tag that is stored in the tag vector.protected void
comment(Element elem)
Writes out comments.protected void
emptyTag(Element elem)
Writes out all empty elements (all tags that have no corresponding end tag).protected void
endTag(Element elem)
Writes out an end tag for the element.protected boolean
isBlockTag(AttributeSet attr)
Determines if the HTML.Tag associated with the element is a block tag.protected boolean
matchNameAttribute(AttributeSet attr, HTML.Tag tag)
Returns true if the StyleConstants.NameAttribute is equal to the tag that is passed in as a parameter.protected void
output(char[] chars, int start, int length)
This method is overriden to map any character entities, such as < to <.protected void
selectContent(AttributeSet attr)
Writes out the content of the SELECT form element.protected void
startTag(Element elem)
Writes out a start tag for the element.protected boolean
synthesizedElement(Element elem)
Returns true if the element is a synthesized element.protected void
text(Element elem)
Writes out text.protected void
textAreaContent(AttributeSet attr)
Writes out text that is contained in a TEXTAREA form element.void
write()
Iterates over the Element tree and controls the writing out of all the tags and its attributes.protected void
writeAttributes(AttributeSet attr)
Writes out the attribute set.protected void
writeEmbeddedTags(AttributeSet attr)
Searches for embedded tags in the AttributeSet and writes them out.protected void
writeLineSeparator()
Writes the line separator.protected void
writeOption(Option option)
Writes out the content of the Option form element.-
Methods inherited from class javax.swing.text.AbstractWriter
decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write
-
-
-
-
Constructor Detail
-
HTMLWriter
public HTMLWriter(Writer w, HTMLDocument doc)
Creates a new HTMLWriter.- Parameters:
w
- a Writerdoc
- an HTMLDocument
-
HTMLWriter
public HTMLWriter(Writer w, HTMLDocument doc, int pos, int len)
Creates a new HTMLWriter.- Parameters:
w
- a Writerdoc
- an HTMLDocumentpos
- the document location from which to fetch the contentlen
- the amount to write out
-
-
Method Detail
-
write
public void write() throws IOException, BadLocationException
Iterates over the Element tree and controls the writing out of all the tags and its attributes.- Specified by:
write
in classAbstractWriter
- Throws:
IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
-
writeAttributes
protected void writeAttributes(AttributeSet attr) throws IOException
Writes out the attribute set. Ignores all attributes with a key of type HTML.Tag, attributes with a key of type StyleConstants, and attributes with a key of type HTML.Attribute.ENDTAG.- Overrides:
writeAttributes
in classAbstractWriter
- Parameters:
attr
- an AttributeSet- Throws:
IOException
- on any I/O error
-
emptyTag
protected void emptyTag(Element elem) throws BadLocationException, IOException
Writes out all empty elements (all tags that have no corresponding end tag).- Parameters:
elem
- an Element- Throws:
IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
-
isBlockTag
protected boolean isBlockTag(AttributeSet attr)
Determines if the HTML.Tag associated with the element is a block tag.- Parameters:
attr
- an AttributeSet- Returns:
- true if tag is block tag, false otherwise.
-
startTag
protected void startTag(Element elem) throws IOException, BadLocationException
Writes out a start tag for the element. Ignores all synthesized elements.- Parameters:
elem
- an Element- Throws:
IOException
- on any I/O errorBadLocationException
-
textAreaContent
protected void textAreaContent(AttributeSet attr) throws BadLocationException, IOException
Writes out text that is contained in a TEXTAREA form element.- Parameters:
attr
- an AttributeSet- Throws:
IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
-
text
protected void text(Element elem) throws BadLocationException, IOException
Writes out text. If a range is specified when the constructor is invoked, then only the appropriate range of text is written out.- Overrides:
text
in classAbstractWriter
- Parameters:
elem
- an Element- Throws:
IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
-
selectContent
protected void selectContent(AttributeSet attr) throws IOException
Writes out the content of the SELECT form element.- Parameters:
attr
- the AttributeSet associated with the form element- Throws:
IOException
- on any I/O error
-
writeOption
protected void writeOption(Option option) throws IOException
Writes out the content of the Option form element.- Parameters:
option
- an Option- Throws:
IOException
- on any I/O error
-
endTag
protected void endTag(Element elem) throws IOException
Writes out an end tag for the element.- Parameters:
elem
- an Element- Throws:
IOException
- on any I/O error
-
comment
protected void comment(Element elem) throws BadLocationException, IOException
Writes out comments.- Parameters:
elem
- an Element- Throws:
IOException
- on any I/O errorBadLocationException
- if pos represents an invalid location within the document.
-
synthesizedElement
protected boolean synthesizedElement(Element elem)
Returns true if the element is a synthesized element. Currently we are only testing for the p-implied tag.
-
matchNameAttribute
protected boolean matchNameAttribute(AttributeSet attr, HTML.Tag tag)
Returns true if the StyleConstants.NameAttribute is equal to the tag that is passed in as a parameter.
-
writeEmbeddedTags
protected void writeEmbeddedTags(AttributeSet attr) throws IOException
Searches for embedded tags in the AttributeSet and writes them out. It also stores these tags in a vector so that when appropriate the corresponding end tags can be written out.- Throws:
IOException
- on any I/O error
-
closeOutUnwantedEmbeddedTags
protected void closeOutUnwantedEmbeddedTags(AttributeSet attr) throws IOException
Searches the attribute set and for each tag that is stored in the tag vector. If the tag isnt found, then the tag is removed from the vector and a corresponding end tag is written out.- Throws:
IOException
- on any I/O error
-
writeLineSeparator
protected void writeLineSeparator() throws IOException
Writes the line separator. This is overriden to make sure we don't replace the newline content in case it is outside normal ascii.- Overrides:
writeLineSeparator
in classAbstractWriter
- Throws:
IOException
- Since:
- 1.3
-
output
protected void output(char[] chars, int start, int length) throws IOException
This method is overriden to map any character entities, such as < to <.super.output
will be invoked to write the content.- Overrides:
output
in classAbstractWriter
- Throws:
IOException
- Since:
- 1.3
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/text/html/htmlwriter.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.