Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

RendererContext.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 1999-2005 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of 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,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.render;
  18. //Java
  19. import java.util.Map;
  20. //FOP
  21. import org.apache.fop.apps.FOUserAgent;
  22. /**
  23. * The Render Context for external handlers. This provides a rendering context
  24. * so that external handlers can get information to be able to render to the
  25. * render target.
  26. */
  27. public class RendererContext {
  28. private String mime;
  29. private AbstractRenderer renderer;
  30. private FOUserAgent userAgent;
  31. private Map props = new java.util.HashMap();
  32. /**
  33. * Contructor for this class. It takes a MIME type as parameter.
  34. *
  35. * @param renderer The current renderer
  36. * @param m The MIME type of the output that's generated.
  37. */
  38. public RendererContext(AbstractRenderer renderer, String m) {
  39. this.renderer = renderer;
  40. this.mime = m;
  41. }
  42. /**
  43. * @return Returns the renderer.
  44. */
  45. public AbstractRenderer getRenderer() {
  46. return renderer;
  47. }
  48. /**
  49. * Returns the MIME type associated with this RendererContext.
  50. *
  51. * @return The MIME type (ex. application/pdf)
  52. */
  53. public String getMimeType() {
  54. return mime;
  55. }
  56. /**
  57. * Sets the user agent.
  58. *
  59. * @param ua The user agent
  60. */
  61. public void setUserAgent(FOUserAgent ua) {
  62. userAgent = ua;
  63. }
  64. /**
  65. * Returns the user agent.
  66. *
  67. * @return The user agent
  68. */
  69. public FOUserAgent getUserAgent() {
  70. return userAgent;
  71. }
  72. /**
  73. * Sets a property on the RendererContext.
  74. *
  75. * @param name The key of the property
  76. * @param val The value of the property
  77. */
  78. public void setProperty(String name, Object val) {
  79. props.put(name, val);
  80. }
  81. /**
  82. * Returns a property from the RendererContext.
  83. *
  84. * @param prop The key of the property to return.
  85. * @return The requested value, <code>null</code> if it doesn't exist.
  86. */
  87. public Object getProperty(String prop) {
  88. return props.get(prop);
  89. }
  90. }