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.

AFPDataObjectInfo.java 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id: $ */
  18. package org.apache.fop.render.afp;
  19. import java.io.InputStream;
  20. import org.apache.commons.logging.Log;
  21. import org.apache.commons.logging.LogFactory;
  22. import org.apache.fop.render.afp.modca.Registry;
  23. /**
  24. * A list of parameters associated with an AFP data objects
  25. */
  26. public class AFPDataObjectInfo {
  27. private static final Log log = LogFactory.getLog("org.apache.fop.afp");
  28. /** the object area info */
  29. private AFPObjectAreaInfo objectAreaInfo;
  30. /** resource info */
  31. private AFPResourceInfo resourceInfo;
  32. /** the data object width */
  33. private int dataWidth;
  34. /** the data object height */
  35. private int dataHeight;
  36. /** the object data in an inputstream */
  37. private InputStream inputStream;
  38. /** the object registry mimetype */
  39. private String mimeType;
  40. /**
  41. * Default constructor
  42. */
  43. public AFPDataObjectInfo() {
  44. }
  45. /**
  46. * Sets the image mime type
  47. *
  48. * @param mimeType the image mime type
  49. */
  50. public void setMimeType(String mimeType) {
  51. this.mimeType = mimeType;
  52. }
  53. /**
  54. * Returns the mime type of this data object
  55. *
  56. * @return the mime type of this data object
  57. */
  58. public String getMimeType() {
  59. return mimeType;
  60. }
  61. /**
  62. * Convenience method to return the object type
  63. *
  64. * @return the object type
  65. */
  66. public Registry.ObjectType getObjectType() {
  67. return Registry.getInstance().getObjectType(getMimeType());
  68. }
  69. /**
  70. * Returns the resource level at which this data object should reside
  71. *
  72. * @return the resource level at which this data object should reside
  73. */
  74. public AFPResourceInfo getResourceInfo() {
  75. if (resourceInfo == null) {
  76. this.resourceInfo = new AFPResourceInfo();
  77. }
  78. return resourceInfo;
  79. }
  80. /**
  81. * Sets the resource level at which this object should reside
  82. *
  83. * @param resourceInfo the resource level at which this data object should reside
  84. */
  85. public void setResourceInfo(AFPResourceInfo resourceInfo) {
  86. this.resourceInfo = resourceInfo;
  87. }
  88. /**
  89. * Sets the object area info
  90. *
  91. * @param objectAreaInfo the object area info
  92. */
  93. public void setObjectAreaInfo(AFPObjectAreaInfo objectAreaInfo) {
  94. this.objectAreaInfo = objectAreaInfo;
  95. }
  96. /**
  97. * Returns the object area info
  98. *
  99. * @return the object area info
  100. */
  101. public AFPObjectAreaInfo getObjectAreaInfo() {
  102. return this.objectAreaInfo;
  103. }
  104. /** {@inheritDoc} */
  105. public String toString() {
  106. return "AFPDataObjectInfo{"
  107. + "mimeType=" + mimeType
  108. + ", dataWidth=" + dataWidth
  109. + ", dataHeight=" + dataHeight
  110. + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
  111. + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "");
  112. }
  113. /**
  114. * Returns the uri of this data object
  115. *
  116. * @return the uri of this data object
  117. */
  118. public String getUri() {
  119. return getResourceInfo().getUri();
  120. }
  121. /**
  122. * Sets the data object uri
  123. *
  124. * @param uri the data object uri
  125. */
  126. public void setUri(String uri) {
  127. getResourceInfo().setUri(uri);
  128. }
  129. /**
  130. * Returns the image data width
  131. *
  132. * @return the image data width
  133. */
  134. public int getDataWidth() {
  135. return dataWidth;
  136. }
  137. /**
  138. * Sets the image data width
  139. *
  140. * @param imageDataWidth the image data width
  141. */
  142. public void setDataWidth(int imageDataWidth) {
  143. this.dataWidth = imageDataWidth;
  144. }
  145. /**
  146. * Returns the image data height
  147. *
  148. * @return the image data height
  149. */
  150. public int getDataHeight() {
  151. return dataHeight;
  152. }
  153. /**
  154. * Sets the image data height
  155. *
  156. * @param imageDataHeight the image data height
  157. */
  158. public void setDataHeight(int imageDataHeight) {
  159. this.dataHeight = imageDataHeight;
  160. }
  161. /**
  162. * Sets the object data inputstream
  163. *
  164. * @param inputStream the object data inputstream
  165. */
  166. public void setInputStream(InputStream inputStream) {
  167. this.inputStream = inputStream;
  168. }
  169. /**
  170. * Returns the object data inputstream
  171. *
  172. * @return the object data inputstream
  173. */
  174. public InputStream getInputStream() {
  175. return this.inputStream;
  176. }
  177. }