Method findAndReplaceSimpleElement.

@param counter
@param defaultValue
@param text
@param name
@param parent
320692
protected Element findAndReplaceSimpleElement(Counter counter, Element parent, String name, String text,
            String defaultValue)
   {
      if ((defaultValue != null) && (text != null) && defaultValue.equals(text))
      {
         Element element = parent.getChild(name, parent.getNamespace());
         // if exist and is default value or if doesn't exist.. just keep the
         // way it is..
         if (((element != null) && defaultValue.equals(element.getText())) || (element == null))
         {
            return element;
         }
      }

      boolean shouldExist = (text != null) && (text.trim().length() > 0);
      Element element = updateElement(counter, parent, name, shouldExist);
      if (shouldExist)
      {
         element.setText(text);
      }
      return element;
   }
431977
protected void updateActivationOS(ActivationOS value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null);
         findAndReplaceSimpleElement(innerCount, root, "family", value.getFamily(), null);
         findAndReplaceSimpleElement(innerCount, root, "arch", value.getArch(), null);
         findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
      }
   }
483260
protected void updatePlugin(Plugin value, String xmlTag, Counter counter, Element element)
   {
      Element root = element;
      Counter innerCount = new Counter(counter.getDepth() + 1);
      findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins");
      findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
      findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
      findAndReplaceSimpleElement(innerCount, root, "extensions",
               (value.isExtensions() == false) ? null : String.valueOf(value.isExtensions()), "false");
      iteratePluginExecution(innerCount, root, value.getExecutions(), "executions", "execution");
      iterateDependency(innerCount, root, value.getDependencies(), "dependencies", "dependency");
      findAndReplaceXpp3DOM(innerCount, root, "goals", (Xpp3Dom) value.getGoals());
      findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null);
      findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration());
   }
326477
protected void updateReportSet(ReportSet value, String xmlTag, Counter counter, Element element)
   {
      Element root = element;
      Counter innerCount = new Counter(counter.getDepth() + 1);
      findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), "default");
      findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration());
      findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null);
      findAndReplaceSimpleLists(innerCount, root, value.getReports(), "reports", "report");
   }
506035
function (name, step) {
            if (this._counters.hasOwnProperty(name)) {
                this._counters[name] += (step || 1);
            } else {
                this._counters[name] = (step || 1);
            }
        }
589808
function (el, parentNode) {
                    // updates the text of the text node
                    update = function (newVal) {
                        node.nodeValue = "" + newVal;
                        teardownCheck(node.parentNode);
                    };

                    var parent = getParentNode(el, parentNode),
                        node = document.createTextNode(binding.value);

                    // When iterating through an Observe.List with no DOM
                    // elements containing the individual items, the parent
                    // is sometimes incorrect not the true parent of the
                    // source element. (#153)
                    if (el.parentNode !== parent) {
                        parent = el.parentNode;
                        parent.insertBefore(node, el);
                        parent.removeChild(el);
                    } else {
                        parent.insertBefore(node, el);
                        parent.removeChild(el);
                    }
                    setupTeardownOnDestroy(parent);
                }
1159086
protected void updateReportPlugin(ReportPlugin value, String xmlTag, Counter counter, Element element)
   {
      Element root = element;
      Counter innerCount = new Counter(counter.getDepth() + 1);
      findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins");
      findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
      findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
      findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null);
      findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration());
      iterateReportSet(innerCount, root, value.getReportSets(), "reportSets", "reportSet");
   }
496364
protected void updateModel(Model value, String xmlTag, Counter counter, Element element)
   {
      Element root = element;
      Counter innerCount = new Counter(counter.getDepth() + 1);
      updateParent(value.getParent(), "parent", innerCount, root);
      findAndReplaceSimpleElement(innerCount, root, "modelVersion", value.getModelVersion(), null);
      findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null);
      findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
      findAndReplaceSimpleElement(innerCount, root, "packaging", value.getPackaging(), "jar");
      findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null);
      findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
      findAndReplaceSimpleElement(innerCount, root, "description", value.getDescription(), null);
      findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null);
      updatePrerequisites(value.getPrerequisites(), "prerequisites", innerCount, root);
      updateIssueManagement(value.getIssueManagement(), "issueManagement", innerCount, root);
      updateCiManagement(value.getCiManagement(), "ciManagement", innerCount, root);
      findAndReplaceSimpleElement(innerCount, root, "inceptionYear", value.getInceptionYear(), null);
      iterateMailingList(innerCount, root, value.getMailingLists(), "mailingLists", "mailingList");
      iterateDeveloper(innerCount, root, value.getDevelopers(), "developers", "developer");
      iterateContributor(innerCount, root, value.getContributors(), "contributors", "contributor");
      iterateLicense(innerCount, root, value.getLicenses(), "licenses", "license");
      updateScm(value.getScm(), "scm", innerCount, root);
      updateOrganization(value.getOrganization(), "organization", innerCount, root);
      updateBuild(value.getBuild(), "build", innerCount, root);
      iterateProfile(innerCount, root, value.getProfiles(), "profiles", "profile");
      findAndReplaceSimpleLists(innerCount, root, value.getModules(), "modules", "module");
      iterateRepository(innerCount, root, value.getRepositories(), "repositories", "repository");
      iterateRepository(innerCount, root, value.getPluginRepositories(), "pluginRepositories", "pluginRepository");
      iterateDependency(innerCount, root, value.getDependencies(), "dependencies", "dependency");
      findAndReplaceXpp3DOM(innerCount, root, "reports", (Xpp3Dom) value.getReports());
      updateReporting(value.getReporting(), "reporting", innerCount, root);
      updateDependencyManagement(value.getDependencyManagement(), "dependencyManagement", innerCount, root);
      updateDistributionManagement(value.getDistributionManagement(), "distributionManagement", innerCount, root);
      findAndReplaceProperties(innerCount, root, "properties", value.getProperties());
   }
