Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1030852 // replaceAngleBracketVars

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3079L/18K).

static <A> S replaceAngleBracketVars(S s, Map<S, A> map) {
  ret empty(map) ? s : join(replaceAngleBracketVars(javaTokWithAngleBrackets(s), map));
}

static <A> LS replaceAngleBracketVars(LS tok, Map<S, A> map, BitSet replacedTokens_out default null) {
  if (empty(map)) ret tok;
  tok = cloneList(tok);
  for (int i = 1; i < l(tok); i += 2) {
    S t = tok.get(i);
    if (isAngleBracketed(t)) {
      A t2 = map.get(t);
      if (t2 == null) t2 = map.get(deAngleBracket(t));
      if (t2 != null) {
        tok.set(i, str(t2));
        bitSetSet(replacedTokens_out, i);
      }
    }
  }
  ret tok;
}

sS replaceAngleBracketVars(S s, O... params) {
  ret replaceAngleBracketVars(s, paramsToMap(params));
}

Author comment

Began life as a copy of #1004293

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030852
Snippet name: replaceAngleBracketVars
Eternal ID of this version: #1030852/8
Text MD5: 55a41f2e87b6fb02c833efbb67cc7f0f
Transpilation MD5: de95ac56d3417b73c1baa279aa6e974a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-15 16:50:43
Source code size: 730 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 191 / 281
Version history: 7 change(s)
Referenced in: [show references]