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 
18 package org.apache.fop.apps;
19 
20 import java.net.URI;
21 import java.util.Map;
22 import java.util.Set;
23 
24 import org.apache.xmlgraphics.image.loader.ImageManager;
25 import org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext.FallbackResolver;
26 import org.apache.xmlgraphics.io.ResourceResolver;
27 
28 import org.apache.fop.apps.io.InternalResourceResolver;
29 import org.apache.fop.configuration.Configuration;
30 import org.apache.fop.fonts.FontManager;
31 import org.apache.fop.layoutmgr.LayoutManagerMaker;
32 
33 /**
34  * This is a mutable implementation of the {@link FopFactoryConfig} to be used for testing purposes.
35  * This is also an example of how to make the seemingly immutable {@link FopFactory} mutable should
36  * a client need to, though this is ill-advised.
37  */
38 public final class MutableConfig implements FopFactoryConfig {
39 
40     private final FopFactoryConfig delegate;
41 
42     private boolean setBreakInheritance;
43     private float sourceResolution;
44 
MutableConfig(FopFactoryBuilder factoryBuilder)45     public MutableConfig(FopFactoryBuilder factoryBuilder) {
46         delegate = factoryBuilder.buildConfiguration();
47         setBreakInheritance = delegate.isBreakIndentInheritanceOnReferenceAreaBoundary();
48         sourceResolution = delegate.getSourceResolution();
49     }
50 
isAccessibilityEnabled()51     public boolean isAccessibilityEnabled() {
52         return delegate.isAccessibilityEnabled();
53     }
54 
55 
isKeepEmptyTags()56     public boolean isKeepEmptyTags() {
57         return delegate.isKeepEmptyTags();
58     }
59 
getLayoutManagerMakerOverride()60     public LayoutManagerMaker getLayoutManagerMakerOverride() {
61         return delegate.getLayoutManagerMakerOverride();
62     }
63 
getResourceResolver()64     public ResourceResolver getResourceResolver() {
65         return delegate.getResourceResolver();
66     }
67 
getBaseURI()68     public URI getBaseURI() {
69         return delegate.getBaseURI();
70     }
71 
validateStrictly()72     public boolean validateStrictly() {
73         return delegate.validateStrictly();
74     }
75 
validateUserConfigStrictly()76     public boolean validateUserConfigStrictly() {
77         return delegate.validateUserConfigStrictly();
78     }
79 
isBreakIndentInheritanceOnReferenceAreaBoundary()80     public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
81         return setBreakInheritance;
82     }
83 
setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value)84     public void setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value) {
85         setBreakInheritance = value;
86     }
87 
getSourceResolution()88     public float getSourceResolution() {
89         return sourceResolution;
90     }
91 
setSourceResolution(float srcRes)92     public void setSourceResolution(float srcRes) {
93         sourceResolution = srcRes;
94     }
95 
getTargetResolution()96     public float getTargetResolution() {
97         return delegate.getTargetResolution();
98     }
99 
getPageHeight()100     public String getPageHeight() {
101         return delegate.getPageHeight();
102     }
103 
getPageWidth()104     public String getPageWidth() {
105         return delegate.getPageWidth();
106     }
107 
getIgnoredNamespaces()108     public Set<String> getIgnoredNamespaces() {
109         return delegate.getIgnoredNamespaces();
110     }
111 
isNamespaceIgnored(String namespace)112     public boolean isNamespaceIgnored(String namespace) {
113         return delegate.isNamespaceIgnored(namespace);
114     }
115 
getUserConfig()116     public Configuration getUserConfig() {
117         return delegate.getUserConfig();
118     }
119 
preferRenderer()120     public boolean preferRenderer() {
121         return delegate.preferRenderer();
122     }
123 
getFontManager()124     public FontManager getFontManager() {
125         return delegate.getFontManager();
126     }
127 
getImageManager()128     public ImageManager getImageManager() {
129         return delegate.getImageManager();
130     }
131 
isComplexScriptFeaturesEnabled()132     public boolean isComplexScriptFeaturesEnabled() {
133         return delegate.isComplexScriptFeaturesEnabled();
134     }
135 
isTableBorderOverpaint()136     public boolean isTableBorderOverpaint() {
137         return delegate.isTableBorderOverpaint();
138     }
139 
getHyphenationPatternNames()140     public Map<String, String> getHyphenationPatternNames() {
141         return delegate.getHyphenationPatternNames();
142     }
143 
getHyphenationResourceResolver()144     public InternalResourceResolver getHyphenationResourceResolver() {
145         return delegate.getHyphenationResourceResolver();
146     }
147 
getFallbackResolver()148     public FallbackResolver getFallbackResolver() {
149         return delegate.getFallbackResolver();
150     }
151 }
152