rewrites the atom to one with relation variable
@param parentAtom parent atom that triggers rewrite
@return rewritten atom
16100
private AttributeAtom rewriteWithRelationVariable(Atom parentAtom){
        if (parentAtom.isResource() && ((AttributeAtom) parentAtom).getRelationVariable().isReturned()) return rewriteWithRelationVariable();
        return this;
    }
838331
def write_parent (self, url_data):
        """"""
        self.write(self.part('parenturl') + self.spaces("parenturl"))
        txt = url_data.parent_url
        if url_data.line > 0:
            txt += _(", line %d") % url_data.line
        if url_data.column > 0:
            txt += _(", col %d") % url_data.column
        if url_data.page > 0:
            txt += _(", page %d") % url_data.page
        self.writeln(txt, color=self.colorparent)
758089
@Override
    protected InfixExpression createCorrectOddnessCheck(ASTRewrite rewrite, Expression numberExpression) {
        Assert.isNotNull(rewrite);
        Assert.isNotNull(numberExpression);

        final AST ast = rewrite.getAST();
        InfixExpression andOddnessCheck = ast.newInfixExpression();
        ParenthesizedExpression parenthesizedExpression = ast.newParenthesizedExpression();
        InfixExpression andExpression = ast.newInfixExpression();

        andExpression.setLeftOperand((Expression) rewrite.createMoveTarget(numberExpression));
        andExpression.setOperator(AND);
        andExpression.setRightOperand(ast.newNumberLiteral("1"));
        parenthesizedExpression.setExpression(andExpression);
        andOddnessCheck.setLeftOperand(parenthesizedExpression);
        andOddnessCheck.setOperator(EQUALS);
        andOddnessCheck.setRightOperand(ast.newNumberLiteral("1"));

        return andOddnessCheck;

    }
552944
@Override
    public Node getParentNode(String parentNodeId)
    {
        NodeLink link = new NodeLink(parentNodeId, getNodeId());

        if (this.parents == null)
        {
            return null;
        }
        else
        {
            return this.parents.get(link);
        }
    }
894894
@Override
    public IAtomContainer containerFromPermutation(int[] permutation) {
        try {
            IAtomContainer permutedContainer = (IAtomContainer) atomContainer.clone();
            IAtom[] atoms = new IAtom[atomContainer.getAtomCount()];
            for (int i = 0; i < atomContainer.getAtomCount(); i++) {
                atoms[permutation[i]] = permutedContainer.getAtom(i);
            }
            permutedContainer.setAtoms(atoms);
            return permutedContainer;
        } catch (CloneNotSupportedException c) {
            return null;
        }
    }
490900
public static void rewriteContent(@NotNull Element parent, @NotNull RewriteContentHandler rewriteContentHandler) {

    // iterate through content list and build new content list
    List<Content> originalContent = parent.getContent();
    List<Content> newContent = new ArrayList<Content>();
    for (Content contentElement : originalContent) {

      // handle element
      if (contentElement instanceof Element) {
        Element element = (Element)contentElement;

        // check if rewrite is needed for element
        List<Content> rewriteContent = rewriteContentHandler.rewriteElement(element);
        if (rewriteContent != null) {
          // element was removed
          if (rewriteContent.isEmpty()) {
            // do not add to newContent
          }

          // element is the same - rewrite child elements
          else if (rewriteContent.size() == 1 && rewriteContent.get(0) == element) { //NOPMD
            rewriteContent(element, rewriteContentHandler);
            newContent.add(element);
          }

          // element was replaced with other content - rewrite and add instead
          else {
            for (Content newContentItem : rewriteContent) {
              if (newContentItem instanceof Element) {
                Element newElement = (Element)newContentItem;
                rewriteContent(newElement, rewriteContentHandler);
              }
              newContent.add(newContentItem.clone());
            }
          }
        }

        // nothing to rewrite - do nothing, but rewrite child element
        else {
          rewriteContent(element, rewriteContentHandler);
          newContent.add(element);
        }

      }

      // handle text node
      else if (contentElement instanceof Text) {
        Text text = (Text)contentElement;

        // check if rewrite is needed for text node
        List<Content> rewriteContent = rewriteContentHandler.rewriteText(text);
        if (rewriteContent != null) {
          // element was removed
          if (rewriteContent.isEmpty()) {
            // do not add to newContent
          }

          // element is the same - ignore
          else if (rewriteContent.size() == 1 && rewriteContent.get(0) == text) { //NOPMD
            // add original element
            newContent.add(text);
          }

          // element was replaced with other content - add instead
          else {
            for (Content newContentItem : rewriteContent) {
              newContent.add(newContentItem.clone());
            }
          }
        }

        // nothing to rewrite - do nothing, but add original text element
        else {
          newContent.add(text);
        }

      }

      // unknown element - just add to new content
      else {
        newContent.add(contentElement);
      }

    }

    // replace original content with new content
    parent.removeContent();
    parent.addContent(newContent);

  }
938575
public static final Atom[] getAtomArray(Atom[] ca,List<Group> hetatms ) throws StructureException{
		List<Atom> atoms = new ArrayList<Atom>();
		Collections.addAll(atoms, ca);

		logger.debug("got {} hetatoms", hetatms.size());

		// we only add atom nr 1, since the getAlignedStructure method actually adds the parent group, and not the atoms...
		for (Group g : hetatms){
			if (g.size() < 1)
				continue;
			//if (debug)
			//   System.out.println("adding group " + g);
			Atom a = g.getAtom(0);
			//if (debug)
			//  System.out.println(a);
			a.setGroup(g);
			atoms.add(a);
		}

		Atom[] arr = atoms.toArray(new Atom[atoms.size()]);

		return arr;
	}
