KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > transcoder > TranscoderSupport


1 /*
2
3    Copyright 2001 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    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.batik.transcoder;
19
20 import java.util.Map JavaDoc;
21
22 /**
23  * This is a utility class that can be used by transcoders that
24  * support transcoding hints and/or error handler.
25  *
26  * @author <a HREF="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
27  * @version $Id: TranscoderSupport.java,v 1.8 2004/08/18 07:15:41 vhardy Exp $
28  */

29 public class TranscoderSupport {
30
31     static final ErrorHandler defaultErrorHandler = new DefaultErrorHandler();
32
33     /** The transcoding hints. */
34     protected TranscodingHints hints = new TranscodingHints();
35     /** The error handler used to report warnings and errors. */
36     protected ErrorHandler handler = defaultErrorHandler;
37
38     /**
39      * Constructs a new <tt>TranscoderSupport</tt>.
40      */

41     public TranscoderSupport() { }
42
43     /**
44      * Returns a copy of the transcoding hints of this transcoder.
45      */

46     public TranscodingHints getTranscodingHints() {
47         return new TranscodingHints(hints);
48     }
49
50     /**
51      * Sets the value of a single preference for the transcoding process.
52      * @param key the key of the hint to be set
53      * @param value the value indicating preferences for the specified
54      * hint category.
55      */

56     public void addTranscodingHint(TranscodingHints.Key key, Object JavaDoc value) {
57         hints.put(key, value);
58     }
59
60     /**
61      * Removes the value of a single preference for the transcoding process.
62      * @param key the key of the hint to remove
63      */

64     public void removeTranscodingHint(TranscodingHints.Key key) {
65         hints.remove(key);
66     }
67
68     /**
69      * Replaces the values of all preferences for the transcoding algorithms
70      * with the specified hints.
71      * @param hints the rendering hints to be set
72      */

73     public void setTranscodingHints(Map JavaDoc hints) {
74         this.hints.putAll(hints);
75     }
76
77     /**
78      * Sets the values of all preferences for the transcoding algorithms
79      * with the specified hints.
80      * @param hints the rendering hints to be set
81      */

82     public void setTranscodingHints(TranscodingHints hints) {
83         this.hints = hints;
84     }
85
86     /**
87      * Sets the error handler this transcoder may use to report
88      * warnings and errors.
89      * @param handler to ErrorHandler to use
90      */

91     public void setErrorHandler(ErrorHandler handler) {
92         this.handler = handler;
93     }
94
95     /**
96      * Returns the error handler this transcoder uses to report
97      * warnings and errors, or null if any.
98      */

99     public ErrorHandler getErrorHandler() {
100         return handler;
101     }
102 }
103
104
105
Popular Tags