src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/FoolProofResolver.java

changeset 0
373ffda63c9a
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.xml.internal.bind.v2.schemagen;
27
28 import java.io.IOException;
29 import java.util.logging.Logger;
30
31 import javax.xml.bind.SchemaOutputResolver;
32 import javax.xml.transform.Result;
33
34 import com.sun.xml.internal.bind.Util;
35
36 /**
37 * {@link SchemaOutputResolver} that wraps the user-specified resolver
38 * and makes sure that it's following the contract.
39 *
40 * <p>
41 * This protects the rest of the {@link XmlSchemaGenerator} from client programming
42 * error.
43 */
44 final class FoolProofResolver extends SchemaOutputResolver {
45 private static final Logger logger = Util.getClassLogger();
46 private final SchemaOutputResolver resolver;
47
48 public FoolProofResolver(SchemaOutputResolver resolver) {
49 assert resolver!=null;
50 this.resolver = resolver;
51 }
52
53 public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
54 logger.entering(getClass().getName(),"createOutput",new Object[]{namespaceUri,suggestedFileName});
55 Result r = resolver.createOutput(namespaceUri,suggestedFileName);
56 if(r!=null) {
57 String sysId = r.getSystemId();
58 logger.finer("system ID = "+sysId);
59 if(sysId!=null) {
60 // TODO: make sure that the system Id is absolute
61
62 // don't use java.net.URI, because it doesn't allow some characters (like SP)
63 // which can legally used as file names.
64
65 // but don't use java.net.URL either, because it doesn't allow a made-up URI
66 // like kohsuke://foo/bar/zot
67 } else
68 throw new AssertionError("system ID cannot be null");
69 }
70 logger.exiting(getClass().getName(),"createOutput",r);
71 return r;
72 }
73 }

mercurial