Define the restore log rules that will be applied
by the {@link restore_logs_processor} when restoring
forum logs. It must return one array
of {@link restore_log_rule} objects
493699
static public function define_restore_log_rules() {
        $rules = array();

        $rules[] = new restore_log_rule('forum', 'add', 'view.php?id={course_module}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'update', 'view.php?id={course_module}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'view', 'view.php?id={course_module}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'view forum', 'view.php?id={course_module}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'mark read', 'view.php?f={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'start tracking', 'view.php?f={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'stop tracking', 'view.php?f={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'subscribe', 'view.php?f={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'unsubscribe', 'view.php?f={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'subscriber', 'subscribers.php?id={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'subscribers', 'subscribers.php?id={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'view subscribers', 'subscribers.php?id={forum}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'add discussion', 'discuss.php?d={forum_discussion}', '{forum_discussion}');
        $rules[] = new restore_log_rule('forum', 'view discussion', 'discuss.php?d={forum_discussion}', '{forum_discussion}');
        $rules[] = new restore_log_rule('forum', 'move discussion', 'discuss.php?d={forum_discussion}', '{forum_discussion}');
        $rules[] = new restore_log_rule('forum', 'delete discussi', 'view.php?id={course_module}', '{forum}',
                                        null, 'delete discussion');
        $rules[] = new restore_log_rule('forum', 'delete discussion', 'view.php?id={course_module}', '{forum}');
        $rules[] = new restore_log_rule('forum', 'add post', 'discuss.php?d={forum_discussion}&parent={forum_post}', '{forum_post}');
        $rules[] = new restore_log_rule('forum', 'update post', 'discuss.php?d={forum_discussion}#p{forum_post}&parent={forum_post}', '{forum_post}');
        $rules[] = new restore_log_rule('forum', 'update post', 'discuss.php?d={forum_discussion}&parent={forum_post}', '{forum_post}');
        $rules[] = new restore_log_rule('forum', 'prune post', 'discuss.php?d={forum_discussion}', '{forum_post}');
        $rules[] = new restore_log_rule('forum', 'delete post', 'discuss.php?d={forum_discussion}', '[post]');

        return $rules;
    }
436807
@Override
    public Object[] getParameters() {
        // return the parameters as used for the rule validation
        Object[] params = new Object[2];
        params[0] = databaseUsed;
        params[1] = rangeMassUsed;
        return params;
    }
187398
def restore_logging(lines, min_level_value, max_level_value):
    """"""
    output = ''
    while lines:
        line = lines[0]
        if line.lstrip() != PASS_LINE_CONTENTS:
            # not our pass statement here, so just leave the line as-is and keep going
            output += line
            lines = lines[1:]
        else:
            # a logging call will start on the next line: find all the lines it includes and those it does not
            logging_lines, remaining_lines = split_call(lines[1:])
            lines = remaining_lines
            logging_stmt = ''.join(logging_lines)
            original_lines = line + logging_stmt

            # replace the logging statement if its level falls b/w min and max
            if not check_level(logging_stmt, True, min_level_value, max_level_value):
                output += logging_stmt
            else:
                # uncomment_lines of this logging statement and remove the pass line
                uncommented_logging_lines = uncomment_lines(logging_lines)
                logging.info('replacing:\n%s\nwith this:\n%s' % (original_lines.rstrip(), uncommented_logging_lines.rstrip()))
                output += uncommented_logging_lines
    return output
1067640
@Override
	public void cacheResult(List<CPRuleUserSegmentRel> cpRuleUserSegmentRels) {
		for (CPRuleUserSegmentRel cpRuleUserSegmentRel : cpRuleUserSegmentRels) {
			if (entityCache.getResult(
						CPRuleUserSegmentRelModelImpl.ENTITY_CACHE_ENABLED,
						CPRuleUserSegmentRelImpl.class,
						cpRuleUserSegmentRel.getPrimaryKey()) == null) {
				cacheResult(cpRuleUserSegmentRel);
			}
			else {
				cpRuleUserSegmentRel.resetOriginalValues();
			}
		}
	}
689005
public List<Rule> getAllActiveRules() {
    List<Rule> rules = new ArrayList<>();
    List<Rule> rulesActive = new ArrayList<>();
    rules.addAll(builtinRules);
    rules.addAll(userRules);
    // Some rules have an internal state so they can do checks over sentence
    // boundaries. These need to be reset so the checks don't suddenly
    // work on different texts with the same data. However, it could be useful
    // to keep the state information if we're checking a continuous text.    
    for (Rule rule : rules) {
      if (!ignoreRule(rule)) {
        rulesActive.add(rule);
      }
    }    
    return rulesActive;
  }
1270715
protected function validateRules($rules, User $user, array $restriction)
    {
        $return = array('validRules' => 0, 'rules' => array());

        if (0 < count($rules)) {
            foreach ($rules as $rule) {
                $rule->setUser($user);
                $checkedLogs = $this->validateRule($rule, $restriction);

                if (false !== $checkedLogs) {
                    $return['validRules']++;
                    $return['rules'][] = array(
                        'rule' => $rule, 'logs' => $checkedLogs
                    );
                }
            }
        }

        return $return;
    }
447015
private List<String> collectRuleNames() {
        List<String> ruleNames = new ArrayList<>();
        for (Rule rule : rules) {
            ruleNames.add(rule.getName());
        }
        Collections.sort(ruleNames);
        return ruleNames;
    }
1189657
@Override
    public TimeZoneRule[] getTimeZoneRules() {
        initTransitionRules();
        int size = 1;
        if (historicRules != null) {
            // historicRules may contain null entries when original zoneinfo data
            // includes non transition data.
            for (int i = 0; i < historicRules.length; i++) {
                if (historicRules[i] != null) {
                    size++;
                }
            }
        }
        if (finalZone != null) {
            if (finalZone.useDaylightTime()) {
                size += 2;
            } else {
                size++;
            }
        }

        TimeZoneRule[] rules = new TimeZoneRule[size];
        int idx = 0;
        rules[idx++] = initialRule;

        if (historicRules != null) {
            for (int i = 0; i < historicRules.length; i++) {
                if (historicRules[i] != null) {
                    rules[idx++] = historicRules[i];
                }
            }
         }

        if (finalZone != null) {
            if (finalZone.useDaylightTime()) {
                TimeZoneRule[] stzr = finalZoneWithStartYear.getTimeZoneRules();
                // Adding only transition rules
                rules[idx++] = stzr[1];
                rules[idx++] = stzr[2];
            } else {
                // Create a TimeArrayTimeZoneRule at finalMillis
                rules[idx++] = new TimeArrayTimeZoneRule(getID() + "(STD)", finalZone.getRawOffset(), 0,
                        new long[] {(long)finalStartMillis}, DateTimeRule.UTC_TIME);
            }
        }
        return rules;
    }
1330704
public function getLogsFromCurrentFile()
    {
        if ($this->currentFile === null) {
            return [];
        }

        if (File::size($this->currentFile) > $this->maxFileSize) {
            return;
        }

        $datePattern = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}';
        $pattern = "/\\[$datePattern\\].*/";
        $fileContent = File::get($this->currentFile);

        preg_match_all($pattern, $fileContent, $rows);

        if (!is_array($rows) || count($rows) === 0) {
            return [];
        }

        $rows = $rows[0];
        $logs = [];

        foreach ($rows as $row) {
            preg_match(
                "/^\\[($datePattern)\\].*?(\\w+)\\."
                . '([A-Z]+): (.*?)( in .*?:[0-9]+)?$/',
                $row,
                $matches
            );

            if (!isset($matches[4])) {
                continue;
            }

            $level = Str::lower($matches[3]);

            $inFile = null;
            if (isset($matches[5])) {
                $inFile = substr($matches[5], 4);
            }

            $logs[] = (object) [
                'context' => $matches[2],
                'level' => $level,
                'levelClass' => static::$levelsClasses[$level],
                'levelImg' => static::$levelsImgs[$level],
                'date' => $matches[1],
                'text' => trim($matches[4]),
                'inFile' => $inFile,
            ];
        }

        return array_reverse($logs);
    }
375050
@Override
    public Iterable<ServerInstanceLogRecordList> getLogLists() {
        return getLogLists((Date) null, (Date) null, (LogRecordHeaderFilter) null);
    }
610859
protected function tryAndProcessRules()
    {
        if (!empty($this->rules) && !is_array($this->rules)) {
            $this->phpci->logFailure('The "rules" option must be an array.');
            return false;
        }

        foreach ($this->rules as &$rule) {
            if (strpos($rule, '/') !== false) {
                $rule = $this->phpci->buildPath . $rule;
            }
        }

        return true;
    }
822069
@Override
    public LogProperties logProperties()
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "logProperties", this);

        final LogProperties lprops = _recoveryLog.logProperties();

        if (tc.isEntryEnabled())
            Tr.exit(tc, "logProperties", lprops);
        return lprops;
    }
