001package com.hfg.html; 002 003 004import com.hfg.xml.XMLNode; 005 006//------------------------------------------------------------------------------ 007/** 008 Represents an object (<object>) tag. 009 <div> 010 @author J. Alex Taylor, hairyfatguy.com 011 </div> 012 */ 013//------------------------------------------------------------------------------ 014// com.hfg XML/HTML Coding Library 015// 016// This library is free software; you can redistribute it and/or 017// modify it under the terms of the GNU Lesser General Public 018// License as published by the Free Software Foundation; either 019// version 2.1 of the License, or (at your option) any later version. 020// 021// This library is distributed in the hope that it will be useful, 022// but WITHOUT ANY WARRANTY; without even the implied warranty of 023// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 024// Lesser General Public License for more details. 025// 026// You should have received a copy of the GNU Lesser General Public 027// License along with this library; if not, write to the Free Software 028// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 029// 030// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 031// jataylor@hairyfatguy.com 032//------------------------------------------------------------------------------ 033 034/* 035From http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict 036 037<!--==================== Object ======================================--> 038<!-- 039 object is used to embed objects as part of HTML pages. 040 param elements should precede other content. Parameters 041 can also be expressed as attribute/value pairs on the 042 object element itself when brevity is desired. 043--> 044 045<!ELEMENT object (#PCDATA | param | %block; | form | %inline; | %misc;)*> 046<!ATTLIST object 047 %attrs; 048 declare (declare) #IMPLIED 049 classid %URI; #IMPLIED 050 codebase %URI; #IMPLIED 051 data %URI; #IMPLIED 052 type %ContentType; #IMPLIED 053 codetype %ContentType; #IMPLIED 054 archive %UriList; #IMPLIED 055 standby %Text; #IMPLIED 056 height %Length; #IMPLIED 057 width %Length; #IMPLIED 058 usemap %URI; #IMPLIED 059 name NMTOKEN #IMPLIED 060 tabindex %Number; #IMPLIED 061 > 062*/ 063public class ObjectTag extends HTMLTag 064{ 065 066 //########################################################################## 067 // CONSTRUCTORS 068 //########################################################################## 069 070 //-------------------------------------------------------------------------- 071 public ObjectTag() 072 { 073 super(HTML.OBJECT); 074 075 // This defeats isEmptyTag() so that the object will always be printed 076 // as a tag pair. Some browsers (at least IE, Mozilla and Safari) have trouble 077 // with an empty object tag. 078 setContent(""); 079 } 080 081 //-------------------------------------------------------------------------- 082 public ObjectTag(XMLNode inXMLNode) 083 { 084 this(); 085 initFromXMLNode(inXMLNode); 086 } 087 088 089 //########################################################################## 090 // PUBLIC METHODS 091 //########################################################################## 092 093 094 //-------------------------------------------------------------------------- 095 /** 096 This attribute may be used to specify a space-separated list of URIs for 097 archives containing resources relevant to the object, which may include the 098 resources specified by the <code>classid</code> and <code>data</code> attributes. 099 Preloading archives will generally result in reduced load times for objects. 100 Archives specified as relative URIs should be interpreted relative to the 101 <code>codebase</code> attribute. 102 @param inValue the value to use for the 'archive' attribute 103 @return this ObjectTag object to enable method chaining 104 */ 105 public ObjectTag setArchive(String inValue) 106 { 107 setAttribute(HTML.ARCHIVE, inValue); 108 return this; 109 } 110 111 112 //-------------------------------------------------------------------------- 113 public ObjectTag setClass(String inValue) 114 { 115 setAttribute(HTML.CLASS, inValue); 116 return this; 117 } 118 119 120 //-------------------------------------------------------------------------- 121 public ObjectTag setClassId(String inValue) 122 { 123 setAttribute(HTML.CLASSID, inValue); 124 return this; 125 } 126 127 //-------------------------------------------------------------------------- 128 public ObjectTag setCodebase(String inValue) 129 { 130 setAttribute(HTML.CODEBASE, inValue); 131 return this; 132 } 133 134 //-------------------------------------------------------------------------- 135 /** 136 This attribute specifies the content type of data expected when downloading 137 the object specified by <code>classid</code>. This attribute is optional but 138 recommended when <code>classid</code> is specified since it allows the user 139 agent to avoid loading information for unsupported content types. When absent, 140 it defaults to the value of the <code>type</code> attribute. 141 @param inValue the value to use for the 'codetype' attribute 142 @return this ObjectTag object to enable method chaining 143 */ 144 public ObjectTag setCodetype(String inValue) 145 { 146 setAttribute(HTML.CODETYPE, inValue); 147 return this; 148 } 149 150 //-------------------------------------------------------------------------- 151 public ObjectTag setData(String inValue) 152 { 153 setAttribute(HTML.DATA, inValue); 154 return this; 155 } 156 157 //-------------------------------------------------------------------------- 158 /** 159 When present, this boolean attribute makes the current OBJECT definition a 160 declaration only. The object must be instantiated by a subsequent OBJECT 161 definition referring to this declaration. 162 @return this ObjectTag object to enable method chaining 163 */ 164 public ObjectTag setDeclare() 165 { 166 setAttribute(HTML.DECLARE, 1); 167 return this; 168 } 169 170 //-------------------------------------------------------------------------- 171 /** 172 This attribute specifies a message that a user agent may render while loading 173 the object's implementation and data. 174 @param inValue the value to use for the 'standby' attribute 175 @return this ObjectTag object to enable method chaining 176 */ 177 public ObjectTag setStandby(String inValue) 178 { 179 setAttribute(HTML.STANDBY, inValue); 180 return this; 181 } 182 183 //-------------------------------------------------------------------------- 184 public ObjectTag setTabIndex(int inValue) 185 { 186 setAttribute(HTML.TABINDEX, inValue); 187 return this; 188 } 189 190 191 //-------------------------------------------------------------------------- 192 /** 193 This attribute specifies the content type for the data specified by data. 194 It is optional but recommended when data is specified since it 195 allows the user agent to avoid loading information for unsupported content 196 types. If the value of this attribute differs from the HTTP Content-Type 197 returned by the server when the object is retrieved, the HTTP Content-Type 198 takes precedence. 199 @param inValue the value to use for the 'type' attribute 200 @return this ObjectTag object to enable method chaining 201 */ 202 public ObjectTag setType(String inValue) 203 { 204 setAttribute(HTML.TYPE, inValue); 205 return this; 206 } 207 208 //-------------------------------------------------------------------------- 209 public ObjectTag setUseMap(String inValue) 210 { 211 setAttribute(HTML.USEMAP, inValue); 212 return this; 213 } 214 215 216 //-------------------------------------------------------------------------- 217 public ObjectTag setWidth(String inValue) 218 { 219 setAttribute(HTML.WIDTH, inValue); 220 return this; 221 } 222 223 //-------------------------------------------------------------------------- 224 public ObjectTag setWidth(int inValue) 225 { 226 setAttribute(HTML.WIDTH, new Integer(inValue).toString()); 227 return this; 228 } 229 230 //-------------------------------------------------------------------------- 231 public String getWidth() 232 { 233 return getAttributeValue(HTML.WIDTH); 234 } 235 236 //-------------------------------------------------------------------------- 237 public ObjectTag setHeight(String inValue) 238 { 239 setAttribute(HTML.HEIGHT, inValue); 240 return this; 241 } 242 243 //-------------------------------------------------------------------------- 244 public ObjectTag setHeight(int inValue) 245 { 246 setAttribute(HTML.HEIGHT, new Integer(inValue).toString()); 247 return this; 248 } 249 250 //-------------------------------------------------------------------------- 251 public String getHeight() 252 { 253 return getAttributeValue(HTML.HEIGHT); 254 } 255 256 257 //-------------------------------------------------------------------------- 258 /** 259 @deprecated 260 @param inValue the value to use for the 'border' attribute 261 @return this ObjectTag object to enable method chaining 262 */ 263 public ObjectTag setBorder(int inValue) 264 { 265 setAttribute(HTML.BORDER, new Integer(inValue).toString()); 266 return this; 267 } 268 269}