88246
public int findPropertyValueAsIntWithDefault(String name, int defVal) {
        return properties().stream()
                .filter(p->name.equals(p.getName()))
                .map(CreatorProperty::getLatestValueAsInt)
                .findFirst().orElse(defVal);
    }
911518
@Override
	public void defineEntityReplacementText(String entity, String value) {
		if (processDocDecl) {
			throw new IllegalStateException("Entity replacement text may not be defined with DOCTYPE processing enabled.");
		}
		if (reader == null) {
			throw new IllegalStateException("Entity replacement text must be defined after setInput()");
		}
		if (documentEntities == null) {
			documentEntities = new HashMap<String, char[]>();
		}
		documentEntities.put(entity, value.toCharArray());
	}
662300
@Override
  public Counter counter(String name) {
    final com.codahale.metrics.Counter counter = registry.counter(name);
    return new Counter() {
      @Override
      public void inc() {
        counter.inc();
      }

      @Override
      public void dec() {
        counter.dec();
      }
    };
  }
1341939
function repeat_elements_fix_clone($i, $elementclone, &$namecloned) {
        $name = $elementclone->getName();
        $namecloned[] = $name;

        if (!empty($name)) {
            $elementclone->setName($name."[$i]");
        }

        if (is_a($elementclone, 'HTML_QuickForm_header')) {
            $value = $elementclone->_text;
            $elementclone->setValue(str_replace('{no}', ($i+1), $value));

        } else if (is_a($elementclone, 'HTML_QuickForm_submit') || is_a($elementclone, 'HTML_QuickForm_button')) {
            $elementclone->setValue(str_replace('{no}', ($i+1), $elementclone->getValue()));

        } else {
            $value=$elementclone->getLabel();
            $elementclone->setLabel(str_replace('{no}', ($i+1), $value));
        }
    }
388438
function (name, reason) {
            if (!this._counters[name]) {
                return;
            }

            if (!this._counterSplits[name]) {
                this._counterSplits[name] = [];
            }

            this._counterSplits[name].push({
                value : this._counters[name],
                reason : reason
            });

            this._counters[name] = 0;
        }
1133475
@Nullable
    @Override
    public DefaultQuery<I, D> doFindCounterExample(A hypothesis, Collection<? extends I> inputs) throws
                                                                                               ModelCheckingException {
        final DefaultQuery<I, D> result = propertyOracle.findCounterExample(hypothesis, inputs);
        if (result != null) {
            LOGGER.logEvent("Spurious counterexample found for property: '" + toString() + "'");
            LOGGER.logCounterexample("Spurious counterexample: " + result);
        }
        return result;
    }
1175423
protected Element findAndReplaceSimpleLists(Counter counter, Element parent, java.util.Collection list,
            String parentName, String childName)
   {
      boolean shouldExist = (list != null) && (list.size() > 0);
      Element element = updateElement(counter, parent, parentName, shouldExist);
      if (shouldExist)
      {
         Iterator it = list.iterator();
         Iterator elIt = element.getChildren(childName, element.getNamespace()).iterator();
         if (!elIt.hasNext())
         {
            elIt = null;
         }

         Counter innerCount = new Counter(counter.getDepth() + 1);
         while (it.hasNext())
         {
            String value = (String) it.next();
            Element el;
            if ((elIt != null) && elIt.hasNext())
            {
               el = (Element) elIt.next();
               if (!elIt.hasNext())
               {
                  elIt = null;
               }
            }
            else
            {
               el = factory.element(childName, element.getNamespace());
               insertAtPreferredLocation(element, el, innerCount);
            }
            el.setText(value);
            innerCount.increaseCount();
         }
         if (elIt != null)
         {
            while (elIt.hasNext())
            {
               elIt.next();
               elIt.remove();
            }
         }
      }
      return element;
   }
512075
protected void updateDeploymentRepository(DeploymentRepository value, String xmlTag, Counter counter,
            Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleElement(innerCount, root, "uniqueVersion",
                  (value.isUniqueVersion() == true) ? null : String.valueOf(value.isUniqueVersion()), "true");
         findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null);
         findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null);
         findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null);
         findAndReplaceSimpleElement(innerCount, root, "layout", value.getLayout(), "default");
      }
   }
856397
protected void updatePatternSet(PatternSet value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleLists(innerCount, root, value.getIncludes(), "includes", "include");
         findAndReplaceSimpleLists(innerCount, root, value.getExcludes(), "excludes", "exclude");
      }
   }