クラスMinimalHTMLWriter

java.lang.Object
javax.swing.text.AbstractWriter
javax.swing.text.html.MinimalHTMLWriter

public class MinimalHTMLWriter extends AbstractWriter
MinimalHTMLWriterは、エディタ・キットで作成されないドキュメントのHTMLを書き出すためにHTMLEditorKitが使用する代替ライターです。 ドキュメントの形式は次のとおりです。
<html>
  <head>
    <style>
       <!-- list of named styles
        p.normal {
           font-family: SansSerif;
           margin-height: 0;
           font-size: 14
        }
       -->
     </style>
  </head>
  <body>
   <p style=normal>
       Bold, italic, and underline attributes
       of the run are emitted as HTML tags.
       The remaining attributes are emitted as
       part of the style attribute of a <span> tag.
       The syntax is similar to inline styles.
   </p>
  </body>
</html>
  • フィールドのサマリー

    クラスで宣言されたフィールド AbstractWriter

    NEWLINE
    修飾子と型
    フィールド
    説明
    protected static final char
    テキスト・パッケージ・モデルの改行法です。
  • コンストラクタのサマリー

    コンストラクタ
    コンストラクタ
    説明
    新しいMinimalHTMLWriterを作成します。
    MinimalHTMLWriter(Writer w, StyledDocument doc, int pos, int len)
    新しいMinimalHTMLWriterを作成します。
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    protected void
    現在使われていません。代わりに<span>が書き出されます。
    protected boolean
    <font>タグ内ならtrueを返します。
    protected boolean
    要素がテキストならtrueを返します。
    protected void
    現在使われていません。代わりに<span>が書き出されます。
    protected void
    text(Element elem)
    テキストを書き出します。
    void
    StyledDocumentからHTML出力を生成します。
    protected void
    StyleConstants.ParagraphConstants、StyleConstants.CharacterConstants、StyleConstants.FontConstants、StyleConstants.ColorConstantsの各型のすべての属性を書き出します。
    protected void
    ドキュメント内の要素で反復し、枝の要素か葉の要素かを判断して要素を処理します。
    protected void
    コンポーネント要素の書出しを行います。意図的に実装しない場合があります。
    protected void
    writeContent(Element elem, boolean needsIndenting)
    HTMLに準拠した方法で属性セットを書き出します。
    protected void
    <p>タグの終了タグを発行します。
    protected void
    適切にインデント処理された終了タグを書き出します。
    protected void
    <head>および<style>のタグを書出し、次にwriteStyles()を起動して<style>タグのコンテンツとしてすべての名前付き書式を書き出します。
    protected void
    属性設定に基づいてテキストのボールド<b>、イタリック<i>、および<u>のタグを生成します。
    protected void
    アイコン要素の書出しを行います。意図的に実装しない場合があります。
    protected void
    テキスト以外の葉の要素の書出しを制御します。
    protected void
    HTMLに準拠した方法で残りの文字レベルの属性(ボールド、イタリック、下線以外の属性)を書き出します。
    protected void
    段落の開始タグを発行します。
    protected void
    適切にインデント処理された開始タグを書き出します。
    protected void
    <style>タグのコンテンツとしてすべての名前付き書式を書き出します。

    クラスで宣言されたメソッド AbstractWriter

    decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, output, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write, writeLineSeparator
    修飾子と型
    メソッド
    説明
    protected void
    インデント・レベルを減分します。
    protected boolean
    行がラップ可能かどうかを返します。
    protected int
    現在の行の長さを返します。
    protected Document
    ドキュメントを取得します。
    protected ElementIterator
    ElementIteratorを取得します。
    int
    出力対象の最後のオフセットを返します。
    protected int
    現在のインデント・レベルを返します。
    protected int
    インデントするスペースの量を返します。
    protected int
    行の長さの最大値を返します。
    改行を表すときに使用する文字列を返します。
    int
    出力対象の最初のオフセットを返します。
    protected String
    要素に関連したテキストを返します。
    protected Writer
    コンテンツを出力するときに使用するライターを返します。
    protected void
    インデント・レベルを増分します。
    protected void
    インデントを行います。
    protected boolean
    このメソッドは、現在の要素が指定された範囲内にあるかどうかを判定します。
    protected boolean
    現在の行の長さが空の場合は、trueを返します。
    protected void
    output(char[] content, int start, int length)
    コンテンツ書込み時の最後の停止です。
    protected void
    setCanWrapLines(boolean newValue)
    行をラップできるかどうかを設定します。
    protected void
    現在の行の長さを設定します。
    protected void
    setIndentSpace(int space)
    インデントにマッピングするスペースの数をサブクラスから指定できるようにします。
    protected void
    1行あたりに書き込むことのできる文字数をサブクラスから設定できるようにします。
    void
    改行を表すときに使用する文字列を設定します。
    protected void
    write(char ch)
    文字を書き出します。
    protected void
    write(char[] chars, int startIndex, int length)
    すべての書出しメソッドはこれを呼び出します。
    protected void
    write(String content)
    文字列を書き出します。
    protected void
    行区切り文字を書き出します。

    クラスオブジェクトで宣言されたメソッド

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    修飾子と型
    メソッド
    説明
    protected Object
    このオブジェクトのコピーを作成して、返します。
    boolean
    このオブジェクトと他のオブジェクトが等しいかどうかを示します。
    protected void
    削除予定のため非推奨: このAPI要素は、将来のバージョンで削除される可能性があります。
    最終決定は非推奨であり、将来のリリースで削除される可能性があります。
    final Class<?>
    このObjectの実行時クラスを返します。
    int
    このオブジェクトに対するハッシュ・コード値を返します。
    final void
    このオブジェクトのモニターで待機中のスレッドを1つ再開します。
    final void
    このオブジェクトのモニターで待機中のすべてのスレッドを再開します。
    オブジェクトの文字列表現を返します。
    final void
    現在のスレッドが目覚めるまで待機します。通常、notifiedまたはinterruptedです。
    final void
    wait(long timeoutMillis)
    現在のスレッドは、通常、notifiedまたはinterruptedであるか、一定のリアルタイムが経過するまで、目覚めるまで待機します。
    final void
    wait(long timeoutMillis, int nanos)
    現在のスレッドは、通常、notifiedまたはinterruptedであるか、一定のリアルタイムが経過するまで、目覚めるまで待機します。
  • コンストラクタの詳細

    • MinimalHTMLWriter

      public MinimalHTMLWriter(Writer w, StyledDocument doc)
      新しいMinimalHTMLWriterを作成します。
      パラメータ:
      w - ライター
      doc - StyledDocument
    • MinimalHTMLWriter

      public MinimalHTMLWriter(Writer w, StyledDocument doc, int pos, int len)
      新しいMinimalHTMLWriterを作成します。
      パラメータ:
      w - ライター
      doc - StyledDocument
      pos - コンテンツを取得するドキュメント内の位置。
      len - 書き出す量。
  • メソッドの詳細

    • write

      public void write() throws IOException, BadLocationException
      StyledDocumentからHTML出力を生成します。
      定義:
      write、クラスAbstractWriter
      スロー:
      IOException - 入出力エラーが発生した場合
      BadLocationException - posがドキュメント内の無効な位置を表す場合。
    • writeAttributes

      protected void writeAttributes(AttributeSet attr) throws IOException
      StyleConstants.ParagraphConstants、StyleConstants.CharacterConstants、StyleConstants.FontConstants、StyleConstants.ColorConstantsの各型のすべての属性を書き出します。 属性名と値はコロンで区切られます。 各ペアはセミコロンで区切られます。
      オーバーライド:
      writeAttributes、クラスAbstractWriter
      パラメータ:
      attr - AttributeSet
      スロー:
      IOException - 入出力エラーが発生した場合
    • text

      protected void text(Element elem) throws IOException, BadLocationException
      テキストを書き出します。
      オーバーライド:
      text、クラスAbstractWriter
      パラメータ:
      elem - Element
      スロー:
      IOException - 入出力エラーが発生した場合
      BadLocationException - posがドキュメント内の無効な位置を表す場合。
    • writeStartTag

      protected void writeStartTag(String tag) throws IOException
      適切にインデント処理された開始タグを書き出します。 またインデント・レベルを増分します。
      パラメータ:
      tag - 開始タグ
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeEndTag

      protected void writeEndTag(String endTag) throws IOException
      適切にインデント処理された終了タグを書き出します。 またインデント・レベルを減らします。
      パラメータ:
      endTag - 終了タグ
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeHeader

      protected void writeHeader() throws IOException
      <head>および<style>のタグを書出し、次にwriteStyles()を起動して<style>タグのコンテンツとしてすべての名前付き書式を書き出します。 コンテンツの前後には、タグをサポートしないアプリケーションやブラウザでもドキュメントが表示できるように、有効なHTMLコメント・マーカーが配置されます。
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeStyles

      protected void writeStyles() throws IOException
      <style>タグのコンテンツとしてすべての名前付き書式を書き出します。
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeBody

      protected void writeBody() throws IOException, BadLocationException
      ドキュメント内の要素で反復し、枝の要素か葉の要素かを判断して要素を処理します。 テキストである葉の要素には特別な処理を行います。
      スロー:
      IOException - 入出力エラーが発生した場合
      BadLocationException - ドキュメント内の無効なロケーションにある場合。
    • writeEndParagraph

      protected void writeEndParagraph() throws IOException
      <p>タグの終了タグを発行します。 タグを書き出す前に、オープンしているほかのすべてのタグが正しくクローズされることを確認します。
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeStartParagraph

      protected void writeStartParagraph(Element elem) throws IOException
      段落の開始タグを発行します。 段落に対応する名前付きスタイルがあれば、<p>タグのクラス属性も生成してその値をスタイルの名前に設定します。
      パラメータ:
      elem - 要素
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeLeaf

      protected void writeLeaf(Element elem) throws IOException
      テキスト以外の葉の要素の書出しを制御します。
      パラメータ:
      elem - 要素
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeImage

      protected void writeImage(Element elem) throws IOException
      アイコン要素の書出しを行います。意図的に実装しない場合があります。 このメソッドの実装方法はポリシーの問題です。 たとえば、<img>タグを生成することになっている場合、src属性(イメージの位置)を表すには、 場合によって、URLを使用することもストリームから読み込むこともあります。
      パラメータ:
      elem - StyleConstants.IconElementName型の要素
      スロー:
      IOException - I/Oエラーが発生した場合。
    • writeComponent

      protected void writeComponent(Element elem) throws IOException
      コンポーネント要素の書出しを行います。意図的に実装しない場合があります。 このメソッドの実装方法はポリシーの問題です。
      パラメータ:
      elem - StyleConstants.ComponentElementName型の要素
      スロー:
      IOException - I/Oエラーが発生した場合。
    • isText

      protected boolean isText(Element elem)
      要素がテキストならtrueを返します。
      パラメータ:
      elem - 要素
      戻り値:
      要素がテキスト要素の場合はtrue
    • writeContent

      protected void writeContent(Element elem, boolean needsIndenting) throws IOException, BadLocationException
      HTMLに準拠した方法で属性セットを書き出します。
      パラメータ:
      elem - 要素
      needsIndenting - needsIndentingtrueの場合、インデントが追加されます
      スロー:
      IOException - 入出力エラーが発生した場合
      BadLocationException - posがドキュメント内の無効な位置を表す場合。
    • writeHTMLTags

      protected void writeHTMLTags(AttributeSet attr) throws IOException
      属性設定に基づいてテキストのボールド<b>、イタリック<i>、および<u>のタグを生成します。
      パラメータ:
      attr - 属性のセット
      スロー:
      IOException - 入出力エラーが発生した場合
    • writeNonHTMLAttributes

      protected void writeNonHTMLAttributes(AttributeSet attr) throws IOException
      HTMLに準拠した方法で残りの文字レベルの属性(ボールド、イタリック、下線以外の属性)を書き出します。 フォント・ファミリやフォント・サイズなどの属性が直接HTMLタグにマッピングされない場合、インライン・スタイルの場合と同様に<span>タグが生成されて、そのスタイル属性が残りの属性のリストを含むように設定されます。
      パラメータ:
      attr - 属性のセット
      スロー:
      IOException - 入出力エラーが発生した場合
    • inFontTag

      protected boolean inFontTag()
      <font>タグ内ならtrueを返します。
      戻り値:
      true(現在<font>タグにある場合)。
    • endFontTag

      protected void endFontTag() throws IOException
      現在使われていません。代わりに<span>が書き出されます。

      <font>タグ用の終了タグを書き出します。

      スロー:
      IOException - 入出力エラーが発生した場合
    • startFontTag

      protected void startFontTag(String style) throws IOException
      現在使われていません。代わりに<span>が書き出されます。

      <font>タグ用の開始タグを書き出します。 フォント・タグは入れ子にできないため、新しい開始タグを書き出す前に、フォント・タグの囲みをクローズします。

      パラメータ:
      style - フォント・スタイル
      スロー:
      IOException - 入出力エラーが発生した場合