Examples of Replacer


Examples of jimm.util.Replacer

public Collection columnsUsed() {
    final ArrayList list = new ArrayList();

    // We are using a replacer passively, to look for curly-delimited
    // expressions. Nothing in the expression text gets modified.
    StringUtils.replaceDelimited(exceptAfter, "{", "}", new Replacer() {
  public Object replace(String str) {
      switch (str.charAt(0)) {
      case '!':    // User column
    UserColumn uc = report.findUserColumn(str.substring(1));
    if (uc != null// Should never be null
View Full Code Here

Examples of jimm.util.Replacer

public Collection userColumnsUsed() {
    final ArrayList list = new ArrayList();

    // We are using a replacer passively, to look for curly-delimited
    // expressions. Nothing in the expression text gets modified.
    StringUtils.replaceDelimited(exceptAfter, "{!", "}", new Replacer() {
  public Object replace(String str) {
      UserColumn uc = report.findUserColumn(str);
      if (uc != null// Should never be null
    list.add(uc);
      return "";    // So we don't bail out
View Full Code Here

Examples of jimm.util.Replacer

    String str = getExpression();
    if (str == null || str.trim().length() == 0)
  return null;

    // Special values
    str = StringUtils.replaceDelimited("#", "{%", "}", new Replacer() {
  public Object replace(String str) {
      Object obj = SpecialField.value(formulaField, str, report);
      return obj == null ? "nil" : obj;
  }},
         str);
    if (str == null) return null;

    // Formula values
    str = StringUtils.replaceDelimited("#", "{@", "}", new Replacer() {
  public Object replace(String str) {
      Formula f = report.findFormula(str);
      return f == null ? "nil" : f.eval(formulaField);
  }},
         str);
    if (str == null) return null;

    // Parameter values
    str = StringUtils.replaceDelimited("#", "{?", "}", new Replacer() {
  public Object replace(String str) {
      Parameter p = report.findParameter(str);
      return p == null ? "nil" : p.getValue();
  }},
         str);
    if (str == null) return null;

    // User column values
    str = StringUtils.replaceDelimited("#", "{!", "}", new Replacer() {
  public Object replace(String str) {
      UserColumn uc = report.findUserColumn(str);
      return uc == null ? "nil" : report.columnValue(uc);
  }},
         str);
    if (str == null) return null;

    // Column values
    str = StringUtils.replaceDelimited("#", "{", "}", new Replacer() {
  public Object replace(String str) {
      Column col = report.findColumn(str);
      if (col == null)
    return "{" + str + "}";
View Full Code Here

Examples of jregex.Replacer

    /** Create a new Replacer object for the given perl 5 substitution
     * expression */
    private static synchronized Replacer makeReplacer(String expression) {
        Pattern pattern = makePattern(expression);
        String replacement = getReplacement(expression);
        return new Replacer(pattern, replacement, true);
    }
View Full Code Here

Examples of jregex.Replacer

    }

    /** Get or create a new Replacer object for the given perl 5
     * substitution expression */
    private static synchronized Replacer getReplacer(String expression) {
        Replacer result = (Replacer) cachedReplacers.get(expression);

        if (result == null) try {
            result = makeReplacer(expression);
            cachedReplacers.put(expression, result);
        } catch (Throwable t) {
View Full Code Here

Examples of jregex.Replacer

                                          String newExpr, String input)
        throws RegexpException
    {
        try {
/*new*/    matcher = null;
/*new*/    Replacer r = getReplacer(newExpr);
/*new*/    String newResult = null;
/*new*/    synchronized (r) { newResult = r.replace(input); }

//*old*/    String oldResult = perl5.substitute(oldExpr, input);
//*cmp*/    if (!newResult.equals(oldResult)) {
//*cmp*/        showError("substitute disagreement!"+
//*cmp*/                           "\n\toldExpr=" + StringUtils.findAndReplace
View Full Code Here

Examples of net.infopeers.commons.regex.Replacer

    PrefixedPlaceholderFormatter f = new PrefixedPlaceholderFormatter();

    String regex = f.getReplaceRegex();
    Pattern p = Pattern.compile(regex);
   
    Replacer replacer = new Replacer(p){
      @Override
      protected String replace(int groupIndex, String value) {
        return value;
      }
    };
   
    assertEquals("/test/abc/format.test", replacer.replace(path));

  }
View Full Code Here

Examples of net.infopeers.commons.regex.Replacer

    private String toPath4Script(
        PatternParserWithPathFormat patternParser) {
      UrlPathParser pp = patternParser.getUrlPathParser();
      String path = pp.getPath();

      Replacer rep = new Replacer(phPattern) {
        @Override
        protected String replace(int groupIndex, String value) {
          return "' + " + value + " + '";
        }
      };
      return rep.replace(path);
    }
View Full Code Here

Examples of org.beangle.commons.text.replacer.Replacer

    System.out.println(sb1.toString());
    System.out.println("one cat two cats in the yard".replaceAll("cat", "dog"));
    System.out.println(clause.replaceAll("<#(.*)/>", "[#$1/]"));

    String test = "aaa    \nbbaad\n";
    Replacer replacer = new Replacer("( +?)\\n", "\n");
    System.out.print(test);
    System.out.print(replacer.process(test));
  }
View Full Code Here

Examples of org.jregex.Replacer

                    } else {
                        String around = Text.getText(arg);
                        pat = new Pattern(Pattern.quote(around));
                    }

                    Replacer r = pat.replacer(repl);
                    String result = r.replaceFirst(initial);

                    return context.runtime.newText(result);
                }
            }));

        obj.registerMethod(obj.runtime.newNativeMethod("Takes two text arguments where the first is the substring to replace, and the second is the replacement to insert. Will replace all matches, if any is found, and return a new Text with the result.", new TypeCheckingNativeMethod("replaceAll") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
                    .builder()
                    .receiverMustMimic(runtime.text)
                    .withRequiredPositional("pattern")
                    .withRequiredPositional("replacement")
                    .getArguments();

                @Override
                public TypeCheckingArgumentsDefinition getArguments() {
                    return ARGUMENTS;
                }

                @Override
                public Object activate(IokeObject self, Object on, List<Object> args, Map<String, Object> keywords, IokeObject context, IokeObject message) throws ControlFlow {
                    getArguments().getEvaluatedArguments(context, message, on, args, new HashMap<String, Object>());
                    String initial = Text.getText(on);
                    String repl = Text.getText(args.get(1));

                    Object arg = args.get(0);

                    Pattern pat = null;
                    if(IokeObject.data(arg) instanceof Regexp) {
                        pat = Regexp.getRegexp(arg);
                    } else {
                        String around = Text.getText(arg);
                        pat = new Pattern(Pattern.quote(around));
                    }

                    Replacer r = pat.replacer(repl);
                    String result = r.replace(initial);

                    return context.runtime.newText(result);
                }
            }));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.