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.

MutableConfig.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. package org.apache.fop.apps;
  18. import java.net.URI;
  19. import java.util.Map;
  20. import java.util.Set;
  21. import org.apache.avalon.framework.configuration.Configuration;
  22. import org.apache.xmlgraphics.image.loader.ImageManager;
  23. import org.apache.fop.apps.io.ResourceResolver;
  24. import org.apache.fop.fonts.FontManager;
  25. import org.apache.fop.layoutmgr.LayoutManagerMaker;
  26. /**
  27. * This is a mutable implementation of the {@link FopFactoryConfig} to be used for testing purposes.
  28. * This is also an example of how to make the seemingly immutable {@link FopFactory} mutable should
  29. * a client need to, though this is ill-advised.
  30. */
  31. public final class MutableConfig implements FopFactoryConfig {
  32. private final FopFactoryConfig delegate;
  33. private boolean setBreakInheritance;
  34. private float sourceResolution;
  35. public MutableConfig(FopFactoryBuilder factoryBuilder) {
  36. delegate = factoryBuilder.buildConfiguration();
  37. setBreakInheritance = delegate.isBreakIndentInheritanceOnReferenceAreaBoundary();
  38. sourceResolution = delegate.getSourceResolution();
  39. }
  40. public boolean isAccessibilityEnabled() {
  41. return delegate.isAccessibilityEnabled();
  42. }
  43. public LayoutManagerMaker getLayoutManagerMakerOverride() {
  44. return delegate.getLayoutManagerMakerOverride();
  45. }
  46. public ResourceResolver getResourceResolver() {
  47. return delegate.getResourceResolver();
  48. }
  49. public URI getBaseURI() {
  50. return delegate.getBaseURI();
  51. }
  52. public boolean validateStrictly() {
  53. return delegate.validateStrictly();
  54. }
  55. public boolean validateUserConfigStrictly() {
  56. return delegate.validateUserConfigStrictly();
  57. }
  58. public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
  59. return setBreakInheritance;
  60. }
  61. public void setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value) {
  62. setBreakInheritance = value;
  63. }
  64. public float getSourceResolution() {
  65. return sourceResolution;
  66. }
  67. public void setSourceResolution(float srcRes) {
  68. sourceResolution = srcRes;
  69. }
  70. public float getTargetResolution() {
  71. return delegate.getTargetResolution();
  72. }
  73. public String getPageHeight() {
  74. return delegate.getPageHeight();
  75. }
  76. public String getPageWidth() {
  77. return delegate.getPageWidth();
  78. }
  79. public Set<String> getIgnoredNamespaces() {
  80. return delegate.getIgnoredNamespaces();
  81. }
  82. public boolean isNamespaceIgnored(String namespace) {
  83. return delegate.isNamespaceIgnored(namespace);
  84. }
  85. public Configuration getUserConfig() {
  86. return delegate.getUserConfig();
  87. }
  88. public boolean preferRenderer() {
  89. return delegate.preferRenderer();
  90. }
  91. public FontManager getFontManager() {
  92. return delegate.getFontManager();
  93. }
  94. public ImageManager getImageManager() {
  95. return delegate.getImageManager();
  96. }
  97. public boolean isComplexScriptFeaturesEnabled() {
  98. return delegate.isComplexScriptFeaturesEnabled();
  99. }
  100. public Map<String, String> getHyphenationPatternNames() {
  101. return delegate.getHyphenationPatternNames();
  102. }
  103. }