Contract| Return type | wob | | Parameter key | Default value | Type | | maker | vector | var | | subject_for_maker | "_use_maker" | string | | field_separator | <char 10/> | type.<one_of pattern string <ref type.vector_of/>/> | | trim_fields | false | boolean | | Water Contract<method string.make_object
maker =vector
subject_for_maker="_use_maker"
field_separator=char.newline =<type.one_of pattern string <type.vector_of number.integer/>/>
trim_fields =false/> | |
See also: subvectors, make_objects, pattern
Creates an object by splitting the _subject string using the
field_separator and calling maker with those parts as objects.
a wob
| Parameter key | Default value | Type |
| field_separator | <char 10/> | type.<one_of pattern string <ref type.vector_of/>/> |
field_separator can either be a pattern that indicates where to
split the string (such as the newline pattern which is the default),
or a vector of integer-pair indices into the string
indicating subvectors to extract as fields.
For more information, see subvectors documentation.
Example: Using default field_separator
"Plusch
Mike".<make_object />
 | <v "Plusch" "Mike"/>
|
Example: Using character field_separator
"10,20".<make_object field_separator=char.comma />
 | <v "10" "20"/>
|
Example: Using pattern field_separator
"one#two&three".
<make_object field_separator=pattern.<one_of <char "#" /> <char "&" /> /> />
 | <v "one" "two" "three"/>
|
a wob
maker is either a method or an object. If it is a method, it is called
with arguments of the parts of the _subject string that are determined
by field_separator. If it is not a method, then maker is the parent
of a new object which is constructed by passing in the field values
to constructor call for maker.
Example: Using a class as maker
<class foo bar=0 baz=0 />
"10,20".<make_object field_separator=char.comma maker=foo />
 | <foo bar="10" baz="20"/>
|
Example: Using a method as maker
<method add_csv_strings _other_unkeyed=opt=wob=ekind.string>
<if> _other_unkeyed.<is_a vector />
_other_unkeyed.<for_each combiner=plus >
integer.<from value />
</for_each>
else
0
</if>
</method>
"10,20,30,35,40".
<make_objects field_separator=char.comma maker=add_csv_strings /> | <v 135/>
|
a wob
| Parameter key | Default value | Type |
| subject_for_maker | "_use_maker" | string |
subject_for_maker is the object used for _subject when
maker is called. There are two special values for this argument.
a wobsubject_for_maker="_use_maker"
The default value for subject_for_maker is
"_use_maker" which simply means
use the value of
maker for _subject.
Example: Use maker as _subject (default)
<class foo last=req first=req />
"Plusch
Mike".<make_object maker=foo subject_for_maker="_use_maker" />
 | <foo last="Plusch" first="Mike"/>
|
a wobsubject_for_maker="_first_value"
If the value is
"_first_value" then the first field value from
the
_subject string is used as the
_subject for the maker call.
Example: Use first value as _subject
"aabbbacc,a,x,all".
<make_object maker=replace subject_for_maker="_first_value" field_separator=char.comma />
 | "xxbbbxcc" |
The above example takes the first value
"aabbbacc" and uses it as
the subject of a call to
replace, which then uses
"a",
"x" and
"all" as arguments. The result is to replace
"all" occurrences of "a" with "x" in the string
"aabbbacc", giving
the result string
"xxbbbxcc".
a wob
| Parameter key | Default value | Type |
| trim_fields | false | boolean |
Indicates whether to trim white space from the beginning and end of fields
found by this method before passing them to the maker.
Example: trim_fields set to true
" one , two ".<make_object field_separator=char.comma trim_fields=true />
 | <v "one" "two"/>
|
© Copyright 2007 Clear Methods, Inc.