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 4.3KB

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