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.1KB

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