Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Reference Apex Classes

Name Arguments Returns Description


matches Boolean Attempts to match the entire region against the
pattern.
If the match succeeds, more information can be
obtained using the start, end, and group
methods.
See Using Regions.

pattern Pattern object Returns the Pattern object from which this Matcher
object was created.
region Integer start Matcher object Sets the limits of this Matcher object's region. The
region is the part of the input sequence that is
Integer end
searched to find a match. This method first resets
the Matcher object, then sets the region to start at
the index specified by start and end at the index
specified by end.
Depending on the transparency boundaries being
used, certain constructs such as anchors may behave
differently at or around the boundaries of the region.
See Using Regions and Using Bounds.

regionEnd Integer Returns the end index (exclusive) of this Matcher


object's region.
See Using Regions.

regionStart Integer Returns the start index (inclusive) of this Matcher


object's region.
See Using Regions.

replaceAll String s String Replaces every subsequence of the input sequence


that matches the pattern with the replacement string
s.

This method first resets the Matcher object, then


scans the input sequence looking for matches of the
pattern. Characters that are not part of any match
are appended directly to the result string; each match
is replaced in the result by the replacement string.
The replacement string may contain references to
captured subsequences.
Note that backslashes (\) and dollar signs ($) in the
replacement string may cause the results to be
different than if the string was treated as a literal
replacement string. Dollar signs may be treated as
references to captured subsequences, and backslashes

647
Reference Apex Classes

Name Arguments Returns Description


are used to escape literal characters in the
replacement string.
Invoking this method changes this Matcher object's
state. If the Matcher object is to be used in further
matching operations it should first be reset.
Given the regular expression a*b, the input
"aabfooaabfooabfoob", and the replacement
string "-", an invocation of this method on a
Matcher object for that expression would yield the
string "-foo-foo-foo-".

replaceFirst String s String Replaces the first subsequence of the input sequence
that matches the pattern with the replacement string
s.

Note that backslashes (\) and dollar signs ($) in the


replacement string may cause the results to be
different than if the string was treated as a literal
replacement string. Dollar signs may be treated as
references to captured subsequences, and backslashes
are used to escape literal characters in the
replacement string.
Invoking this method changes this Matcher object's
state. If the Matcher object is to be used in further
matching operations it should first be reset.
Given the regular expression dog, the input
"zzzdogzzzdogzzz", and the replacement string
"cat", an invocation of this method on a Matcher
object for that expression would return the string
"zzzcatzzzdogzzz".

requireEnd Boolean Returns true if more input could change a positive


match into a negative one.
If this method returns true, and a match was found,
then more input could cause the match to be lost.
If this method returns false and a match was found,
then more input might change the match but the
match won't be lost.
If a match was not found, then requireEnd has no
meaning.

648
Reference Apex Classes

Name Arguments Returns Description


reset Matcher object Resets this Matcher object. Resetting a Matcher
object discards all of its explicit state information.
This method does not change whether the Matcher
object uses anchoring bounds. You must explicitly
use the useAnchoringBounds method to change
the anchoring bounds.
For more information, see Using Bounds.

reset String s Matcher Resets this Matcher object with the new input
sequence s. Resetting a Matcher object discards all
of its explicit state information.
start Integer Returns the start index of the first character of the
previous match.
start Integer groupIndex Integer Returns the start index of the subsequence captured
by the group specified by groupIndex during the
previous match operation. Captured groups are
indexed from left to right, starting at one. Group
zero denotes the entire pattern, so the expression
m.start(0) is equivalent to m.start().

See Understanding Capturing Groups on page 641.

useAnchoringBounds Boolean b Matcher object Sets the anchoring bounds of the region for the
Matcher object. By default, a Matcher object uses
anchoring bounds regions.
If you specify true for this method, the Matcher
object uses anchoring bounds. If you specify false,
non-anchoring bounds are used.
If a Matcher object uses anchoring bounds, the
boundaries of this Matcher object's region match
start and end of line anchors such as ^ and $.
For more information, see Using Bounds on page
641.

