@MinDoc(copyright="Copyright 2004, 2009 A. Weinert", author="Albrecht Weinert", version="V.56", lastModified="28.06.2021", usage="use for human friendly parsers", purpose="translate (polyglotly) keywords to unique integer codes") public class Action extends Object implements Cloneable
code
) and an
action-(value
).Action
, for example, would be (= code = 3)
to "Monday"
(= value = 2)
.selectedBy()
) can
ascertain, if a given String hits one of the keywords fully (Monday) or
as an abbreviation (Mo). Case can optionally be ignored (mO, LuNd).TimeHelper
.parse()
).Abbreviation | code | Meaning | Value |
---|---|---|---|
NOP | 0 | Do nothing | any, no meaning. |
SWD | 3 | Set day of week | 0: Sunday .. 6: Saturday |
SMON | 4 | Set Month | 1: January .. 12: December |
STZO | 5 | Set time zone offset in minutes |
-12*60 .. +12*60 should be n*30 |
STIM | 6 | Set time of day or the 0/12 hour add on hour:minute:second.ms |
0: Midnight 0:0:0 1: AM, ante meridiem) 2: Noon 12:00:00 3: Afternoon (PM, post meridiem, = add 12 h to clock reading) 4: End of day 23:59:59,999 (1 ms before next day) |
SDAY | 7 | Set day relative to today | 0: today, +1: tomorrow -1: yesterday, -2: day before ... |
SDAT | 8 | Set complete time / date day.month.year hour:minute:second.ms |
0: now |
SRATE | 11 | Set a rate / frequency | 1 : every second, 2: every minute, 3: every hour, .. |
SVERBOS | 13 | Set a level of verbosity for logs or reports | Verbos.DEBUG ..
Verbos.SILENT
|
TextHelper
,
TimeHelper.parse(CharSequence)
,
ColorHelper.getColor(CharSequence)
,
TimeHelper.TIME_CHOOSE
Modifier and Type | Class and Description |
---|---|
static class |
Action.Filter
A filter for Actions.
|
Modifier and Type | Field and Description |
---|---|
static Action.Filter |
ALL
A filter for (all) Actions.
|
int |
anzKeys
Number of keywords.
|
int |
code
Action code.
|
static int |
NOP
Action code: Don't do anything.
|
static int |
SCOLOR
Action code: Select colour.
|
static int |
SDAT
Action code: Set complete date.
|
static int |
SDAY
Action code: Set the day relative to today.
|
static int |
SMON
Action code: Set month.
|
static int |
SRATE
Action code: Rate.
|
static int |
STOD
Action code: Set time of day.
|
static int |
STZO
Action code: Set time zone offset.
|
static int |
SVERBOS
Action code: Report level.
|
static int |
SWD
Action code: Set day of week.
|
int |
value
Actions parameter (value).
|
Constructor and Description |
---|
Action(int code,
int value,
String[] keys)
Common Constructor (without any checks).
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Copy this Action.
|
boolean |
equals(Object other)
Compare to other Action.
|
String |
getKey(int number)
Get one of the keywords (by index).
|
int |
hashCode()
Hash code.
|
static Action.Filter |
makeCodeFilter(int code)
A filter for Actions by code.
|
static Action |
select(Action[] list,
Action.Filter filter,
CharSequence key,
boolean ignoreCase)
Find an Action from a list according to key.
|
int |
selectedBy(CharSequence key,
boolean ignoreCase)
Can this action be chosen by key.
|
String |
toString()
State as String.
|
public static final int NOP
0
public static final int SWD
public static final int SMON
public static final int STZO
code
= Offset in minutes -12*60..+12*60 in 60 (30,15) steps5
public static final int STOD
public static final int SDAY
code
= 0 : today, -1 : yesterday, +1 : tomorrow, and so on..7
public static final int SDAT
public static final int SRATE
code
= 1 : every second, 2: every minute, 3 : every hour,
4 : daily, 5 : weekly.11
public static final int SVERBOS
Verbos.toString()
,
Constant Field Valuespublic static final int SCOLOR
public final int code
public final int value
public final int anzKeys
public static final Action.Filter ALL
public Action(int code, int value, String[] keys)
keys
as is, i.e without copying it.select(Action[], Filter, CharSequence, boolean)
.TimeHelper.TIME_CHOOSE
, for human friendly time
parsers or ColorVal.COLOR_CHOOSE
for the same
with colours.code
- action codevalue
- action parameter, valuekeys
- all keywords meaning (code, value).public final Object clone()
public String getKey(int number)
number
and an index may be given
negative (absolute
value is used); compare selectedBy()
.number
- number of key + or - 1..anzKeys
public int selectedBy(CharSequence key, boolean ignoreCase)
key
- null or shorter than 2 (excluding an end dot) returns 0ignoreCase
- true means case insensitive matchingTextHelper.startsWith()
public static Action select(Action[] list, Action.Filter filter, CharSequence key, boolean ignoreCase)
list
(an array) of
Action
s, if that Action
is selected by the
key
and null otherwise.Action
, that matches key
directly
and completely, is returned. Other Action
s found, that would match
key
as an abbreviation, are ignored. (The first complete
match ends the search; complete matches are not checked for
ambiguousness.) If ignoreCase
is true, the matching is case
insensitive.Action
in list,
not equal
to the fist found, that matches key
as an abbreviation.Action
s rejected by the optional
filter
are ignored (as if not on list).list
- the list of possible Action
s to match key tofilter
- an optional filter, to select a subset from list. null
accepts all Action
s from list.key
- the choice; if key ends with a dot (.) that is removed;
if key is (then) shorter than 2, null is returnedignoreCase
- true: match non regarding caseAction
object or nullTimeHelper.parseDuration(CharSequence)
,
TextHelper.startsWith(CharSequence, CharSequence, boolean)
,
Action.Filter
,
makeCodeFilter(int)
public static Action.Filter makeCodeFilter(int code)
code
code
.code
- the action code