@Override public void startElement(String uri, String local, String qname, Attributes atts) throws SAXException { if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}, attrs: {3}", new Object[]{uri, local, qname, atts}); } // work gracefully with misconfigured parsers that don't support namespaces if( uri==null || uri.length()==0 ) uri=""; if( local==null || local.length()==0 ) local=qname; if( qname==null || qname.length()==0 ) qname=local; processText(!context.getCurrentState().isMixed()); tagName.uri = uri; tagName.local = local; tagName.qname = qname; tagName.atts = atts; next.startElement(tagName); }
private void processText( boolean ignorable ) throws SAXException { if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer) || context.getCurrentState().isMixed())) { if(textReported) { textReported = false; } else { visitor.text(buffer); } } buffer.setLength(0); }
/** * Allows to access elements which are expected in current state. * Useful for getting elements for current parent. * * @return */ public Collection<QName> getCurrentExpectedElements() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedChildElements() : null; } finally { popCoordinator(); } }
/** * Allows to access attributes which are expected in current state. * Useful for getting attributes for current parent. * * @return */ public Collection<QName> getCurrentExpectedAttributes() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedAttributes() : null; } finally { popCoordinator(); } }
/** * Starts the packing scope, without adding any item. * * This allows us to return an empty pack, thereby allowing the user * to distinguish empty array vs null array. */ public void start( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister) throws SAXException{ try { if(!hasStarted()) { this.bean = (BeanT)context.getCurrentState().getTarget(); this.acc = acc; this.lister = lister; this.pack = lister.startPacking(bean,acc); } } catch (AccessorException e) { Loader.handleGenericException(e,true); // recover from this error by ignoring future items. this.lister = Lister.getErrorInstance(); this.acc = Accessor.getErrorInstance(); } } }
/** * Adds a new item to this packing scope. */ public void add( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister, ItemT value) throws SAXException{ try { if(!hasStarted()) { this.bean = (BeanT)context.getCurrentState().getTarget(); this.acc = acc; this.lister = lister; this.pack = lister.startPacking(bean,acc); } lister.addToPack(pack,value); } catch (AccessorException e) { Loader.handleGenericException(e,true); // recover from this error by ignoring future items. this.lister = Lister.getErrorInstance(); this.acc = Accessor.getErrorInstance(); } }
@Override public void startElement(String uri, String local, String qname, Attributes atts) throws SAXException { if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}, attrs: {3}", new Object[]{uri, local, qname, atts}); } // work gracefully with misconfigured parsers that don't support namespaces if( uri==null || uri.length()==0 ) uri=""; if( local==null || local.length()==0 ) local=qname; if( qname==null || qname.length()==0 ) qname=local; processText(!context.getCurrentState().isMixed()); tagName.uri = uri; tagName.local = local; tagName.qname = qname; tagName.atts = atts; next.startElement(tagName); }
private void processText( boolean ignorable ) throws SAXException { if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer) || context.getCurrentState().isMixed())) { if(textReported) { textReported = false; } else { visitor.text(buffer); } } buffer.setLength(0); }
/** * Allows to access attributes which are expected in current state. * Useful for getting attributes for current parent. * * @return */ public Collection<QName> getCurrentExpectedAttributes() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedAttributes() : null; } finally { popCoordinator(); } }
/** * Allows to access elements which are expected in current state. * Useful for getting elements for current parent. * * @return */ public Collection<QName> getCurrentExpectedElements() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedChildElements() : null; } finally { popCoordinator(); } }
/** * Starts the packing scope, without adding any item. * * This allows us to return an empty pack, thereby allowing the user * to distinguish empty array vs null array. */ public void start( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister) throws SAXException{ try { if(!hasStarted()) { this.bean = (BeanT)context.getCurrentState().getTarget(); this.acc = acc; this.lister = lister; this.pack = lister.startPacking(bean,acc); } } catch (AccessorException e) { Loader.handleGenericException(e,true); // recover from this error by ignoring future items. this.lister = Lister.getErrorInstance(); this.acc = Accessor.getErrorInstance(); } } }
/** * Adds a new item to this packing scope. */ public void add( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister, ItemT value) throws SAXException{ try { if(!hasStarted()) { this.bean = (BeanT)context.getCurrentState().getTarget(); this.acc = acc; this.lister = lister; this.pack = lister.startPacking(bean,acc); } lister.addToPack(pack,value); } catch (AccessorException e) { Loader.handleGenericException(e,true); // recover from this error by ignoring future items. this.lister = Lister.getErrorInstance(); this.acc = Accessor.getErrorInstance(); } }
@Override public void startElement(String uri, String local, String qname, Attributes atts) throws SAXException { if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}, attrs: {3}", new Object[]{uri, local, qname, atts}); } // work gracefully with misconfigured parsers that don't support namespaces if( uri==null || uri.length()==0 ) uri=""; if( local==null || local.length()==0 ) local=qname; if( qname==null || qname.length()==0 ) qname=local; processText(!context.getCurrentState().isMixed()); tagName.uri = uri; tagName.local = local; tagName.qname = qname; tagName.atts = atts; next.startElement(tagName); }
private void processText( boolean ignorable ) throws SAXException { if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer) || context.getCurrentState().isMixed())) { if(textReported) { textReported = false; } else { visitor.text(buffer); } } buffer.setLength(0); }
private void processText( boolean ignorable ) throws SAXException { if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer) || context.getCurrentState().isMixed())) { if(textReported) { textReported = false; } else { visitor.text(buffer); } } buffer.setLength(0); }
/** * Allows to access elements which are expected in current state. * Useful for getting elements for current parent. * * @return */ public Collection<QName> getCurrentExpectedElements() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedChildElements() : null; } finally { popCoordinator(); } }
/** * Allows to access attributes which are expected in current state. * Useful for getting attributes for current parent. * * @return */ public Collection<QName> getCurrentExpectedAttributes() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedAttributes() : null; } finally { popCoordinator(); } }
/** * Allows to access attributes which are expected in current state. * Useful for getting attributes for current parent. * * @return */ public Collection<QName> getCurrentExpectedAttributes() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedAttributes() : null; } finally { popCoordinator(); } }
/** * Allows to access elements which are expected in current state. * Useful for getting elements for current parent. * * @return */ public Collection<QName> getCurrentExpectedElements() { pushCoordinator(); try { State s = getCurrentState(); Loader l = s.loader; return (l != null) ? l.getExpectedChildElements() : null; } finally { popCoordinator(); } }
/** * Starts the packing scope, without adding any item. * * This allows us to return an empty pack, thereby allowing the user * to distinguish empty array vs null array. */ public void start( Accessor<BeanT,PropT> acc, Lister<BeanT,PropT,ItemT,PackT> lister) throws SAXException{ try { if(!hasStarted()) { this.bean = (BeanT)context.getCurrentState().getTarget(); this.acc = acc; this.lister = lister; this.pack = lister.startPacking(bean,acc); } } catch (AccessorException e) { Loader.handleGenericException(e,true); // recover from this error by ignoring future items. this.lister = Lister.getErrorInstance(); this.acc = Accessor.getErrorInstance(); } } }