コード例 #1
0
  public static FacetValue getEnterpriseFacetValue(final XSDSimpleTypeDefinition startingType) {
    FacetValue fv = new FacetValue();

    final XSDSimpleTypeDefinition definingEnterpriseType = getDefiningEnterpriseType(startingType);
    fv.type = startingType;
    EnterpriseDatatypeInfo edi =
        ModelerCore.getWorkspaceDatatypeManager().getEnterpriseDatatypeInfo(definingEnterpriseType);
    fv.value = edi.getRuntimeType();

    if (startingType == definingEnterpriseType) {
      // this "facet" set in the specified type, so it is not default.
      // check parent for real default:
      final XSDSimpleTypeDefinition dftDefiner =
          getDefiningEnterpriseType(definingEnterpriseType.getBaseTypeDefinition());
      EnterpriseDatatypeInfo ediDft =
          ModelerCore.getWorkspaceDatatypeManager().getEnterpriseDatatypeInfo(dftDefiner);
      fv.defaultValue = ediDft.getRuntimeType();
      // set a fake facet to allow inherited checks to work:
      fv.facet =
          new XSDConstrainingFacetImpl() {
            @Override
            public String getFacetName() {
              return "This is not a real facet!"; //$NON-NLS-1$
            }

            @Override
            public XSDConcreteComponent getContainer() {
              return dftDefiner;
            }
          }; // endanon
    } else {
      // facet set by a parent, so it is default:
      fv.defaultValue = fv.value;
      // set a fake facet to allow inherited checks to work:
      fv.facet =
          new XSDConstrainingFacetImpl() {
            @Override
            public String getFacetName() {
              return "This is not a real facet!"; //$NON-NLS-1$
            }

            @Override
            public XSDConcreteComponent getContainer() {
              return definingEnterpriseType;
            }
          }; // endanon
    } // endif

    Boolean rtFixed = edi.getRuntimeTypeFixed();
    if (rtFixed != null) {
      fv.isFixedLocal = rtFixed.booleanValue();
    } // endif -- fixed null

    return fv;
  }
コード例 #2
0
  public static boolean isSubtypeOf(
      XSDSimpleTypeDefinition startFrom, XSDSimpleTypeDefinition lookFor) {
    XSDSimpleTypeDefinition current = startFrom;
    XSDSimpleTypeDefinition root = startFrom.getRootTypeDefinition();

    while (current != root) {
      if (current == lookFor) {
        return true;
      } // endif
      current = current.getBaseTypeDefinition();
    } // endwhile

    return false;
  }
コード例 #3
0
  private static XSDSimpleTypeDefinition getDefiningEnterpriseType(
      XSDSimpleTypeDefinition simpleType) {
    XSDSimpleTypeDefinition root = simpleType.getRootTypeDefinition();
    XSDSimpleTypeDefinition rv = root; // if nothing else is found, root will be right.

    while (simpleType != root) {
      if (ModelerCore.getWorkspaceDatatypeManager().isEnterpriseDatatype(simpleType)) {
        rv = simpleType;
        break;
      } // endif

      // try the parent:
      simpleType = simpleType.getBaseTypeDefinition();
    } // endwhile

    return rv;
  }
コード例 #4
0
  private Object[] getXSDSimpleTypeDefinitionChildren_ATOMIC(XSDSimpleTypeDefinition parent) {
    ArrayList<Object> list = new ArrayList<Object>();
    // add Base Type if not a pre-defined type
    if (parent != null
        && parent.getSchema() != null
        && parent.getSchema().getSchemaForSchema() != null) {
      if (!parent.getSchema().getSchemaForSchema().getTypeDefinitions().contains(parent)) {
        list.add(parent.getBaseTypeDefinition());
      }
    }

    if (!Util.isBuildInType(parent)) {
      list.addAll(parent.getFacetContents());
    }

    return list.toArray(new Object[list.size()]);
  }
コード例 #5
0
  public static boolean needsNumeric(XSDSimpleTypeDefinition simpleType) {
    // check main first:
    if (ModelerCore.getWorkspaceDatatypeManager().isNumeric(simpleType)) return true;

    // above only checks against decimal:
    XSDSimpleTypeDefinition base = simpleType.getBaseTypeDefinition();

    if (base != null) {
      String basename = base.getName();
      for (int i = 0; i < NUMERIC_TYPES.length; i++) {
        String numericTypeName = NUMERIC_TYPES[i];
        if (numericTypeName.equalsIgnoreCase(basename)) {
          return true;
        } // endif
      } // endfor
    } // endif

    return false;
  }
コード例 #6
0
 private Object[] getXSDSimpleTypeDefinitionChildren_LIST(XSDSimpleTypeDefinition parent) {
   // FIXME: How do we indicate it is a LIST?
   return new XSDSimpleTypeDefinition[] {parent.getBaseTypeDefinition()};
 }