48734
public static ParenthesizedExpression parenthesizeAndReplace(Expression expression) {
    ParenthesizedExpression newExpr = new ParenthesizedExpression();
    expression.replaceWith(newExpr);
    newExpr.setExpression(expression);
    return newExpr;
  }
329365
public List<PermutationSolution<Integer>> execute(List<PermutationSolution<Integer>> parents) {
    if (null == parents) {
      throw new JMetalException("Null parameter") ;
    } else if (parents.size() != 2) {
      throw new JMetalException("There must be two parents instead of " + parents.size()) ;
    }

    return doCrossover(crossoverProbability, parents) ;
  }
1099142
@Override
  public MtasSpanQuery rewrite(IndexReader reader) throws IOException {
    MtasSpanQuery newBigQuery = bigQuery.rewrite(reader);
    MtasSpanQuery newSmallQuery = smallQuery.rewrite(reader);
    if (newBigQuery == null || newBigQuery instanceof MtasSpanMatchNoneQuery
        || newSmallQuery == null
        || newSmallQuery instanceof MtasSpanMatchNoneQuery) {
      return new MtasSpanMatchNoneQuery(field);
    }
    if (!newBigQuery.equals(bigQuery) || !newSmallQuery.equals(smallQuery)) {
      return new MtasSpanContainingQuery(newBigQuery, newSmallQuery)
          .rewrite(reader);
    } else if (newBigQuery.equals(newSmallQuery)) {
      return newBigQuery;
    } else if (baseQuery == null) {
      return new MtasSpanMatchNoneQuery(field);
    } else {
      baseQuery = (SpanContainingQuery) baseQuery.rewrite(reader);
      return super.rewrite(reader);
    }
  }
1366423
@Override
    public void setAtom(IAtom atom, int position) {
        if (atoms[position] == null && atom != null) atomCount++;
        if (atoms[position] != null && atom == null) atomCount--;
        atoms[position] = atom;
    }
507948
public SimpleOrderedMap<Object> rewrite(
      MtasSolrSearchComponent searchComponent) throws IOException {
    SimpleOrderedMap<Object> response = new SimpleOrderedMap<>();
    Iterator<Entry<String, Object>> it;
    switch (action) {
    case ComponentCollection.ACTION_LIST:
      response.add("now", now);
      response.add("list", list);
      break;
    case ComponentCollection.ACTION_CREATE:
    case ComponentCollection.ACTION_POST:
    case ComponentCollection.ACTION_IMPORT:
      if (componentCollection != null && status != null) {
        it = status.iterator();
        while (it.hasNext()) {
          Entry<String, Object> entry = it.next();
          response.add(entry.getKey(), entry.getValue());
        }
      }
      break;
    case ComponentCollection.ACTION_CHECK:
      if (status != null) {
        it = status.iterator();
        while (it.hasNext()) {
          Entry<String, Object> entry = it.next();
          response.add(entry.getKey(), entry.getValue());
        }
      }
      break;
    case ComponentCollection.ACTION_GET:
      if (status != null) {
        it = status.iterator();
        while (it.hasNext()) {
          Entry<String, Object> entry = it.next();
          response.add(entry.getKey(), entry.getValue());
        }
      }
      if (values != null) {
        response.add("values", values);
      }
      break;
    default:
      break;
    }
    return response;
  }
598167
public void replaceMapChildren(Map<String, String> map, String parentId) {
		ArrayList<StringEntity> entities = new ArrayList<>();
		for (String key : map.keySet()) {
			StringEntity entity = new StringEntity();
			entity.setParentId(parentId);
			entity.setId(key);
			entity.setValue(map.get(key));
			entities.add(entity);
		}
		replaceChildren(entities, parentId);
	}
1017331
public ImmutableSet<DataAtom> chaseAtom(DataAtom atom, ImmutableCollection<ImmutableLinearInclusionDependency<AtomPredicate>> dependencies) {
        return dependencies.stream()
                .map(dependency -> immutableUnificationTools.computeAtomMGU(dependency.getBody(), atom)
                        .map(theta -> theta.applyToDataAtom(dependency.getHead())))
                .filter(Optional::isPresent)
                .map(Optional::get)
                .collect(ImmutableCollectors.toSet());
    }
1139160
@Override
  public MtasSpanQuery rewrite(IndexReader reader) throws IOException {
    baseQuery = (MtasExtendedSpanTermQuery) baseQuery.rewrite(reader);
    return super.rewrite(reader);
  }
999700
private void visitParentExpression(AbstractFunctionExpression parentExpr) {

        if (nextFunctionBodyStart == null) {
            nextFunctionBodyStart = parentExpr;
        }

        if (currentFunctionName != null) {
            updateCurrentFunction(parentExpr);
        } else {
            createFunctionIfNeeded(parentExpr);
        }

        if (GremlinQueryOptimizer.isOrExpression(parentExpr)) {
            //reset
            currentFunctionName = null;
            //don't include 'or' in generated functions
            nextFunctionBodyStart = null;
        }

    }
779519
IAtom newCDKAtom(Atom atom) {
        Element element = atom.element();
        boolean unknown = element == Element.Unknown;
        if (unknown) {
            IPseudoAtom pseudoAtom = builder.newInstance(IPseudoAtom.class, element.symbol());
            pseudoAtom.setSymbol(element.symbol());
            pseudoAtom.setLabel(atom.label());
            return pseudoAtom;
        }
        return createAtom(element);
    }