DefaultParticleBinder.java revision 325
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* {@link ParticleBinder} that follows the JAXB spec.
*
* @author Kohsuke Kawaguchi
*/
final class DefaultParticleBinder extends ParticleBinder {
if(checker.hasNameCollision()) {
true, false, false, p,
p.getLocator(), false, false, false);
} else {
}
}
public boolean checkFallback( XSParticle p ) {
}
// scan the tree by a checker.
if(superClass!=null)
return checker;
}
/**
* Marks particles that need to be mapped to properties,
* by reading customization info.
*/
private final class Checker implements XSTermVisitor {
this.forcedProps = forcedProps;
}
boolean hasNameCollision() {
return collisionInfo!=null;
}
return collisionInfo;
}
/**
* If a collision is found, this field will be non-null.
*/
/** Used to check name collision. */
/**
* @see DefaultParticleBinder#build(XSParticle, Collection<com.sun.xml.internal.xsom.XSParticle>)
*/
public void particle( XSParticle p ) {
if(getLocalPropCustomization(p)!=null
// if a property customization is specfied,
// check that value and turn around.
check(p);
mark(p);
return;
}
// a repeated model group gets its own property
mark(p);
return;
}
if(forcedProps.contains(p)) {
// this particle must become a property
mark(p);
return;
}
outerParticle = p;
t.visit(this);
}
/**
* This field points to the parent XSParticle.
* The value is only valid when we are processing XSTerm.
*/
private XSParticle outerParticle;
}
// choice gets mapped to a property
if(mg.getCompositor()== XSModelGroup.Compositor.CHOICE && builder.getGlobalBinding().isChoiceContentPropertyEnabled()) {
return;
}
}
}
}
}
/**
* Checks the name collision of a newly found particle.
*/
private void check( XSParticle p ) {
if( collisionInfo==null )
}
/**
* Marks a particle that it's going to be mapped to a property.
*/
private void mark( XSParticle p ) {
}
/**
* Marked particles.
*
* A map from XSParticle to its label.
*/
/**
* Checks name collisions among particles that belong to sequences.
*/
private final class NameCollisionChecker {
/**
* Checks the label conflict of a particle.
* This method shall be called for each marked particle.
*
* @return
* a description of a collision if a name collision is
* found. Otherwise null.
*/
// this can be used for particles with a property customization,
// which may not have element declaration as its term.
// // we only check particles with element declarations.
// _assert( p.getTerm().isElementDecl() );
// collide with occupied labels
}
// problem was found. no need to check further
}
}
return null;
}
/** List of particles reported through the check method. */
/**
* Label names already used in the base type.
*/
/**
* Checks the conflict of two particles.
* @return
* true if the check was successful.
*/
}
/**
* Reads fields of the super class and includes them
* to name collision tests.
*/
}
}
}
/** Keep the computed label names for particles. */
/**
* Hides the computeLabel method of the outer class
* and adds caching.
*/
return label;
}
}
/**
* Builds properties by using the result computed by Checker
*/
private final class Builder implements XSTermVisitor {
this.markedParticles = markedParticles;
}
/** All marked particles. */
/**
* When we are visiting inside an optional particle, this flag
* is set to true.
*
* <p>
*/
private boolean insideOptionalParticle;
/** Returns true if a particle is marked. */
private boolean marked( XSParticle p ) {
return markedParticles.containsKey(p);
}
/** Gets a label of a particle. */
return markedParticles.get(p);
}
public void particle( XSParticle p ) {
if(marked(p)) {
} else {
// repeated model groups should have been marked already
assert !p.isRepeated();
boolean oldIOP = insideOptionalParticle;
// this is an unmarked particle
t.visit(this);
}
}
public void elementDecl( XSElementDecl e ) {
// because the corresponding particle must be marked.
assert false;
}
// because the corresponding particle must be marked.
assert false;
}
}
boolean oldIOP = insideOptionalParticle;
particle(p);
}
}
}