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.

EmbeddedData.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.ss.extractor;
  16. import org.apache.poi.ss.usermodel.Shape;
  17. /**
  18. * A collection of embedded object informations and content
  19. */
  20. public class EmbeddedData {
  21. private String filename;
  22. private byte[] embeddedData;
  23. private Shape shape;
  24. private String contentType = "binary/octet-stream";
  25. public EmbeddedData(String filename, byte[] embeddedData, String contentType) {
  26. setFilename(filename);
  27. setEmbeddedData(embeddedData);
  28. setContentType(contentType);
  29. }
  30. /**
  31. * @return the filename
  32. */
  33. public String getFilename() {
  34. return filename;
  35. }
  36. /**
  37. * Sets the filename
  38. *
  39. * @param filename the filename
  40. */
  41. public void setFilename(String filename) {
  42. if (filename == null) {
  43. this.filename = "unknown.bin";
  44. } else {
  45. this.filename = filename.replaceAll("[^/\\\\]*[/\\\\]", "").trim();
  46. }
  47. }
  48. /**
  49. * @return the embedded object byte array
  50. */
  51. public byte[] getEmbeddedData() {
  52. return embeddedData;
  53. }
  54. /**
  55. * Sets the embedded object as byte array
  56. *
  57. * @param embeddedData the embedded object byte array
  58. */
  59. public void setEmbeddedData(byte[] embeddedData) {
  60. this.embeddedData = (embeddedData == null) ? null : embeddedData.clone();
  61. }
  62. /**
  63. * @return the shape which links to the embedded object
  64. */
  65. public Shape getShape() {
  66. return shape;
  67. }
  68. /**
  69. * Sets the shape which links to the embedded object
  70. *
  71. * @param shape the shape
  72. */
  73. public void setShape(Shape shape) {
  74. this.shape = shape;
  75. }
  76. /**
  77. * @return the content-/mime-type of the embedded object, the default (if unknown) is {@code binary/octet-stream}
  78. */
  79. public String getContentType() {
  80. return contentType;
  81. }
  82. /**
  83. * Sets the content-/mime-type
  84. *
  85. * @param contentType the content-type
  86. */
  87. public void setContentType(String contentType) {
  88. this.contentType = contentType;
  89. }
  90. }