LEFT | RIGHT |
1 // Copyright 2007 Google Inc. All Rights Reserved. | 1 // Copyright 2007 Google Inc. All Rights Reserved. |
2 // Licensed under the Apache License, Version 2.0 (the "License"); | 2 // Licensed under the Apache License, Version 2.0 (the "License"); |
3 // you may not use this file except in compliance with the License. | 3 // you may not use this file except in compliance with the License. |
4 // You may obtain a copy of the License at | 4 // You may obtain a copy of the License at |
5 // | 5 // |
6 // http://www.apache.org/licenses/LICENSE-2.0 | 6 // http://www.apache.org/licenses/LICENSE-2.0 |
7 // | 7 // |
8 // Unless required by applicable law or agreed to in writing, software | 8 // Unless required by applicable law or agreed to in writing, software |
9 // distributed under the License is distributed on an "AS IS" BASIS, | 9 // distributed under the License is distributed on an "AS IS" BASIS, |
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
(...skipping 27 matching lines...) Expand all Loading... |
38 public class GadgetHandler implements ContentHandler { | 38 public class GadgetHandler implements ContentHandler { |
39 private final BuildInfo buildInfo; | 39 private final BuildInfo buildInfo; |
40 private final UriCallback retriever; | 40 private final UriCallback retriever; |
41 | 41 |
42 public GadgetHandler(BuildInfo buildInfo, UriCallback retriever) { | 42 public GadgetHandler(BuildInfo buildInfo, UriCallback retriever) { |
43 this.buildInfo = buildInfo; | 43 this.buildInfo = buildInfo; |
44 this.retriever = retriever; | 44 this.retriever = retriever; |
45 } | 45 } |
46 | 46 |
47 public boolean canHandle( | 47 public boolean canHandle( |
48 URI uri, String contentType, ContentTypeCheck checker) { | 48 URI uri, CajolingService.Transform transform, |
| 49 String contentType, ContentTypeCheck checker) { |
49 return checker.check("application/xml", contentType); | 50 return checker.check("application/xml", contentType); |
50 } | 51 } |
51 | 52 |
52 public Pair<String, String> apply(URI uri, String contentType, String charSet, | 53 public Pair<String, String> apply(URI uri, CajolingService.Transform trans,· |
53 byte[] content, OutputStream response) | 54 String contentType, String charSet, byte[] content, OutputStream response) |
54 throws UnsupportedContentTypeException { | 55 throws UnsupportedContentTypeException { |
55 try { | 56 try { |
56 OutputStreamWriter writer = new OutputStreamWriter(response, "UTF-8"); | 57 OutputStreamWriter writer = new OutputStreamWriter(response, "UTF-8"); |
57 cajoleGadget(uri, new String(content, charSet), writer); | 58 cajoleGadget(uri, new String(content, charSet), writer); |
58 writer.flush(); | 59 writer.flush(); |
59 return new Pair<String, String>("text/javascript", "UTF-8"); | 60 return new Pair<String, String>("text/javascript", "UTF-8"); |
60 } catch (ParseException e) { | 61 } catch (ParseException e) { |
61 e.printStackTrace(); | 62 e.printStackTrace(); |
62 throw new UnsupportedContentTypeException(); | 63 throw new UnsupportedContentTypeException(); |
63 } catch (IllegalArgumentException e) { | 64 } catch (IllegalArgumentException e) { |
64 e.printStackTrace(); | 65 e.printStackTrace(); |
(...skipping 28 matching lines...) Expand all Loading... |
93 throw new RuntimeException("UTF-8 should be supported.", ex); | 94 throw new RuntimeException("UTF-8 should be supported.", ex); |
94 } | 95 } |
95 } | 96 } |
96 }; | 97 }; |
97 | 98 |
98 CharProducer p = CharProducer.Factory.create( | 99 CharProducer p = CharProducer.Factory.create( |
99 new StringReader(cajaInput), new InputSource(inputUri)); | 100 new StringReader(cajaInput), new InputSource(inputUri)); |
100 rewriter.rewrite(inputUri, p, uriCallback, "canvas", output); | 101 rewriter.rewrite(inputUri, p, uriCallback, "canvas", output); |
101 } | 102 } |
102 } | 103 } |
LEFT | RIGHT |