예제 #1
0
 private EdmFunctionParameter.Builder parseEdmFunctionParameter(
     XMLEventReader2 reader, StartElement2 paramStartElement) {
   List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
   Attribute2 modeAttribute = paramStartElement.getAttributeByName("Mode");
   String nullableS = getAttributeValueIfExists(paramStartElement, "Nullable");
   String maxLength = getAttributeValueIfExists(paramStartElement, "MaxLength");
   String precision = getAttributeValueIfExists(paramStartElement, "Precision");
   String scale = getAttributeValueIfExists(paramStartElement, "Scale");
   while (reader.hasNext()) {
     XMLEvent2 event = reader.nextEvent();
     if (event.isStartElement()) {
       EdmAnnotation<?> anElement = getAnnotationElements(event, reader);
       if (anElement != null) {
         annotElements.add(anElement);
       }
     }
     if (isEndElement(event, paramStartElement.getName())) {
       return EdmFunctionParameter.newBuilder()
           .setName(paramStartElement.getAttributeByName("Name").getValue())
           .setType(
               EdmType.newDeferredBuilder(
                   paramStartElement.getAttributeByName("Type").getValue(), dataServices))
           .setMode(modeAttribute != null ? Mode.valueOf(modeAttribute.getValue()) : null)
           .setNullable(nullableS == null ? null : "true".equalsIgnoreCase(nullableS))
           .setMaxLength(
               maxLength == null
                   ? null
                   : maxLength.equals("Max") ? Integer.MAX_VALUE : Integer.parseInt(maxLength))
           .setPrecision(precision == null ? null : Integer.parseInt(precision))
           .setScale(scale == null ? null : Integer.parseInt(scale))
           .setAnnotations(getAnnotations(paramStartElement))
           .setAnnotationElements(annotElements);
     }
   }
   throw new UnsupportedOperationException();
 }
예제 #2
0
  private EdmProperty.Builder parseEdmProperty(XMLEventReader2 reader, XMLEvent2 event) {
    List<EdmAnnotation<?>> annotElements = new ArrayList<EdmAnnotation<?>>();
    StartElement2 startElement = event.asStartElement();
    String propertyName = getAttributeValueIfExists(startElement, "Name");
    String propertyType = getAttributeValueIfExists(startElement, "Type");
    String propertyNullable = getAttributeValueIfExists(startElement, "Nullable");
    String maxLength = getAttributeValueIfExists(startElement, "MaxLength");
    String unicode = getAttributeValueIfExists(startElement, "Unicode");
    String fixedLength = getAttributeValueIfExists(startElement, "FixedLength");
    String collation = getAttributeValueIfExists(startElement, "Collation");
    String collectionKindS = getAttributeValueIfExists(startElement, "CollectionKind");
    CollectionKind ckind = CollectionKind.NONE;
    if (collectionKindS != null) {
      ckind = Enum.valueOf(CollectionKind.class, collectionKindS);
    }
    String defaultValue = getAttributeValueIfExists(startElement, "DefaultValue");
    String precision = getAttributeValueIfExists(startElement, "Precision");
    String scale = getAttributeValueIfExists(startElement, "Scale");

    String storeGeneratedPattern =
        getAttributeValueIfExists(
            startElement, new QName2(NS_EDMANNOTATION, "StoreGeneratedPattern"));
    String concurrencyMode = getAttributeValueIfExists(startElement, "ConcurrencyMode");

    String mimeType = getAttributeValueIfExists(startElement, M_MIMETYPE);
    String fcTargetPath = getAttributeValueIfExists(startElement, M_FC_TARGETPATH);
    String fcContentKind = getAttributeValueIfExists(startElement, M_FC_CONTENTKIND);
    String fcKeepInContent = getAttributeValueIfExists(startElement, M_FC_KEEPINCONTENT);
    String fcEpmContentKind = getAttributeValueIfExists(startElement, M_FC_EPMCONTENTKIND);
    String fcEpmKeepInContent = getAttributeValueIfExists(startElement, M_FC_EPMKEEPINCONTENT);
    String fcNsPrefix = getAttributeValueIfExists(startElement, M_FC_NSPREFIX);
    String fcNsUri = getAttributeValueIfExists(startElement, M_FC_NSURI);

    while (reader.hasNext()) {
      XMLEvent2 event2 = reader.nextEvent();

      if (event2.isStartElement()) {
        EdmAnnotation<?> anElement = getAnnotationElements(event2, reader);
        if (anElement != null) {
          annotElements.add(anElement);
        }
      }

      if (isEndElement(event2, startElement.getName())) {
        return EdmProperty.newBuilder(propertyName)
            .setType(EdmType.newDeferredBuilder(propertyType, dataServices))
            .setNullable("true".equalsIgnoreCase(propertyNullable))
            .setMaxLength(
                maxLength == null
                    ? null
                    : maxLength.equals("Max") ? Integer.MAX_VALUE : Integer.parseInt(maxLength))
            .setUnicode(unicode == null ? null : "true".equalsIgnoreCase(unicode))
            .setFixedLength(fixedLength == null ? null : "true".equalsIgnoreCase(fixedLength))
            .setCollation(collation)
            .setConcurrencyMode(concurrencyMode)
            .setStoreGeneratedPattern(storeGeneratedPattern)
            .setMimeType(mimeType)
            .setFcTargetPath(fcTargetPath)
            .setFcContentKind(fcContentKind)
            .setFcKeepInContent(fcKeepInContent)
            .setFcEpmContentKind(fcEpmContentKind)
            .setFcEpmKeepInContent(fcEpmKeepInContent)
            .setFcNsPrefix(fcNsPrefix)
            .setFcNsUri(fcNsUri)
            .setCollectionKind(ckind)
            .setDefaultValue(defaultValue)
            .setPrecision(precision == null ? null : Integer.parseInt(precision))
            .setScale(scale == null ? null : Integer.parseInt(scale))
            .setAnnotations(getAnnotations(startElement))
            .setAnnotationElements(annotElements.isEmpty() ? null : annotElements);
      }
    }
    throw new UnsupportedOperationException();
  }