Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7258

findAll{it.name() returns an error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 2.3.9, 2.4.0-rc-2
    • None
    • XML Processing
    • None

    Description

      After a node was added ore changed, findAll

      {it.name() ==.... does not work anymore. -> "groovy.lang.MissingMethodException: No signature of method: java.lang.String.name() is applicable for argument types: () values: [] Possible solutions: take(int), any(), any(groovy.lang.Closure), wait(), dump(), next() error at line: 46" The same code works with groovy 1.8.xxx Example: {code:Java}

      // node where new node have to be inserted into
      def rootNode = records.'**'.findAll

      {it.name() == parentNode1}[0]
      if (parentNode2 != '') {rootNode = rootNode.findAll{it.name() == parentNode2}[0]}
      if (parentNode3 != '') {rootNode = rootNode.findAll{it.name() == parentNode3}[0]}
      if (parentNode4 != '') {rootNode = rootNode.findAll{it.name() == parentNode4}[0]}
      if (parentNode5 != '') {rootNode = rootNode.findAll{it.name() == parentNode5}[0]}
      def childNode = rootNode.children()
      def count = childNode.size()

      if (insertPosition == ''){insertPosition = count}

      if (childNode.find{it.name() == szAttribute})
      {
      rootNode.findAll{it.name() == szAttribute}[0].setValue(szValue)
      AttrModiState = 'MODIFIED'
      }
      else
      { childNode.add(insertPosition.toInteger(), new XmlParser(false,false).parseText('<'+szAttribute+'>'+szValue+'</'+szAttribute+'>')) AttrModiState = 'INSERTED' }
      
      

      rootNode = records.'**'.findAll{it.name() == parentNode1}

      [0] --> line where error occurs

      Attachments

        1. groovy.txt
          3 kB
          Blaha Horst

        Activity

          People

            Unassigned Unassigned
            uniquare Blaha Horst
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: