You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PaintTarget.java 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal;
  5. import java.io.Serializable;
  6. import java.util.Map;
  7. /**
  8. * This interface defines the methods for painting XML to the UIDL stream.
  9. *
  10. * @author IT Mill Ltd.
  11. * @version
  12. * @VERSION@
  13. * @since 3.0
  14. */
  15. public interface PaintTarget extends Serializable {
  16. /**
  17. * Prints single XMLsection.
  18. *
  19. * Prints full XML section. The section data is escaped from XML tags and
  20. * surrounded by XML start and end-tags.
  21. *
  22. * @param sectionTagName
  23. * the name of the tag.
  24. * @param sectionData
  25. * the scetion data.
  26. * @throws PaintException
  27. * if the paint operation failed.
  28. */
  29. public void addSection(String sectionTagName, String sectionData)
  30. throws PaintException;
  31. /**
  32. * Prints element start tag of a paintable section. Starts a paintable
  33. * section using the given tag. The PaintTarget may implement a caching
  34. * scheme, that checks the paintable has actually changed or can a cached
  35. * version be used instead. This method should call the startTag method.
  36. * <p>
  37. * If the Paintable is found in cache and this function returns true it may
  38. * omit the content and close the tag, in which case cached content should
  39. * be used.
  40. * </p>
  41. *
  42. * @param paintable
  43. * the paintable to start.
  44. * @param tag
  45. * the name of the start tag.
  46. * @return <code>true</code> if paintable found in cache, <code>false</code>
  47. * otherwise.
  48. * @throws PaintException
  49. * if the paint operation failed.
  50. * @see #startTag(String)
  51. * @since 3.1
  52. */
  53. public boolean startTag(Paintable paintable, String tag)
  54. throws PaintException;
  55. /**
  56. * Paints a component reference as an attribute to current tag. This method
  57. * is meant to enable component interactions on client side. With reference
  58. * the client side component can communicate directly to other component.
  59. *
  60. * Note! This is still an experimental feature and API is likely to change
  61. * in future.
  62. *
  63. * @param paintable
  64. * the Paintable to reference
  65. * @param referenceName
  66. * @throws PaintException
  67. *
  68. * @since 5.2
  69. */
  70. public void paintReference(Paintable paintable, String referenceName)
  71. throws PaintException;
  72. /**
  73. * Prints element start tag.
  74. *
  75. * <pre>
  76. * Todo:
  77. * Checking of input values
  78. * </pre>
  79. *
  80. * @param tagName
  81. * the name of the start tag.
  82. * @throws PaintException
  83. * if the paint operation failed.
  84. */
  85. public void startTag(String tagName) throws PaintException;
  86. /**
  87. * Prints element end tag.
  88. *
  89. * If the parent tag is closed before every child tag is closed an
  90. * PaintException is raised.
  91. *
  92. * @param tagName
  93. * the name of the end tag.
  94. * @throws PaintException
  95. * if the paint operation failed.
  96. */
  97. public void endTag(String tagName) throws PaintException;
  98. /**
  99. * Adds a boolean attribute to component. Atributes must be added before any
  100. * content is written.
  101. *
  102. * @param name
  103. * the Attribute name.
  104. * @param value
  105. * the Attribute value.
  106. *
  107. * @throws PaintException
  108. * if the paint operation failed.
  109. */
  110. public void addAttribute(String name, boolean value) throws PaintException;
  111. /**
  112. * Adds a integer attribute to component. Atributes must be added before any
  113. * content is written.
  114. *
  115. * @param name
  116. * the Attribute name.
  117. * @param value
  118. * the Attribute value.
  119. *
  120. * @throws PaintException
  121. * if the paint operation failed.
  122. */
  123. public void addAttribute(String name, int value) throws PaintException;
  124. /**
  125. * Adds a resource attribute to component. Atributes must be added before
  126. * any content is written.
  127. *
  128. * @param name
  129. * the Attribute name
  130. * @param value
  131. * the Attribute value
  132. *
  133. * @throws PaintException
  134. * if the paint operation failed.
  135. */
  136. public void addAttribute(String name, Resource value) throws PaintException;
  137. /**
  138. * Adds a long attribute to component. Atributes must be added before any
  139. * content is written.
  140. *
  141. * @param name
  142. * the Attribute name.
  143. * @param value
  144. * the Attribute value.
  145. *
  146. * @throws PaintException
  147. * if the paint operation failed.
  148. */
  149. public void addAttribute(String name, long value) throws PaintException;
  150. /**
  151. * Adds a float attribute to component. Atributes must be added before any
  152. * content is written.
  153. *
  154. * @param name
  155. * the Attribute name.
  156. * @param value
  157. * the Attribute value.
  158. *
  159. * @throws PaintException
  160. * if the paint operation failed.
  161. */
  162. public void addAttribute(String name, float value) throws PaintException;
  163. /**
  164. * Adds a double attribute to component. Atributes must be added before any
  165. * content is written.
  166. *
  167. * @param name
  168. * the Attribute name.
  169. * @param value
  170. * the Attribute value.
  171. *
  172. * @throws PaintException
  173. * if the paint operation failed.
  174. */
  175. public void addAttribute(String name, double value) throws PaintException;
  176. /**
  177. * Adds a string attribute to component. Atributes must be added before any
  178. * content is written.
  179. *
  180. * @param name
  181. * the Boolean attribute name.
  182. * @param value
  183. * the Boolean attribute value.
  184. *
  185. * @throws PaintException
  186. * if the paint operation failed.
  187. */
  188. public void addAttribute(String name, String value) throws PaintException;
  189. /**
  190. * TODO
  191. *
  192. * @param name
  193. * @param value
  194. * @throws PaintException
  195. */
  196. public void addAttribute(String name, Map<?, ?> value)
  197. throws PaintException;
  198. /**
  199. * Adds a string type variable.
  200. *
  201. * @param owner
  202. * the Listener for variable changes.
  203. * @param name
  204. * the Variable name.
  205. * @param value
  206. * the Variable initial value.
  207. *
  208. * @throws PaintException
  209. * if the paint operation failed.
  210. */
  211. public void addVariable(VariableOwner owner, String name, String value)
  212. throws PaintException;
  213. /**
  214. * Adds a int type variable.
  215. *
  216. * @param owner
  217. * the Listener for variable changes.
  218. * @param name
  219. * the Variable name.
  220. * @param value
  221. * the Variable initial value.
  222. *
  223. * @throws PaintException
  224. * if the paint operation failed.
  225. */
  226. public void addVariable(VariableOwner owner, String name, int value)
  227. throws PaintException;
  228. /**
  229. * Adds a long type variable.
  230. *
  231. * @param owner
  232. * the Listener for variable changes.
  233. * @param name
  234. * the Variable name.
  235. * @param value
  236. * the Variable initial value.
  237. *
  238. * @throws PaintException
  239. * if the paint operation failed.
  240. */
  241. public void addVariable(VariableOwner owner, String name, long value)
  242. throws PaintException;
  243. /**
  244. * Adds a float type variable.
  245. *
  246. * @param owner
  247. * the Listener for variable changes.
  248. * @param name
  249. * the Variable name.
  250. * @param value
  251. * the Variable initial value.
  252. *
  253. * @throws PaintException
  254. * if the paint operation failed.
  255. */
  256. public void addVariable(VariableOwner owner, String name, float value)
  257. throws PaintException;
  258. /**
  259. * Adds a double type variable.
  260. *
  261. * @param owner
  262. * the Listener for variable changes.
  263. * @param name
  264. * the Variable name.
  265. * @param value
  266. * the Variable initial value.
  267. *
  268. * @throws PaintException
  269. * if the paint operation failed.
  270. */
  271. public void addVariable(VariableOwner owner, String name, double value)
  272. throws PaintException;
  273. /**
  274. * Adds a boolean type variable.
  275. *
  276. * @param owner
  277. * the Listener for variable changes.
  278. * @param name
  279. * the Variable name.
  280. * @param value
  281. * the Variable initial value.
  282. *
  283. * @throws PaintException
  284. * if the paint operation failed.
  285. */
  286. public void addVariable(VariableOwner owner, String name, boolean value)
  287. throws PaintException;
  288. /**
  289. * Adds a string array type variable.
  290. *
  291. * @param owner
  292. * the Listener for variable changes.
  293. * @param name
  294. * the Variable name.
  295. * @param value
  296. * the Variable initial value.
  297. *
  298. * @throws PaintException
  299. * if the paint operation failed.
  300. */
  301. public void addVariable(VariableOwner owner, String name, String[] value)
  302. throws PaintException;
  303. /**
  304. * Adds a upload stream type variable.
  305. *
  306. * @param owner
  307. * the Listener for variable changes.
  308. * @param name
  309. * the Variable name.
  310. *
  311. * @throws PaintException
  312. * if the paint operation failed.
  313. */
  314. public void addUploadStreamVariable(VariableOwner owner, String name)
  315. throws PaintException;
  316. /**
  317. * Prints single XML section.
  318. * <p>
  319. * Prints full XML section. The section data must be XML and it is
  320. * surrounded by XML start and end-tags.
  321. * </p>
  322. *
  323. * @param sectionTagName
  324. * the tag name.
  325. * @param sectionData
  326. * the section data to be printed.
  327. * @param namespace
  328. * the namespace.
  329. * @throws PaintException
  330. * if the paint operation failed.
  331. */
  332. public void addXMLSection(String sectionTagName, String sectionData,
  333. String namespace) throws PaintException;
  334. /**
  335. * Adds UIDL directly. The UIDL must be valid in accordance with the
  336. * UIDL.dtd
  337. *
  338. * @param uidl
  339. * the UIDL to be added.
  340. * @throws PaintException
  341. * if the paint operation failed.
  342. */
  343. public void addUIDL(java.lang.String uidl) throws PaintException;
  344. /**
  345. * Adds text node. All the contents of the text are XML-escaped.
  346. *
  347. * @param text
  348. * the Text to add
  349. * @throws PaintException
  350. * if the paint operation failed.
  351. */
  352. void addText(String text) throws PaintException;
  353. /**
  354. * Adds CDATA node to target UIDL-tree.
  355. *
  356. * @param text
  357. * the Character data to add
  358. * @throws PaintException
  359. * if the paint operation failed.
  360. * @since 3.1
  361. */
  362. void addCharacterData(String text) throws PaintException;
  363. public void addAttribute(String string, Object[] keys);
  364. /**
  365. * @return the "tag" string used in communication to present given
  366. * {@link Paintable} type. Terminal may define how to present
  367. * paintable.
  368. */
  369. public String getTag(Paintable paintable);
  370. }