[jboss-svn-commits] JBoss Common SVN: r3822 - jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 3 07:51:22 EST 2009
Author: alex.loubyansky at jboss.com
Date: 2009-12-03 07:51:22 -0500 (Thu, 03 Dec 2009)
New Revision: 3822
Modified:
jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java
Log:
move position.handler.startParticle(..) to position.startParticle(..)
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java 2009-12-03 03:28:09 UTC (rev 3821)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/SundayContentHandler.java 2009-12-03 12:51:22 UTC (rev 3822)
@@ -65,8 +65,6 @@
private Object root;
private NamespaceRegistry nsRegistry = new NamespaceRegistry();
- private ParticleHandler defParticleHandler = DefaultHandlers.ELEMENT_HANDLER;
-
private UnmarshallingContextImpl ctx = new UnmarshallingContextImpl();
// DTD information frm startDTD
private String dtdRootName;
@@ -338,7 +336,7 @@
flushIgnorableCharacters();
position.handler = DefaultHandlers.XOP_HANDLER;
position.ignoreCharacters = true;
- position.o = position.handler.startParticle(stack.peek().o, startName, stack.peek().particle, null, nsRegistry);
+ position.startParticle(position.o, null, nsRegistry);
TypeBinding xopIncludeType = new TypeBinding(new QName(Constants.NS_XOP_INCLUDE, "Include"));
xopIncludeType.setSchemaBinding(schema);
@@ -376,13 +374,9 @@
if(newPosition.particle.isRepeatable())
startRepeatableParticle(stack.peek(), o, startName, newPosition.particle);
- ParticleHandler handler = getHandler(newPosition.particle.getTerm());
- o = handler.startParticle(o, newPosition.qName, newPosition.particle, atts, nsRegistry);
- newPosition.o = o;
- newPosition.handler = handler;
+ o = newPosition.startParticle(o, atts, nsRegistry);
newPosition.parentType = parentType;
- stack.push(newPosition);
-
+ stack.push(newPosition);
newPosition = newPosition.getNext();
}
@@ -436,13 +430,9 @@
newPosition = newPosition.getNext();
while (newPosition.getNext() != null)
{
- ParticleHandler handler = getHandler(newPosition.particle.getTerm());
- o = handler.startParticle(o, position.qName, newPosition.particle, atts, nsRegistry);
- newPosition.o = o;
- newPosition.handler = handler;
+ o = newPosition.startParticle(o, atts, nsRegistry);
newPosition.parentType = position.parentType;
stack.push(newPosition);
-
newPosition = newPosition.getNext();
}
@@ -457,8 +447,6 @@
}
}
- Object parent = stack.isEmpty() ? null : (repeated ? stack.peek1().o : stack.peek().o);
-
ElementBinding element = (ElementBinding) position.particle.getTerm();
// TODO xsi:type support should be implemented in a better way
@@ -502,6 +490,7 @@
.getMaxOccurs(), position.particle.getMaxOccursUnbounded());
}
+ Object parent = stack.isEmpty() ? null : (repeated ? stack.peek1().o : stack.peek().o);
if (!repeated && position.particle.isRepeatable())
startRepeatableParticle(stack.peek(), parent, startName, position.particle);
@@ -511,7 +500,7 @@
position.handler = type.getHandler();
if (position.handler == null)
- position.handler = defParticleHandler;
+ position.handler = DefaultHandlers.ELEMENT_HANDLER;
List<ElementInterceptor> localInterceptors = position.parentType == null
? Collections.EMPTY_LIST
@@ -547,7 +536,7 @@
String nil = atts.getValue(Constants.NS_XML_SCHEMA_INSTANCE, "nil");
if (nil == null || !("1".equals(nil) || "true".equals(nil)))
- position.o = position.handler.startParticle(parent, startName, position.particle, atts, nsRegistry);
+ position.startParticle(parent, atts, nsRegistry);
else
position.o = NIL;
@@ -555,19 +544,6 @@
stack.push(position);
}
- private ParticleHandler getHandler(TermBinding term)
- {
- ParticleHandler handler = null;
- if(term.isModelGroup())
- handler = ((ModelGroupBinding)term).getHandler();
- else if(term.isWildcard())
- //handler = ((WildcardBinding)term).getWildcardHandler();
- handler = NoopParticleHandler.INSTANCE;
- else
- throw new IllegalArgumentException("Unexpected term " + term);
- return handler == null ? defParticleHandler : handler;
- }
-
private void endRepeatableParent(QName startName)
{
int stackIndex = stack.size() - 2;
@@ -588,12 +564,9 @@
if(position.particle.isRepeatable())
{
endParticle(position, stackIndex - 1);
-
- ParticleHandler handler = getHandler(position.particle.getTerm());
- position.reset();
parentPosition = stack.peek(stackIndex - 1);
- position.o = handler.startParticle(parentPosition.o, position.qName, position.particle, null, nsRegistry);
-
+ position.reset();
+ position.startParticle(parentPosition.o, null, nsRegistry);
break;
}
@@ -653,9 +626,8 @@
{
parentPosition = position;
position = stack.peek(stackIndex);
- ParticleHandler handler = getHandler(position.particle.getTerm());
position.reset();
- position.o = handler.startParticle(parentPosition.o, position.qName, position.particle, null, nsRegistry);
+ position.startParticle(parentPosition.o, null, nsRegistry);
}
}
@@ -1225,6 +1197,14 @@
throw new UnsupportedOperationException();
}
+ public Object startParticle(Object parent, Attributes atts, NamespaceRegistry nsRegistry)
+ {
+ if(handler == null)
+ handler = getHandler(particle.getTerm());
+ o = handler.startParticle(parent, qName, particle, atts, nsRegistry);
+ return o;
+ }
+
public void endParticle()
{
o = handler.endParticle(o, qName, particle);
@@ -1247,6 +1227,19 @@
if(nonXsiParticle != null)
particle = nonXsiParticle;
}
+
+ private ParticleHandler getHandler(TermBinding term)
+ {
+ ParticleHandler handler = null;
+ if(term.isModelGroup())
+ handler = ((ModelGroupBinding)term).getHandler();
+ else if(term.isWildcard())
+ //handler = ((WildcardBinding)term).getWildcardHandler();
+ handler = NoopParticleHandler.INSTANCE;
+ else
+ throw new IllegalArgumentException("Unexpected term " + term);
+ return handler == null ? DefaultHandlers.ELEMENT_HANDLER : handler;
+ }
}
static class StackImpl
More information about the jboss-svn-commits
mailing list