Examples of CMDataType


Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

      return;
    }

    // attribute name
    String attributeName = getRequiredName(ownerNode, attrDecl);
    CMDataType attrType = attrDecl.getAttrType();
    String defaultValue = null;
    // = sign
    buffer.append(attributeName + "="); //$NON-NLS-1$
    // attribute value
    if (attrType != null) {
      // insert any value that is implied
      if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (attrType.getImpliedValue() != null)) {
        defaultValue = attrType.getImpliedValue();
      }
      // otherwise, if an enumerated list of values exists, use the
      // first value
      else if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) {
        defaultValue = attrType.getEnumeratedValues()[0];
      }
    }
   
    char attrQuote = '\"';
    // Found a double quote, wrap the attribute in single quotes
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

                  // out.

                  //BUG214516/196544 - Fixed NPE that was caused by an attr having
                  // a null attr type
                  String defaultValue = null;
                  CMDataType attrType = attributeDeclaration.getAttrType();
                  if (attrType != null) {
                    if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && attrType.getImpliedValue() != null)
                      defaultValue = attrType.getImpliedValue();
                    else if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) {
                      defaultValue = attrType.getEnumeratedValues()[0];
                    }
                  }

                  // xml:space="preserve" means preserve
                  // space,
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

    if (attr == null)
      return false;
    CMAttributeDeclaration decl = CMNodeUtil.getAttributeDeclaration(attr);
    if (decl == null)
      return false;
    CMDataType type = decl.getAttrType();
    if (type == null)
      return false;
    String values[] = type.getEnumeratedValues();
    if (values == null)
      return false;
    return (values.length == 1 && values[0].equals(decl.getAttrName()));
  }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

    if (parent.getNodeType() == Node.ELEMENT_NODE) {
      CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
      if (parentDecl != null) {
        // XSD-specific ability - no filtering
        CMDataType childType = parentDecl.getDataType();
        if (childType != null) {
          String[] childStrings = childType.getEnumeratedValues();
          String defaultValue = childType.getImpliedValue();
          if (childStrings != null || defaultValue != null) {
            // the content string is the sole valid child...so replace the rest
            int begin = contentAssistRequest.getReplacementBeginPosition();
            int length = contentAssistRequest.getReplacementLength();
            if (parent instanceof IDOMNode) {
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

          }
        }
        // Then, the value must be checked.
        if (state == ErrorState.NONE_ERROR) { // Need more check.
          // Now, the value should be checked, if the type is ENUM.
          CMDataType attrType = adec.getAttrType();
          String actualValue = a.getValue();
          if (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) {
            // Check FIXED value.
            String validValue = attrType.getImpliedValue();
            if (!actualValue.equals(validValue)) {
              rgnType = REGION_VALUE;
              state = ErrorState.UNDEFINED_VALUE_ERROR;
            }
          }
          else if (CMDataType.URI.equals(attrType.getDataTypeName())) {
            // TODO: URI validation?
            if (false && actualValue.indexOf('#') < 0 && actualValue.indexOf(":/") == -1 && CMUtil.isHTML(edec)) { //$NON-NLS-1$ //$NON-NLS-2$
              IStructuredDocumentRegion start = ((IDOMNode) node).getStartStructuredDocumentRegion();
              if (start != null && start.getFirstRegion().getTextLength() == 1) {
                IPath basePath = new Path(((IDOMNode) node).getModel().getBaseLocation());
                if (basePath.segmentCount() > 1) {
                  IPath path = ModuleCoreSupport.resolve(basePath, actualValue);
                  IResource found = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
                  if (found == null || !found.isAccessible()) {
                    rgnType = REGION_VALUE;
                    state = ErrorState.RESOURCE_NOT_FOUND;
                  }
                }
              }
            }
          }
          else if (CMDataType.ENUM.equals(attrType.getDataTypeName())) {
            /*
             * Check current value is valid among a known list.
             * There may be enumerated values provided even when
             * the datatype is not ENUM, but we'll only validate
             * against that list if the type matches.
             */
            String[] enumeratedValues = attrType.getEnumeratedValues();
            // several candidates are found.
            boolean found = false;
            for (int j = 0; j < enumeratedValues.length; j++) {
              // At 1st, compare ignoring case.
              if (actualValue.equalsIgnoreCase(enumeratedValues[j])) {
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

   * (1) value type is ENUM,
   * (2) only one value is defined in the enumeration,
   * (3) the value has same name to the attribute name.
   */
  public static boolean isBooleanAttr(CMAttributeDeclaration adec) {
    CMDataType attrtype = adec.getAttrType();
    if (attrtype == null)
      return false;
    if (attrtype.getDataTypeName() != CMDataType.ENUM)
      return false;
    String[] values = attrtype.getEnumeratedValues();
    if (values.length != 1)
      return false;
    return values[0].equals(adec.getAttrName());
  }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

          }
        }
        // Then, the value must be checked.
        if (state == ErrorState.NONE_ERROR) { // Need more check.
          // Now, the value should be checked, if the type is ENUM.
          CMDataType attrType = adec.getAttrType();
          if (a instanceof IDOMAttr) {
            final ITextRegion region = ((IDOMAttr) a).getEqualRegion();
            if (region == null) {
              rgnType = REGION_NAME;
              state = ErrorState.MISSING_ATTR_VALUE_EQUALS_ERROR;
            }
          }
          String actualValue = a.getValue();
          if (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) {
            // Check FIXED value.
            String validValue = attrType.getImpliedValue();
            if (!actualValue.equals(validValue)) {
              rgnType = REGION_VALUE;
              state = ErrorState.UNDEFINED_VALUE_ERROR;
            }
          }
          else if (CMDataType.URI.equals(attrType.getDataTypeName())) {
            // TODO: URI validation?
            if (false && actualValue.indexOf('#') < 0 && actualValue.indexOf(":/") == -1 && CMUtil.isHTML(edec)) { //$NON-NLS-1$ //$NON-NLS-2$
              IStructuredDocumentRegion start = ((IDOMNode) node).getStartStructuredDocumentRegion();
              if (start != null && start.getFirstRegion().getTextLength() == 1) {
                IPath basePath = new Path(((IDOMNode) node).getModel().getBaseLocation());
                if (basePath.segmentCount() > 1) {
                  IPath path = ModuleCoreSupport.resolve(basePath, actualValue);
                  IResource found = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
                  if (found == null || !found.isAccessible()) {
                    rgnType = REGION_VALUE;
                    state = ErrorState.RESOURCE_NOT_FOUND;
                  }
                }
              }
            }
          }
          else if (CMDataType.ENUM.equals(attrType.getDataTypeName())) {
            /*
             * Check current value is valid among a known list.
             * There may be enumerated values provided even when
             * the datatype is not ENUM, but we'll only validate
             * against that list if the type matches.
             */
            String[] enumeratedValues = attrType.getEnumeratedValues();
            // several candidates are found.
            boolean found = false;
            for (int j = 0; j < enumeratedValues.length; j++) {
              // At 1st, compare ignoring case.
              if (actualValue.equalsIgnoreCase(enumeratedValues[j])) {
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

                  // out.

                  //BUG214516/196544 - Fixed NPE that was caused by an attr having
                  // a null attr type
                  String defaultValue = null;
                  CMDataType attrType = attributeDeclaration.getAttrType();
                  if (attrType != null) {
                    if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && attrType.getImpliedValue() != null)
                      defaultValue = attrType.getImpliedValue();
                    else if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) {
                      defaultValue = attrType.getEnumeratedValues()[0];
                    }
                  }

                  // xml:space="preserve" means preserve
                  // space,
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

      }
    }

    if (value == null)
    {
      CMDataType dataType = ad.getAttrType();
      if (dataType != null)
      {
        value = getValue(dataType);
      }
    }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType

     

  public boolean isValidEmptyValue(CMAttributeDeclaration ad)
  {   
    boolean result = true;
    CMDataType dataType = ad.getAttrType();
    if (dataType != null)
    {                                                         
      String propertyValue = (String)dataType.getProperty("isValidEmptyValue"); //$NON-NLS-1$
      if (propertyValue != null && propertyValue.equals("false")) //$NON-NLS-1$
      {
        result = false;
      }
    }  
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.