001: /*
002: * Copyright (c) 1998-2007 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Adam Megacz
028: */
029:
030: package com.caucho.jaxb.property;
031:
032: import com.caucho.jaxb.BinderImpl;
033: import com.caucho.jaxb.JAXBContextImpl;
034: import com.caucho.jaxb.JAXBUtil;
035: import com.caucho.jaxb.NodeIterator;
036: import com.caucho.jaxb.mapping.Namer;
037: import com.caucho.jaxb.skeleton.LaxAnyTypeSkeleton;
038: import com.caucho.util.L10N;
039:
040: import javax.xml.XMLConstants;
041: import javax.xml.bind.JAXBException;
042: import javax.xml.bind.Marshaller;
043: import javax.xml.bind.Unmarshaller;
044: import javax.xml.namespace.QName;
045: import javax.xml.stream.XMLStreamException;
046: import javax.xml.stream.XMLStreamReader;
047: import javax.xml.stream.XMLStreamWriter;
048:
049: import java.io.IOException;
050:
051: import org.w3c.dom.Node;
052:
053: /**
054: * a property referencing some other Skeleton
055: */
056: public class LaxAnyTypeProperty extends Property {
057: public static final QName SCHEMA_TYPE = new QName(
058: XMLConstants.W3C_XML_SCHEMA_NS_URI, "anyType", "xsd");
059:
060: private static final L10N L = new L10N(LaxAnyTypeProperty.class);
061:
062: private LaxAnyTypeSkeleton _skeleton;
063:
064: public LaxAnyTypeProperty(JAXBContextImpl context)
065: throws JAXBException {
066: _skeleton = new LaxAnyTypeSkeleton(context);
067: }
068:
069: public Object read(Unmarshaller u, XMLStreamReader in,
070: Object previous) throws IOException, XMLStreamException,
071: JAXBException {
072: return _skeleton.read(u, in);
073: }
074:
075: public Object bindFrom(BinderImpl binder, NodeIterator node,
076: Object previous) throws IOException, JAXBException {
077: return _skeleton.bindFrom(binder, null, node);
078: }
079:
080: public void write(Marshaller m, XMLStreamWriter out, Object obj,
081: Namer namer) throws IOException, XMLStreamException,
082: JAXBException {
083: _skeleton.write(m, out, obj, namer, null);
084: }
085:
086: public Node bindTo(BinderImpl binder, Node node, Object obj,
087: Namer namer) throws IOException, JAXBException {
088: return _skeleton.bindTo(binder, node, obj, namer, null);
089: }
090:
091: public QName getSchemaType() {
092: return SCHEMA_TYPE;
093: }
094:
095: public boolean isXmlPrimitiveType() {
096: return false;
097: }
098:
099: public String toString() {
100: return "LaxAnyTypeProperty[" + _skeleton + "]";
101: }
102: }
|