635026
public function rules()
    {
        $rules = parent::rules();
        $rules = array_merge($rules, [
            ['fieldTwig', 'string'],
            ['fieldTwig', 'default', 'value' => ''],
            ['columnType', 'string'],
            ['columnType', 'default', 'value' => ''],
            ['decimals', 'number'],
            ['decimals', 'default', 'value' => 0],
            ['textareaRows', 'number'],
            ['textareaRows', 'default', 'value' => 5],
            ['parseBeforeSave', 'boolean'],
            ['parseBeforeSave', 'default', 'value' => false],
            ['parseOnMove', 'boolean'],
            ['parseOnMove', 'default', 'value' => false],
            ['displayType', 'string'],
            ['displayType', 'default', 'value' => 'hidden'],
            ['allowSelect', 'boolean'],
            ['allowSelect', 'default', 'value' => false],
        ]);

        return $rules;
    }
746189
public java.util.List<ScalingRule> getRules() {
        if (rules == null) {
            rules = new com.amazonaws.internal.SdkInternalList<ScalingRule>();
        }
        return rules;
    }
178715
def unit_rules_restore(root):
    # type: (Nonterminal) -> Nonterminal
    
    items = Traversing.post_order(root)
    items = filter(lambda x: isinstance(x, ReducedUnitRule), items)
    for rule in items:
        parent_nonterm = rule.from_symbols[0]  # type: Nonterminal
        # restore chain of unit rules
        for r in rule.by_rules:
            created_rule = r()  # type: Rule
            parent_nonterm._set_to_rule(created_rule)
            created_rule._from_symbols.append(parent_nonterm)
            created_nonterm = r.toSymbol()  # type: Nonterminal
            created_rule._to_symbols.append(created_nonterm)
            created_nonterm._set_from_rule(created_rule)
            parent_nonterm = created_nonterm
        # restore last rule
        last_rule = rule.end_rule()  # type: Rule
        last_rule._from_symbols.append(parent_nonterm)
        parent_nonterm._set_to_rule(last_rule)
        for ch in rule.to_symbols:  # type: Nonterminal
            ch._set_from_rule(last_rule)
            last_rule._to_symbols.append(ch)
    return root
