Java Code Examples for com.sun.xml.internal.xsom.XSComponent#apply()

The following examples show how to use com.sun.xml.internal.xsom.XSComponent#apply() . 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: BGMBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the component maps to a property, forwards to purple, otherwise to green.
 *
 * If the component is mapped to a type, this method needs to return true.
 * See the chart at the class javadoc.
 */
public void ying( XSComponent sc, @Nullable XSComponent referer ) {
    if(sc.apply(toPurple)==true || getClassSelector().bindToType(sc,referer)!=null)
        sc.visit(purple);
    else
        sc.visit(green);
}
 
Example 2
Source File: BGMBuilder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the component maps to a property, forwards to purple, otherwise to green.
 *
 * If the component is mapped to a type, this method needs to return true.
 * See the chart at the class javadoc.
 */
public void ying( XSComponent sc, @Nullable XSComponent referer ) {
    if(sc.apply(toPurple)==true || getClassSelector().bindToType(sc,referer)!=null)
        sc.visit(purple);
    else
        sc.visit(green);
}
 
Example 3
Source File: BIProperty.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static BIProperty getDefault( BGMBuilder builder, XSComponent c ) {
    while(c!=null) {
        c = c.apply(defaultCustomizationFinder);
        if(c!=null) {
            BIProperty prop = builder.getBindInfo(c).get(BIProperty.class);
            if(prop!=null)  return prop;
        }
    }

    // default to the global one
    return builder.getGlobalBinding().getDefaultProperty();
}
 
Example 4
Source File: ClassSelector.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copies a schema fragment into the javadoc of the generated class.
 */
private void addSchemaFragmentJavadoc( CClassInfo bean, XSComponent sc ) {

    // first, pick it up from <documentation> if any.
    String doc = builder.getBindInfo(sc).getDocumentation();
    if(doc!=null)
        append(bean, doc);

    // then the description of where this component came from
    Locator loc = sc.getLocator();
    String fileName = null;
    if(loc!=null) {
        fileName = loc.getPublicId();
        if(fileName==null)
            fileName = loc.getSystemId();
    }
    if(fileName==null)  fileName="";

    String lineNumber=Messages.format( Messages.JAVADOC_LINE_UNKNOWN);
    if(loc!=null && loc.getLineNumber()!=-1)
        lineNumber = String.valueOf(loc.getLineNumber());

    String componentName = sc.apply( new ComponentNameFunction() );
    String jdoc = Messages.format( Messages.JAVADOC_HEADING, componentName, fileName, lineNumber );
    append(bean,jdoc);

    // then schema fragment
    StringWriter out = new StringWriter();
    out.write("<pre>\n");
    SchemaWriter sw = new SchemaWriter(new JavadocEscapeWriter(out));
    sc.visit(sw);
    out.write("</pre>");
    append(bean,out.toString());
}
 
Example 5
Source File: BGMBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the component maps to a property, forwards to purple, otherwise to green.
 *
 * If the component is mapped to a type, this method needs to return true.
 * See the chart at the class javadoc.
 */
public void ying( XSComponent sc, @Nullable XSComponent referer ) {
    if(sc.apply(toPurple)==true || getClassSelector().bindToType(sc,referer)!=null)
        sc.visit(purple);
    else
        sc.visit(green);
}
 
Example 6
Source File: BIProperty.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static BIProperty getDefault( BGMBuilder builder, XSComponent c ) {
    while(c!=null) {
        c = c.apply(defaultCustomizationFinder);
        if(c!=null) {
            BIProperty prop = builder.getBindInfo(c).get(BIProperty.class);
            if(prop!=null)  return prop;
        }
    }

    // default to the global one
    return builder.getGlobalBinding().getDefaultProperty();
}
 
Example 7
Source File: BGMBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the component maps to a property, forwards to purple, otherwise to green.
 *
 * If the component is mapped to a type, this method needs to return true.
 * See the chart at the class javadoc.
 */
public void ying( XSComponent sc, @Nullable XSComponent referer ) {
    if(sc.apply(toPurple)==true || getClassSelector().bindToType(sc,referer)!=null)
        sc.visit(purple);
    else
        sc.visit(green);
}
 
