File: sublist.md

package info (click to toggle)
bnd 5.0.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 44,128 kB
  • sloc: java: 249,039; xml: 90,728; sh: 655; perl: 153; makefile: 96; python: 47; javascript: 9
file content (31 lines) | stat: -rw-r--r-- 675 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
layout: default
class: Macro
title: sublist ';' START ';' END (';' LIST )*
summary: Return a sublist of the list
---

	static String	_sublist	= "${sublist;<start>;<end>;<list>}";

	public String _sublist(String args[]) throws Exception {
		verifyCommand(args, _sublist, null, 4, Integer.MAX_VALUE);

		int start = Integer.parseInt(args[1]);
		int end = Integer.parseInt(args[2]);
		ExtList<String> list = toList(args, 3, Integer.MAX_VALUE);

		if (start < 0)
			start = list.size() + start + 1;

		if (end < 0)
			end = list.size() + end + 1;

		if (start > end) {
			int t = start;
			start = end;
			end = t;
		}

		return Processor.join(list.subList(start, end));
	}