linkprimitive.java

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

JAVA
67
字号
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.ContentElements;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import java.util.*;/** * The LinkPrimitive class encapsulates the details of building * an a href tag for a simple link. It limits the content to text * and images. * */public class LinkPrimitive implements IHtmlPrimitive{  private String url;  private Style style;  private List producers = new ArrayList();  /** Construct a LinkPrimitive instance with the specified URL. */  public LinkPrimitive(String url)  {    this.url = url;  }  /** Set the style for this link. */  public void setStyle(Style style)  {    this.style = style;  }  /** Add a TextPrimitive object to this link. */  public void addText(TextPrimitive content)  {    producers.add(content);  }  /** Add some text to this link. */  public void addText(String content)  {    producers.add(new TextPrimitive(content));  }  /** Add an ImagePrimitive object to this link. */  public void addImage(ImagePrimitive content)  {    producers.add(content);  }  /** Build the content for this primitive and append it to   *  the specified buffer.*/  public void buildContent(StringBuffer buffer)  {    String href_string = Formatting.convertToAttribute("href", url);    String style_string = Formatting.convertToAttribute("class", this.style);    buffer.append("<a" +style_string+href_string+ ">");    Iterator producers_iterator = producers.iterator();    while (producers_iterator.hasNext())    {      IHtmlPrimitive content = (IHtmlPrimitive) producers_iterator.next();      content.buildContent(buffer);    }    buffer.append("</a>");  }}

⌨️ 快捷键说明

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