Example 8
Source File: BIProperty.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static BIProperty getDefault( BGMBuilder builder, XSComponent c ) {
    while(c!=null) {
        c = c.apply(defaultCustomizationFinder);
        if(c!=null) {
            BIProperty prop = builder.getBindInfo(c).get(BIProperty.class);
            if(prop!=null)  return prop;
        }
    }

    // default to the global one
    return builder.getGlobalBinding().getDefaultProperty();
}
 
Example 9
Source File: XSFinder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invokes this object as a visitor with the specified component.
 */
public final boolean find( XSComponent c ) {
    return c.apply(this);
}
 
Example 10
Source File: AbstractAxisImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public Iterator<T> iterator(XSComponent contextNode) {
    return contextNode.apply(this);
}
 
Example 11
Source File: AbstractAxisImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public Iterator<T> iterator(XSComponent contextNode) {
    return contextNode.apply(this);
}
 
Example 12
Source File: AbstractAxisImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public Iterator<T> iterator(XSComponent contextNode) {
    return contextNode.apply(this);
}
 
Example 13
Source File: ClassSelector.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real meat of the "bindToType" code.
 *
 * @param cannotBeDelayed
 *      if the binding of the body of the class cannot be defered
 *      and needs to be done immediately. If the flag is false,
 *      the binding of the body will be done later, to avoid
 *      cyclic binding problem.
 * @param referer
 *      The component that refers to <tt>sc</tt>. This can be null,
 *      if figuring out the referer is too hard, in which case
 *      the error message might be less user friendly.
 */
// TODO: consider getting rid of "cannotBeDelayed"
CTypeInfo _bindToClass( @NotNull XSComponent sc, XSComponent referer, boolean cannotBeDelayed ) {
    // check if this class is already built.
    if(!bindMap.containsKey(sc)) {
        // craete a bind task

        // if this is a global declaration, make sure they will be generated
        // under a package.
        boolean isGlobal = false;
        if( sc instanceof XSDeclaration ) {
            isGlobal = ((XSDeclaration)sc).isGlobal();
            if( isGlobal )
                pushClassScope( new CClassInfoParent.Package(
                    getPackage(((XSDeclaration)sc).getTargetNamespace())) );
        }

        // otherwise check if this component should become a class.
        CElement bean = sc.apply(classBinder);

        if( isGlobal )
            popClassScope();

        if(bean==null)
            return null;

        // can this namespace generate a class?
        if (bean instanceof CClassInfo) {
            XSSchema os = sc.getOwnerSchema();
            BISchemaBinding sb = builder.getBindInfo(os).get(BISchemaBinding.class);
            if(sb!=null && !sb.map) {
                // nope
                getErrorReporter().error(sc.getLocator(),
                    Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS, sc.apply( new ComponentNameFunction() ) );
                getErrorReporter().error(sb.getLocation(),
                    Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS_MAP_FALSE, os.getTargetNamespace() );
                if(referer!=null)
                    getErrorReporter().error(referer.getLocator(),
                        Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS_REFERER, referer.apply( new ComponentNameFunction() ) );
            }
        }


        queueBuild( sc, bean );
    }

    Binding bind = bindMap.get(sc);
    if( cannotBeDelayed )
        bind.build();

    return bind.bean;
}
 
Example 14
Source File: XSFinder.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invokes this object as a visitor with the specified component.
 */
public final boolean find( XSComponent c ) {
    return c.apply(this);
}
 
Example 15
Source File: XSFinder.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invokes this object as a visitor with the specified component.
 */
public final boolean find( XSComponent c ) {
    return c.apply(this);
}
 
Example 16
Source File: XSFinder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invokes this object as a visitor with the specified component.
 */
public final boolean find( XSComponent c ) {
    return c.apply(this);
}
 
Example 17
Source File: ClassSelector.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real meat of the "bindToType" code.
 *
 * @param cannotBeDelayed
 *      if the binding of the body of the class cannot be defered
 *      and needs to be done immediately. If the flag is false,
 *      the binding of the body will be done later, to avoid
 *      cyclic binding problem.
 * @param referer
 *      The component that refers to <tt>sc</tt>. This can be null,
 *      if figuring out the referer is too hard, in which case
 *      the error message might be less user friendly.
 */
