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 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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 was experimental api and got replaced by
  61. * {@link #addAttribute(String, Paintable)} and
  62. * {@link #addVariable(VariableOwner, String, Paintable)}.
  63. *
  64. * @param paintable
  65. * the Paintable to reference
  66. * @param referenceName
  67. * @throws PaintException
  68. *
  69. * @since 5.2
  70. * @deprecated use {@link #addAttribute(String, Paintable)} or
  71. * {@link #addVariable(VariableOwner, String, Paintable)}
  72. * instead
  73. */
  74. @Deprecated
  75. public void paintReference(Paintable paintable, String referenceName)
  76. throws PaintException;
  77. /**
  78. * Prints element start tag.
  79. *
  80. * <pre>
  81. * Todo:
  82. * Checking of input values
  83. * </pre>
  84. *
  85. * @param tagName
  86. * the name of the start tag.
  87. * @throws PaintException
  88. * if the paint operation failed.
  89. */
  90. public void startTag(String tagName) throws PaintException;
  91. /**
  92. * Prints element end tag.
  93. *
  94. * If the parent tag is closed before every child tag is closed an
  95. * PaintException is raised.
  96. *
  97. * @param tagName
  98. * the name of the end tag.
  99. * @throws PaintException
  100. * if the paint operation failed.
  101. */
  102. public void endTag(String tagName) throws PaintException;
  103. /**
  104. * Adds a boolean attribute to component. Atributes must be added before any
  105. * content is written.
  106. *
  107. * @param name
  108. * the Attribute name.
  109. * @param value
  110. * the Attribute value.
  111. *
  112. * @throws PaintException
  113. * if the paint operation failed.
  114. */
  115. public void addAttribute(String name, boolean value) throws PaintException;
  116. /**
  117. * Adds a integer attribute to component. Atributes must be added before any
  118. * content is written.
  119. *
  120. * @param name
  121. * the Attribute name.
  122. * @param value
  123. * the Attribute value.
  124. *
  125. * @throws PaintException
  126. * if the paint operation failed.
  127. */
  128. public void addAttribute(String name, int value) throws PaintException;
  129. /**
  130. * Adds a resource attribute to component. Atributes must be added before
  131. * any content is written.
  132. *
  133. * @param name
  134. * the Attribute name
  135. * @param value
  136. * the Attribute value
  137. *
  138. * @throws PaintException
  139. * if the paint operation failed.
  140. */
  141. public void addAttribute(String name, Resource value) throws PaintException;
  142. /**
  143. * Adds a long attribute to component. Atributes must be added before any
  144. * content is written.
  145. *
  146. * @param name
  147. * the Attribute name.
  148. * @param value
  149. * the Attribute value.
  150. *
  151. * @throws PaintException
  152. * if the paint operation failed.
  153. */
  154. public void addAttribute(String name, long value) throws PaintException;
  155. /**
  156. * Adds a float attribute to component. Atributes must be added before any
  157. * content is written.
  158. *
  159. * @param name
  160. * the Attribute name.
  161. * @param value
  162. * the Attribute value.
  163. *
  164. * @throws PaintException
  165. * if the paint operation failed.
  166. */
  167. public void addAttribute(String name, float value) throws PaintException;
  168. /**
  169. * Adds a double attribute to component. Atributes must be added before any
  170. * content is written.
  171. *
  172. * @param name
  173. * the Attribute name.
  174. * @param value
  175. * the Attribute value.
  176. *
  177. * @throws PaintException
  178. * if the paint operation failed.
  179. */
  180. public void addAttribute(String name, double value) throws PaintException;
  181. /**
  182. * Adds a string attribute to component. Atributes must be added before any
  183. * content is written.
  184. *
  185. * @param name
  186. * the Boolean attribute name.
  187. * @param value
  188. * the Boolean attribute value.
  189. *
  190. * @throws PaintException
  191. * if the paint operation failed.
  192. */
  193. public void addAttribute(String name, String value) throws PaintException;
  194. /**
  195. * TODO
  196. *
  197. * @param name
  198. * @param value
  199. * @throws PaintException
  200. */
  201. public void addAttribute(String name, Map<?, ?> value)
  202. throws PaintException;
  203. /**
  204. * Adds a Paintable type attribute. On client side the value will be a
  205. * terminal specific reference to corresponding component on client side
  206. * implementation.
  207. *
  208. * @param name
  209. * the name of the attribute
  210. * @param value
  211. * the Paintable to be referenced on client side
  212. * @throws PaintException
  213. */
  214. public void addAttribute(String name, Paintable value)
  215. throws PaintException;
  216. /**
  217. * Adds a string type variable.
  218. *
  219. * @param owner
  220. * the Listener for variable changes.
  221. * @param name
  222. * the Variable name.
  223. * @param value
  224. * the Variable initial value.
  225. *
  226. * @throws PaintException
  227. * if the paint operation failed.
  228. */
  229. public void addVariable(VariableOwner owner, String name, String value)
  230. throws PaintException;
  231. /**
  232. * Adds a int type variable.
  233. *
  234. * @param owner
  235. * the Listener for variable changes.
  236. * @param name
  237. * the Variable name.
  238. * @param value
  239. * the Variable initial value.
  240. *
  241. * @throws PaintException
  242. * if the paint operation failed.
  243. */
  244. public void addVariable(VariableOwner owner, String name, int value)
  245. throws PaintException;
  246. /**
  247. * Adds a long type variable.
  248. *
  249. * @param owner
  250. * the Listener for variable changes.
  251. * @param name
  252. * the Variable name.
  253. * @param value
  254. * the Variable initial value.
  255. *
  256. * @throws PaintException
  257. * if the paint operation failed.
  258. */
  259. public void addVariable(VariableOwner owner, String name, long value)
  260. throws PaintException;
  261. /**
  262. * Adds a float type variable.
  263. *
  264. * @param owner
  265. * the Listener for variable changes.
  266. * @param name
  267. * the Variable name.
  268. * @param value
  269. * the Variable initial value.
  270. *
  271. * @throws PaintException
  272. * if the paint operation failed.
  273. */
  274. public void addVariable(VariableOwner owner, String name, float value)
  275. throws PaintException;
  276. /**
  277. * Adds a double type variable.
  278. *
  279. * @param owner
  280. * the Listener for variable changes.
  281. * @param name
  282. * the Variable name.
  283. * @param value
  284. * the Variable initial value.
  285. *
  286. * @throws PaintException
  287. * if the paint operation failed.
  288. */
  289. public void addVariable(VariableOwner owner, String name, double value)
  290. throws PaintException;
  291. /**
  292. * Adds a boolean type variable.
  293. *
  294. * @param owner
  295. * the Listener for variable changes.
  296. * @param name
  297. * the Variable name.
  298. * @param value
  299. * the Variable initial value.
  300. *
  301. * @throws PaintException
  302. * if the paint operation failed.
  303. */
  304. public void addVariable(VariableOwner owner, String name, boolean value)
  305. throws PaintException;
  306. /**
  307. * Adds a string array type variable.
  308. *
  309. * @param owner
  310. * the Listener for variable changes.
  311. * @param name
  312. * the Variable name.
  313. * @param value
  314. * the Variable initial value.
  315. *
  316. * @throws PaintException
  317. * if the paint operation failed.
  318. */
  319. public void addVariable(VariableOwner owner, String name, String[] value)
  320. throws PaintException;
  321. /**
  322. * Adds a Paintable type variable. On client side the variable value will be
  323. * a terminal specific reference to corresponding component on client side
  324. * implementation. When updated from client side, terminal will map the
  325. * client side component reference back to a corresponding server side
  326. * reference.
  327. *
  328. * @param owner
  329. * the Listener for variable changes
  330. * @param name
  331. * the name of the variable
  332. * @param value
  333. * the initial value of the variable
  334. *
  335. * @throws PaintException
  336. * if the paint oparation fails
  337. */
  338. public void addVariable(VariableOwner owner, String name, Paintable value)
  339. throws PaintException;
  340. /**
  341. * Adds a upload stream type variable.
  342. *
  343. * @param owner
  344. * the Listener for variable changes.
  345. * @param name
  346. * the Variable name.
  347. *
  348. * @throws PaintException
  349. * if the paint operation failed.
  350. */
  351. public void addUploadStreamVariable(VariableOwner owner, String name)
  352. throws PaintException;
  353. /**
  354. * Prints single XML section.
  355. * <p>
  356. * Prints full XML section. The section data must be XML and it is
  357. * surrounded by XML start and end-tags.
  358. * </p>
  359. *
  360. * @param sectionTagName
  361. * the tag name.
  362. * @param sectionData
  363. * the section data to be printed.
  364. * @param namespace
  365. * the namespace.
  366. * @throws PaintException
  367. * if the paint operation failed.
  368. */
  369. public void addXMLSection(String sectionTagName, String sectionData,
  370. String namespace) throws PaintException;
  371. /**
  372. * Adds UIDL directly. The UIDL must be valid in accordance with the
  373. * UIDL.dtd
  374. *
  375. * @param uidl
  376. * the UIDL to be added.
  377. * @throws PaintException
  378. * if the paint operation failed.
  379. */
  380. public void addUIDL(java.lang.String uidl) throws PaintException;
  381. /**
  382. * Adds text node. All the contents of the text are XML-escaped.
  383. *
  384. * @param text
  385. * the Text to add
  386. * @throws PaintException
  387. * if the paint operation failed.
  388. */
  389. void addText(String text) throws PaintException;
  390. /**
  391. * Adds CDATA node to target UIDL-tree.
  392. *
  393. * @param text
  394. * the Character data to add
  395. * @throws PaintException
  396. * if the paint operation failed.
  397. * @since 3.1
  398. */
  399. void addCharacterData(String text) throws PaintException;
  400. public void addAttribute(String string, Object[] keys);
  401. /**
  402. * @return the "tag" string used in communication to present given
  403. * {@link Paintable} type. Terminal may define how to present
  404. * paintable.
  405. */
  406. public String getTag(Paintable paintable);
  407. }