KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > publisher > serverimpl > requestmodel > PublisherRequest


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.publisher.serverimpl.requestmodel;
17
18 import org.outerj.daisy.publisher.serverimpl.PublisherImpl;
19 import org.xml.sax.ContentHandler JavaDoc;
20 import org.xml.sax.helpers.AttributesImpl JavaDoc;
21
22 import java.util.Locale JavaDoc;
23
24 public class PublisherRequest extends AbstractParentPublisherRequest implements Request {
25     private final Locale JavaDoc locale;
26     private final String JavaDoc styleHint;
27     private final boolean inlineExceptions;
28     private final PublisherVersionMode versionMode;
29
30     /**
31      *
32      * @param locale allowed to be null
33      * @param styleHint optional, allowed to be null
34      * @param versionMode optional, allowed to be null
35      */

36     public PublisherRequest(Locale JavaDoc locale, String JavaDoc styleHint, boolean inlineExceptions, PublisherVersionMode versionMode) {
37         this.locale = locale;
38         this.styleHint = styleHint;
39         this.inlineExceptions = inlineExceptions;
40         this.versionMode = versionMode;
41     }
42
43     public void process(ContentHandler JavaDoc contentHandler, PublisherContext publisherContext) throws Exception JavaDoc {
44         contentHandler.startDocument();
45         contentHandler.startPrefixMapping("p", PublisherImpl.NAMESPACE);
46         AttributesImpl JavaDoc attrs = new AttributesImpl JavaDoc();
47         if (styleHint != null)
48             attrs.addAttribute("", "styleHint", "styleHint", "CDATA", styleHint);
49         contentHandler.startElement(PublisherImpl.NAMESPACE, "publisherResponse", "p:publisherResponse", attrs);
50
51         PublisherContextImpl childPublisherContext = new PublisherContextImpl(publisherContext);
52         if (locale != null)
53             childPublisherContext.setLocale(locale);
54         if (versionMode != null)
55             childPublisherContext.setVersionMode(versionMode);
56         super.process(contentHandler, childPublisherContext);
57
58         contentHandler.endElement(PublisherImpl.NAMESPACE, "publisherResponse", "p:publisherResponse");
59         contentHandler.endPrefixMapping("p");
60         contentHandler.endDocument();
61     }
62
63     public boolean getInlineExceptions() {
64         return inlineExceptions;
65     }
66 }
67
Popular Tags