Package com.caucho.jaxb.skeleton

Examples of com.caucho.jaxb.skeleton.ClassSkeleton


  }

  public void generateSchemaParticle(XMLStreamWriter out, Class cl)
    throws XMLStreamException, JAXBException
  {
    ClassSkeleton skeleton = _context.getSkeleton(cl);
    skeleton.generateSchema(out);
  }
View Full Code Here


  {
    try {
      if (reader.nextTag() != XMLStreamReader.START_ELEMENT)
        throw new JAXBException(L.l("Expected root element"));

      ClassSkeleton skel = _context.getRootElement(reader.getName());

      if (skel == null)
        throw new JAXBException(L.l("'{0}' is an unknown root element",
              reader.getName()));

      return skel.read(this, reader);
    }
    catch (JAXBException e) {
      throw e;
    }
    catch (Exception e) {
View Full Code Here

      throw new IllegalArgumentException(L.l("JAXB object may not be null"));

    if (xmlNode == null)
      throw new IllegalArgumentException(L.l("Node may not be null"));

    ClassSkeleton skeleton = _context.findSkeletonForObject(jaxbObject);

    if (skeleton == null)
      throw new MarshalException(L.l("Unable to marshal {0}: its type unknown to this JAXBContext", jaxbObject));

    Document doc = xmlNode.getOwnerDocument();

    if (xmlNode.getNodeType() == Node.DOCUMENT_NODE)
      doc = (Document) xmlNode;

    Node child = doc.createElement("root");

    try {
      xmlNode.appendChild(skeleton.bindTo(this, child, jaxbObject, null, null));
    }
    catch (IOException e) {
      throw new JAXBException(e);
    }
  }
View Full Code Here

      root = doc.getDocumentElement();
    }

    QName name = JAXBUtil.qnameFromNode(root);

    ClassSkeleton skeleton = _context.getRootElement(name);

    if (skeleton == null)
      throw new UnmarshalException(L.l("Root element {0} is unknown to this context",
                                       name));

    try {
      return skeleton.bindFrom(this, null, new NodeIterator(root));
    }
    catch (IOException e) {
      throw new JAXBException(e);
    }
  }
View Full Code Here

    if (xmlNode.getNodeType() == Node.DOCUMENT_NODE) {
      Document doc = (Document) xmlNode;
      root = doc.getDocumentElement();
    }

    ClassSkeleton skeleton = _context.findSkeletonForClass(declaredType);

    if (skeleton == null)
      throw new UnmarshalException(L.l("Type {0} is unknown to this context",
                                       declaredType));

    try {
      T value = (T) skeleton.bindFrom(this, null, new NodeIterator(root));

      QName qname = JAXBUtil.qnameFromNode(root);

      return new JAXBElement<T>(qname, declaredType, value);
    }
View Full Code Here

    Object jaxbObject = getJAXBNode(root);

    if (jaxbObject == null)
      throw new JAXBException(L.l("Unknown xmlNode"));

    ClassSkeleton skeleton = _context.findSkeletonForObject(jaxbObject);

    if (skeleton == null) {
      // we strip the JAXBElement when we bind objects, so rewrap
      // the object and try again
      QName qname = JAXBUtil.qnameFromNode(root);

      jaxbObject = new JAXBElement(qname, jaxbObject.getClass(), jaxbObject);

      skeleton = _context.findSkeletonForObject(jaxbObject);

      if (skeleton == null)
        throw new UnmarshalException(L.l("Type {0} is unknown to this context",
                                         jaxbObject.getClass()));
    }

    try {
      return skeleton.bindFrom(this, jaxbObject, new NodeIterator(root));
    }
    catch (IOException e) {
      throw new JAXBException(e);
    }
  }
View Full Code Here

  }

  public Node updateXML(Object jaxbObject, Node xmlNode)
    throws JAXBException
  {
    ClassSkeleton skeleton = _context.findSkeletonForObject(jaxbObject);

    if (skeleton == null)
      throw new MarshalException(L.l("Unable to update {0}: its type unknown to this JAXBContext", jaxbObject));

    try {
      return skeleton.bindTo(this, xmlNode, jaxbObject, null, null);
    }
    catch (IOException e) {
      throw new JAXBException(e);
    }
  }
View Full Code Here

   * Marshal the content tree rooted at jaxbElement into a .
   */
  public void marshal(Object jaxbElement, XMLStreamWriter writer)
    throws JAXBException
  {
    ClassSkeleton skeleton = _context.findSkeletonForObject(jaxbElement);

    if (skeleton == null)
      throw new MarshalException(L.l("Unable to marshal {0}: its type unknown to this JAXBContext", jaxbElement));

    Class c = skeleton.getType();
    writer = StaxUtil.toRepairingXMLStreamWriter(writer);

    // tck/JAXBMarshall
    if (! _context.createJAXBIntrospector().isElement(jaxbElement) &&
        ! c.isAnnotationPresent(XmlRootElement.class))
      throw new MarshalException("JAXBIntrospector.isElement()==false");

    /*
    String name = null;
    String namespace = null;

    /// XXX: put into skeleton?
    XmlType xmlTypeAnnotation = (XmlType) c.getAnnotation(XmlType.class);

    if (name == null) {
      name =
        (xmlTypeAnnotation == null ? c.getName() : xmlTypeAnnotation.name());
    }

    XmlRootElement xre = (XmlRootElement) c.getAnnotation(XmlRootElement.class);

    if (xre != null)
      name = xre.name();*/

    String encoding = getEncoding();

    if (encoding == null)
      encoding = "utf-8";

    try {
      if (!isFragment())
        writer.writeStartDocument(encoding, "1.0");

      // XXX this needs to happen after the startElement is written
      // jaxb/5003
      /*
      if (getNoNSSchemaLocation() != null)
        writer.writeAttribute("xsi",
                              "http://www.w3.org/2001/XMLSchema-instance",
                              "noNamespaceSchemaLocation",
                              getNoNSSchemaLocation());
      */

      skeleton.write(this, writer, jaxbElement, null, null);

      writer.writeEndDocument();
    }
    catch (JAXBException e) {
      throw e;
View Full Code Here

    Map<QName,Property> qnameToPropertyMap = new HashMap<QName,Property>();
    Map<Class,Property> classToPropertyMap = new HashMap<Class,Property>();

    for (int i = 0; i < skeletons.size(); i++) {
      ClassSkeleton skeleton = skeletons.get(i);
      map.put(skeleton.getElementName(), this);

      QName qname = skeleton.getElementName();
      Property property = _context.createProperty(skeleton.getType());

      qnameToPropertyMap.put(qname, property);
      classToPropertyMap.put(skeleton.getType(), property);
    }

    _property = new MultiProperty(qnameToPropertyMap, classToPropertyMap);

    if (List.class.isAssignableFrom(_accessor.getType()))
View Full Code Here

      JAXBElement element = (JAXBElement) obj;

      return element.getName();
    }
    else {
      ClassSkeleton skeleton = _context.findSkeletonForObject(obj);

      if (skeleton == null || skeleton.getElementName() == null)
        throw new JAXBException(L.l("Cannot find root element name for object {0}", obj));

      return skeleton.getElementName();
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.jaxb.skeleton.ClassSkeleton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.