Package javax.xml.bind

Examples of javax.xml.bind.JAXBElement$GlobalScope


    public JAXBElement unmarshal(Object obj, Class javaClass) {
        if(!(obj instanceof Node)) {
            return null;
        }
        XMLRoot xmlRoot = (XMLRoot)xmlBinder.unmarshal((Node)obj, javaClass);
        return new JAXBElement(new QName(xmlRoot.getNamespaceURI(), xmlRoot.getLocalName()), javaClass, xmlRoot.getObject());
    }
View Full Code Here


              if(qname != null) {
                Object unwrappedValue = null;
                if(value instanceof WrappedValue) {
                  unwrappedValue = ((WrappedValue)value).getWrappedValue();
                }
                value = new JAXBElement(qname, unwrappedValue.getClass(), unwrappedValue);
              }
            }
            return value;
        } catch (Exception e) {
            throw new UnmarshalException(e);
View Full Code Here

              if(qname != null) {
                Object unwrappedValue = null;
                if(value instanceof WrappedValue) {
                  unwrappedValue = ((WrappedValue)value).getWrappedValue();
                }
                value = new JAXBElement(qname, unwrappedValue.getClass(), unwrappedValue);
              }
            }
            return value;
        } catch (Exception e) {
            throw new UnmarshalException(e);
View Full Code Here

              if(qname != null) {
                Object unwrappedValue = null;
                if(value instanceof WrappedValue) {
                  unwrappedValue = ((WrappedValue)value).getWrappedValue();
                }
                value = new JAXBElement(qname, unwrappedValue.getClass(), unwrappedValue);
             
              }
            }
            return value;
        } catch (Exception e) {
View Full Code Here

              if(qname != null) {
                Object unwrappedValue = null;
                if(value instanceof WrappedValue) {
                  unwrappedValue = ((WrappedValue)value).getWrappedValue();
                }
                value = new JAXBElement(qname, unwrappedValue.getClass(), unwrappedValue);
              }
            }
            return value;
        } catch (Exception e) {
            throw new UnmarshalException(e);
View Full Code Here

              if(qname != null) {
                Object unwrappedValue = null;
                if(value instanceof WrappedValue) {
                  unwrappedValue = ((WrappedValue)value).getWrappedValue();
                }
                value = new JAXBElement(qname, unwrappedValue.getClass(), unwrappedValue);
              }
            }
            return value;
        } catch(Exception ex) {
            throw new JAXBException(ex);
View Full Code Here

              if(qname != null) {
                Object unwrappedValue = null;
                if(value instanceof WrappedValue) {
                  unwrappedValue = ((WrappedValue)value).getWrappedValue();
                }
                value = new JAXBElement(qname, unwrappedValue.getClass(), unwrappedValue);
              }
            }
            return value;
        } catch (Exception e) {
            throw new UnmarshalException(e);
View Full Code Here

      // element of the object being marshalled to - need to create a
      // JAXBElement from the returned XMLRoot object
      if (obj instanceof XMLRoot) {
        XMLRoot xmlRoot = ((XMLRoot)obj);
        QName qname = new QName(xmlRoot.getNamespaceURI(), xmlRoot.getLocalName());
        return new JAXBElement(qname, xmlRoot.getObject().getClass(), xmlRoot.getObject());
      }
     
      // at this point, the default root element of the object being marshalled
      // to == the root element - here we need to create a JAXBElement
      // instance using information from the returned object
      org.eclipse.persistence.sessions.Session sess = xmlUnmarshaller.getXMLContext().getSession(obj);
      XMLDescriptor desc = (XMLDescriptor) sess.getClassDescriptor(obj);
     
    // here we are assuming that if we've gotten this far, there
      // must be a default root element set on the descriptor.  if
      // this is incorrect, we need to check for null and throw an
      // exception
      String rootName = desc.getDefaultRootElement();
      if (rootName == null) {
        // TODO:  we should probably throw an exception at this point
            return new JAXBElement(new QName(""), obj.getClass(), obj);
      }
        String rootNamespaceUri = null;
        int idx = rootName.indexOf(":");
        if (idx != -1) {
            rootNamespaceUri = desc.getNamespaceResolver().resolveNamespacePrefix(rootName.substring(0, idx));
            rootName = rootName.substring(idx + 1);
        }
       
      QName qname;
        if (rootNamespaceUri == null) {
          qname = new QName(rootName);
        } else {
          qname = new QName(rootNamespaceUri, rootName);
        }

        return new JAXBElement(qname, obj.getClass(), obj);
    }
View Full Code Here

              if(qname != null) {
                Object unwrappedValue = null;
                if(value instanceof WrappedValue) {
                  unwrappedValue = ((WrappedValue)value).getWrappedValue();
                }
                value = new JAXBElement(qname, unwrappedValue.getClass(), unwrappedValue);
              }
            }
            return value;
        } catch (Exception e) {
            throw new UnmarshalException(e);
View Full Code Here

                            }
                        }
                        for(Object element : (Collection<Object>) value) {
                            if(wrapItemInJAXBElement) {
                                if(!(element instanceof JAXBElement)) {
                                    element = new JAXBElement(new QName(""), domainClass, element);
                                }
                                containerPolicy.addInto(element, container, null);
                            } else {
                                containerPolicy.addInto(JAXBIntrospector.getValue(element), container, null);
                            }
View Full Code Here

TOP

Related Classes of javax.xml.bind.JAXBElement$GlobalScope

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.