Esempio n. 1
0
  /** Build an processor. */
  public BBProcessor build() {
    this.createdScopes = new HashMap<Scope, ProcScope>();
    this.codes = new HashMap<Code, ProcCode>();
    this.constants = new HashMap<Constant, PatternConstant>();

    BBProcessor processor = new BBProcessor();
    processor.setScope(createScope(conf.getRootScope()));
    processor.setPrefix(createTemplate(conf.getPrefix()));
    processor.setSuffix(createTemplate(conf.getSuffix()));
    processor.setParams(conf.getParams());
    processor.setConstants(new HashSet<PatternConstant>(constants.values()));
    processor.setNestingLimit(conf.getNestingLimit());
    processor.setPropagateNestingException(conf.isPropagateNestingException());

    // Init scopes
    for (ProcScope scope : createdScopes.values()) {
      scope.init();
    }

    return processor;
  }
Esempio n. 2
0
 /**
  * Find or create the scope.
  *
  * @param scope the scope configuration
  * @return scope scope
  */
 private ProcScope createScope(Scope scope) {
   ProcScope created = createdScopes.get(scope);
   if (created == null) {
     created = new ProcScope(scope.getName());
     createdScopes.put(scope, created);
     created.setStrong(scope.isStrong());
     created.setIgnoreText(scope.isIgnoreText());
     if (scope.getParent() != null) {
       created.setParent(createScope(scope.getParent()));
     }
     Set<ProcCode> scopeCodes = new HashSet<ProcCode>();
     for (Code code : scope.getCodes()) {
       scopeCodes.add(createCode(code));
     }
     created.setScopeCodes(scopeCodes);
     created.setMin(scope.getMin());
     created.setMax(scope.getMax());
   }
   return created;
 }