01: /*
02: * Copyright (c) 1998-2007 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * Resin Open Source is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License as published by
11: * the Free Software Foundation; either version 2 of the License, or
12: * (at your option) any later version.
13: *
14: * Resin Open Source is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17: * of NON-INFRINGEMENT. See the GNU General Public License for more
18: * details.
19: *
20: * You should have received a copy of the GNU General Public License
21: * along with Resin Open Source; if not, write to the
22: *
23: * Free Software Foundation, Inc.
24: * 59 Temple Place, Suite 330
25: * Boston, MA 02111-1307 USA
26: *
27: * @author Emil Ong
28: */
29:
30: package com.caucho.jaxb.mapping;
31:
32: import com.caucho.util.L10N;
33: import com.caucho.xml.stream.StaxUtil;
34:
35: import static javax.xml.XMLConstants.*;
36: import javax.xml.bind.annotation.*;
37: import javax.xml.bind.JAXBException;
38: import javax.xml.bind.Marshaller;
39: import javax.xml.bind.Unmarshaller;
40: import javax.xml.namespace.QName;
41: import javax.xml.stream.events.*;
42: import javax.xml.stream.XMLStreamException;
43: import javax.xml.stream.XMLStreamReader;
44: import javax.xml.stream.XMLStreamWriter;
45:
46: import java.io.IOException;
47:
48: import java.lang.annotation.*;
49: import java.lang.reflect.*;
50:
51: import java.util.Map;
52: import java.util.logging.Logger;
53:
54: /**
55: *
56: **/
57: public class NilWrapper extends XmlMapping {
58: private static final Logger log = Logger.getLogger(NilWrapper.class
59: .getName());
60: private static final L10N L = new L10N(NilWrapper.class);
61: private static final QName XSI_NIL_NAME = new QName(
62: W3C_XML_SCHEMA_INSTANCE_NS_URI, "nil", "xsi");
63:
64: public static final NilWrapper INSTANCE = new NilWrapper();
65:
66: private NilWrapper() {
67: }
68:
69: public void write(Marshaller m, XMLStreamWriter out, Object obj)
70: throws IOException, XMLStreamException, JAXBException {
71: StaxUtil.writeAttribute(out, XSI_NIL_NAME, "true");
72: }
73:
74: public QName getQName(Object obj) throws JAXBException {
75: return XSI_NIL_NAME;
76: }
77:
78: public void putQNames(Map<QName, XmlMapping> map)
79: throws JAXBException {
80: throw new UnsupportedOperationException();
81: }
82:
83: public void generateSchema(XMLStreamWriter out)
84: throws JAXBException, XMLStreamException {
85: throw new UnsupportedOperationException();
86: }
87:
88: public String toString() {
89: return "NilWrapper[]";
90: }
91: }
|