Package flex2.compiler.mxml.dom

Examples of flex2.compiler.mxml.dom.Node


      {
        Class retType = info.getGetterMethod().getReturnType();

        if (VirtualFile.class.isAssignableFrom(retType))
        {
          VirtualFile file = (VirtualFile) info.getGetterMethod().invoke(targetConfig, (Object[])null);
          if (file != null)
          {
            if (info.doChecksum())
              compile_checksum.append(file.getName());
            link_checksum.append(file.getName());
          }
          continue;
        }
        else if (retType.isArray() && VirtualFile.class.isAssignableFrom(retType.getComponentType()))
        {
          VirtualFile[] files = (VirtualFile[]) info.getGetterMethod().invoke(targetConfig, (Object[])null);
          for (int j = 0; files != null && j < files.length; j++)
          {
            if (files[j] != null)
            {
              if (info.doChecksum())
                compile_checksum.append(files[j].getName());
              link_checksum.append(files[j].getName());
            }
          }
          continue;
        }
      }

      if (args[i] instanceof Object[])
      {
        Object[] a = (Object[]) args[i];
        for (int j = 0; j < a.length; j++)
        {
          if (info.doChecksum())
            compile_checksum.append(a[j]);
          link_checksum.append(a[j]);
        }
      }
      else if (args[i] instanceof List)
      {
        List l = (List) args[i];
        for (int j = 0; j < l.size(); j++)
        {
          if (info.doChecksum())
            compile_checksum.append(l.get(j));
          link_checksum.append(l.get(j));
        }
      }
      else
      {
        if (info.doChecksum())
          compile_checksum.append(args[i]);
        link_checksum.append(args[i]);
      }
    }

    if (info.getGetterMethod() == null)
    {
      // C: need to make sure that all the VirtualFile-based config values should have getters.
      return;
    }

    Class retType = info.getGetterMethod().getReturnType();

    if (VirtualFile.class.isAssignableFrom(retType))
    {
      VirtualFile file = (VirtualFile) info.getGetterMethod().invoke(targetConfig, (Object[])null);
      if (file != null && !file.isDirectory())
      {
        if (info.doChecksum())
          compile_checksum_ts.append(file.getLastModified());
        link_checksum_ts.append(file.getLastModified());
      }
    }
    else if (retType.isArray() && VirtualFile.class.isAssignableFrom(retType.getComponentType()))
    {
      VirtualFile[] files = (VirtualFile[]) info.getGetterMethod().invoke(targetConfig, (Object[])null);
View Full Code Here


    /**
     * Create virtual file for given file and throw configuration exception if not possible
     */
    public static VirtualFile getVirtualFile(String path, boolean reportError) throws ConfigurationException
    {
        VirtualFile result = null;
        File file = new File(path);

        if (file != null && file.exists())
        {
            try
View Full Code Here

    {
            // No need to check to see if the appPath is supported again.
      if ((appPath != null && files[i].getName().equals(appPath.getName())) || isSupported(files[i]))
      {
        String name = files[i].getName();
        VirtualFile pathRoot = calculatePathRoot(files[i]);
        if (pathRoot != null)
        {
                    String relativePath = calculateRelativePath(name);
                    String namespaceURI = relativePath.replace('/', '.');
                    String localPart = calculateLocalPart(name);
View Full Code Here

    Set checkNodes = (Set)unit.getContext().removeAttribute(MxmlCompiler.CHECK_NODES);
    if (checkNodes != null && !checkNodes.isEmpty())
    {
      for (Iterator iter = checkNodes.iterator(); iter.hasNext(); )
      {
        Node node = (Node)iter.next();
        ThreadLocalToolkit.log(new AnalyzerAdapter.CouldNotResolveToComponent(node.image), unit.getSource());
      }
    }
        return ThreadLocalToolkit.errorCount() > 0;
  }
View Full Code Here

       
        assignIndices(node);

        for (int i = 0, count = node.getChildCount(); i < count; i++)
        {
            Node child = (Node) node.getChildAt(i);
            if (child instanceof CDATANode)
            {
                CDATANode cdata = (CDATANode) child;
                if (cdata.image.trim().length() > 0)
                {
                    // C: ignore CDATANode if other XML elements exist...
                    log(child, new XMLBuilder.MixedContent(child.image));
                }
                else
                {
                    // Whitespace is OK
                    serializer.write(cdata.image);
                }
            }
            else
            {
                PrefixMapping.pushNodeNamespace(child, namespaces);

                if (e4xElementsByLocalName != null)
                {
                    StringBuilder e4xbuffer = new StringBuilder(e4xElementsByLocalName);
                    String destProp = child.getLocalPart();
                    if (child.getNamespace().length() > 0)
                    {
                        PrefixMapping pm = namespaces.peek();
                        destProp = "ns" + pm.getNs() + "::" + destProp;
                    }
                    e4xbuffer.append(".").append(destProp).append("[").append(child.getIndex()).append("]");

                    destinationPropertyStack.push(destProp);
                    processNode(child, serializer, e4xbuffer.toString(), destinationPropertyStack, namespaces);
                    destinationPropertyStack.pop();
                }
                else
                {
                    StringBuilder e4xbuffer = new StringBuilder(xmlList.getId());
                    e4xbuffer.append("[").append(i).append("]");

                    destinationPropertyStack.push(child.getLocalPart());
                    processNode(child, serializer, e4xbuffer.toString(), destinationPropertyStack, namespaces);
                    destinationPropertyStack.pop();
                }

                PrefixMapping.popNodeNamespace(namespaces);
View Full Code Here

        Integer zero = IntegerPool.getNumber(0);

        for (int i = 0, count = parent.getChildCount(); i < count; i++)
        {
            Node child = (Node) parent.getChildAt(i);
            if (child instanceof CDATANode)
            {
                continue;
            }

            if (!counts.containsKey(child.image))
            {
                counts.put(child.image, zero);
                child.setIndex(0);
            }
            else
            {
                int num = counts.get(child.image).intValue() + 1;
                counts.put(child.image, IntegerPool.getNumber(num));
                child.setIndex(num);
            }
        }
    }
View Full Code Here

    {
        Map<String, Array> arrays = createArrays(parent, countChildren(node));

        for (int i = 0, count = node.getChildCount(); i < count; i++)
        {
            Node child = (Node)node.getChildAt(i);
            if (child instanceof CDATANode)
            {
                // C: ignore CDATANode if other XML elements exist...
                log(child, new IgnoringCDATA(child.image));
                continue;
            }

            String namespaceURI = child.getNamespace();
            String localPart = child.getLocalPart();

            // C: move this check to Grammar.jj or SyntaxAnalyzer
            if (SymbolTable.OBJECT.equals(localPart) && namespaceURI.length() == 0)
            {
                log(child, new ObjectTag());
                continue;
            }

            Object value = processNode(child);

            if (value == null)
            {
                //  continue;
            }
            else if (arrays.containsKey(localPart))
            {
                Array arrayVal = arrays.get(localPart);
                if (value instanceof BindingExpression)
                {
                    BindingExpression bexpr = (BindingExpression)value;
                    bexpr.setDestination(arrayVal);
                    bexpr.setDestinationProperty(arrayVal.size());
                    bexpr.setDestinationLValue(Integer.toString(arrayVal.size()));
                }
                else if (value instanceof Model)
                {
                    Model valueModel = (Model)value;
                    valueModel.setParent(arrayVal);
                    valueModel.setParentIndex(arrayVal.size());
                }

                arrayVal.addEntry(value, child.beginLine);
            }
            else
            {
                if (value instanceof BindingExpression)
                {
                    BindingExpression bexpr = (BindingExpression)value;
                    bexpr.setDestination(parent);
                    bexpr.setDestinationProperty(localPart);
                    bexpr.setDestinationLValue(localPart);
                }
                else if (value instanceof Model)
                {
                    Model valueModel = (Model)value;
                    valueModel.setParent(parent);
                }

                parent.setProperty(localPart, value, child.beginLine);
            }
        }

        for (int i = 0, count = node.getChildCount(); i < count; i++)
        {
            Node child = (Node)node.getChildAt(i);
            if (child instanceof CDATANode)
            {
                continue;
            }

            String namespaceURI = child.getNamespace();
            String localPart = child.getLocalPart();
            if (SymbolTable.OBJECT.equals(localPart) && namespaceURI.length() == 0)
            {
                continue;
            }
View Full Code Here

            }
        }

        for (int i = 0, count = node.getChildCount(); i < count; i++)
        {
            Node child = (Node)node.getChildAt(i);
            if (child instanceof CDATANode)
            {
                continue;
            }

            String namespaceURI = child.getNamespace();
            String localPart = child.getLocalPart();

            if (SymbolTable.OBJECT.equals(localPart) && namespaceURI.length() == 0)
            {
                continue;
            }
View Full Code Here

        int numCData = 0;
       
        for (int i = 0, count = node.getChildCount(); i < count; i++)
        {
            Node child = (Node) node.getChildAt(i);
            if (child instanceof CDATANode)
            {
              numCData++;
                CDATANode cdata = (CDATANode) child;
               
                if (cdata.image.length() > 0)
                {
                    if (cdata.inCDATA)
                    {
                        //in CDATA Section, leave exactly as is
                        if (e4x)
                        {
                            ((StringWriter) serializer).write("<![CDATA[" + cdata.image + "]]>");
                        }
                        else
                        {
                          try
                          {
                            ((XMLStringSerializer) serializer).writeString(cdata.image);
                          }
                          catch (IOException e)
                            {
                                logError(cdata, e.getLocalizedMessage());
                            }
                        }                       
                    }
                    else
                    {
                        // We're not in CDATA section so extract bindings and cleanup binding escapes
                        BindingExpression be = textParser.parseBindingExpression(cdata.image, cdata.beginLine);
                        if (be != null)
                        {
                            if (be.isTwoWayPrimary() && !allowTwoWayBind)
                            {
                                log(cdata, new AbstractBuilder.TwoWayBindingNotAllowed());
                            }
                            else
                            {
                                be.setDestinationLValue(getElementsByLocalName + ".text()[" + (numCData - 1) + "]");
                                be.setDestinationProperty(destinationProperty + "[" + node.getIndex() + "]" + ".text()[" + i + "]" );
                                be.setDestination(xml);
                                be.setDestinationXMLNode(true);

                                xml.setHasBindings(true);

                                if (e4x)
                                {
                                    be.setDestinationE4X(true);
                                    PrefixMapping.pushNamespaces(be, namespaces);
                                }
                               
                                // Inject placeholder cdata child so we can target it
                                // with binding.
                                ((StringWriter) serializer).write("<![CDATA[" "]]>");
                            }
                        }
                        else if (e4x)
                        {
                            ((StringWriter) serializer).write(TextParser.replaceBindingEscapesForE4X(cdata.image));
                        }
                        else
                        {
                            String text = TextParser.cleanupBindingEscapes(cdata.image);
                            text = TextParser.cleanupAtFunctionEscapes(text);
                            try
                            {
                              ((XMLStringSerializer) serializer).writeString(text);
                            }
                            catch (IOException e)
                            {
                                logError(cdata, e.getLocalizedMessage());
                            }
                        }                       
                    }                   
                }
            }
            else if (e4x)
            {
                PrefixMapping.pushNodeNamespace(child, namespaces);
               
                if (getElementsByLocalName != null)
                {
                    StringBuilder e4xbuffer = new StringBuilder(getElementsByLocalName);
                    String destProp = child.getLocalPart();
                    if (child.getNamespace().length() > 0)
                    {
                        PrefixMapping pm = namespaces.peek();
                        destProp = "ns" + pm.getNs() + "::" + destProp;
                    }
                    e4xbuffer.append(".").append(destProp).append("[").append(child.getIndex()).append("]");

                    destinationProperty.push(destProp);
                    processNode(e4x, child, serializer, e4xbuffer.toString(), destinationProperty, namespaces);
                    destinationProperty.pop();
                }
                else
                {
                    processNode(e4x, child, serializer, xml.getId(), destinationProperty, namespaces);
                }
               
                PrefixMapping.popNodeNamespace(namespaces);
            }
            else
            {
                String classNamespaceUtil = NameFormatter.toDot(standardDefs.CLASS_NAMESPACEUTIL);
                document.addImport(classNamespaceUtil, node.beginLine);

                StringBuilder buffer = new StringBuilder(classNamespaceUtil + ".getElementsByLocalName(");
                buffer.append((getElementsByLocalName == null) ? xml.getId() : getElementsByLocalName);
                buffer.append(", \"").append(child.getLocalPart()).append("\")[").append(child.getIndex()).append("]");

                destinationProperty.push(child.getLocalPart());
                processNode(e4x, child, serializer, buffer.toString(), destinationProperty, null);
                destinationProperty.pop();
            }
        }
    }
View Full Code Here

        Integer zero = IntegerPool.getNumber(0);

        for (int i = 0, count = parent.getChildCount(); i < count; i++)
        {
            Node child = (Node) parent.getChildAt(i);
            if (child instanceof CDATANode)
            {
                continue;
            }

            if (!counts.containsKey(child.image))
            {
                counts.put(child.image, zero);
                child.setIndex(0);
            }
            else
            {
                int num = counts.get(child.image).intValue() + 1;
                counts.put(child.image, IntegerPool.getNumber(num));
                child.setIndex(num);
            }
        }
    }
View Full Code Here

TOP

Related Classes of flex2.compiler.mxml.dom.Node

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.