Creates human readable description for And element.

@param builder     - StringBuilder instance to which description will be appended
@param expressions - field expressions
@return same StringBuilder instance as parameter
326656
@VisibleForTesting
    StringBuilder createAndDescription(final StringBuilder builder, final List<FieldExpression> expressions) {
        if ((expressions.size() - 2) >= 0) {
            for (int j = 0; j < expressions.size() - 2; j++) {
                builder.append(String.format(" %s, ", describe(expressions.get(j), true)));
            }
            builder.append(String.format(" %s ", describe(expressions.get(expressions.size() - 2), true)));
        }
        builder.append(String.format(" %s ", bundle.getString("and")));
        builder.append(describe(expressions.get(expressions.size() - 1), true));
        return builder;
    }
800890
public T xpath(String expression, String value) {
        if (xpathMessageConstructionInterceptor == null) {
            xpathMessageConstructionInterceptor = new XpathMessageConstructionInterceptor();

            if (getAction().getMessageBuilder() != null) {
                (getAction().getMessageBuilder()).add(xpathMessageConstructionInterceptor);
            } else {
                PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
                messageBuilder.getMessageInterceptors().add(xpathMessageConstructionInterceptor);

                getAction().setMessageBuilder(messageBuilder);
            }
        }

        xpathMessageConstructionInterceptor.getXPathExpressions().put(expression, value);
        return self;
    }
1174049
final public SetExpressionBuilder<T> set(final String to) {
    final int sourceLineNumber = builder.getSourceLineNumber();
    return new SetExpressionBuilder<T>(new ExpressionHandler<T>() {
      public T handleExpression(Expression e) {
        return statementHandler().handleStatement(new SetStatement(sourceLineNumber, to, e));
      }
    });
  }
1141568
public ResponseBuilder getRepresentation(final ResponseBuilder builder) {
        // Add NonRDFSource-related "describe*" link headers, provided this isn't an ACL resource
        getResource().getBinaryMetadata().filter(ds -> !ACL.equals(getRequest().getExt())).ifPresent(ds -> {
            final String base = getBaseBinaryIdentifier();
            final String description = base + (base.contains("?") ? "&" : "?") + "ext=description";
            if (syntax != null) {
                builder.link(description, "canonical").link(base, "describes")
                    .link(base + "#description", "alternate");
            } else {
                builder.link(base, "canonical").link(description, "describedby")
                    .type(ds.getMimeType().orElse(APPLICATION_OCTET_STREAM));
            }
        });

        // Add a "self" link header
        builder.link(getSelfIdentifier(), "self");

        // URI Template
        builder.header(LINK_TEMPLATE,
                "<" + getIdentifier() + "{?version}>; rel=\"" + Memento.Memento.getIRIString() + "\"");

        // NonRDFSources responses (strong ETags, etc)
        if (getResource().getBinaryMetadata().isPresent() && syntax == null) {
            return getLdpNr(builder);
        }

        // RDFSource responses (weak ETags, etc)
        final IRI profile = getProfile(getRequest().getAcceptableMediaTypes(), syntax);
        return getLdpRs(builder, syntax, profile);
    }
1338477
public Builder text(String s) {
        // null values add no text
        if (s == null) {
            return this;
        }
        html.a(Util.escapeXml(s));
        text.a(s);
        return this;
    }
419330
public static ExpressionConstructor constructor(Class<?> type, Expression... fields) {
		return new ExpressionConstructor(type, asList(fields));
	}
871160
public CronDefinitionBuilder and() {
        cronDefinitionBuilder.register(new FieldDefinition(fieldName, constraints.createConstraintsInstance(), optional));
        return cronDefinitionBuilder;
    }
271653
private static final List<Element> buildDescription(String description) {
		
		// Assertions.
		if (description == null) {
			String msg = "Argument 'description' cannot be null.";
			throw new IllegalArgumentException(msg);
		}
		
		List<Element> rslt = new LinkedList<Element>();
		Element e = fac.createElement("p");
		e.setText(description);
		rslt.add(e);
		return rslt;

	}
