Paints a single rule.

@param rule the rule to paint.
@param xml the writer to send the output to
343456
private void paintRule(final Rule rule, final XmlStringBuilder xml) {
		if (rule.getCondition() == null) {
			throw new SystemException("Rule cannot be painted as it has no condition");
		}

		paintCondition(rule.getCondition(), xml);

		for (Action action : rule.getOnTrue()) {
			paintAction(action, "ui:onTrue", xml);
		}

		for (Action action : rule.getOnFalse()) {
			paintAction(action, "ui:onFalse", xml);
		}
	}
72973
public void setRules(java.util.Collection<Rule> rules) {
        if (rules == null) {
            this.rules = null;
            return;
        }

        this.rules = new java.util.ArrayList<Rule>(rules);
    }
1155794
private void paintTableActions(final WTable table, final WebXmlRenderContext renderContext) {
		XmlStringBuilder xml = renderContext.getWriter();
		List<WButton> tableActions = table.getActions();

		if (!tableActions.isEmpty()) {
			boolean hasActions = false;

			for (WButton button : tableActions) {
				if (!button.isVisible()) {
					continue;
				}

				if (!hasActions) {
					hasActions = true;
					xml.appendTag("ui:actions");
				}

				xml.appendTag("ui:action");

				List<WTable.ActionConstraint> constraints = table.getActionConstraints(button);

				if (constraints != null) {
					for (WTable.ActionConstraint constraint : constraints) {
						int minRows = constraint.getMinSelectedRowCount();
						int maxRows = constraint.getMaxSelectedRowCount();
						String message = constraint.getMessage();
						String type = constraint.isError() ? "error" : "warning";

						xml.appendTagOpen("ui:condition");
						xml.appendOptionalAttribute("minSelectedRows", minRows > 0, minRows);
						xml.appendOptionalAttribute("maxSelectedRows", maxRows > 0, maxRows);
						xml.appendAttribute("selectedOnOther", this.selectedOnOther);
						xml.appendAttribute("type", type);
						xml.appendAttribute("message", I18nUtilities.format(null, message));
						xml.appendEnd();
					}
				}

				button.paint(renderContext);

				xml.appendEndTag("ui:action");
			}

			if (hasActions) {
				xml.appendEndTag("ui:actions");
			}
		}
	}
