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.

RendererContext.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright 1999-2004 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 FOUserAgent userAgent;
  30. private Map props = new java.util.HashMap();
  31. /**
  32. * Contructor for this class. It takes a MIME type as parameter.
  33. *
  34. * @param m The MIME type of the output that's generated.
  35. */
  36. public RendererContext(String m) {
  37. mime = m;
  38. }
  39. /**
  40. * Returns the MIME type associated with this RendererContext.
  41. *
  42. * @return The MIME type (ex. application/pdf)
  43. */
  44. public String getMimeType() {
  45. return mime;
  46. }
  47. /**
  48. * Sets the user agent.
  49. *
  50. * @param ua The user agent
  51. */
  52. public void setUserAgent(FOUserAgent ua) {
  53. userAgent = ua;
  54. }
  55. /**
  56. * Returns the user agent.
  57. *
  58. * @return The user agent
  59. */
  60. public FOUserAgent getUserAgent() {
  61. return userAgent;
  62. }
  63. /**
  64. * Sets a property on the RendererContext.
  65. *
  66. * @param name The key of the property
  67. * @param val The value of the property
  68. */
  69. public void setProperty(String name, Object val) {
  70. props.put(name, val);
  71. }
  72. /**
  73. * Returns a property from the RendererContext.
  74. *
  75. * @param prop The key of the property to return.
  76. * @return The requested value, <code>null</code> if it doesn't exist.
  77. */
  78. public Object getProperty(String prop) {
  79. return props.get(prop);
  80. }
  81. }