Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlCursor$TokenType


      StringMultiset tagAttributes = tag.getAttributes();

      while (index < size) {
        Token token = tokens.get(index);
        index++;
        TokenType tokenType = token.getType();
        if (ATTRIBUTE == tokenType) {
          String attribute = token.getValue();
          attribute = ignoreCase ? attribute.toLowerCase() : attribute;
          attributes.add(attribute);
          tagAttributes.add(attribute);
        } else if (TAG == tokenType) {
          // Tag closing token
          tag.setDirty(false);
          inTag = false;
          break;
        }
      }
      if (newAttributes && attributes.size() != 0) {
        line.putTag(TAG_ATTRIBUTES, attributes);
      } else if (!newAttributes && attributes.size() == 0) {
        line.putTag(TAG_ATTRIBUTES, null);
      }
    } else {
      line.putTag(TAG_ATTRIBUTES, null);
    }

    while (index < size) {
      Token token = tokens.get(index);
      index++;
      TokenType tokenType = token.getType();
      if (TAG == tokenType) {
        if (inTag) {
          if (">".equals(token.getValue()) || "/>".equals(token.getValue())) {
            // If type is "tag" and content is ">", this is HTML token.
            inTag = false;
          }
        } else {
          // Check that we are in html mode.
          if (CodeMirror2.HTML.equals(token.getMode())) {
            lastTagTokenIndex = index - 1;
            inTag = true;
          }
        }
      }
    }

    if (inTag) {
      if (lastTagTokenIndex != -1) {
        index = lastTagTokenIndex;
        Token token = tokens.get(index);
        index++;
        String tagName = token.getValue().substring(1).trim();
        tag = new HtmlTagWithAttributes(tagName);
        StringMultiset tagAttributes = tag.getAttributes();
        while (index < size) {
          token = tokens.get(index);
          index++;
          TokenType tokenType = token.getType();
          if (ATTRIBUTE == tokenType) {
            String attribute = token.getValue();
            tagAttributes.add(ignoreCase ? attribute.toLowerCase() : attribute);
          }
        }
View Full Code Here


  static boolean buildInvocationSequenceContext(
      JsonArray<Token> tokens, boolean expectingPeriod, JsonArray<String> contextParts) {
    // right-to-left tokens processing loop.
    while (!tokens.isEmpty()) {
      Token lastToken = tokens.pop();
      TokenType lastTokenType = lastToken.getType();
      String lastTokenValue = lastToken.getValue();

      // Omit whitespaces.
      if (lastTokenType == WHITESPACE) {
        continue;
View Full Code Here

    JsonArray<Token> tokens = result.getTokens();
    Token lastToken = tokens.peek();
    Preconditions.checkNotNull(lastToken,
        "Last token expected to be non-null; text='%s', position=%s", text, position);
    TokenType lastTokenType = lastToken.getType();
    String lastTokenValue = lastToken.getValue();
    if (!addSpace) {
      if (lastTokenType == STRING || lastTokenType == REGEXP) {
        return new ExtendedParseResult<T>(result, Context.IN_STRING);
      } else if (lastTokenType == TokenType.COMMENT) {
View Full Code Here

    if (TokenType.WHITESPACE == tokens.get(0).getType()) {
      indent = tokens.get(0).getValue().length();
    }

    Token lastToken = tokens.pop();
    TokenType lastTokenType = lastToken.getType();

    if (lastTokenType == WHITESPACE) {
      return new CompletionContext<T>("", "", false, CompletionType.GLOBAL, parseResult, indent);
    }
View Full Code Here

   
  }
 
  private SubHandling getSubHandling(ExtensibleType actions)
  {
    XmlCursor cursor = actions.newCursor();
    cursor.toChild(PRES_RULES, "sub-handling");
    SubHandlingDocument.SubHandling subHandling = (SubHandlingDocument.SubHandling) cursor.getObject();
   
    if (subHandling.enumValue().equals(SubHandlingDocument.SubHandling.ALLOW))
      return SubHandling.ALLOW;
    else if (subHandling.enumValue().equals(SubHandlingDocument.SubHandling.CONFIRM))
      return SubHandling.CONFIRM;
View Full Code Here

 
  private boolean matchOma(ConditionsType conditions, String subscriberAor)
  {
    try
    {
      XmlCursor cursor = conditions.newCursor();
      cursor.push();
      if (cursor.toChild(OMA_COMMON_POLICY, "external-list"))
      {
        ExternalList list = (ExternalList) cursor.getObject();
        for (int i = 0; i < list.getEntryArray().length; i++)
        {
          String anchor = list.getEntryArray(i).getAnc();
          if (match(anchor, subscriberAor))
            return true;
        }
      }
      cursor.pop();
      if (cursor.toChild(OMA_COMMON_POLICY, "anonymous-request"))
      {
        return subscriberAor.equals("sip:anonymous@anonymous.invalid");
        // TODO add better support to anonymous-request
      }
     
View Full Code Here

  }
 
 
  private boolean matchOmaOtherIdentity(ConditionsType conditions)
  {
    XmlCursor cursor = conditions.newCursor();
    return cursor.toChild(OMA_COMMON_POLICY, "other-identity");
  }
View Full Code Here

      if (_states.size() == 0)
        return null;
      if (_states.size() == 1)
        return _states.get(0);
     
      XmlCursor cursor = null;
      String contentType = null;
      Map<String, String> namespaces = new HashMap<String, String>();
      for (State state : _states)
      {
        XmlObject o = (XmlObject) state.getContent();
        if (cursor == null)
        {
          cursor = o.copy().newCursor();
          cursor.push();
          cursor.toFirstChild();
          cursor.toEndToken();
          contentType = state.getContentType();
        }
        else
        {
          XmlCursor cursor2 = o.newCursor();
          cursor2.toFirstChild(); // Presence
          cursor2.toFirstChild(); // tuple
          cursor2.getAllNamespaces(namespaces);
          do
          {
            add(cursor2, cursor);
          }
          while (cursor2.toNextSibling());
          cursor2.dispose();
        }
      }
      cursor.toParent();
      cursor.toLastAttribute();
      for (String name : namespaces.keySet())
View Full Code Here

    protected WebAppDocument convertToServletSchema(XmlObject xmlObject) throws XmlException {

        String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
        String version = "2.5";
        XmlCursor cursor = xmlObject.newCursor();
        try {
            cursor.toStartDoc();
            cursor.toFirstChild();
            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI())) {
                SchemaConversionUtils.convertSchemaVersion(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version);
                XmlObject result = xmlObject.changeType(WebAppDocument.type);
                XmlBeansUtil.validateDD(result);
                return (WebAppDocument) result;
            }

            if ("http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI())) {
                SchemaConversionUtils.convertSchemaVersion(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version);
                XmlObject result = xmlObject.changeType(WebAppDocument.type);
                XmlBeansUtil.validateDD(result);
                return (WebAppDocument) result;
            }

            //otherwise assume DTD
            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
            String publicId = xmlDocumentProperties.getDoctypePublicId();
            boolean is22 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId);
            if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId) ||
                    is22) {
                XmlCursor moveable = xmlObject.newCursor();
                try {
                    moveable.toStartDoc();
                    moveable.toFirstChild();

                    SchemaConversionUtils.convertToSchema(cursor, SchemaConversionUtils.JAVAEE_NAMESPACE, schemaLocationURL, version);
                    cursor.toStartDoc();
                    cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "web-app");
                    cursor.toFirstChild();
                    SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
                    SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
                    cursor.push();
                    if (cursor.toNextSibling(TAGLIB)) {
                        cursor.toPrevSibling();
                        moveable.toCursor(cursor);
                        cursor.beginElement("jsp-config", SchemaConversionUtils.JAVAEE_NAMESPACE);
                        while (moveable.toNextSibling(TAGLIB)) {
                            moveable.moveXml(cursor);
                        }
                    }
                    cursor.pop();
                    do {
                        String name = cursor.getName().getLocalPart();
                        if ("filter".equals(name) || "servlet".equals(name) || "context-param".equals(name)) {
                            cursor.push();
                            cursor.toFirstChild();
                            SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
                            while (cursor.toNextSibling(SchemaConversionUtils.JAVAEE_NAMESPACE, "init-param")) {
                                cursor.push();
                                cursor.toFirstChild();
                                SchemaConversionUtils.convertToDescriptionGroup(SchemaConversionUtils.JAVAEE_NAMESPACE, cursor, moveable);
                                cursor.pop();
                            }
                            cursor.pop();
                            cursor.push();
                            if (cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "jsp-file")) {
                                String jspFile = cursor.getTextValue();
                                if (!jspFile.startsWith("/")){
                                    if (is22) {
                                        cursor.setTextValue("/" + jspFile);
                                    } else {
                                        throw new XmlException("jsp-file does not start with / and this is not a 2.2 web app: " + jspFile);
                                    }
                                }
                            }
                            cursor.pop();
                        }
                    } while (cursor.toNextSibling());
                } finally {
                    moveable.dispose();
                }
            }
        } finally {
            cursor.dispose();
        }
View Full Code Here

    }
   
    static XmlObject getWebservicesType(URL wsDDUrl) throws DeploymentException {
        try {
            XmlObject webservicesDocumentUntyped = XmlObject.Factory.parse(wsDDUrl);
            XmlCursor cursor = webservicesDocumentUntyped.newCursor();
            try {
                if (cursor.currentTokenType() != XmlCursor.TokenType.START) {
                    while(cursor.toNextToken()  != XmlCursor.TokenType.START) {}
                }
                QName qname = cursor.getName();
                if (WebservicesDocument.type.getDocumentElementName().equals(qname)) {
                    return getJ2EEWebServices(webservicesDocumentUntyped);
                } else if (org.apache.geronimo.xbeans.javaee.WebservicesDocument.type.getDocumentElementName().equals(qname)) {
                    return getJavaEEWebServices(webservicesDocumentUntyped);
                } else {
                    return null;
                }
            } finally {
                cursor.dispose();
            }
        } catch (XmlException e) {
            throw new DeploymentException("Could not read descriptor document", e);
        } catch (IOException e) {
            return null;
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlCursor$TokenType

Copyright © 2018 www.massapicom. 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.