874275
protected void generateBuilderFactoryContributions(MemberDescription description) {
		if (description.isTopElement()) {
			return;
		}
		if (description.getStandardContainers().isEmpty() && description.getNoBodyContainers().isEmpty()) {
			return;
		}
		List<String> modifiers = description.getModifiers();
		if (modifiers.size() <= 1) {
			// No need to create a function with the modifier's label in the name.
			modifiers = Collections.singletonList(""); //$NON-NLS-1$
		}
		final boolean enableAppenders = getCodeBuilderConfig().isISourceAppendableEnable();
		for (final String modifier : modifiers) {
			final String createFunctionName = "create" //$NON-NLS-1$
					+ Strings.toFirstUpper(modifier)
					+ Strings.toFirstUpper(description.getElementDescription().getName());

			String container = null;
			if (!description.getStandardContainers().isEmpty()) {
				container = description.getStandardContainers().iterator().next();
			} else {
				container = description.getNoBodyContainers().iterator().next();
			}

			final String createContainerFunctionName = "add" //$NON-NLS-1$
					+ Strings.toFirstUpper(container);
			final TypeReference containerBuilder = description.getContainerDescription().getBuilderInterfaceType();
			this.builderFactoryContributions.addContribution(new StringConcatenationClient() {
				@Override
				protected void appendTo(TargetStringConcatenation it) {
					it.append("\t/** Create the factory for a " + getLanguageName() + " " //$NON-NLS-1$ //$NON-NLS-2$
							+ description.getElementDescription().getElementType().getSimpleName() + "."); //$NON-NLS-1$
					it.newLine();
					it.append("\t * @param name the name of the " //$NON-NLS-1$
							+ description.getElementDescription().getName());
					it.newLine();
					it.append("\t * @param resourceSet the set of the resources that must be used for"); //$NON-NLS-1$
					it.newLine();
					it.append("\t *    containing the generated resource, and resolving types from names."); //$NON-NLS-1$
					it.newLine();
					it.append("\t * @return the factory."); //$NON-NLS-1$
					it.newLine();
					it.append("\t */"); //$NON-NLS-1$
					it.newLine();
					it.append("\t@"); //$NON-NLS-1$
					it.append(Pure.class);
					it.newLine();
					it.append("\tpublic "); //$NON-NLS-1$
					it.append(description.getElementDescription().getBuilderInterfaceType());
					it.append(" "); //$NON-NLS-1$
					it.append(createFunctionName);
					it.append("(String name, "); //$NON-NLS-1$
					it.append(ResourceSet.class);
					it.append(" resourceSet) {"); //$NON-NLS-1$
					it.newLine();
					it.append("\t\treturn "); //$NON-NLS-1$
					it.append(createFunctionName);
					it.append("(name, createResource(resourceSet));"); //$NON-NLS-1$
					it.newLine();
					it.append("\t}"); //$NON-NLS-1$
					it.newLineIfNotEmpty();
					it.newLine();
					it.append("\t/** Create the factory for a " + getLanguageName() + " " //$NON-NLS-1$ //$NON-NLS-2$
							+ description.getElementDescription().getElementType().getSimpleName() + "."); //$NON-NLS-1$
					it.newLine();
					it.append("\t * @param name the name of the " //$NON-NLS-1$
							+ description.getElementDescription().getName());
					it.newLine();
					it.append("\t * @param resource the resource that must be used for"); //$NON-NLS-1$
					it.newLine();
					it.append("\t *    containing the generated resource, and resolving types from names."); //$NON-NLS-1$
					it.newLine();
					it.append("\t * @return the factory."); //$NON-NLS-1$
					it.newLine();
					it.append("\t */"); //$NON-NLS-1$
					it.newLine();
					it.append("\t@"); //$NON-NLS-1$
					it.append(Pure.class);
					it.newLine();
					it.append("\tpublic "); //$NON-NLS-1$
					it.append(description.getElementDescription().getBuilderInterfaceType());
					it.append(" "); //$NON-NLS-1$
					it.append(createFunctionName);
					it.append("(String name, "); //$NON-NLS-1$
					it.append(Resource.class);
					it.append(" resource) {"); //$NON-NLS-1$
					it.newLine();
					it.append("\t\t"); //$NON-NLS-1$
					it.append(getScriptBuilderInterface());
					it.append(" scriptBuilder = createScript(getFooPackageName(), resource);"); //$NON-NLS-1$
					it.newLine();
					it.append("\t\t"); //$NON-NLS-1$
					it.append(containerBuilder);
					it.append(" containerBuilder = scriptBuilder."); //$NON-NLS-1$
					it.append(createContainerFunctionName);
					it.append("(getFooTypeName());"); //$NON-NLS-1$
					it.newLine();
					it.append("\t\treturn containerBuilder.add"); //$NON-NLS-1$
					it.append(Strings.toFirstUpper(modifier));
					it.append(Strings.toFirstUpper(description.getElementDescription().getName()));
					it.append("(name);"); //$NON-NLS-1$
					it.newLine();
					it.append("\t}"); //$NON-NLS-1$
					it.newLineIfNotEmpty();
					it.newLine();
				}
			});
			if (enableAppenders) {
				final String buildFunctionName = "build" //$NON-NLS-1$
						+ Strings.toFirstUpper(modifier)
						+ Strings.toFirstUpper(description.getElementDescription().getName());
				final TypeReference appender = getCodeElementExtractor().getElementAppenderImpl(
						description.getElementDescription().getName());
				this.builderFactoryContributions.addContribution(new StringConcatenationClient() {
					@Override
					protected void appendTo(TargetStringConcatenation it) {
						it.append("\t/** Create the appender for a " + getLanguageName() + " " //$NON-NLS-1$ //$NON-NLS-2$
								+ description.getElementDescription().getElementType().getSimpleName() + "."); //$NON-NLS-1$
						it.newLine();
						it.append("\t * @param name the name of the " //$NON-NLS-1$
								+ description.getElementDescription().getName());
						it.newLine();
						it.append("\t * @param resourceSet the set of the resources that must be used for"); //$NON-NLS-1$
						it.newLine();
						it.append("\t *    containing the generated resource, and resolving types from names."); //$NON-NLS-1$
						it.newLine();
						it.append("\t * @return the appender."); //$NON-NLS-1$
						it.newLine();
						it.append("\t */"); //$NON-NLS-1$
						it.newLine();
						it.append("\t@"); //$NON-NLS-1$
						it.append(Pure.class);
						it.newLine();
						it.append("\tpublic "); //$NON-NLS-1$
						it.append(appender);
						it.append(" "); //$NON-NLS-1$
						it.append(buildFunctionName);
						it.append("(String name, "); //$NON-NLS-1$
						it.append(ResourceSet.class);
						it.append(" resourceSet) {"); //$NON-NLS-1$
						it.newLine();
						it.append("\t\t"); //$NON-NLS-1$
						it.append(appender);
						it.append(" a = new "); //$NON-NLS-1$
						it.append(appender);
						it.append("("); //$NON-NLS-1$
						it.append(createFunctionName);
						it.append("(name, resourceSet));"); //$NON-NLS-1$
						it.newLine();
						it.append("\t\tgetInjector().injectMembers(a);"); //$NON-NLS-1$
						it.newLine();
						it.append("\t\treturn a;"); //$NON-NLS-1$
						it.newLine();
						it.append("\t}"); //$NON-NLS-1$
						it.newLineIfNotEmpty();
						it.newLine();
						it.append("\t/** Create the appender for a " + getLanguageName() + " " //$NON-NLS-1$ //$NON-NLS-2$
								+ description.getElementDescription().getElementType().getSimpleName() + "."); //$NON-NLS-1$
						it.newLine();
						it.append("\t * @param name the name of the " //$NON-NLS-1$
								+ description.getElementDescription().getName());
						it.newLine();
						it.append("\t * @param resource the resource that must be used for"); //$NON-NLS-1$
						it.newLine();
						it.append("\t *    containing the generated resource, and resolving types from names."); //$NON-NLS-1$
						it.newLine();
						it.append("\t * @return the appender."); //$NON-NLS-1$
						it.newLine();
						it.append("\t */"); //$NON-NLS-1$
						it.newLine();
						it.append("\t@"); //$NON-NLS-1$
						it.append(Pure.class);
						it.newLine();
						it.append("\tpublic "); //$NON-NLS-1$
						it.append(appender);
						it.append(" "); //$NON-NLS-1$
						it.append(buildFunctionName);
						it.append("(String name, "); //$NON-NLS-1$
						it.append(Resource.class);
						it.append(" resource) {"); //$NON-NLS-1$
						it.newLine();
						it.append("\t\t"); //$NON-NLS-1$
						it.append(appender);
						it.append(" a = new "); //$NON-NLS-1$
						it.append(appender);
						it.append("("); //$NON-NLS-1$
						it.append(createFunctionName);
						it.append("(name, resource));"); //$NON-NLS-1$
						it.newLine();
						it.append("\t\tgetInjector().injectMembers(a);"); //$NON-NLS-1$
						it.newLine();
						it.append("\t\treturn a;"); //$NON-NLS-1$
						it.newLine();
						it.append("\t}"); //$NON-NLS-1$
						it.newLineIfNotEmpty();
						it.newLine();
					}
				});
			}
		}
	}