971830
@Override
    public int previous() {
        int result;
        int startPos;

        CharacterIterator text = getText();

        fLastStatusIndexValid = false;

        // if we have cached break positions and we're still in the range
        // covered by them, just move one step backward in the cache
        if (fCachedBreakPositions != null) {
            if (fPositionInCache > 0) {
                --fPositionInCache;
                // If we're at the beginning of the cache, need to reevaluate the
                // rule status
                if (fPositionInCache <= 0) {
                    fLastStatusIndexValid = false;
                }
                int pos = fCachedBreakPositions[fPositionInCache];
                text.setIndex(pos);
                return pos;
            } else {
                reset();
            }
        }

        // if we're already sitting at the beginning of the text, return DONE
        startPos = current();
        if (fText == null || startPos == fText.getBeginIndex()) {
            fLastRuleStatusIndex  = 0;
            fLastStatusIndexValid = true;
            return BreakIterator.DONE;
        }

        // Rules with an exact reverse table are handled here.
        if (fRData.fSRTable != null || fRData.fSFTable != null) {
            result =  handlePrevious(fRData.fRTable);
            if (fDictionaryCharCount > 0) {
                result = checkDictionary(result, startPos, true);
            }
            return result;
        }

        // old rule syntax
        // set things up.  handlePrevious() will back us up to some valid
        // break position before the current position (we back our internal
        // iterator up one step to prevent handlePrevious() from returning
        // the current position), but not necessarily the last one before
        // where we started

        int       start = current();

        previous32(fText);
        int       lastResult    = handlePrevious(fRData.fRTable);
        if (lastResult == BreakIterator.DONE) {
            lastResult = fText.getBeginIndex();
            fText.setIndex(lastResult);
        }
        result = lastResult;
        int      lastTag       = 0;
        boolean  breakTagValid = false;

        // iterate forward from the known break position until we pass our
        // starting point.  The last break position before the starting
        // point is our return value

        for (;;) {
            result         = next();
            if (result == BreakIterator.DONE || result >= start) {
                break;
            }
            lastResult     = result;
            lastTag        = fLastRuleStatusIndex;
            breakTagValid  = true;
        }

        // fLastBreakTag wants to have the value for section of text preceding
        // the result position that we are to return (in lastResult.)  If
        // the backwards rules overshot and the above loop had to do two or more
        // handleNext()s to move up to the desired return position, we will have a valid
        // tag value. But, if handlePrevious() took us to exactly the correct result position,
        // we wont have a tag value for that position, which is only set by handleNext().

        // Set the current iteration position to be the last break position
        // before where we started, and then return that value.
        fText.setIndex(lastResult);
        fLastRuleStatusIndex  = lastTag;       // for use by getRuleStatus()
        fLastStatusIndexValid = breakTagValid;
        return lastResult;
    }
1112061
public java.util.List<PatchRule> getPatchRules() {
        if (patchRules == null) {
            patchRules = new com.amazonaws.internal.SdkInternalList<PatchRule>();
        }
        return patchRules;
    }