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ů.

Html5File.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.ui;
  17. import java.io.Serializable;
  18. import com.vaadin.event.dd.DropHandler;
  19. import com.vaadin.server.StreamVariable;
  20. /**
  21. * {@link DragAndDropWrapper} can receive also files from client computer if
  22. * appropriate HTML 5 features are supported on client side. This class wraps
  23. * information about dragged file on server side.
  24. */
  25. public class Html5File implements Serializable {
  26. private final String name;
  27. private final long size;
  28. private StreamVariable streamVariable;
  29. private final String type;
  30. /**
  31. * Constructs a new Html5 file wrapper.
  32. *
  33. * @param name
  34. * the file name
  35. * @param size
  36. * the size of the file
  37. * @param mimeType
  38. * the type of the file
  39. */
  40. public Html5File(String name, long size, String mimeType) {
  41. this.name = name;
  42. this.size = size;
  43. type = mimeType;
  44. }
  45. public String getFileName() {
  46. return name;
  47. }
  48. public long getFileSize() {
  49. return size;
  50. }
  51. public String getType() {
  52. return type;
  53. }
  54. /**
  55. * Sets the {@link StreamVariable} that into which the file contents will be
  56. * written. Usage of StreamVariable is similar to {@link Upload} component.
  57. * <p>
  58. * If the {@link StreamVariable} is not set in the {@link DropHandler} the
  59. * file contents will not be sent to server.
  60. * <p>
  61. * <em>Note!</em> receiving file contents is experimental feature depending
  62. * on HTML 5 API's. It is supported only by modern web browsers like Firefox
  63. * 3.6 and above and recent webkit based browsers (Safari 5, Chrome 6) at
  64. * this time.
  65. *
  66. * @param streamVariable
  67. * the callback that returns stream where the implementation
  68. * writes the file contents as it arrives.
  69. */
  70. public void setStreamVariable(StreamVariable streamVariable) {
  71. this.streamVariable = streamVariable;
  72. }
  73. public StreamVariable getStreamVariable() {
  74. return streamVariable;
  75. }
  76. }