usePattern Pattern pattern Matcher object Changes the Pattern object that the Matcher object
uses to find matches. This method causes the
Matcher object to lose information about the groups
of the last match that occurred. The Matcher object's
position in the input is maintained.

649
Reference Publisher Action Classes

Name Arguments Returns Description


useTransparentBounds Boolean b Matcher object Sets the transparency bounds for this Matcher object.
By default, a Matcher object uses anchoring bounds
regions.
If you specify true for this method, the Matcher
object uses transparent bounds. If you specify false,
opaque bounds are used.
For more information, see Using Bounds.

Publisher Action Classes


Note: In the application, QuickActions are referred to as actions.

The publisher actions feature lets you create actions and add them to the Chatter publisher on the home page, the Chatter
tab, and record detail pages. It also allows you to customize the order in which the standard Chatter actions appear, including
Post, File, Link, and Poll.
There are two general types of actions: create actions and custom actions.

• Create actions let users create records. They’re different from the New button on object tabs and the Quick Create and
Create New features on the home page. Create actions respect your validation rules and field requiredness, and you can
choose each action’s fields.
• Custom actions are Visualforce pages with functionality you define. For example, you might create a custom action to let
users write comments longer than 1000 characters.

For both types of actions, you can create either object-specific actions or global actions.
This section contains information about the Apex classes for creating these actions—referred to as QuickActions in Apex.
For more information on publisher actions, see the online help.

See Also:
QuickAction Class
QuickAction.QuickActionRequest Class
QuickAction.QuickActionResult Class

QuickAction Class
Use Apex to request and process publisher actions on objects that allow custom fields, on objects that appear in a Chatter feed,
or are available globally.

Methods
The following are static methods of the QuickAction class.

650
Reference Apex Classes

Method Arguments Return Type Description


performQuickAction QuickAction. QuickAction. Performs the quick action specified in the
QuickActionRequest QuickActionResult quick action request and returns the action
performQuickAction result.
performQuickAction QuickAction. QuickAction. Performs the quick action specified in the
QuickActionRequest QuickActionResult quick action request with the option for
performQuickAction partial success, and returns the result.
Boolean allOrNothing The allOrNothing argument specifies
whether this operation allows partial success.
If you specify false for this argument and
a record fails, the remainder of the DML
operation can still succeed. This method
returns a result object that can be used to
verify which records succeeded, which failed,
and why.

performQuickActions LIST<QuickAction. LIST<QuickAction. Performs the quick actions specified in the


QuickActionRequest> QuickActionResult> quick action request list and returns action
performQuickActions results.
performQuickActions LIST<QuickAction. LIST<QuickAction. Performs the quick actions specified in the
QuickActionRequest> QuickActionResult> quick action request list with the option for
performQuickActions partial success, and returns action results.
Boolean allOrNothing The allOrNothing argument specifies
whether this operation allows partial success.
If you specify false for this argument and
a record fails, the remainder of the DML
operation can still succeed. This method
returns a result object that can be used to
verify which records succeeded, which failed,
and why.

Samples
In this sample, the trigger determines if the new contacts to be inserted are created by a quick action. If so, it sets the
WhereFrom__c custom field to a value that depends on whether the quick action is global or local to the contact. Otherwise,
if the inserted contacts don’t originate from a quick action, the WhereFrom__c field is set to 'NoAction'.

trigger accTrig2 on Contact (before insert) {


for (Contact c : Trigger.new) {
if (c.getQuickActionName() == QuickAction.CreateContact) {
c.WhereFrom__c = 'GlobaActionl';
} else if (c.getQuickActionName() == Schema.Account.QuickAction.CreateContact) {
c.WhereFrom__c = 'AccountAction';
} else if (c.getQuickActionName() == null) {
c.WhereFrom__c = 'NoAction';
} else {
System.assert(false);
}
}
}

651

You might also like