Beispiel #1
0
  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();
  }
Beispiel #2
0
  /**
   * Derives a name from a schema component.
   *
   * <p>This method handles prefix/suffix modification and XML-to-Java name conversion.
   *
   * @param name The base name. This should be things like element names or type names.
   * @param comp The component from which the base name was taken. Used to determine how names are
   *     modified.
   */
  public String deriveName(String name, XSComponent comp) {
    XSSchema owner = comp.getOwnerSchema();

    name = getNameConverter().toClassName(name);

    if (owner != null) {
      BISchemaBinding sb = getBindInfo(owner).get(BISchemaBinding.class);

      if (sb != null) name = sb.mangleClassName(name, comp);
    }

    return name;
  }
Beispiel #3
0
  /**
   * Gets the BindInfo object associated to a schema component.
   *
   * @return null if no bind info is associated to this schema component.
   */
  private BindInfo _getBindInfoReadOnly(XSComponent schemaComponent) {

    BindInfo bi = externalBindInfos.get(schemaComponent);
    if (bi != null) return bi;

    XSAnnotation annon = schemaComponent.getAnnotation();
    if (annon != null) {
      bi = (BindInfo) annon.getAnnotation();
      if (bi != null) {
        if (bi.getOwner() == null) bi.setOwner(this, schemaComponent);
        return bi;
      }
    }

    return null;
  }
Beispiel #4
0
  public CReferencePropertyInfo createReferenceProperty(
      String defaultName,
      boolean forConstant,
      XSComponent source,
      RawTypeSet types,
      boolean isMixed,
      boolean dummy,
      boolean content,
      boolean isMixedExtended) {

    if (types
        == null) { // this is a special case where we need to generate content because potential
      // subtypes would need to be able to override what's store inside
      content = true;
    } else {
      if (!types.refs.isEmpty())
        // if this property is empty, don't acknowleedge the customization
        // this allows pointless property customization to be reported as an error
        markAsAcknowledged();
    }
    constantPropertyErrorCheck();

    String name = getPropertyName(forConstant);
    if (name == null) name = defaultName;

    CReferencePropertyInfo prop =
        wrapUp(
            new CReferencePropertyInfo(
                name,
                (types == null) ? true : types.getCollectionMode().isRepeated() || isMixed,
                (types == null) ? false : types.isRequired(),
                isMixed,
                source,
                getCustomizations(source),
                source.getLocator(),
                dummy,
                content,
                isMixedExtended),
            source);
    if (types != null) {
      types.addTo(prop);
    }

    BIInlineBinaryData.handle(source, prop);
    return prop;
  }
Beispiel #5
0
  public CValuePropertyInfo createValueProperty(
      String defaultName, boolean forConstant, XSComponent source, TypeUse tu, QName typeName) {

    markAsAcknowledged();
    constantPropertyErrorCheck();

    String name = getPropertyName(forConstant);
    if (name == null) {
      name = defaultName;
      if (tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode())
        name = JJavaName.getPluralForm(name);
    }

    CValuePropertyInfo prop =
        wrapUp(
            new CValuePropertyInfo(
                name, source, getCustomizations(source), source.getLocator(), tu, typeName),
            source);
    BIInlineBinaryData.handle(source, prop);
    return prop;
  }
 public Iterator<T> iterator(XSComponent contextNode) {
   return contextNode.apply(this);
 }
Beispiel #7
0
 /**
  * If the component maps to a property, forwards to purple, otherwise to green.
  *
  * <p>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);
 }