paragraphprimitive.java

来自「考勤管理系统源码」· Java 代码 · 共 81 行

JAVA
81
字号
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.ContentElements;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import java.util.*;/** The ParagraphPrimitive class encapsulates the logic for *  creating a paragraph that encloses text, links, spans, *  and images. */public class ParagraphPrimitive implements IHtmlPrimitive{  private List primitives = new ArrayList();  private Style style;  /** Construct a ParagraphPrimitive with the specified style and text.*/  public ParagraphPrimitive(Style style, String text)  {    this.style = style;    addText(text);  }  /** add the specified text to this ParagraphPrimitive*/  public void addText(String text)  {    primitives.add(new TextPrimitive(text));  }  /** add the specified text with the specified style*/  public void addText(Style style, String text)  {    primitives.add(new SpanPrimitive(style, text));  }  /** Add the specified primitive to this ParagraphPrimitive */  public void addImage(ImagePrimitive primitive)  {    primitives.add(primitive);  }  /** Add the specified primitive to this ParagraphPrimitive */  public void addLink(LinkPrimitive primitive)  {    primitives.add(primitive);  }  /** Add the specified primitive to this ParagraphPrimitive */  public void addSpan(SpanPrimitive primitive)  {    primitives.add(primitive);  }  /** Add the specified primitive to this ParagraphPrimitive */  public void addText(TextPrimitive primitive)  {    primitives.add(primitive);  }  /** Add the a line break to this ParagraphPrimitive */  public void addLineBreak()  {    TextPrimitive text = new TextPrimitive();    text.addLineBreak();    primitives.add(text);  }  /** Build the content for this primitive and append it to   *  the specified buffer.*/  public void buildContent(StringBuffer buffer)  {    String style_string = Formatting.convertToAttribute("class", style);    buffer.append("<p " +style_string+ ">");    Iterator it = primitives.iterator();    while (it.hasNext())    {      IHtmlPrimitive primitive = (IHtmlPrimitive) it.next();      primitive.buildContent(buffer);    }    buffer.append("</p>\n");  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?