// TODO: consider getting rid of "cannotBeDelayed"
CTypeInfo _bindToClass( @NotNull XSComponent sc, XSComponent referer, boolean cannotBeDelayed ) {
    // check if this class is already built.
    if(!bindMap.containsKey(sc)) {
        // craete a bind task

        // if this is a global declaration, make sure they will be generated
        // under a package.
        boolean isGlobal = false;
        if( sc instanceof XSDeclaration ) {
            isGlobal = ((XSDeclaration)sc).isGlobal();
            if( isGlobal )
                pushClassScope( new CClassInfoParent.Package(
                    getPackage(((XSDeclaration)sc).getTargetNamespace())) );
        }

        // otherwise check if this component should become a class.
        CElement bean = sc.apply(classBinder);

        if( isGlobal )
            popClassScope();

        if(bean==null)
            return null;

        // can this namespace generate a class?
        if (bean instanceof CClassInfo) {
            XSSchema os = sc.getOwnerSchema();
            BISchemaBinding sb = builder.getBindInfo(os).get(BISchemaBinding.class);
            if(sb!=null && !sb.map) {
                // nope
                getErrorReporter().error(sc.getLocator(),
                    Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS, sc.apply( new ComponentNameFunction() ) );
                getErrorReporter().error(sb.getLocation(),
                    Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS_MAP_FALSE, os.getTargetNamespace() );
                if(referer!=null)
                    getErrorReporter().error(referer.getLocator(),
                        Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS_REFERER, referer.apply( new ComponentNameFunction() ) );
            }
        }


        queueBuild( sc, bean );
    }

    Binding bind = bindMap.get(sc);
    if( cannotBeDelayed )
        bind.build();

    return bind.bean;
}
 
Example 18
Source File: ClassSelector.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The real meat of the "bindToType" code.
 *
 * @param cannotBeDelayed
 *      if the binding of the body of the class cannot be defered
 *      and needs to be done immediately. If the flag is false,
 *      the binding of the body will be done later, to avoid
 *      cyclic binding problem.
 * @param referer
 *      The component that refers to <tt>sc</tt>. This can be null,
 *      if figuring out the referer is too hard, in which case
 *      the error message might be less user friendly.
 */
// TODO: consider getting rid of "cannotBeDelayed"
CTypeInfo _bindToClass( @NotNull XSComponent sc, XSComponent referer, boolean cannotBeDelayed ) {
    // check if this class is already built.
    if(!bindMap.containsKey(sc)) {
        // craete a bind task

        // if this is a global declaration, make sure they will be generated
        // under a package.
        boolean isGlobal = false;
        if( sc instanceof XSDeclaration ) {
            isGlobal = ((XSDeclaration)sc).isGlobal();
            if( isGlobal )
                pushClassScope( new CClassInfoParent.Package(
                    getPackage(((XSDeclaration)sc).getTargetNamespace())) );
        }

        // otherwise check if this component should become a class.
        CElement bean = sc.apply(classBinder);

        if( isGlobal )
            popClassScope();

        if(bean==null)
            return null;

        // can this namespace generate a class?
        if (bean instanceof CClassInfo) {
            XSSchema os = sc.getOwnerSchema();
            BISchemaBinding sb = builder.getBindInfo(os).get(BISchemaBinding.class);
            if(sb!=null && !sb.map) {
                // nope
                getErrorReporter().error(sc.getLocator(),
                    Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS, sc.apply( new ComponentNameFunction() ) );
                getErrorReporter().error(sb.getLocation(),
                    Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS_MAP_FALSE, os.getTargetNamespace() );
                if(referer!=null)
                    getErrorReporter().error(referer.getLocator(),
                        Messages.ERR_REFERENCE_TO_NONEXPORTED_CLASS_REFERER, referer.apply( new ComponentNameFunction() ) );
            }
        }


        queueBuild( sc, bean );
    }

    Binding bind = bindMap.get(sc);
    if( cannotBeDelayed )
        bind.build();

    return bind.bean;
}
 
Example 19
Source File: NameGetter.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Gets the name of the specified component in the default locale.
 * This method is just a wrapper.
 */
public static String get( XSComponent comp ) {
    return (String)comp.apply(theInstance);
}
 
Example 20
Source File: NameGetter.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Gets the name of the specified component in the default locale.
 * This method is just a wrapper.
 */
public static String get( XSComponent comp ) {
    return (String)comp.apply(theInstance);
}