com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext Java Examples
The following examples show how to use
com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassBeanInfoImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException { BeanT bean = null; if (factoryMethod == null){ bean = ClassFactory.create0(jaxbType); }else { Object o = ClassFactory.create(factoryMethod); if( jaxbType.isInstance(o) ){ bean = (BeanT)o; } else { throw new InstantiationException("The factory method didn't return a correct object"); } } if(xmlLocatorField!=null) // need to copy because Locator is mutable try { xmlLocatorField.set(bean,new LocatorImpl(context.getLocator())); } catch (AccessorException e) { context.handleError(e); } return bean; }
Example #2
Source File: RuntimeBuiltinLeafInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public Class parse(CharSequence text) throws SAXException { TODO.checkSpec("JSR222 Issue #42"); try { String name = WhiteSpaceProcessor.trim(text).toString(); ClassLoader cl = UnmarshallingContext.getInstance().classLoader; if(cl==null) cl = Thread.currentThread().getContextClassLoader(); if(cl!=null) return cl.loadClass(name); else return Class.forName(name); } catch (ClassNotFoundException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
Example #3
Source File: ClassBeanInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException { BeanT bean = null; if (factoryMethod == null){ bean = ClassFactory.create0(jaxbType); }else { Object o = ClassFactory.create(factoryMethod); if( jaxbType.isInstance(o) ){ bean = (BeanT)o; } else { throw new InstantiationException("The factory method didn't return a correct object"); } } if(xmlLocatorField!=null) // need to copy because Locator is mutable try { xmlLocatorField.set(bean,new LocatorImpl(context.getLocator())); } catch (AccessorException e) { context.handleError(e); } return bean; }
Example #4
Source File: SingleMapNodeProperty.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { // create or obtain the Map object try { target.set((BeanT)state.getPrev().getTarget()); map.set(acc.get(target.get())); depthCounter++; if(map.get() == null) { map.set(ClassFactory.create(mapImplClass)); } map.get().clear(); state.setTarget(map.get()); } catch (AccessorException e) { // recover from error by setting a dummy Map that receives and discards the values handleGenericException(e,true); state.setTarget(new HashMap()); } }
Example #5
Source File: ClassBeanInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public boolean reset(BeanT bean, UnmarshallingContext context) throws SAXException { try { if(superClazz!=null) superClazz.reset(bean,context); for( Property<BeanT> p : properties ) p.reset(bean); return true; } catch (AccessorException e) { context.handleError(e); return false; } }
Example #6
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public URI parse(CharSequence text) throws SAXException { try { return new URI(text.toString()); } catch (URISyntaxException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
Example #7
Source File: AnyTypeBeanInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public boolean reset(Object element, UnmarshallingContext context) { return false; // NodeList nl = element.getChildNodes(); // while(nl.getLength()>0) // element.removeChild(nl.item(0)); // NamedNodeMap al = element.getAttributes(); // while(al.getLength()>0) // element.removeAttributeNode((Attr)al.item(0)); // return true; }
Example #8
Source File: Accessor.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void receive(UnmarshallingContext.State state, Object o) throws SAXException { try { set((BeanT) state.getTarget(), (ValueT) o); } catch (AccessorException e) { Loader.handleGenericException(e, true); } catch (IllegalAccessError iae) { // throw UnmarshalException instead IllegalAccesssError | Issue 475 Loader.handleGenericError(iae); } }
Example #9
Source File: Lister.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public Pack(BeanT bean, Accessor<BeanT,PropT> acc) { this.bean = bean; this.acc = acc; this.context = UnmarshallingContext.getInstance(); this.location = new LocatorEx.Snapshot(context.getLocator()); context.addPatcher(this); }
Example #10
Source File: RuntimeClassInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public BeanT parse(CharSequence lexical) throws AccessorException, SAXException { UnmarshallingContext ctxt = UnmarshallingContext.getInstance(); BeanT inst; if(ctxt!=null) inst = (BeanT)ctxt.createInstance(ownerClass); else // when this runs for parsing enum constants, // there's no UnmarshallingContext. inst = ClassFactory.create(ownerClass); xacc.parse(inst,lexical); return inst; }
Example #11
Source File: SingleMapNodeProperty.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { if(ea.matches(keyTag)) { state.setLoader(keyLoader); state.setReceiver(keyReceiver); return; } if(ea.matches(valueTag)) { state.setLoader(valueLoader); state.setReceiver(valueReceiver); return; } super.childElement(state,ea); }
Example #12
Source File: ElementBeanInfoImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public final void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { state.loader = core; state.intercepter = this; // TODO: make sure there aren't too many duplicate of this code // create the object to unmarshal Object child; UnmarshallingContext context = state.getContext(); // let's see if we can reuse the existing peer object child = context.getOuterPeer(); if(child!=null && jaxbType!=child.getClass()) child = null; // unexpected type. if(child!=null) reset((JAXBElement)child,context); if(child==null) child = context.createInstance(ElementBeanInfoImpl.this); fireBeforeUnmarshal(ElementBeanInfoImpl.this, child, state); context.recordOuterPeer(child); UnmarshallingContext.State p = state.prev; p.backup = p.target; p.target = child; core.startElement(state,ea); }
Example #13
Source File: ArrayERProperty.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { ChildLoader child = children.get(ea.uri,ea.local); if (child == null) { child = children.get(CATCH_ALL); } if (child == null) { super.childElement(state,ea); return; } state.loader = child.loader; state.receiver = child.receiver; }
Example #14
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public URL parse(CharSequence text) throws SAXException { TODO.checkSpec("JSR222 Issue #42"); try { return new URL(WhiteSpaceProcessor.trim(text).toString()); } catch (MalformedURLException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
Example #15
Source File: AnyTypeBeanInfo.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public boolean reset(Object element, UnmarshallingContext context) { return false; // NodeList nl = element.getChildNodes(); // while(nl.getLength()>0) // element.removeChild(nl.item(0)); // NamedNodeMap al = element.getAttributes(); // while(al.getLength()>0) // element.removeAttributeNode((Attr)al.item(0)); // return true; }
Example #16
Source File: JAXBContextImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Based on the tag name, determine what object to unmarshal, * and then set a new object and its loader to the current unmarshaller state. * * @return * null if the given name pair is not recognized. */ public final Loader selectRootLoader( UnmarshallingContext.State state, TagName tag ) { JaxBeanInfo beanInfo = rootMap.get(tag.uri,tag.local); if(beanInfo==null) return null; return beanInfo.getLoader(this,true); }
Example #17
Source File: SingleMapNodeProperty.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { if(ea.matches(entryTag)) { state.setLoader(entryLoader); } else { super.childElement(state,ea); } }
Example #18
Source File: AnyTypeBeanInfo.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public boolean reset(Object element, UnmarshallingContext context) { return false; // NodeList nl = element.getChildNodes(); // while(nl.getLength()>0) // element.removeChild(nl.item(0)); // NamedNodeMap al = element.getAttributes(); // while(al.getLength()>0) // element.removeAttributeNode((Attr)al.item(0)); // return true; }
Example #19
Source File: ElementBeanInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public final void startElement(UnmarshallingContext.State state, TagName ea) throws SAXException { state.setLoader(core); state.setIntercepter(this); // TODO: make sure there aren't too many duplicate of this code // create the object to unmarshal Object child; UnmarshallingContext context = state.getContext(); // let's see if we can reuse the existing peer object child = context.getOuterPeer(); if(child!=null && jaxbType!=child.getClass()) child = null; // unexpected type. if(child!=null) reset((JAXBElement)child,context); if(child==null) child = context.createInstance(ElementBeanInfoImpl.this); fireBeforeUnmarshal(ElementBeanInfoImpl.this, child, state); context.recordOuterPeer(child); UnmarshallingContext.State p = state.getPrev(); p.setBackup(p.getTarget()); p.setTarget(child); core.startElement(state,ea); }
Example #20
Source File: ClassBeanInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public boolean reset(BeanT bean, UnmarshallingContext context) throws SAXException { try { if(superClazz!=null) superClazz.reset(bean,context); for( Property<BeanT> p : properties ) p.reset(bean); return true; } catch (AccessorException e) { context.handleError(e); return false; } }
Example #21
Source File: ArrayBeanInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { if(ea.matches("","item")) { state.setLoader(itemLoader); state.setReceiver(this); } else { super.childElement(state,ea); } }
Example #22
Source File: JAXBContextImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Based on the tag name, determine what object to unmarshal, * and then set a new object and its loader to the current unmarshaller state. * * @return * null if the given name pair is not recognized. */ public final Loader selectRootLoader( UnmarshallingContext.State state, TagName tag ) { JaxBeanInfo beanInfo = rootMap.get(tag.uri,tag.local); if(beanInfo==null) return null; return beanInfo.getLoader(this,true); }
Example #23
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public DataHandler parse(CharSequence text) { if(text instanceof Base64Data) return ((Base64Data)text).getDataHandler(); else return new DataHandler(new ByteArrayDataSource(decodeBase64(text), UnmarshallingContext.getInstance().getXMIMEContentType())); }
Example #24
Source File: SingleMapNodeProperty.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void childElement(UnmarshallingContext.State state, TagName ea) throws SAXException { if(ea.matches(keyTag)) { state.setLoader(keyLoader); state.setReceiver(keyReceiver); return; } if(ea.matches(valueTag)) { state.setLoader(valueLoader); state.setReceiver(valueReceiver); return; } super.childElement(state,ea); }
Example #25
Source File: RuntimeBuiltinLeafInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public URI parse(CharSequence text) throws SAXException { try { return new URI(text.toString()); } catch (URISyntaxException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
Example #26
Source File: AnyTypeBeanInfo.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public boolean reset(Object element, UnmarshallingContext context) { return false; // NodeList nl = element.getChildNodes(); // while(nl.getLength()>0) // element.removeChild(nl.item(0)); // NamedNodeMap al = element.getAttributes(); // while(al.getLength()>0) // element.removeAttributeNode((Attr)al.item(0)); // return true; }
Example #27
Source File: RuntimeBuiltinLeafInfoImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException { try { return DatatypeConverterImpl.getDatatypeFactory() .newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396) } catch (Exception e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
Example #28
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public UUID parse(CharSequence text) throws SAXException { TODO.checkSpec("JSR222 Issue #42"); try { return UUID.fromString(WhiteSpaceProcessor.trim(text).toString()); } catch (IllegalArgumentException e) { UnmarshallingContext.getInstance().handleError(e); return null; } }
Example #29
Source File: RuntimeBuiltinLeafInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public DataHandler parse(CharSequence text) { if(text instanceof Base64Data) return ((Base64Data)text).getDataHandler(); else return new DataHandler(new ByteArrayDataSource(decodeBase64(text), UnmarshallingContext.getInstance().getXMIMEContentType())); }
Example #30
Source File: Lister.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public Pack(BeanT bean, Accessor<BeanT,PropT> acc) { this.bean = bean; this.acc = acc; this.context = UnmarshallingContext.getInstance(); this.location = new LocatorEx.Snapshot(context.getLocator()); context.addPatcher(this); }