Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ThemeResource.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal;
  5. import com.vaadin.service.FileTypeResolver;
  6. /**
  7. * <code>ThemeResource</code> is a named theme dependant resource provided and
  8. * managed by a theme. The actual resource contents are dynamically resolved to
  9. * comply with the used theme by the terminal adapter. This is commonly used to
  10. * provide static images, flash, java-applets, etc for the terminals.
  11. *
  12. * @author Vaadin Ltd.
  13. * @since 3.0
  14. */
  15. @SuppressWarnings("serial")
  16. public class ThemeResource implements Resource {
  17. /**
  18. * Id of the terminal managed resource.
  19. */
  20. private String resourceID = null;
  21. /**
  22. * Creates a resource.
  23. *
  24. * @param resourceId
  25. * the Id of the resource.
  26. */
  27. public ThemeResource(String resourceId) {
  28. if (resourceId == null) {
  29. throw new NullPointerException("Resource ID must not be null");
  30. }
  31. if (resourceId.length() == 0) {
  32. throw new IllegalArgumentException("Resource ID can not be empty");
  33. }
  34. if (resourceId.charAt(0) == '/') {
  35. throw new IllegalArgumentException(
  36. "Resource ID must be relative (can not begin with /)");
  37. }
  38. resourceID = resourceId;
  39. }
  40. /**
  41. * Tests if the given object equals this Resource.
  42. *
  43. * @param obj
  44. * the object to be tested for equality.
  45. * @return <code>true</code> if the given object equals this Icon,
  46. * <code>false</code> if not.
  47. * @see java.lang.Object#equals(Object)
  48. */
  49. @Override
  50. public boolean equals(Object obj) {
  51. return obj instanceof ThemeResource
  52. && resourceID.equals(((ThemeResource) obj).resourceID);
  53. }
  54. /**
  55. * @see java.lang.Object#hashCode()
  56. */
  57. @Override
  58. public int hashCode() {
  59. return resourceID.hashCode();
  60. }
  61. /**
  62. * @see java.lang.Object#toString()
  63. */
  64. @Override
  65. public String toString() {
  66. return resourceID.toString();
  67. }
  68. /**
  69. * Gets the resource id.
  70. *
  71. * @return the resource id.
  72. */
  73. public String getResourceId() {
  74. return resourceID;
  75. }
  76. /**
  77. * @see com.vaadin.terminal.Resource#getMIMEType()
  78. */
  79. @Override
  80. public String getMIMEType() {
  81. return FileTypeResolver.getMIMEType(getResourceId());
  82. }
  83. }