120866
public static void saveXML(Document document, File file) {
		OutputFormat format = OutputFormat.createPrettyPrint();
		XMLWriter xmlWriter = null;
		try {

			xmlWriter = new XMLWriter(new FileOutputStream(file), format);
			xmlWriter.write(document);

		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			if (xmlWriter != null) {
				try {
					xmlWriter.close();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
	}
162798
public void paintXml(final WComponent component, final Writer writer) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("paintXml called for component class " + component.getClass());
		}

		String templateText = null;

		if (component instanceof AbstractWComponent) {
			AbstractWComponent abstractComp = ((AbstractWComponent) component);
			templateText = abstractComp.getTemplateMarkUp();
		}

		try {
			Map<String, WComponent> componentsByKey = new HashMap<>();
			VelocityContext context = new VelocityContext();
			fillContext(component, context, componentsByKey);

			VelocityWriter velocityWriter = new VelocityWriter(writer, componentsByKey,
					UIContextHolder.getCurrent());

			if (templateText != null) {
				VelocityEngine engine = VelocityEngineFactory.getVelocityEngine();
				engine.evaluate(context, velocityWriter, component.getClass().getSimpleName(),
						templateText);
			} else {
				Template template = getTemplate(component);

				if (template == null) {
					LOG.warn(
							"VelocityRenderer invoked for a component with no template: " + component.
							getClass().getName());
				} else {
					template.merge(context, velocityWriter);
				}
			}

			velocityWriter.close();

			if (component instanceof VelocityProperties) {
				((VelocityProperties) component).mapUsed();
			}
		} catch (ResourceNotFoundException rnfe) {
			LOG.error("Could not find template '" + url + "' for component " + component.getClass().
					getName(), rnfe);
		} catch (ParseErrorException pee) {
			// syntax error : problem parsing the template
			LOG.error("Parse problems", pee);
		} catch (MethodInvocationException mie) {
			// something invoked in the template
			// threw an exception
			Throwable wrapped = mie.getWrappedThrowable();

			LOG.error("Problems with velocity", mie);

			if (wrapped != null) {
				LOG.error("Wrapped exception...", wrapped);
			}
		} catch (Exception e) {
			LOG.error("Problems with velocity", e);
		}
	}
228721
function (rule) {
    var msg = this.messages.render(rule);
    this.errors.add(rule.attribute, msg);
    this.errorCount++;
  }
1367838
public void addIconRule(String extension, String icon, String bigIcon, String smallIconStyle, String bigIconStyle) {

        CmsIconRule rule = new CmsIconRule(extension, icon, bigIcon, smallIconStyle, bigIconStyle);
        m_iconRules.put(extension, rule);
    }
1224451
public void xml(String xml) {
    if (LogLevel.DEBUG < logConfiguration.logLevel) {
      return;
    }
    printlnInternal(LogLevel.DEBUG, logConfiguration.xmlFormatter.format(xml));
  }
428013
private static void printAsXML(Rule rule, StringBuilder xmlStringBuilder) {
    if (rule.version != null) {
      xmlStringBuilder.append("  <!-- since " + rule.version + " -->");
      xmlStringBuilder.append(LINE_SEPARATOR);
    }
    xmlStringBuilder.append("  <rule>");
    xmlStringBuilder.append(LINE_SEPARATOR);
    xmlStringBuilder.append("    <key>" + rule.fixedRuleKey() + "</key>");
    xmlStringBuilder.append(LINE_SEPARATOR);
    xmlStringBuilder.append("    <severity>" + rule.severity + "</severity>");
    xmlStringBuilder.append(LINE_SEPARATOR);
    xmlStringBuilder.append("    <name><![CDATA[" + rule.name + "]]></name>");
    xmlStringBuilder.append(LINE_SEPARATOR);
    xmlStringBuilder.append("    <internalKey><![CDATA[" + rule.internalKey + "]]></internalKey>");
    xmlStringBuilder.append(LINE_SEPARATOR);
    xmlStringBuilder.append("    <description><![CDATA[" + rule.description + "]]></description>");
    xmlStringBuilder.append(LINE_SEPARATOR);
    if (!rule.tags.isEmpty()) {
      for (String tag : rule.tags) {
        xmlStringBuilder.append("    <tag>" + tag + "</tag>");
        xmlStringBuilder.append(LINE_SEPARATOR);
      }
    }

    if (!rule.parameters.isEmpty()) {
      List<RuleParameter> sortedParameters = Lists.newArrayList(rule.parameters);
      Collections.sort(sortedParameters, new Comparator<RuleParameter>() {
        @Override
        public int compare(RuleParameter o1, RuleParameter o2) {
          return o1.key.compareTo(o2.key);
        }
      });
      for (RuleParameter parameter : sortedParameters) {
        xmlStringBuilder.append("    <param>");
        xmlStringBuilder.append(LINE_SEPARATOR);
        xmlStringBuilder.append("      <key>" + parameter.key + "</key>");
        xmlStringBuilder.append(LINE_SEPARATOR);
        if (StringUtils.isNotBlank(parameter.description)) {
          xmlStringBuilder.append("      <description><![CDATA[" + parameter.description + "]]></description>");
          xmlStringBuilder.append(LINE_SEPARATOR);
        }
        if (StringUtils.isNotBlank(parameter.defaultValue) && !"null".equals(parameter.defaultValue)) {
          xmlStringBuilder.append("      <defaultValue>" + parameter.defaultValue + "</defaultValue>");
          xmlStringBuilder.append(LINE_SEPARATOR);
        }
        xmlStringBuilder.append("    </param>");
        xmlStringBuilder.append(LINE_SEPARATOR);
      }
    }

    xmlStringBuilder.append("  </rule>");
    xmlStringBuilder.append(LINE_SEPARATOR);
    xmlStringBuilder.append(LINE_SEPARATOR);
  }
310545
public synchronized void addRule(final RuleImpl rule) throws InvalidPatternException {
        final List<TerminalNode> terminals = this.ruleBuilder.addRule( rule,
                                                                       this.kBase );

        BaseNode[] nodes = terminals.toArray( new BaseNode[terminals.size()] );
        this.rules.put( rule.getFullyQualifiedName(), nodes );
        if (rule.isQuery()) {
            this.queries.put( rule.getName(), nodes );
        }
    }
181033
@Requires({
    "isValidPattern(pattern)",
    "rule != null"
  })
  @Ensures({
    "rule.equals(get(pattern))",
    "!isOverriden(pattern)"
  })
  public void put(String pattern, R rule) {
    String canon = pattern.replace('/', '.');
    boolean exact = !canon.endsWith(".*");
    if (!exact) {
      canon = canon.substring(0, canon.length() - 2);
    }

    String[] parts = canon.split("\\.");

    TernaryNode current = root;
    TernaryNode parent = root;
    int parentIndex = -1;
    for (int i = 0; i < parts.length; ++i) {
      TernaryNode next = current.children.get(parts[i]);
      if (next == null) {
        next = new TernaryNode(null, false);
        current.children.put(parts[i], next);
      }
      if (next.rule != null && !next.exact) {
        parent = next;
        parentIndex = i;
      }
      current = next;
    }

    if (!exact) {
      /* Override patterns beginning with this one. */
      current.children.clear();
    }

    if (!rule.equals(parent.rule)) {
      current.rule = rule;
      current.exact = exact;
    } else {
      /*
       * The new rule we are inserting is already specified through
       * inheritance. Remove spurious nodes. This ensures that any
       * overriding branch is meaningful; that is, it specifies a rule
       * value different from the inherited one.
       */
      current = parent;
      for (int i = parentIndex + 1; i < parts.length; ++i) {
        TernaryNode next = current.children.get(parts[i]);
        if (next.rule == null) {
          current.children.remove(parts[i]);
          break;
        }
      }
    }
  }
1329708
public void addRule(final TreeRule rule) {
    if (rule == null) {
      throw new IllegalArgumentException("Null rules are not accepted");
    }
    if (rules == null) {
      rules = new TreeMap<Integer, TreeMap<Integer, TreeRule>>();
    }
    
    TreeMap<Integer, TreeRule> level = rules.get(rule.getLevel());
    if (level == null) {
      level = new TreeMap<Integer, TreeRule>();
      level.put(rule.getOrder(), rule);
      rules.put(rule.getLevel(), level);
    } else {
      level.put(rule.getOrder(), rule);
    }
    
    changed.put("rules", true);
  }
371627
public void setRules(java.util.Collection<RuleSummary> rules) {
        if (rules == null) {
            this.rules = null;
            return;
        }

        this.rules = new java.util.ArrayList<RuleSummary>(rules);
    }
813410
public void execute(int rule, int... ids) throws Exception{
        setCurrentRule(rule);
        for(int id: ids){
            Node node = currentRule.nodes().get(id);
            if(node.action== BufferAction.INSTANCE){
                System.out.println("BUFFERRING");
                parser.getBuffer().push();
            }else if(node.action instanceof PublishAction){
                PublishAction action = (PublishAction)node.action;
                Chars data = parser.getBuffer().pop(action.begin, action.end);
                System.out.println(action.name+"(\""+ StringUtil.toLiteral(data, false)+"\")");
            }else if(node.action instanceof EventAction){
                EventAction action = (EventAction)node.action;
                System.out.println(action.name+"()");
            }else if(node.action instanceof ErrorAction){
                ErrorAction action = (ErrorAction)node.action;
                System.out.println("error(\""+StringUtil.toLiteral(action.errorMessage, false)+"\")");
                fatalError(action.errorMessage);
            }
            scene.executing(node);
        }
    }
1367934
private void paintInGroupAction(final Action action, final String elementName,
			final XmlStringBuilder xml) {
		xml.appendTagOpen(elementName);
		xml.appendAttribute("action", getActionTypeName(action.getActionType()));
		xml.appendClose();
		xml.appendTagOpen("ui:target");
		xml.appendAttribute("groupId", action.getTarget().getId());
		xml.appendAttribute("id", ((AbstractAction) action).getTargetInGroup().getId());
		xml.appendEnd();
		xml.appendEndTag(elementName);
	}
291047
private void paintOriginalXML(final String originalXML, final PrintWriter writer) {
		// Replace any CDATA Sections embedded in XML
		String xml = originalXML.replaceAll("<!\\[CDATA\\[", "CDATASTART");
		xml = xml.replaceAll("\\]\\]>", "CDATAFINISH");

		// Paint Output
		writer.println("<div>");
		writer.println("<!-- VALIDATE XML ERROR - START XML -->");
		writer.println("<![CDATA[");
		writer.println(xml);
		writer.println("]]>");
		writer.println("<!-- VALIDATE XML ERROR - END XML -->");
		writer.println("</div>");
	}
917526
public void addRule(final Element element) {
		FxCopRule rule = new FxCopRule(element.getAttribute("TypeName"), element.getAttribute("Category"), element.getAttribute("CheckId"));
		rule.setUrl(getNamedTagText(element, "Url"));
		rule.setDescription(getNamedTagText(element, "Description"));
		rule.setName(getNamedTagText(element, "Name"));

		rules.put(getRuleKey(rule.getCategory(), rule.getCheckId()), rule);
	}