205570
protected String elementAsString(XMLStreamReader reader, String key, Map<String, String> expressions)
      throws XMLStreamException
   {
      String elementtext = rawElementText(reader);

      if (key != null && expressions != null && elementtext != null && elementtext.indexOf("${") != -1)
         expressions.put(key, elementtext);
      
      return getSubstitutionValue(elementtext);
   }
1003612
protected List<Expression> transformExpressions(List<? extends Expression> expressions, ExpressionTransformer transformer) {
        List<Expression> list = new ArrayList<Expression>(expressions.size());
        for (Expression expr : expressions ) {
            list.add(transformer.transform(expr));
        }
        return list;
    }
539455
protected void generateBlockExpressionBuilderImpl() {
		final TypeReference builderInterface = getBlockExpressionBuilderInterface();
		final TypeReference builder = getBlockExpressionBuilderImpl();
		final StringConcatenationClient content = new StringConcatenationClient() {
			@Override
			protected void appendTo(TargetStringConcatenation it) {
				it.append("/** Builder of a " + getLanguageName() //$NON-NLS-1$
						+ " XBlockExpression."); //$NON-NLS-1$
				it.newLine();
				it.append(" */"); //$NON-NLS-1$
				it.newLine();
				it.append("@SuppressWarnings(\"all\")"); //$NON-NLS-1$
				it.newLine();
				it.append("public class "); //$NON-NLS-1$
				it.append(builder.getSimpleName());
				it.append(" extends "); //$NON-NLS-1$
				it.append(getAbstractBuilderImpl());
				it.append(" implements "); //$NON-NLS-1$
				it.append(builderInterface);
				it.append(" {"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
				it.append(generateMembers(false, false));
				it.append("}"); //$NON-NLS-1$
				it.newLineIfNotEmpty();
				it.newLine();
			}
		};
		final JavaFileAccess javaFile = getFileAccessFactory().createJavaFile(builder, content);
		javaFile.writeTo(getSrcGen());
	}
747777
protected void appendField(final StringBuilder builder, final String key, final int value) {
        if (builder.length() > 0) {
            builder.append("&");
        }
        builder.append(key).append("=").append(value);
    }
771342
public Expression create(String expression, ExpressionType expressionType, PropertyResolver propertyResolver) {
        if (expressionType == null) {
            expressionType = ExpressionType.MVEL;
        }
        if (propertyResolver == null) {
            propertyResolver = SystemAndTestPropertyResolver.INSTANCE;
        }
        switch (expressionType) {
        case MVEL:
            return new MVELExpression(expression, propertyResolver);
        default:
            throw CommonKnowledgeMessages.MESSAGES.unknownExpressionType(expressionType.toString());
        }
    }
15004
protected ExpressionContextDescription getExpressionContextDescription() {
		for (final CodeElementExtractor.ElementDescription containerDescription : getCodeElementExtractor().getTopElements(
				getGrammar(), getCodeBuilderConfig())) {
			final AbstractRule rule = getMemberRule(containerDescription);
			if (rule != null) {
				final Pattern fieldTypePattern = Pattern.compile(getExpressionConfig().getExpressionFieldTypenamePattern());
				final ExpressionContextDescription description = getCodeElementExtractor().visitMemberElements(
						containerDescription, rule, null,
					(it, grammarContainer, memberContainer, classifier) -> {
						if (fieldTypePattern.matcher(classifier.getName()).find()) {
							final Assignment expressionAssignment = findAssignmentFromTerminalPattern(
									memberContainer,
									getExpressionConfig().getExpressionGrammarPattern());
							final CodeElementExtractor.ElementDescription memberDescription =
									it.newElementDescription(classifier.getName(), memberContainer,
											classifier, XExpression.class);
							return new ExpressionContextDescription(
									containerDescription,
									memberDescription,
									ensureContainerKeyword(containerDescription.getGrammarComponent()),
									ensureFieldDeclarationKeyword(memberDescription),
									expressionAssignment);
						}
						return null;
					},
					null);
				if (description != null) {
					return description;
				}
			}
		}
		return null;
	}
1218287
public static StringBuilder appendProblems(Object object, StringBuilder builder) {
        if (object instanceof CompilationProblem[]) {
            final CompilationProblem[] problem = (CompilationProblem[]) object;
            for (CompilationProblem aProblem : problem) {
                builder.append("\t")
                       .append(aProblem)
                       .append("\n");
            }
        } else if (object != null) {
            builder.append(object);
        }
        return builder;
    }
1372350
final public ExecExpressionBuilder<T> exec() {
    final int sourceLineNumber = builder.getSourceLineNumber();
    return new ExecExpressionBuilder<T>(new ExpressionHandler<T>() {
      public T handleExpression(Expression e) {
        return statementHandler().handleStatement(new ExpressionStatement(sourceLineNumber, e));
      }
    });
  }