📄 pageprimitive.java
字号:
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Layout;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import java.util.*;/** The PagePrimitive class encapsulates the details of * building the HTML for a page. */public class PagePrimitive implements IHtmlPrimitive{ private String title; private String styleSheet; private ArrayList primitives = new ArrayList(); /** Construct an instance of PagePrimitive with the specified title. */ public PagePrimitive(String title, String styleSheet) { this.title = title; this.styleSheet = styleSheet; } /** Add primitives to the body */ public void addToBody(IHtmlPrimitive primitive) { primitives.add(primitive); } /** Build the content for this primitive and append it to * the specified buffer.*/ public void buildContent(StringBuffer buffer) { // add the head buffer.append("<html>\n"); buffer.append("<head>"); buffer.append("<title>" +title+ "</title>"); // add a link to the style sheet if (this.styleSheet != null) { String href_string = Formatting.convertToAttribute("href", styleSheet); buffer.append("<link rel=\"stylesheet\" type=\"text/css\" " +href_string+ "></link>\n"); } buffer.append("</head>\n"); buffer.append("<body>\n"); // ask each primitive to add its HTML to the buffer Iterator primitives_iterator = primitives.iterator(); while (primitives_iterator.hasNext()) { IHtmlPrimitive primitive = (IHtmlPrimitive) primitives_iterator.next(); primitive.buildContent(buffer); buffer.append("\n"); } // close out the body and html elements buffer.append("</body>\n"); buffer.append("</html>"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -