Пример #1
0
  @Override
  public Maybe<String> findVariable(String name) {
    Maybe<String> result = findSpecialVariableValue(name);
    if (!result.isNothing()) return result;

    result = findVariableInPages(name);
    if (!result.isNothing()) return result;

    return findVariableInContext(name);
  }
Пример #2
0
 public SymbolMatch makeMatch(ScanString input) {
   for (Matcher matcher : getWikiMatchers()) {
     Maybe<Integer> matchLength = matcher.makeMatch(input);
     if (!matchLength.isNothing()) return new SymbolMatch(this, input, matchLength.getValue());
   }
   return SymbolMatch.noMatch;
 }
Пример #3
0
 private Maybe<String> findSpecialVariableValue(String key) {
   String value;
   if (key.equals("RUNNING_PAGE_NAME")) value = page.getName();
   else if (key.equals("RUNNING_PAGE_PATH")) value = page.getPath();
   else if (key.equals("PAGE_NAME")) value = namedPage.getName();
   else if (key.equals("PAGE_PATH")) value = namedPage.getPath();
   else if (key.equals("FITNESSE_PORT")) {
     Maybe<String> port = findVariableInContext("FITNESSE_PORT");
     value = port.isNothing() ? "-1" : port.getValue();
   } else if (key.equals("FITNESSE_ROOTPATH")) {
     Maybe<String> path = findVariableInContext("FITNESSE_ROOTPATH");
     value = path.isNothing() ? "" : path.getValue();
   } else if (key.equals("FITNESSE_VERSION")) {
     Maybe<String> version = findVariableInContext("FITNESSE_VERSION");
     value = version.isNothing() ? "" : version.getValue();
   } else return Maybe.noString;
   return new Maybe<String>(value);
 }
Пример #4
0
 private Maybe<String> lookInParentPages(String name) {
   for (SourcePage sourcePage : page.getAncestors()) {
     if (!inCache(sourcePage)) {
       // The cache is passed along... page is rendered as a normal page.
       Parser.make(copyForPage(sourcePage), sourcePage.getContent()).parse();
       putVariable(sourcePage, "", Maybe.noString);
     }
     Maybe<String> result = findVariableInCache(sourcePage, name);
     if (!result.isNothing()) return result;
   }
   return Maybe.noString;
 }
Пример #5
0
 private Maybe<String> findVariableInPages(String name) {
   Maybe<String> localVariable = findVariableInCache(name);
   if (!localVariable.isNothing()) return new Maybe<String>(localVariable.getValue());
   return lookInParentPages(name);
 }