id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,400 |
zalando-stups/java-sproc-wrapper
|
src/main/java/de/zalando/sprocwrapper/proxy/StoredProcedure.java
|
StoredProcedure.partitionArguments
|
@SuppressWarnings("unchecked")
private Map<Integer, Object[]> partitionArguments(final DataSourceProvider dataSourceProvider,
final Object[] args) {
// use TreeMap here to maintain ordering by shard ID
final Map<Integer, Object[]> argumentsByShardId = Maps.newTreeMap();
// we need to partition by datasource instead of virtual shard ID (different virtual shard IDs are mapped to
// the same datasource e.g. by VirtualShardMd5Strategy)
final Map<DataSource, Integer> shardIdByDataSource = Maps.newHashMap();
// TODO: currently only implemented for single shardKey argument as first argument!
final List<Object> originalArgument = (List<Object>) args[0];
if (originalArgument == null || originalArgument.isEmpty()) {
throw new IllegalArgumentException("ShardKey (first argument) of sproc '" + name + "' not defined");
}
List<Object> partitionedArgument = null;
Object[] partitionedArguments = null;
int shardId;
Integer existingShardId;
DataSource dataSource;
for (final Object key : originalArgument) {
shardId = getShardId(new Object[] {key});
dataSource = dataSourceProvider.getDataSource(shardId);
existingShardId = shardIdByDataSource.get(dataSource);
if (existingShardId != null) {
// we already saw the same datasource => use the virtual shard ID of the first argument with the same
// datasource
shardId = existingShardId;
} else {
shardIdByDataSource.put(dataSource, shardId);
}
partitionedArguments = argumentsByShardId.get(shardId);
if (partitionedArguments == null) {
partitionedArgument = Lists.newArrayList();
partitionedArguments = new Object[args.length];
partitionedArguments[0] = partitionedArgument;
if (args.length > 1) {
System.arraycopy(args, 1, partitionedArguments, 1, args.length - 1);
}
argumentsByShardId.put(shardId, partitionedArguments);
} else {
partitionedArgument = (List<Object>) partitionedArguments[0];
}
partitionedArgument.add(key);
}
return argumentsByShardId;
}
|
java
|
@SuppressWarnings("unchecked")
private Map<Integer, Object[]> partitionArguments(final DataSourceProvider dataSourceProvider,
final Object[] args) {
// use TreeMap here to maintain ordering by shard ID
final Map<Integer, Object[]> argumentsByShardId = Maps.newTreeMap();
// we need to partition by datasource instead of virtual shard ID (different virtual shard IDs are mapped to
// the same datasource e.g. by VirtualShardMd5Strategy)
final Map<DataSource, Integer> shardIdByDataSource = Maps.newHashMap();
// TODO: currently only implemented for single shardKey argument as first argument!
final List<Object> originalArgument = (List<Object>) args[0];
if (originalArgument == null || originalArgument.isEmpty()) {
throw new IllegalArgumentException("ShardKey (first argument) of sproc '" + name + "' not defined");
}
List<Object> partitionedArgument = null;
Object[] partitionedArguments = null;
int shardId;
Integer existingShardId;
DataSource dataSource;
for (final Object key : originalArgument) {
shardId = getShardId(new Object[] {key});
dataSource = dataSourceProvider.getDataSource(shardId);
existingShardId = shardIdByDataSource.get(dataSource);
if (existingShardId != null) {
// we already saw the same datasource => use the virtual shard ID of the first argument with the same
// datasource
shardId = existingShardId;
} else {
shardIdByDataSource.put(dataSource, shardId);
}
partitionedArguments = argumentsByShardId.get(shardId);
if (partitionedArguments == null) {
partitionedArgument = Lists.newArrayList();
partitionedArguments = new Object[args.length];
partitionedArguments[0] = partitionedArgument;
if (args.length > 1) {
System.arraycopy(args, 1, partitionedArguments, 1, args.length - 1);
}
argumentsByShardId.put(shardId, partitionedArguments);
} else {
partitionedArgument = (List<Object>) partitionedArguments[0];
}
partitionedArgument.add(key);
}
return argumentsByShardId;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"Map",
"<",
"Integer",
",",
"Object",
"[",
"]",
">",
"partitionArguments",
"(",
"final",
"DataSourceProvider",
"dataSourceProvider",
",",
"final",
"Object",
"[",
"]",
"args",
")",
"{",
"// use TreeMap here to maintain ordering by shard ID",
"final",
"Map",
"<",
"Integer",
",",
"Object",
"[",
"]",
">",
"argumentsByShardId",
"=",
"Maps",
".",
"newTreeMap",
"(",
")",
";",
"// we need to partition by datasource instead of virtual shard ID (different virtual shard IDs are mapped to",
"// the same datasource e.g. by VirtualShardMd5Strategy)",
"final",
"Map",
"<",
"DataSource",
",",
"Integer",
">",
"shardIdByDataSource",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"// TODO: currently only implemented for single shardKey argument as first argument!",
"final",
"List",
"<",
"Object",
">",
"originalArgument",
"=",
"(",
"List",
"<",
"Object",
">",
")",
"args",
"[",
"0",
"]",
";",
"if",
"(",
"originalArgument",
"==",
"null",
"||",
"originalArgument",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"ShardKey (first argument) of sproc '\"",
"+",
"name",
"+",
"\"' not defined\"",
")",
";",
"}",
"List",
"<",
"Object",
">",
"partitionedArgument",
"=",
"null",
";",
"Object",
"[",
"]",
"partitionedArguments",
"=",
"null",
";",
"int",
"shardId",
";",
"Integer",
"existingShardId",
";",
"DataSource",
"dataSource",
";",
"for",
"(",
"final",
"Object",
"key",
":",
"originalArgument",
")",
"{",
"shardId",
"=",
"getShardId",
"(",
"new",
"Object",
"[",
"]",
"{",
"key",
"}",
")",
";",
"dataSource",
"=",
"dataSourceProvider",
".",
"getDataSource",
"(",
"shardId",
")",
";",
"existingShardId",
"=",
"shardIdByDataSource",
".",
"get",
"(",
"dataSource",
")",
";",
"if",
"(",
"existingShardId",
"!=",
"null",
")",
"{",
"// we already saw the same datasource => use the virtual shard ID of the first argument with the same",
"// datasource",
"shardId",
"=",
"existingShardId",
";",
"}",
"else",
"{",
"shardIdByDataSource",
".",
"put",
"(",
"dataSource",
",",
"shardId",
")",
";",
"}",
"partitionedArguments",
"=",
"argumentsByShardId",
".",
"get",
"(",
"shardId",
")",
";",
"if",
"(",
"partitionedArguments",
"==",
"null",
")",
"{",
"partitionedArgument",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"partitionedArguments",
"=",
"new",
"Object",
"[",
"args",
".",
"length",
"]",
";",
"partitionedArguments",
"[",
"0",
"]",
"=",
"partitionedArgument",
";",
"if",
"(",
"args",
".",
"length",
">",
"1",
")",
"{",
"System",
".",
"arraycopy",
"(",
"args",
",",
"1",
",",
"partitionedArguments",
",",
"1",
",",
"args",
".",
"length",
"-",
"1",
")",
";",
"}",
"argumentsByShardId",
".",
"put",
"(",
"shardId",
",",
"partitionedArguments",
")",
";",
"}",
"else",
"{",
"partitionedArgument",
"=",
"(",
"List",
"<",
"Object",
">",
")",
"partitionedArguments",
"[",
"0",
"]",
";",
"}",
"partitionedArgument",
".",
"add",
"(",
"key",
")",
";",
"}",
"return",
"argumentsByShardId",
";",
"}"
] |
split arguments by shard.
@param dataSourceProvider
@param args the original argument list
@return map of virtual shard ID to argument list (TreeMap with ordered keys: sorted by shard ID)
|
[
"split",
"arguments",
"by",
"shard",
"."
] |
b86a6243e83e8ea33d1a46e9dbac8c79082dc0ec
|
https://github.com/zalando-stups/java-sproc-wrapper/blob/b86a6243e83e8ea33d1a46e9dbac8c79082dc0ec/src/main/java/de/zalando/sprocwrapper/proxy/StoredProcedure.java#L324-L379
|
4,401 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/GenericTemplateElementBuilder.java
|
GenericTemplateElementBuilder.addLoginButton
|
public GenericTemplateElementBuilder addLoginButton(String url) {
Button button = ButtonFactory.createLoginButton(url);
this.element.addButton(button);
return this;
}
|
java
|
public GenericTemplateElementBuilder addLoginButton(String url) {
Button button = ButtonFactory.createLoginButton(url);
this.element.addButton(button);
return this;
}
|
[
"public",
"GenericTemplateElementBuilder",
"addLoginButton",
"(",
"String",
"url",
")",
"{",
"Button",
"button",
"=",
"ButtonFactory",
".",
"createLoginButton",
"(",
"url",
")",
";",
"this",
".",
"element",
".",
"addButton",
"(",
"button",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a login button on a generic template.
@param url
the url
@return this builder.
|
[
"Adds",
"a",
"login",
"button",
"on",
"a",
"generic",
"template",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/GenericTemplateElementBuilder.java#L207-L211
|
4,402 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/GenericTemplateElementBuilder.java
|
GenericTemplateElementBuilder.addBuyButton
|
public GenericTemplateElementBuilder addBuyButton(String payload,
PaymentSummary paymentSummary) {
Button button = ButtonFactory.createBuyButton(payload, paymentSummary);
this.element.addButton(button);
return this;
}
|
java
|
public GenericTemplateElementBuilder addBuyButton(String payload,
PaymentSummary paymentSummary) {
Button button = ButtonFactory.createBuyButton(payload, paymentSummary);
this.element.addButton(button);
return this;
}
|
[
"public",
"GenericTemplateElementBuilder",
"addBuyButton",
"(",
"String",
"payload",
",",
"PaymentSummary",
"paymentSummary",
")",
"{",
"Button",
"button",
"=",
"ButtonFactory",
".",
"createBuyButton",
"(",
"payload",
",",
"paymentSummary",
")",
";",
"this",
".",
"element",
".",
"addButton",
"(",
"button",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a buy button on a generic template.
@param payload
the payload
@param paymentSummary
the payment summary
@return this builder.
|
[
"Adds",
"a",
"buy",
"button",
"on",
"a",
"generic",
"template",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/GenericTemplateElementBuilder.java#L233-L238
|
4,403 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java
|
MessengerProfileApi.setWhitelistedDomains
|
public static void setWhitelistedDomains(List<String> whitelistedDomains) {
SetWhitelistedDomainsRequest request = new SetWhitelistedDomainsRequest(whitelistedDomains);
FbBotMillNetworkController.postMessengerProfile(request);
}
|
java
|
public static void setWhitelistedDomains(List<String> whitelistedDomains) {
SetWhitelistedDomainsRequest request = new SetWhitelistedDomainsRequest(whitelistedDomains);
FbBotMillNetworkController.postMessengerProfile(request);
}
|
[
"public",
"static",
"void",
"setWhitelistedDomains",
"(",
"List",
"<",
"String",
">",
"whitelistedDomains",
")",
"{",
"SetWhitelistedDomainsRequest",
"request",
"=",
"new",
"SetWhitelistedDomainsRequest",
"(",
"whitelistedDomains",
")",
";",
"FbBotMillNetworkController",
".",
"postMessengerProfile",
"(",
"request",
")",
";",
"}"
] |
Adds a list of domains that needs to be whitelisted.
@param whitelistedDomains
the list of domains to whitelist.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/messenger-profile/domain-whitelisting"
>Facebook's Messenger Platform Domain Whitelisting Documentation</a>
|
[
"Adds",
"a",
"list",
"of",
"domains",
"that",
"needs",
"to",
"be",
"whitelisted",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java#L150-L153
|
4,404 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java
|
MessengerProfileApi.setAccountLinkingUrl
|
public static void setAccountLinkingUrl(String accountLinkingUrl) {
SetAccountLinkingUrlRequest request = new SetAccountLinkingUrlRequest(accountLinkingUrl);
FbBotMillNetworkController.postMessengerProfile(request);
}
|
java
|
public static void setAccountLinkingUrl(String accountLinkingUrl) {
SetAccountLinkingUrlRequest request = new SetAccountLinkingUrlRequest(accountLinkingUrl);
FbBotMillNetworkController.postMessengerProfile(request);
}
|
[
"public",
"static",
"void",
"setAccountLinkingUrl",
"(",
"String",
"accountLinkingUrl",
")",
"{",
"SetAccountLinkingUrlRequest",
"request",
"=",
"new",
"SetAccountLinkingUrlRequest",
"(",
"accountLinkingUrl",
")",
";",
"FbBotMillNetworkController",
".",
"postMessengerProfile",
"(",
"request",
")",
";",
"}"
] |
Adds an URL used for account linking.
@param accountLinkingUrl
the URL for the account linking.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/messenger-profile/account-linking-url"
>Facebook's Messenger Platform Account Linking URL Documentation</a>
|
[
"Adds",
"an",
"URL",
"used",
"for",
"account",
"linking",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java#L176-L179
|
4,405 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java
|
MessengerProfileApi.setPersistentMenus
|
public static void setPersistentMenus(List<PersistentMenu> persistentMenu) {
PersistentMenuRequest persistentMenuRequest = new PersistentMenuRequest();
persistentMenuRequest.addAllPersistentMenu(persistentMenu);
FbBotMillNetworkController.postMessengerProfile(persistentMenuRequest);
}
|
java
|
public static void setPersistentMenus(List<PersistentMenu> persistentMenu) {
PersistentMenuRequest persistentMenuRequest = new PersistentMenuRequest();
persistentMenuRequest.addAllPersistentMenu(persistentMenu);
FbBotMillNetworkController.postMessengerProfile(persistentMenuRequest);
}
|
[
"public",
"static",
"void",
"setPersistentMenus",
"(",
"List",
"<",
"PersistentMenu",
">",
"persistentMenu",
")",
"{",
"PersistentMenuRequest",
"persistentMenuRequest",
"=",
"new",
"PersistentMenuRequest",
"(",
")",
";",
"persistentMenuRequest",
".",
"addAllPersistentMenu",
"(",
"persistentMenu",
")",
";",
"FbBotMillNetworkController",
".",
"postMessengerProfile",
"(",
"persistentMenuRequest",
")",
";",
"}"
] |
Sets the persistent menus.
@param persistentMenu
the new persistent menus
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu">
Facebook's Messenger Platform Persistent Menu Documentation</a>
|
[
"Sets",
"the",
"persistent",
"menus",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java#L203-L207
|
4,406 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java
|
MessengerProfileApi.setHomeUrl
|
public static void setHomeUrl(HomeUrl homeUrl) {
HomeUrlRequest homeUrlRequest = new HomeUrlRequest();
homeUrlRequest.setHomeUrl(homeUrl);
FbBotMillNetworkController.postMessengerProfile(homeUrlRequest);
}
|
java
|
public static void setHomeUrl(HomeUrl homeUrl) {
HomeUrlRequest homeUrlRequest = new HomeUrlRequest();
homeUrlRequest.setHomeUrl(homeUrl);
FbBotMillNetworkController.postMessengerProfile(homeUrlRequest);
}
|
[
"public",
"static",
"void",
"setHomeUrl",
"(",
"HomeUrl",
"homeUrl",
")",
"{",
"HomeUrlRequest",
"homeUrlRequest",
"=",
"new",
"HomeUrlRequest",
"(",
")",
";",
"homeUrlRequest",
".",
"setHomeUrl",
"(",
"homeUrl",
")",
";",
"FbBotMillNetworkController",
".",
"postMessengerProfile",
"(",
"homeUrlRequest",
")",
";",
"}"
] |
This sets the home url of the Bot
@param homeUrl
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/messenger-profile/home-url/v2.9">
Chat Extension Home URL</a>
|
[
"This",
"sets",
"the",
"home",
"url",
"of",
"the",
"Bot"
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/MessengerProfileApi.java#L230-L235
|
4,407 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/FbBotConfiguration.java
|
FbBotConfiguration.buildFbBotConfig
|
private void buildFbBotConfig() {
FbBotMillContext.getInstance().setup(
ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_PAGE_TOKEN),
ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_VALIDATION_TOKEN));
}
|
java
|
private void buildFbBotConfig() {
FbBotMillContext.getInstance().setup(
ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_PAGE_TOKEN),
ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_VALIDATION_TOKEN));
}
|
[
"private",
"void",
"buildFbBotConfig",
"(",
")",
"{",
"FbBotMillContext",
".",
"getInstance",
"(",
")",
".",
"setup",
"(",
"ConfigurationUtils",
".",
"getEncryptedConfiguration",
"(",
")",
".",
"getProperty",
"(",
"FB_BOTMILL_PAGE_TOKEN",
")",
",",
"ConfigurationUtils",
".",
"getEncryptedConfiguration",
"(",
")",
".",
"getProperty",
"(",
"FB_BOTMILL_VALIDATION_TOKEN",
")",
")",
";",
"}"
] |
Builds the Fb bot config.
@throws BotMillMissingConfigurationException
the bot mill missing configuration exception
|
[
"Builds",
"the",
"Fb",
"bot",
"config",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/FbBotConfiguration.java#L23-L29
|
4,408 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/event/base/BaseStringEvent.java
|
BaseStringEvent.verifyStringMatch
|
protected boolean verifyStringMatch(String text) {
if (text == null) {
return false;
}
if (!this.caseSensitive) {
text = text.toLowerCase();
}
return text.equals(this.expectedString);
}
|
java
|
protected boolean verifyStringMatch(String text) {
if (text == null) {
return false;
}
if (!this.caseSensitive) {
text = text.toLowerCase();
}
return text.equals(this.expectedString);
}
|
[
"protected",
"boolean",
"verifyStringMatch",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"this",
".",
"caseSensitive",
")",
"{",
"text",
"=",
"text",
".",
"toLowerCase",
"(",
")",
";",
"}",
"return",
"text",
".",
"equals",
"(",
"this",
".",
"expectedString",
")",
";",
"}"
] |
Verify string match.
@param text
the string used to check if it matches the event string.
@return true, if successful
|
[
"Verify",
"string",
"match",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/event/base/BaseStringEvent.java#L84-L92
|
4,409 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.addPaymentSettings
|
public static void addPaymentSettings(PaymentSettings paymentSettings) {
if (paymentSettings == null) {
logger.error("FbBotMill validation error: Payment Settings can't be null or empty!");
return;
}
FbBotMillNetworkController.postThreadSetting(paymentSettings);
}
|
java
|
public static void addPaymentSettings(PaymentSettings paymentSettings) {
if (paymentSettings == null) {
logger.error("FbBotMill validation error: Payment Settings can't be null or empty!");
return;
}
FbBotMillNetworkController.postThreadSetting(paymentSettings);
}
|
[
"public",
"static",
"void",
"addPaymentSettings",
"(",
"PaymentSettings",
"paymentSettings",
")",
"{",
"if",
"(",
"paymentSettings",
"==",
"null",
")",
"{",
"logger",
".",
"error",
"(",
"\"FbBotMill validation error: Payment Settings can't be null or empty!\"",
")",
";",
"return",
";",
"}",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"paymentSettings",
")",
";",
"}"
] |
This method is used to add any payment settings needed.
@param paymentSettings
the payment settings object.
@see <a
href="https://developers.facebook.com/docs/messenger-platform/thread-settings/payment"
>Payments settings</a>
|
[
"This",
"method",
"is",
"used",
"to",
"add",
"any",
"payment",
"settings",
"needed",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L88-L94
|
4,410 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.deleteGetStartedButton
|
public static void deleteGetStartedButton() {
CallToActionsRequest request = new CallToActionsRequest(
ThreadState.NEW_THREAD, null);
FbBotMillNetworkController.deleteThreadSetting(request);
}
|
java
|
public static void deleteGetStartedButton() {
CallToActionsRequest request = new CallToActionsRequest(
ThreadState.NEW_THREAD, null);
FbBotMillNetworkController.deleteThreadSetting(request);
}
|
[
"public",
"static",
"void",
"deleteGetStartedButton",
"(",
")",
"{",
"CallToActionsRequest",
"request",
"=",
"new",
"CallToActionsRequest",
"(",
"ThreadState",
".",
"NEW_THREAD",
",",
"null",
")",
";",
"FbBotMillNetworkController",
".",
"deleteThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Removes the current Get Started Button.
@see #setGetStartedButton(String)
|
[
"Removes",
"the",
"current",
"Get",
"Started",
"Button",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L145-L149
|
4,411 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.setPersistentMenu
|
public static void setPersistentMenu(List<Button> buttons) {
if (buttons == null || buttons.isEmpty() || buttons.size() > 5) {
logger.error("FbBotMill validation error: Persistent Menu Buttons can't be null or empty and must be less than 5!");
return;
}
CallToActionsRequest request = new CallToActionsRequest(
ThreadState.EXISTING_THREAD, buttons);
FbBotMillNetworkController.postThreadSetting(request);
}
|
java
|
public static void setPersistentMenu(List<Button> buttons) {
if (buttons == null || buttons.isEmpty() || buttons.size() > 5) {
logger.error("FbBotMill validation error: Persistent Menu Buttons can't be null or empty and must be less than 5!");
return;
}
CallToActionsRequest request = new CallToActionsRequest(
ThreadState.EXISTING_THREAD, buttons);
FbBotMillNetworkController.postThreadSetting(request);
}
|
[
"public",
"static",
"void",
"setPersistentMenu",
"(",
"List",
"<",
"Button",
">",
"buttons",
")",
"{",
"if",
"(",
"buttons",
"==",
"null",
"||",
"buttons",
".",
"isEmpty",
"(",
")",
"||",
"buttons",
".",
"size",
"(",
")",
">",
"5",
")",
"{",
"logger",
".",
"error",
"(",
"\"FbBotMill validation error: Persistent Menu Buttons can't be null or empty and must be less than 5!\"",
")",
";",
"return",
";",
"}",
"CallToActionsRequest",
"request",
"=",
"new",
"CallToActionsRequest",
"(",
"ThreadState",
".",
"EXISTING_THREAD",
",",
"buttons",
")",
";",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Sets a Persistent Menu of buttons which is always available to the user.
This menu should contain top-level actions that users can enact at any
point. Having a persistent menu easily communicates the basic
capabilities of your bot for first-time and returning users. The menu can
be invoked by a user, by tapping on the 3-caret icon on the left of the
composer.
@param buttons
a list of {@link Button} (max 5 elements) to use as menu. The
buttons can only be {@link PostbackButton} or
{@link WebUrlButton}. Phone buttons are not supported.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/thread-settings/persistent-menu"
>Facebook's Persistent Menu Documentation</a>
|
[
"Sets",
"a",
"Persistent",
"Menu",
"of",
"buttons",
"which",
"is",
"always",
"available",
"to",
"the",
"user",
".",
"This",
"menu",
"should",
"contain",
"top",
"-",
"level",
"actions",
"that",
"users",
"can",
"enact",
"at",
"any",
"point",
".",
"Having",
"a",
"persistent",
"menu",
"easily",
"communicates",
"the",
"basic",
"capabilities",
"of",
"your",
"bot",
"for",
"first",
"-",
"time",
"and",
"returning",
"users",
".",
"The",
"menu",
"can",
"be",
"invoked",
"by",
"a",
"user",
"by",
"tapping",
"on",
"the",
"3",
"-",
"caret",
"icon",
"on",
"the",
"left",
"of",
"the",
"composer",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L167-L175
|
4,412 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.deletePersistentMenu
|
public static void deletePersistentMenu() {
CallToActionsRequest request = new CallToActionsRequest(
ThreadState.EXISTING_THREAD, null);
FbBotMillNetworkController.deleteThreadSetting(request);
}
|
java
|
public static void deletePersistentMenu() {
CallToActionsRequest request = new CallToActionsRequest(
ThreadState.EXISTING_THREAD, null);
FbBotMillNetworkController.deleteThreadSetting(request);
}
|
[
"public",
"static",
"void",
"deletePersistentMenu",
"(",
")",
"{",
"CallToActionsRequest",
"request",
"=",
"new",
"CallToActionsRequest",
"(",
"ThreadState",
".",
"EXISTING_THREAD",
",",
"null",
")",
";",
"FbBotMillNetworkController",
".",
"deleteThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Removes the current Persistent Menu.
@see #setPersistentMenu(List)
|
[
"Removes",
"the",
"current",
"Persistent",
"Menu",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L182-L186
|
4,413 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.setWhiteListDomains
|
public static void setWhiteListDomains(List<String> whiteListDomains) {
WhitelistDomainRequest request = new WhitelistDomainRequest(
whiteListDomains, DomainActionType.ADD);
FbBotMillNetworkController.postThreadSetting(request);
}
|
java
|
public static void setWhiteListDomains(List<String> whiteListDomains) {
WhitelistDomainRequest request = new WhitelistDomainRequest(
whiteListDomains, DomainActionType.ADD);
FbBotMillNetworkController.postThreadSetting(request);
}
|
[
"public",
"static",
"void",
"setWhiteListDomains",
"(",
"List",
"<",
"String",
">",
"whiteListDomains",
")",
"{",
"WhitelistDomainRequest",
"request",
"=",
"new",
"WhitelistDomainRequest",
"(",
"whiteListDomains",
",",
"DomainActionType",
".",
"ADD",
")",
";",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Adds a list of domains that needs to be "white listed".
@param whiteListDomains
the list of domains in String.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/thread-settings/domain-whitelisting"
>Facebook's Messenger Platform Domain Whitelisting Thread Settings
Documentation</a>
|
[
"Adds",
"a",
"list",
"of",
"domains",
"that",
"needs",
"to",
"be",
"white",
"listed",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L198-L202
|
4,414 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.addWhiteListDomain
|
public static void addWhiteListDomain(String domain) {
WhitelistDomainRequest request = new WhitelistDomainRequest();
request.addWhiteListedDomain(domain);
request.setDomainActionType(DomainActionType.ADD);
FbBotMillNetworkController.postThreadSetting(request);
}
|
java
|
public static void addWhiteListDomain(String domain) {
WhitelistDomainRequest request = new WhitelistDomainRequest();
request.addWhiteListedDomain(domain);
request.setDomainActionType(DomainActionType.ADD);
FbBotMillNetworkController.postThreadSetting(request);
}
|
[
"public",
"static",
"void",
"addWhiteListDomain",
"(",
"String",
"domain",
")",
"{",
"WhitelistDomainRequest",
"request",
"=",
"new",
"WhitelistDomainRequest",
"(",
")",
";",
"request",
".",
"addWhiteListedDomain",
"(",
"domain",
")",
";",
"request",
".",
"setDomainActionType",
"(",
"DomainActionType",
".",
"ADD",
")",
";",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Adds a single domain on the list of domains that needs to be
"white listed".
@param domain
the domain that needs to be "white listed".
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/thread-settings/domain-whitelisting"
>Facebook's Messenger Platform Domain Whitelisting Thread Settings
Documentation</a>
|
[
"Adds",
"a",
"single",
"domain",
"on",
"the",
"list",
"of",
"domains",
"that",
"needs",
"to",
"be",
"white",
"listed",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L215-L220
|
4,415 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.deleteWhiteListDomain
|
public static void deleteWhiteListDomain(String domain) {
WhitelistDomainRequest request = new WhitelistDomainRequest();
request.addWhiteListedDomain(domain);
request.setDomainActionType(DomainActionType.REMOVE);
FbBotMillNetworkController.postThreadSetting(request);
}
|
java
|
public static void deleteWhiteListDomain(String domain) {
WhitelistDomainRequest request = new WhitelistDomainRequest();
request.addWhiteListedDomain(domain);
request.setDomainActionType(DomainActionType.REMOVE);
FbBotMillNetworkController.postThreadSetting(request);
}
|
[
"public",
"static",
"void",
"deleteWhiteListDomain",
"(",
"String",
"domain",
")",
"{",
"WhitelistDomainRequest",
"request",
"=",
"new",
"WhitelistDomainRequest",
"(",
")",
";",
"request",
".",
"addWhiteListedDomain",
"(",
"domain",
")",
";",
"request",
".",
"setDomainActionType",
"(",
"DomainActionType",
".",
"REMOVE",
")",
";",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Removes a single domain on the list of domains that needs to be
"white listed".
@param domain
the domain that needs to be removed.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/thread-settings/domain-whitelisting"
>Facebook's Messenger Platform Domain Whitelisting Thread Settings
Documentation</a>
|
[
"Removes",
"a",
"single",
"domain",
"on",
"the",
"list",
"of",
"domains",
"that",
"needs",
"to",
"be",
"white",
"listed",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L233-L238
|
4,416 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.deleteWhiteListDomains
|
public static void deleteWhiteListDomains(List<String> whiteListDomains) {
WhitelistDomainRequest request = new WhitelistDomainRequest(
whiteListDomains, DomainActionType.REMOVE);
FbBotMillNetworkController.postThreadSetting(request);
}
|
java
|
public static void deleteWhiteListDomains(List<String> whiteListDomains) {
WhitelistDomainRequest request = new WhitelistDomainRequest(
whiteListDomains, DomainActionType.REMOVE);
FbBotMillNetworkController.postThreadSetting(request);
}
|
[
"public",
"static",
"void",
"deleteWhiteListDomains",
"(",
"List",
"<",
"String",
">",
"whiteListDomains",
")",
"{",
"WhitelistDomainRequest",
"request",
"=",
"new",
"WhitelistDomainRequest",
"(",
"whiteListDomains",
",",
"DomainActionType",
".",
"REMOVE",
")",
";",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Removes a list of domains that are currently "white listed".
@param whiteListDomains
the list of domains that needs to be removed.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/thread-settings/domain-whitelisting"
>Facebook's Messenger Platform Domain Whitelisting Thread Settings
Documentation</a>
|
[
"Removes",
"a",
"list",
"of",
"domains",
"that",
"are",
"currently",
"white",
"listed",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L250-L254
|
4,417 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.setPaymentsPublicKey
|
public static void setPaymentsPublicKey(String publicKey) {
PaymentSettings request = new PaymentSettings();
request.setPrivacyUrl(publicKey);
FbBotMillNetworkController.postThreadSetting(request);
}
|
java
|
public static void setPaymentsPublicKey(String publicKey) {
PaymentSettings request = new PaymentSettings();
request.setPrivacyUrl(publicKey);
FbBotMillNetworkController.postThreadSetting(request);
}
|
[
"public",
"static",
"void",
"setPaymentsPublicKey",
"(",
"String",
"publicKey",
")",
"{",
"PaymentSettings",
"request",
"=",
"new",
"PaymentSettings",
"(",
")",
";",
"request",
".",
"setPrivacyUrl",
"(",
"publicKey",
")",
";",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Sets the payment public key. The payment_public_key is used to encrypt
sensitive payment data sent to you.
@param publicKey
the public key to set.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/thread-settings/payment"
>Facebook's Messenger Platform Payments Thread Settings
Documentation</a>
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/payments-reference#encryption_key"
>Facebook's Messenger Platform Creating Encryption Documentation</a>
@since 1.2.0
|
[
"Sets",
"the",
"payment",
"public",
"key",
".",
"The",
"payment_public_key",
"is",
"used",
"to",
"encrypt",
"sensitive",
"payment",
"data",
"sent",
"to",
"you",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L369-L373
|
4,418 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java
|
ThreadSettingsApi.setPaymentsPrivacyUrl
|
public static void setPaymentsPrivacyUrl(String privacyUrl) {
PaymentSettings request = new PaymentSettings();
request.setPrivacyUrl(privacyUrl);
FbBotMillNetworkController.postThreadSetting(request);
}
|
java
|
public static void setPaymentsPrivacyUrl(String privacyUrl) {
PaymentSettings request = new PaymentSettings();
request.setPrivacyUrl(privacyUrl);
FbBotMillNetworkController.postThreadSetting(request);
}
|
[
"public",
"static",
"void",
"setPaymentsPrivacyUrl",
"(",
"String",
"privacyUrl",
")",
"{",
"PaymentSettings",
"request",
"=",
"new",
"PaymentSettings",
"(",
")",
";",
"request",
".",
"setPrivacyUrl",
"(",
"privacyUrl",
")",
";",
"FbBotMillNetworkController",
".",
"postThreadSetting",
"(",
"request",
")",
";",
"}"
] |
Sets the payment privacy Url. The payment_privacy_url will appear in
Facebook's payment dialogs and people will be able to view these terms.
@param privacyUrl
the privacy Url to set.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/thread-settings/payment"
>Facebook's Messenger Platform Payments Thread Settings
Documentation</a>
@since 1.2.0
|
[
"Sets",
"the",
"payment",
"privacy",
"Url",
".",
"The",
"payment_privacy_url",
"will",
"appear",
"in",
"Facebook",
"s",
"payment",
"dialogs",
"and",
"people",
"will",
"be",
"able",
"to",
"view",
"these",
"terms",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/ThreadSettingsApi.java#L387-L391
|
4,419 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/autoreply/AutoReply.java
|
AutoReply.reply
|
public void reply(MessageEnvelope envelope) {
FbBotMillResponse response = createResponse(envelope);
if (response != null) {
// If the response is valid, replies to it.
if (validate(response)) {
FbBotMillNetworkController.postJsonMessage(response);
}
}
}
|
java
|
public void reply(MessageEnvelope envelope) {
FbBotMillResponse response = createResponse(envelope);
if (response != null) {
// If the response is valid, replies to it.
if (validate(response)) {
FbBotMillNetworkController.postJsonMessage(response);
}
}
}
|
[
"public",
"void",
"reply",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"FbBotMillResponse",
"response",
"=",
"createResponse",
"(",
"envelope",
")",
";",
"if",
"(",
"response",
"!=",
"null",
")",
"{",
"// If the response is valid, replies to it.",
"if",
"(",
"validate",
"(",
"response",
")",
")",
"{",
"FbBotMillNetworkController",
".",
"postJsonMessage",
"(",
"response",
")",
";",
"}",
"}",
"}"
] |
Method which defines the reply flow.
@param envelope
the current callback message
|
[
"Method",
"which",
"defines",
"the",
"reply",
"flow",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/autoreply/AutoReply.java#L49-L57
|
4,420 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/actionframe/ActionFrame.java
|
ActionFrame.process
|
public boolean process(MessageEnvelope envelope) {
if (this.event == null) {
return false;
}
boolean triggered = this.event.verifyEventCondition(envelope);
if (triggered) {
beforeReply(envelope);
if (this.reply != null) {
this.reply.reply(envelope);
}
afterReply(envelope);
}
return triggered;
}
|
java
|
public boolean process(MessageEnvelope envelope) {
if (this.event == null) {
return false;
}
boolean triggered = this.event.verifyEventCondition(envelope);
if (triggered) {
beforeReply(envelope);
if (this.reply != null) {
this.reply.reply(envelope);
}
afterReply(envelope);
}
return triggered;
}
|
[
"public",
"boolean",
"process",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"this",
".",
"event",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"boolean",
"triggered",
"=",
"this",
".",
"event",
".",
"verifyEventCondition",
"(",
"envelope",
")",
";",
"if",
"(",
"triggered",
")",
"{",
"beforeReply",
"(",
"envelope",
")",
";",
"if",
"(",
"this",
".",
"reply",
"!=",
"null",
")",
"{",
"this",
".",
"reply",
".",
"reply",
"(",
"envelope",
")",
";",
"}",
"afterReply",
"(",
"envelope",
")",
";",
"}",
"return",
"triggered",
";",
"}"
] |
Executes the reply if the event is triggered.
@param envelope
the incoming message.
@return true, if the event has been triggered.
|
[
"Executes",
"the",
"reply",
"if",
"the",
"event",
"is",
"triggered",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/actionframe/ActionFrame.java#L142-L156
|
4,421 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/actionframe/ActionFrame.java
|
ActionFrame.processMultipleReply
|
public boolean processMultipleReply(MessageEnvelope envelope) {
if (this.event == null) {
return false;
}
boolean triggered = this.event.verifyEventCondition(envelope);
if (triggered) {
beforeReply(envelope);
if (this.replies != null) {
synchronized (replies) {
for (AutoReply reply : replies) {
reply.reply(envelope);
}
}
}
afterReply(envelope);
}
return triggered;
}
|
java
|
public boolean processMultipleReply(MessageEnvelope envelope) {
if (this.event == null) {
return false;
}
boolean triggered = this.event.verifyEventCondition(envelope);
if (triggered) {
beforeReply(envelope);
if (this.replies != null) {
synchronized (replies) {
for (AutoReply reply : replies) {
reply.reply(envelope);
}
}
}
afterReply(envelope);
}
return triggered;
}
|
[
"public",
"boolean",
"processMultipleReply",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"this",
".",
"event",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"boolean",
"triggered",
"=",
"this",
".",
"event",
".",
"verifyEventCondition",
"(",
"envelope",
")",
";",
"if",
"(",
"triggered",
")",
"{",
"beforeReply",
"(",
"envelope",
")",
";",
"if",
"(",
"this",
".",
"replies",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"replies",
")",
"{",
"for",
"(",
"AutoReply",
"reply",
":",
"replies",
")",
"{",
"reply",
".",
"reply",
"(",
"envelope",
")",
";",
"}",
"}",
"}",
"afterReply",
"(",
"envelope",
")",
";",
"}",
"return",
"triggered",
";",
"}"
] |
Executes multiple replies when multiple autoreply is set.
@param envelope
the incoming message.
@return true, if the event has been triggered.
|
[
"Executes",
"multiple",
"replies",
"when",
"multiple",
"autoreply",
"is",
"set",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/actionframe/ActionFrame.java#L165-L182
|
4,422 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonFactory.java
|
ButtonFactory.createUrlButton
|
public static Button createUrlButton(String title, String url,
WebViewHeightRatioType ratioType) {
return new WebUrlButton(title, url, ratioType);
}
|
java
|
public static Button createUrlButton(String title, String url,
WebViewHeightRatioType ratioType) {
return new WebUrlButton(title, url, ratioType);
}
|
[
"public",
"static",
"Button",
"createUrlButton",
"(",
"String",
"title",
",",
"String",
"url",
",",
"WebViewHeightRatioType",
"ratioType",
")",
"{",
"return",
"new",
"WebUrlButton",
"(",
"title",
",",
"url",
",",
"ratioType",
")",
";",
"}"
] |
Creates a web view button.
@param title
the button label.
@param url
the URL to whom redirect when clicked.
@param ratioType
the web view ratio type.
@return the button
|
[
"Creates",
"a",
"web",
"view",
"button",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonFactory.java#L88-L91
|
4,423 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonFactory.java
|
ButtonFactory.createPostbackButton
|
public static Button createPostbackButton(String title, String payload) {
return new PostbackButton(title, ButtonType.POSTBACK, payload);
}
|
java
|
public static Button createPostbackButton(String title, String payload) {
return new PostbackButton(title, ButtonType.POSTBACK, payload);
}
|
[
"public",
"static",
"Button",
"createPostbackButton",
"(",
"String",
"title",
",",
"String",
"payload",
")",
"{",
"return",
"new",
"PostbackButton",
"(",
"title",
",",
"ButtonType",
".",
"POSTBACK",
",",
"payload",
")",
";",
"}"
] |
Creates a button which sends a payload back when clicked.
@param title
the button label.
@param payload
the payload to send back when clicked.
@return a {@link PostbackButton}.
|
[
"Creates",
"a",
"button",
"which",
"sends",
"a",
"payload",
"back",
"when",
"clicked",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonFactory.java#L102-L104
|
4,424 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonFactory.java
|
ButtonFactory.createPhoneNumberButton
|
public static Button createPhoneNumberButton(String title,
String phoneNumber) {
return new PostbackButton(title, ButtonType.PHONE_NUMBER, phoneNumber);
}
|
java
|
public static Button createPhoneNumberButton(String title,
String phoneNumber) {
return new PostbackButton(title, ButtonType.PHONE_NUMBER, phoneNumber);
}
|
[
"public",
"static",
"Button",
"createPhoneNumberButton",
"(",
"String",
"title",
",",
"String",
"phoneNumber",
")",
"{",
"return",
"new",
"PostbackButton",
"(",
"title",
",",
"ButtonType",
".",
"PHONE_NUMBER",
",",
"phoneNumber",
")",
";",
"}"
] |
Creates a button with a phone number.
@param title
the button label.
@param phoneNumber
a phone number. Must be in the format '+' prefix followed by
the country code, area code and local number.
@return a {@link PostbackButton}.
|
[
"Creates",
"a",
"button",
"with",
"a",
"phone",
"number",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonFactory.java#L116-L119
|
4,425 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.getDailyUniqueActiveThreadCounts
|
public static DailyUniqueActiveThreadCounts getDailyUniqueActiveThreadCounts() {
String pageToken = FbBotMillContext.getInstance().getPageToken();
BotMillNetworkResponse response = NetworkUtils
.get(FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSAGING_INSIGHT_ACTIVE_THREADS_URL
+ pageToken);
return FbBotMillJsonUtils.fromJson(response.getResponse(),
DailyUniqueActiveThreadCounts.class);
}
|
java
|
public static DailyUniqueActiveThreadCounts getDailyUniqueActiveThreadCounts() {
String pageToken = FbBotMillContext.getInstance().getPageToken();
BotMillNetworkResponse response = NetworkUtils
.get(FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSAGING_INSIGHT_ACTIVE_THREADS_URL
+ pageToken);
return FbBotMillJsonUtils.fromJson(response.getResponse(),
DailyUniqueActiveThreadCounts.class);
}
|
[
"public",
"static",
"DailyUniqueActiveThreadCounts",
"getDailyUniqueActiveThreadCounts",
"(",
")",
"{",
"String",
"pageToken",
"=",
"FbBotMillContext",
".",
"getInstance",
"(",
")",
".",
"getPageToken",
"(",
")",
";",
"BotMillNetworkResponse",
"response",
"=",
"NetworkUtils",
".",
"get",
"(",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_BASE_URL",
"+",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_MESSAGING_INSIGHT_ACTIVE_THREADS_URL",
"+",
"pageToken",
")",
";",
"return",
"FbBotMillJsonUtils",
".",
"fromJson",
"(",
"response",
".",
"getResponse",
"(",
")",
",",
"DailyUniqueActiveThreadCounts",
".",
"class",
")",
";",
"}"
] |
GETs the daily unique active thread counts.
@return the daily unique active thread counts.
|
[
"GETs",
"the",
"daily",
"unique",
"active",
"thread",
"counts",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L105-L113
|
4,426 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.getDailyUniqueConversationCounts
|
public static DailyUniqueConversationCounts getDailyUniqueConversationCounts() {
String pageToken = FbBotMillContext.getInstance().getPageToken();
BotMillNetworkResponse response = NetworkUtils
.get(FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSAGING_INSIGHT_CONVERSATION_URL
+ pageToken);
return FbBotMillJsonUtils.fromJson(response.getResponse(),
DailyUniqueConversationCounts.class);
}
|
java
|
public static DailyUniqueConversationCounts getDailyUniqueConversationCounts() {
String pageToken = FbBotMillContext.getInstance().getPageToken();
BotMillNetworkResponse response = NetworkUtils
.get(FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSAGING_INSIGHT_CONVERSATION_URL
+ pageToken);
return FbBotMillJsonUtils.fromJson(response.getResponse(),
DailyUniqueConversationCounts.class);
}
|
[
"public",
"static",
"DailyUniqueConversationCounts",
"getDailyUniqueConversationCounts",
"(",
")",
"{",
"String",
"pageToken",
"=",
"FbBotMillContext",
".",
"getInstance",
"(",
")",
".",
"getPageToken",
"(",
")",
";",
"BotMillNetworkResponse",
"response",
"=",
"NetworkUtils",
".",
"get",
"(",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_BASE_URL",
"+",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_MESSAGING_INSIGHT_CONVERSATION_URL",
"+",
"pageToken",
")",
";",
"return",
"FbBotMillJsonUtils",
".",
"fromJson",
"(",
"response",
".",
"getResponse",
"(",
")",
",",
"DailyUniqueConversationCounts",
".",
"class",
")",
";",
"}"
] |
GETs the daily unique conversation counts.
@return the daily unique conversation counts.
|
[
"GETs",
"the",
"daily",
"unique",
"conversation",
"counts",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L120-L128
|
4,427 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.postThreadSetting
|
public static void postThreadSetting(StringEntity input) {
String pageToken = FbBotMillContext.getInstance().getPageToken();
// If the page token is invalid, returns.
if (!validatePageToken(pageToken)) {
return;
}
String url = FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_THREAD_SETTINGS_URL
+ pageToken;
postInternal(url, input);
}
|
java
|
public static void postThreadSetting(StringEntity input) {
String pageToken = FbBotMillContext.getInstance().getPageToken();
// If the page token is invalid, returns.
if (!validatePageToken(pageToken)) {
return;
}
String url = FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_THREAD_SETTINGS_URL
+ pageToken;
postInternal(url, input);
}
|
[
"public",
"static",
"void",
"postThreadSetting",
"(",
"StringEntity",
"input",
")",
"{",
"String",
"pageToken",
"=",
"FbBotMillContext",
".",
"getInstance",
"(",
")",
".",
"getPageToken",
"(",
")",
";",
"// If the page token is invalid, returns.",
"if",
"(",
"!",
"validatePageToken",
"(",
"pageToken",
")",
")",
"{",
"return",
";",
"}",
"String",
"url",
"=",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_BASE_URL",
"+",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_THREAD_SETTINGS_URL",
"+",
"pageToken",
";",
"postInternal",
"(",
"url",
",",
"input",
")",
";",
"}"
] |
POSTs a thread setting as a JSON string to Facebook.
@param input
the JSON data to send.
|
[
"POSTs",
"a",
"thread",
"setting",
"as",
"a",
"JSON",
"string",
"to",
"Facebook",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L165-L176
|
4,428 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.postMessengerProfile
|
public static void postMessengerProfile(StringEntity input) {
String pageToken = FbBotMillContext.getInstance().getPageToken();
// If the page token is invalid, returns.
if (!validatePageToken(pageToken)) {
return;
}
String url = FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSENGER_PROFILE
+ pageToken;
postInternal(url, input);
}
|
java
|
public static void postMessengerProfile(StringEntity input) {
String pageToken = FbBotMillContext.getInstance().getPageToken();
// If the page token is invalid, returns.
if (!validatePageToken(pageToken)) {
return;
}
String url = FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSENGER_PROFILE
+ pageToken;
postInternal(url, input);
}
|
[
"public",
"static",
"void",
"postMessengerProfile",
"(",
"StringEntity",
"input",
")",
"{",
"String",
"pageToken",
"=",
"FbBotMillContext",
".",
"getInstance",
"(",
")",
".",
"getPageToken",
"(",
")",
";",
"// If the page token is invalid, returns.",
"if",
"(",
"!",
"validatePageToken",
"(",
"pageToken",
")",
")",
"{",
"return",
";",
"}",
"String",
"url",
"=",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_BASE_URL",
"+",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_MESSENGER_PROFILE",
"+",
"pageToken",
";",
"postInternal",
"(",
"url",
",",
"input",
")",
";",
"}"
] |
Post messenger profile.
@param input
the input
|
[
"Post",
"messenger",
"profile",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L184-L195
|
4,429 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.postInternal
|
private static BotMillNetworkResponse postInternal(String url,
StringEntity input) {
BotMillNetworkResponse response = NetworkUtils.post(url, input);
propagateResponse(response);
return response;
}
|
java
|
private static BotMillNetworkResponse postInternal(String url,
StringEntity input) {
BotMillNetworkResponse response = NetworkUtils.post(url, input);
propagateResponse(response);
return response;
}
|
[
"private",
"static",
"BotMillNetworkResponse",
"postInternal",
"(",
"String",
"url",
",",
"StringEntity",
"input",
")",
"{",
"BotMillNetworkResponse",
"response",
"=",
"NetworkUtils",
".",
"post",
"(",
"url",
",",
"input",
")",
";",
"propagateResponse",
"(",
"response",
")",
";",
"return",
"response",
";",
"}"
] |
Performs a POST and propagates it to the registered monitors.
@param url
the URL where to post.
@param input
the object to send.
@return the response.
|
[
"Performs",
"a",
"POST",
"and",
"propagates",
"it",
"to",
"the",
"registered",
"monitors",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L300-L305
|
4,430 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.deleteMessengerProfile
|
public static void deleteMessengerProfile(StringEntity input) {
String pageToken = FbBotMillContext.getInstance().getPageToken();
// If the page token is invalid, returns.
if (!validatePageToken(pageToken)) {
return;
}
String url = FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSENGER_PROFILE
+ pageToken;
BotMillNetworkResponse response = NetworkUtils.delete(url, input);
propagateResponse(response);
}
|
java
|
public static void deleteMessengerProfile(StringEntity input) {
String pageToken = FbBotMillContext.getInstance().getPageToken();
// If the page token is invalid, returns.
if (!validatePageToken(pageToken)) {
return;
}
String url = FbBotMillNetworkConstants.FACEBOOK_BASE_URL
+ FbBotMillNetworkConstants.FACEBOOK_MESSENGER_PROFILE
+ pageToken;
BotMillNetworkResponse response = NetworkUtils.delete(url, input);
propagateResponse(response);
}
|
[
"public",
"static",
"void",
"deleteMessengerProfile",
"(",
"StringEntity",
"input",
")",
"{",
"String",
"pageToken",
"=",
"FbBotMillContext",
".",
"getInstance",
"(",
")",
".",
"getPageToken",
"(",
")",
";",
"// If the page token is invalid, returns.",
"if",
"(",
"!",
"validatePageToken",
"(",
"pageToken",
")",
")",
"{",
"return",
";",
"}",
"String",
"url",
"=",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_BASE_URL",
"+",
"FbBotMillNetworkConstants",
".",
"FACEBOOK_MESSENGER_PROFILE",
"+",
"pageToken",
";",
"BotMillNetworkResponse",
"response",
"=",
"NetworkUtils",
".",
"delete",
"(",
"url",
",",
"input",
")",
";",
"propagateResponse",
"(",
"response",
")",
";",
"}"
] |
DELETEs a JSON string as a Facebook's Messenger Profile.
@param input
the JSON data to send.
|
[
"DELETEs",
"a",
"JSON",
"string",
"as",
"a",
"Facebook",
"s",
"Messenger",
"Profile",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L384-L396
|
4,431 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.validatePageToken
|
private static boolean validatePageToken(String pageToken) {
if (pageToken == null || "".equals(pageToken)) {
logger.error("FbBotMill validation error: Page token can't be null or empty! Have you called the method FbBotMillContext.getInstance().setup(String, String)?");
return false;
}
return true;
}
|
java
|
private static boolean validatePageToken(String pageToken) {
if (pageToken == null || "".equals(pageToken)) {
logger.error("FbBotMill validation error: Page token can't be null or empty! Have you called the method FbBotMillContext.getInstance().setup(String, String)?");
return false;
}
return true;
}
|
[
"private",
"static",
"boolean",
"validatePageToken",
"(",
"String",
"pageToken",
")",
"{",
"if",
"(",
"pageToken",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"pageToken",
")",
")",
"{",
"logger",
".",
"error",
"(",
"\"FbBotMill validation error: Page token can't be null or empty! Have you called the method FbBotMillContext.getInstance().setup(String, String)?\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates a Facebook Page Token.
@param pageToken
the token to validate.
@return true if the token is not null or empty, false otherwise.
|
[
"Validates",
"a",
"Facebook",
"Page",
"Token",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L416-L422
|
4,432 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.toStringEntity
|
private static StringEntity toStringEntity(Object object) {
StringEntity input = null;
try {
String json = FbBotMillJsonUtils.toJson(object);
input = new StringEntity(json, "UTF-8");
input.setContentType("application/json");
logger.debug("Request: {}", inputStreamToString(input.getContent()));
} catch (Exception e) {
logger.error("Error during JSON message creation: ", e);
}
return input;
}
|
java
|
private static StringEntity toStringEntity(Object object) {
StringEntity input = null;
try {
String json = FbBotMillJsonUtils.toJson(object);
input = new StringEntity(json, "UTF-8");
input.setContentType("application/json");
logger.debug("Request: {}", inputStreamToString(input.getContent()));
} catch (Exception e) {
logger.error("Error during JSON message creation: ", e);
}
return input;
}
|
[
"private",
"static",
"StringEntity",
"toStringEntity",
"(",
"Object",
"object",
")",
"{",
"StringEntity",
"input",
"=",
"null",
";",
"try",
"{",
"String",
"json",
"=",
"FbBotMillJsonUtils",
".",
"toJson",
"(",
"object",
")",
";",
"input",
"=",
"new",
"StringEntity",
"(",
"json",
",",
"\"UTF-8\"",
")",
";",
"input",
".",
"setContentType",
"(",
"\"application/json\"",
")",
";",
"logger",
".",
"debug",
"(",
"\"Request: {}\"",
",",
"inputStreamToString",
"(",
"input",
".",
"getContent",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error during JSON message creation: \"",
",",
"e",
")",
";",
"}",
"return",
"input",
";",
"}"
] |
Utility method that converts an object to its StringEntity
representation.
@param object
the object to convert to a StringEntity.
@return a {@link StringEntity} object containing the object JSON.
|
[
"Utility",
"method",
"that",
"converts",
"an",
"object",
"to",
"its",
"StringEntity",
"representation",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L432-L443
|
4,433 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java
|
FbBotMillNetworkController.inputStreamToString
|
private static String inputStreamToString(InputStream stream)
throws IOException {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
String resultString = null;
while ((length = stream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
resultString = result.toString("UTF-8");
return resultString;
}
|
java
|
private static String inputStreamToString(InputStream stream)
throws IOException {
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
String resultString = null;
while ((length = stream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
resultString = result.toString("UTF-8");
return resultString;
}
|
[
"private",
"static",
"String",
"inputStreamToString",
"(",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"result",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"int",
"length",
";",
"String",
"resultString",
"=",
"null",
";",
"while",
"(",
"(",
"length",
"=",
"stream",
".",
"read",
"(",
"buffer",
")",
")",
"!=",
"-",
"1",
")",
"{",
"result",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"length",
")",
";",
"}",
"resultString",
"=",
"result",
".",
"toString",
"(",
"\"UTF-8\"",
")",
";",
"return",
"resultString",
";",
"}"
] |
Utility method which converts an InputStream to a String.
@param stream
the InputStream to convert.
@return a String with the InputStream content.
@throws IOException
Signals that an I/O exception has occurred.
|
[
"Utility",
"method",
"which",
"converts",
"an",
"InputStream",
"to",
"a",
"String",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/network/FbBotMillNetworkController.java#L454-L465
|
4,434 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/incoming/handler/IncomingToOutgoingMessageHandler.java
|
IncomingToOutgoingMessageHandler.toEventActionFrame
|
private FbBotMillEvent toEventActionFrame(FbBotMillController botMillController)
throws BotMillEventMismatchException {
boolean caseSensitive = botMillController.caseSensitive();
switch (botMillController.eventType()) {
case MESSAGE:
if (!botMillController.text().equals("")) {
return new MessageEvent(botMillController.text(), caseSensitive);
} else {
throw new BotMillEventMismatchException("text attribute missing");
}
case MESSAGE_PATTERN:
if (!botMillController.pattern().equals("")) {
return new MessagePatternEvent(Pattern.compile(botMillController.pattern()));
} else {
throw new BotMillEventMismatchException("pattern attribute missing");
}
case POSTBACK:
if (!botMillController.postback().equals("")) {
return new PostbackEvent(botMillController.postback());
} else {
throw new BotMillEventMismatchException("postback attribute missing");
}
case POSTBACK_PATTERN:
if (!botMillController.postbackPattern().equals("")) {
return new PostbackPatternEvent(Pattern.compile(botMillController.postbackPattern()));
} else {
throw new BotMillEventMismatchException("postback pattern attribute missing");
}
case QUICK_REPLY_MESSAGE:
if (!botMillController.quickReplyPayload().equals("")) {
return new QuickReplyMessageEvent(botMillController.quickReplyPayload());
} else {
throw new BotMillEventMismatchException("quickpayload attribute missing");
}
case QUICK_REPLY_MESSAGE_PATTERN:
if (!botMillController.quickReplyPayloadPattern().equals("")) {
return new QuickReplyMessagePatternEvent(Pattern.compile(botMillController.quickReplyPayloadPattern()));
} else {
throw new BotMillEventMismatchException("quickpayload pattern attribute missing");
}
case REFERRAL:
return new ReferralEvent();
case ACCOUNT_LINKING:
return new AccountLinkingEvent();
case LOCATION:
return new LocationEvent();
case IMAGE:
return new ImageEvent();
case VIDEO:
return new VideoEvent();
case AUDIO:
return new AudioEvent();
case FILE:
return new FileEvent();
case ANY:
return new AnyEvent();
default:
throw new BotMillEventMismatchException("Unsupported Event Type: " + botMillController.eventType());
}
}
|
java
|
private FbBotMillEvent toEventActionFrame(FbBotMillController botMillController)
throws BotMillEventMismatchException {
boolean caseSensitive = botMillController.caseSensitive();
switch (botMillController.eventType()) {
case MESSAGE:
if (!botMillController.text().equals("")) {
return new MessageEvent(botMillController.text(), caseSensitive);
} else {
throw new BotMillEventMismatchException("text attribute missing");
}
case MESSAGE_PATTERN:
if (!botMillController.pattern().equals("")) {
return new MessagePatternEvent(Pattern.compile(botMillController.pattern()));
} else {
throw new BotMillEventMismatchException("pattern attribute missing");
}
case POSTBACK:
if (!botMillController.postback().equals("")) {
return new PostbackEvent(botMillController.postback());
} else {
throw new BotMillEventMismatchException("postback attribute missing");
}
case POSTBACK_PATTERN:
if (!botMillController.postbackPattern().equals("")) {
return new PostbackPatternEvent(Pattern.compile(botMillController.postbackPattern()));
} else {
throw new BotMillEventMismatchException("postback pattern attribute missing");
}
case QUICK_REPLY_MESSAGE:
if (!botMillController.quickReplyPayload().equals("")) {
return new QuickReplyMessageEvent(botMillController.quickReplyPayload());
} else {
throw new BotMillEventMismatchException("quickpayload attribute missing");
}
case QUICK_REPLY_MESSAGE_PATTERN:
if (!botMillController.quickReplyPayloadPattern().equals("")) {
return new QuickReplyMessagePatternEvent(Pattern.compile(botMillController.quickReplyPayloadPattern()));
} else {
throw new BotMillEventMismatchException("quickpayload pattern attribute missing");
}
case REFERRAL:
return new ReferralEvent();
case ACCOUNT_LINKING:
return new AccountLinkingEvent();
case LOCATION:
return new LocationEvent();
case IMAGE:
return new ImageEvent();
case VIDEO:
return new VideoEvent();
case AUDIO:
return new AudioEvent();
case FILE:
return new FileEvent();
case ANY:
return new AnyEvent();
default:
throw new BotMillEventMismatchException("Unsupported Event Type: " + botMillController.eventType());
}
}
|
[
"private",
"FbBotMillEvent",
"toEventActionFrame",
"(",
"FbBotMillController",
"botMillController",
")",
"throws",
"BotMillEventMismatchException",
"{",
"boolean",
"caseSensitive",
"=",
"botMillController",
".",
"caseSensitive",
"(",
")",
";",
"switch",
"(",
"botMillController",
".",
"eventType",
"(",
")",
")",
"{",
"case",
"MESSAGE",
":",
"if",
"(",
"!",
"botMillController",
".",
"text",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"MessageEvent",
"(",
"botMillController",
".",
"text",
"(",
")",
",",
"caseSensitive",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BotMillEventMismatchException",
"(",
"\"text attribute missing\"",
")",
";",
"}",
"case",
"MESSAGE_PATTERN",
":",
"if",
"(",
"!",
"botMillController",
".",
"pattern",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"MessagePatternEvent",
"(",
"Pattern",
".",
"compile",
"(",
"botMillController",
".",
"pattern",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BotMillEventMismatchException",
"(",
"\"pattern attribute missing\"",
")",
";",
"}",
"case",
"POSTBACK",
":",
"if",
"(",
"!",
"botMillController",
".",
"postback",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"PostbackEvent",
"(",
"botMillController",
".",
"postback",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BotMillEventMismatchException",
"(",
"\"postback attribute missing\"",
")",
";",
"}",
"case",
"POSTBACK_PATTERN",
":",
"if",
"(",
"!",
"botMillController",
".",
"postbackPattern",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"PostbackPatternEvent",
"(",
"Pattern",
".",
"compile",
"(",
"botMillController",
".",
"postbackPattern",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BotMillEventMismatchException",
"(",
"\"postback pattern attribute missing\"",
")",
";",
"}",
"case",
"QUICK_REPLY_MESSAGE",
":",
"if",
"(",
"!",
"botMillController",
".",
"quickReplyPayload",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"QuickReplyMessageEvent",
"(",
"botMillController",
".",
"quickReplyPayload",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BotMillEventMismatchException",
"(",
"\"quickpayload attribute missing\"",
")",
";",
"}",
"case",
"QUICK_REPLY_MESSAGE_PATTERN",
":",
"if",
"(",
"!",
"botMillController",
".",
"quickReplyPayloadPattern",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"return",
"new",
"QuickReplyMessagePatternEvent",
"(",
"Pattern",
".",
"compile",
"(",
"botMillController",
".",
"quickReplyPayloadPattern",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BotMillEventMismatchException",
"(",
"\"quickpayload pattern attribute missing\"",
")",
";",
"}",
"case",
"REFERRAL",
":",
"return",
"new",
"ReferralEvent",
"(",
")",
";",
"case",
"ACCOUNT_LINKING",
":",
"return",
"new",
"AccountLinkingEvent",
"(",
")",
";",
"case",
"LOCATION",
":",
"return",
"new",
"LocationEvent",
"(",
")",
";",
"case",
"IMAGE",
":",
"return",
"new",
"ImageEvent",
"(",
")",
";",
"case",
"VIDEO",
":",
"return",
"new",
"VideoEvent",
"(",
")",
";",
"case",
"AUDIO",
":",
"return",
"new",
"AudioEvent",
"(",
")",
";",
"case",
"FILE",
":",
"return",
"new",
"FileEvent",
"(",
")",
";",
"case",
"ANY",
":",
"return",
"new",
"AnyEvent",
"(",
")",
";",
"default",
":",
"throw",
"new",
"BotMillEventMismatchException",
"(",
"\"Unsupported Event Type: \"",
"+",
"botMillController",
".",
"eventType",
"(",
")",
")",
";",
"}",
"}"
] |
To event action frame.
@param botMillController
the bot mill controller
@return the fb bot mill event
@throws BotMillEventMismatchException
the bot mill event mismatch exception
|
[
"To",
"event",
"action",
"frame",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/incoming/handler/IncomingToOutgoingMessageHandler.java#L253-L313
|
4,435 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.safeGetQuickReplyPayload
|
protected String safeGetQuickReplyPayload(MessageEnvelope envelope) {
if (envelope != null && envelope.getMessage() != null
&& envelope.getMessage().getQuickReply() != null
&& envelope.getMessage().getQuickReply().getPayload() != null) {
return envelope.getMessage().getQuickReply().getPayload();
}
return "";
}
|
java
|
protected String safeGetQuickReplyPayload(MessageEnvelope envelope) {
if (envelope != null && envelope.getMessage() != null
&& envelope.getMessage().getQuickReply() != null
&& envelope.getMessage().getQuickReply().getPayload() != null) {
return envelope.getMessage().getQuickReply().getPayload();
}
return "";
}
|
[
"protected",
"String",
"safeGetQuickReplyPayload",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getQuickReply",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getQuickReply",
"(",
")",
".",
"getPayload",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getQuickReply",
"(",
")",
".",
"getPayload",
"(",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
Retrieves a quick reply payload from an envelope. It never returns null.
@param envelope
the message envelope.
@return the text message if found or an empty String otherwise. It never
returns null.
|
[
"Retrieves",
"a",
"quick",
"reply",
"payload",
"from",
"an",
"envelope",
".",
"It",
"never",
"returns",
"null",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L91-L99
|
4,436 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.safeGetRecipientId
|
protected String safeGetRecipientId(MessageEnvelope envelope) {
if (envelope != null && envelope.getRecipient() != null
&& envelope.getRecipient().getId() != null) {
return envelope.getRecipient().getId();
}
return "";
}
|
java
|
protected String safeGetRecipientId(MessageEnvelope envelope) {
if (envelope != null && envelope.getRecipient() != null
&& envelope.getRecipient().getId() != null) {
return envelope.getRecipient().getId();
}
return "";
}
|
[
"protected",
"String",
"safeGetRecipientId",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getRecipient",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getRecipient",
"(",
")",
".",
"getId",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"envelope",
".",
"getRecipient",
"(",
")",
".",
"getId",
"(",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
Retrieves the recipient ID from an envelope. It never returns null.
@param envelope
the message envelope.
@return the recipient ID if found or an empty String otherwise. It never
returns null.
|
[
"Retrieves",
"the",
"recipient",
"ID",
"from",
"an",
"envelope",
".",
"It",
"never",
"returns",
"null",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L125-L131
|
4,437 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.safeGetSenderId
|
protected String safeGetSenderId(MessageEnvelope envelope) {
if (envelope != null && envelope.getSender() != null
&& envelope.getSender().getId() != null) {
return envelope.getSender().getId();
}
return "";
}
|
java
|
protected String safeGetSenderId(MessageEnvelope envelope) {
if (envelope != null && envelope.getSender() != null
&& envelope.getSender().getId() != null) {
return envelope.getSender().getId();
}
return "";
}
|
[
"protected",
"String",
"safeGetSenderId",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getSender",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getSender",
"(",
")",
".",
"getId",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"envelope",
".",
"getSender",
"(",
")",
".",
"getId",
"(",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
Retrieves the sender ID from an envelope. It never returns null.
@param envelope
the message envelope.
@return the sender ID if found or an empty String otherwise. It never
returns null.
|
[
"Retrieves",
"the",
"sender",
"ID",
"from",
"an",
"envelope",
".",
"It",
"never",
"returns",
"null",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L141-L147
|
4,438 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.safeGetRecipient
|
protected User safeGetRecipient(MessageEnvelope envelope) {
if (envelope != null && envelope.getRecipient() != null
&& envelope.getRecipient().getId() != null) {
return envelope.getRecipient();
}
return new User();
}
|
java
|
protected User safeGetRecipient(MessageEnvelope envelope) {
if (envelope != null && envelope.getRecipient() != null
&& envelope.getRecipient().getId() != null) {
return envelope.getRecipient();
}
return new User();
}
|
[
"protected",
"User",
"safeGetRecipient",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getRecipient",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getRecipient",
"(",
")",
".",
"getId",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"envelope",
".",
"getRecipient",
"(",
")",
";",
"}",
"return",
"new",
"User",
"(",
")",
";",
"}"
] |
Retrieves the recipient from an envelope. It never returns null.
@param envelope
the message envelope.
@return a {@link User} containing the recipient if found, empty
otherwise. It never returns null.
|
[
"Retrieves",
"the",
"recipient",
"from",
"an",
"envelope",
".",
"It",
"never",
"returns",
"null",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L157-L163
|
4,439 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.getLocationMessage
|
protected LocationCoordinates getLocationMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getPayload() != null
&& envelope.getMessage().getAttachments().get(0).getPayload() instanceof QuickReplyLocationPayload) {
QuickReplyLocationPayload payload = (QuickReplyLocationPayload) envelope
.getMessage().getAttachments().get(0).getPayload();
return payload.getCoordinates();
}
return null;
}
|
java
|
protected LocationCoordinates getLocationMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getPayload() != null
&& envelope.getMessage().getAttachments().get(0).getPayload() instanceof QuickReplyLocationPayload) {
QuickReplyLocationPayload payload = (QuickReplyLocationPayload) envelope
.getMessage().getAttachments().get(0).getPayload();
return payload.getCoordinates();
}
return null;
}
|
[
"protected",
"LocationCoordinates",
"getLocationMessage",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getPayload",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getPayload",
"(",
")",
"instanceof",
"QuickReplyLocationPayload",
")",
"{",
"QuickReplyLocationPayload",
"payload",
"=",
"(",
"QuickReplyLocationPayload",
")",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getPayload",
"(",
")",
";",
"return",
"payload",
".",
"getCoordinates",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Retrieves the location from an envelope. It return nulls if none was
retrieved.
@param envelope
the message envelope
@return a {@link LocationCoordinates} containing the coordinates that the
user sets from the quick reply location payload.
|
[
"Retrieves",
"the",
"location",
"from",
"an",
"envelope",
".",
"It",
"return",
"nulls",
"if",
"none",
"was",
"retrieved",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L174-L188
|
4,440 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.getImageMessage
|
protected Attachment getImageMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.IMAGE) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
java
|
protected Attachment getImageMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.IMAGE) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
[
"protected",
"Attachment",
"getImageMessage",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getType",
"(",
")",
"==",
"AttachmentType",
".",
"IMAGE",
")",
"{",
"return",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the image message.
@param envelope the envelope
@return the image message
|
[
"Gets",
"the",
"image",
"message",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L196-L207
|
4,441 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.getAudioMessage
|
protected Attachment getAudioMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.AUDIO) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
java
|
protected Attachment getAudioMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.AUDIO) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
[
"protected",
"Attachment",
"getAudioMessage",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getType",
"(",
")",
"==",
"AttachmentType",
".",
"AUDIO",
")",
"{",
"return",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the audio message.
@param envelope the envelope
@return the audio message
|
[
"Gets",
"the",
"audio",
"message",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L215-L226
|
4,442 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.getVideoMessage
|
protected Attachment getVideoMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.VIDEO) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
java
|
protected Attachment getVideoMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.VIDEO) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
[
"protected",
"Attachment",
"getVideoMessage",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getType",
"(",
")",
"==",
"AttachmentType",
".",
"VIDEO",
")",
"{",
"return",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the video message.
@param envelope the envelope
@return the video message
|
[
"Gets",
"the",
"video",
"message",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L234-L245
|
4,443 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.getFileMessage
|
protected Attachment getFileMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.FILE) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
java
|
protected Attachment getFileMessage(MessageEnvelope envelope) {
if (envelope != null
&& envelope.getMessage() != null
&& envelope.getMessage().getAttachments() != null
&& envelope.getMessage().getAttachments().get(0) != null
&& envelope.getMessage().getAttachments().get(0).getType() == AttachmentType.FILE) {
return envelope.getMessage().getAttachments().get(0);
}
return null;
}
|
[
"protected",
"Attachment",
"getFileMessage",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getType",
"(",
")",
"==",
"AttachmentType",
".",
"FILE",
")",
"{",
"return",
"envelope",
".",
"getMessage",
"(",
")",
".",
"getAttachments",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets the file message.
@param envelope the envelope
@return the file message
|
[
"Gets",
"the",
"file",
"message",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L253-L264
|
4,444 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.safeGetSender
|
protected User safeGetSender(MessageEnvelope envelope) {
if (envelope != null && envelope.getSender() != null
&& envelope.getSender().getId() != null) {
return envelope.getSender();
}
return new User();
}
|
java
|
protected User safeGetSender(MessageEnvelope envelope) {
if (envelope != null && envelope.getSender() != null
&& envelope.getSender().getId() != null) {
return envelope.getSender();
}
return new User();
}
|
[
"protected",
"User",
"safeGetSender",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"if",
"(",
"envelope",
"!=",
"null",
"&&",
"envelope",
".",
"getSender",
"(",
")",
"!=",
"null",
"&&",
"envelope",
".",
"getSender",
"(",
")",
".",
"getId",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"envelope",
".",
"getSender",
"(",
")",
";",
"}",
"return",
"new",
"User",
"(",
")",
";",
"}"
] |
Retrieves the sender from an envelope. It never returns null.
@param envelope
the message envelope.
@return a {@link User} containing the sender if found, empty otherwise.
It never returns null.
|
[
"Retrieves",
"the",
"sender",
"from",
"an",
"envelope",
".",
"It",
"never",
"returns",
"null",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L274-L280
|
4,445 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java
|
FbBotMillBean.eventKind
|
protected FbBotMillEventType eventKind(MessageEnvelope envelope) {
IncomingMessage message = envelope.getMessage();
if (message != null) {
if (message instanceof ReceivedMessage) {
if (getLocationMessage(envelope) != null) {
return FbBotMillEventType.LOCATION;
}
if(getImageMessage(envelope) != null) {
return FbBotMillEventType.IMAGE;
}
if(getVideoMessage(envelope) != null) {
return FbBotMillEventType.VIDEO;
}
if(getAudioMessage(envelope) != null) {
return FbBotMillEventType.AUDIO;
}
if(getFileMessage(envelope) != null) {
return FbBotMillEventType.FILE;
}
return FbBotMillEventType.MESSAGE;
}
if (message instanceof EchoMessage) {
return FbBotMillEventType.ECHO;
}
}
if (envelope.getPostback() != null) {
return FbBotMillEventType.POSTBACK;
}
if (envelope.getDelivery() != null) {
return FbBotMillEventType.DELIVERY;
}
if (envelope.getRead() != null) {
return FbBotMillEventType.READ;
}
if (envelope.getAccountLinking() != null) {
return FbBotMillEventType.ACCOUNT_LINKING;
}
if (envelope.getOptin() != null) {
return FbBotMillEventType.AUTHENTICATION;
}
if (envelope.getCheckoutUpdate() != null) {
return FbBotMillEventType.CHECKOUT_UPDATE;
}
if (envelope.getReferral() != null) {
return FbBotMillEventType.REFERRAL;
}
if (envelope.getPayment() != null) {
return FbBotMillEventType.PAYMENT;
}
if (envelope.getPreCheckout() != null) {
return FbBotMillEventType.PRE_CHECKOUT;
}
return FbBotMillEventType.ANY;
}
|
java
|
protected FbBotMillEventType eventKind(MessageEnvelope envelope) {
IncomingMessage message = envelope.getMessage();
if (message != null) {
if (message instanceof ReceivedMessage) {
if (getLocationMessage(envelope) != null) {
return FbBotMillEventType.LOCATION;
}
if(getImageMessage(envelope) != null) {
return FbBotMillEventType.IMAGE;
}
if(getVideoMessage(envelope) != null) {
return FbBotMillEventType.VIDEO;
}
if(getAudioMessage(envelope) != null) {
return FbBotMillEventType.AUDIO;
}
if(getFileMessage(envelope) != null) {
return FbBotMillEventType.FILE;
}
return FbBotMillEventType.MESSAGE;
}
if (message instanceof EchoMessage) {
return FbBotMillEventType.ECHO;
}
}
if (envelope.getPostback() != null) {
return FbBotMillEventType.POSTBACK;
}
if (envelope.getDelivery() != null) {
return FbBotMillEventType.DELIVERY;
}
if (envelope.getRead() != null) {
return FbBotMillEventType.READ;
}
if (envelope.getAccountLinking() != null) {
return FbBotMillEventType.ACCOUNT_LINKING;
}
if (envelope.getOptin() != null) {
return FbBotMillEventType.AUTHENTICATION;
}
if (envelope.getCheckoutUpdate() != null) {
return FbBotMillEventType.CHECKOUT_UPDATE;
}
if (envelope.getReferral() != null) {
return FbBotMillEventType.REFERRAL;
}
if (envelope.getPayment() != null) {
return FbBotMillEventType.PAYMENT;
}
if (envelope.getPreCheckout() != null) {
return FbBotMillEventType.PRE_CHECKOUT;
}
return FbBotMillEventType.ANY;
}
|
[
"protected",
"FbBotMillEventType",
"eventKind",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"IncomingMessage",
"message",
"=",
"envelope",
".",
"getMessage",
"(",
")",
";",
"if",
"(",
"message",
"!=",
"null",
")",
"{",
"if",
"(",
"message",
"instanceof",
"ReceivedMessage",
")",
"{",
"if",
"(",
"getLocationMessage",
"(",
"envelope",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"LOCATION",
";",
"}",
"if",
"(",
"getImageMessage",
"(",
"envelope",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"IMAGE",
";",
"}",
"if",
"(",
"getVideoMessage",
"(",
"envelope",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"VIDEO",
";",
"}",
"if",
"(",
"getAudioMessage",
"(",
"envelope",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"AUDIO",
";",
"}",
"if",
"(",
"getFileMessage",
"(",
"envelope",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"FILE",
";",
"}",
"return",
"FbBotMillEventType",
".",
"MESSAGE",
";",
"}",
"if",
"(",
"message",
"instanceof",
"EchoMessage",
")",
"{",
"return",
"FbBotMillEventType",
".",
"ECHO",
";",
"}",
"}",
"if",
"(",
"envelope",
".",
"getPostback",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"POSTBACK",
";",
"}",
"if",
"(",
"envelope",
".",
"getDelivery",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"DELIVERY",
";",
"}",
"if",
"(",
"envelope",
".",
"getRead",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"READ",
";",
"}",
"if",
"(",
"envelope",
".",
"getAccountLinking",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"ACCOUNT_LINKING",
";",
"}",
"if",
"(",
"envelope",
".",
"getOptin",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"AUTHENTICATION",
";",
"}",
"if",
"(",
"envelope",
".",
"getCheckoutUpdate",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"CHECKOUT_UPDATE",
";",
"}",
"if",
"(",
"envelope",
".",
"getReferral",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"REFERRAL",
";",
"}",
"if",
"(",
"envelope",
".",
"getPayment",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"PAYMENT",
";",
"}",
"if",
"(",
"envelope",
".",
"getPreCheckout",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"FbBotMillEventType",
".",
"PRE_CHECKOUT",
";",
"}",
"return",
"FbBotMillEventType",
".",
"ANY",
";",
"}"
] |
Returns the kind of callback received for the current envelope.
@param envelope
the envelope to inspect.
@return a {@link FbBotMillEventType} representing the current callback
type.
|
[
"Returns",
"the",
"kind",
"of",
"callback",
"received",
"for",
"the",
"current",
"envelope",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/bean/FbBotMillBean.java#L290-L343
|
4,446 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/api/UploadApi.java
|
UploadApi.uploadAttachment
|
public static UploadAttachmentResponse uploadAttachment(
AttachmentType attachmentType, String attachmentUrl) {
AttachmentPayload payload = new AttachmentPayload(attachmentUrl, true);
Attachment attachment = new Attachment(attachmentType, payload);
AttachmentMessage message = new AttachmentMessage(attachment);
FbBotMillMessageResponse toSend = new FbBotMillMessageResponse(null, message);
return FbBotMillNetworkController.postUploadAttachment(toSend);
}
|
java
|
public static UploadAttachmentResponse uploadAttachment(
AttachmentType attachmentType, String attachmentUrl) {
AttachmentPayload payload = new AttachmentPayload(attachmentUrl, true);
Attachment attachment = new Attachment(attachmentType, payload);
AttachmentMessage message = new AttachmentMessage(attachment);
FbBotMillMessageResponse toSend = new FbBotMillMessageResponse(null, message);
return FbBotMillNetworkController.postUploadAttachment(toSend);
}
|
[
"public",
"static",
"UploadAttachmentResponse",
"uploadAttachment",
"(",
"AttachmentType",
"attachmentType",
",",
"String",
"attachmentUrl",
")",
"{",
"AttachmentPayload",
"payload",
"=",
"new",
"AttachmentPayload",
"(",
"attachmentUrl",
",",
"true",
")",
";",
"Attachment",
"attachment",
"=",
"new",
"Attachment",
"(",
"attachmentType",
",",
"payload",
")",
";",
"AttachmentMessage",
"message",
"=",
"new",
"AttachmentMessage",
"(",
"attachment",
")",
";",
"FbBotMillMessageResponse",
"toSend",
"=",
"new",
"FbBotMillMessageResponse",
"(",
"null",
",",
"message",
")",
";",
"return",
"FbBotMillNetworkController",
".",
"postUploadAttachment",
"(",
"toSend",
")",
";",
"}"
] |
Method to upload an attachment to Facebook's server in order to use it
later. Requires the pages_messaging permission.
@param attachmentType
the type of attachment to upload to Facebook. Please notice
that currently Facebook supports only image, audio, video and
file attachments.
@param attachmentUrl
the URL of the attachment to upload to Facebook.
@return nonexpiring ID for the attachment.
|
[
"Method",
"to",
"upload",
"an",
"attachment",
"to",
"Facebook",
"s",
"server",
"in",
"order",
"to",
"use",
"it",
"later",
".",
"Requires",
"the",
"pages_messaging",
"permission",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/api/UploadApi.java#L61-L68
|
4,447 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonTemplateBuilder.java
|
ButtonTemplateBuilder.addUrlButton
|
public ButtonTemplateBuilder addUrlButton(String title, String url,
WebViewHeightRatioType ratioType) {
Button button = ButtonFactory.createUrlButton(title, url, ratioType);
this.payload.addButton(button);
return this;
}
|
java
|
public ButtonTemplateBuilder addUrlButton(String title, String url,
WebViewHeightRatioType ratioType) {
Button button = ButtonFactory.createUrlButton(title, url, ratioType);
this.payload.addButton(button);
return this;
}
|
[
"public",
"ButtonTemplateBuilder",
"addUrlButton",
"(",
"String",
"title",
",",
"String",
"url",
",",
"WebViewHeightRatioType",
"ratioType",
")",
"{",
"Button",
"button",
"=",
"ButtonFactory",
".",
"createUrlButton",
"(",
"title",
",",
"url",
",",
"ratioType",
")",
";",
"this",
".",
"payload",
".",
"addButton",
"(",
"button",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a button which redirects to an URL when clicked to the current
template. There can be at most 3 buttons.
@param title
the title of the url button
@param url
the actual link of the this url button
@param ratioType
the size of the web view url.
@return
this builder
|
[
"Adds",
"a",
"button",
"which",
"redirects",
"to",
"an",
"URL",
"when",
"clicked",
"to",
"the",
"current",
"template",
".",
"There",
"can",
"be",
"at",
"most",
"3",
"buttons",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonTemplateBuilder.java#L93-L98
|
4,448 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonTemplateBuilder.java
|
ButtonTemplateBuilder.addPhoneNumberButton
|
public ButtonTemplateBuilder addPhoneNumberButton(String title,
String phoneNumber) {
Button button = ButtonFactory.createPhoneNumberButton(title,
phoneNumber);
this.payload.addButton(button);
return this;
}
|
java
|
public ButtonTemplateBuilder addPhoneNumberButton(String title,
String phoneNumber) {
Button button = ButtonFactory.createPhoneNumberButton(title,
phoneNumber);
this.payload.addButton(button);
return this;
}
|
[
"public",
"ButtonTemplateBuilder",
"addPhoneNumberButton",
"(",
"String",
"title",
",",
"String",
"phoneNumber",
")",
"{",
"Button",
"button",
"=",
"ButtonFactory",
".",
"createPhoneNumberButton",
"(",
"title",
",",
"phoneNumber",
")",
";",
"this",
".",
"payload",
".",
"addButton",
"(",
"button",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a button with a phone number to the current template. There can be
at most 3 buttons.
@param title
the button label.
@param phoneNumber
a phone number.
@return this builder.
|
[
"Adds",
"a",
"button",
"with",
"a",
"phone",
"number",
"to",
"the",
"current",
"template",
".",
"There",
"can",
"be",
"at",
"most",
"3",
"buttons",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonTemplateBuilder.java#L110-L116
|
4,449 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonTemplateBuilder.java
|
ButtonTemplateBuilder.addPostbackButton
|
public ButtonTemplateBuilder addPostbackButton(String title, String payload) {
Button button = ButtonFactory.createPostbackButton(title, payload);
this.payload.addButton(button);
return this;
}
|
java
|
public ButtonTemplateBuilder addPostbackButton(String title, String payload) {
Button button = ButtonFactory.createPostbackButton(title, payload);
this.payload.addButton(button);
return this;
}
|
[
"public",
"ButtonTemplateBuilder",
"addPostbackButton",
"(",
"String",
"title",
",",
"String",
"payload",
")",
"{",
"Button",
"button",
"=",
"ButtonFactory",
".",
"createPostbackButton",
"(",
"title",
",",
"payload",
")",
";",
"this",
".",
"payload",
".",
"addButton",
"(",
"button",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a button which sends a payload back when clicked to the current
template. There can be at most 3 buttons.
@param title
the button label.
@param payload
the payload to send back when clicked.
@return this builder.
|
[
"Adds",
"a",
"button",
"which",
"sends",
"a",
"payload",
"back",
"when",
"clicked",
"to",
"the",
"current",
"template",
".",
"There",
"can",
"be",
"at",
"most",
"3",
"buttons",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ButtonTemplateBuilder.java#L128-L132
|
4,450 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java
|
FbBotMillMockMediator.sendTextMessage
|
public void sendTextMessage(String message) {
MessageEnvelope envelope = new MessageEnvelope();
ReceivedMessage body = new ReceivedMessage();
body.setText(message);
envelope.setMessage(body);
envelope.setSender(new User(facebookMockId));
System.out.println("Sending message: [" + message + "] as user : ["
+ facebookMockId + "].");
forward(envelope);
System.out.println("Sent!");
}
|
java
|
public void sendTextMessage(String message) {
MessageEnvelope envelope = new MessageEnvelope();
ReceivedMessage body = new ReceivedMessage();
body.setText(message);
envelope.setMessage(body);
envelope.setSender(new User(facebookMockId));
System.out.println("Sending message: [" + message + "] as user : ["
+ facebookMockId + "].");
forward(envelope);
System.out.println("Sent!");
}
|
[
"public",
"void",
"sendTextMessage",
"(",
"String",
"message",
")",
"{",
"MessageEnvelope",
"envelope",
"=",
"new",
"MessageEnvelope",
"(",
")",
";",
"ReceivedMessage",
"body",
"=",
"new",
"ReceivedMessage",
"(",
")",
";",
"body",
".",
"setText",
"(",
"message",
")",
";",
"envelope",
".",
"setMessage",
"(",
"body",
")",
";",
"envelope",
".",
"setSender",
"(",
"new",
"User",
"(",
"facebookMockId",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Sending message: [\"",
"+",
"message",
"+",
"\"] as user : [\"",
"+",
"facebookMockId",
"+",
"\"].\"",
")",
";",
"forward",
"(",
"envelope",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Sent!\"",
")",
";",
"}"
] |
Sends a text message to all the registered bots. Used to simulate a user
typing in chat with your bot.
@param message
the message to send.
|
[
"Sends",
"a",
"text",
"message",
"to",
"all",
"the",
"registered",
"bots",
".",
"Used",
"to",
"simulate",
"a",
"user",
"typing",
"in",
"chat",
"with",
"your",
"bot",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java#L141-L153
|
4,451 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java
|
FbBotMillMockMediator.sendPayload
|
public void sendPayload(String payload) {
MessageEnvelope envelope = new MessageEnvelope();
Postback postback = new Postback();
postback.setPayload(payload);
envelope.setPostback(postback);
envelope.setSender(new User(facebookMockId));
System.out.println("Sending payload: [" + payload + "] as user : ["
+ facebookMockId + "].");
forward(envelope);
System.out.println("Sent!");
}
|
java
|
public void sendPayload(String payload) {
MessageEnvelope envelope = new MessageEnvelope();
Postback postback = new Postback();
postback.setPayload(payload);
envelope.setPostback(postback);
envelope.setSender(new User(facebookMockId));
System.out.println("Sending payload: [" + payload + "] as user : ["
+ facebookMockId + "].");
forward(envelope);
System.out.println("Sent!");
}
|
[
"public",
"void",
"sendPayload",
"(",
"String",
"payload",
")",
"{",
"MessageEnvelope",
"envelope",
"=",
"new",
"MessageEnvelope",
"(",
")",
";",
"Postback",
"postback",
"=",
"new",
"Postback",
"(",
")",
";",
"postback",
".",
"setPayload",
"(",
"payload",
")",
";",
"envelope",
".",
"setPostback",
"(",
"postback",
")",
";",
"envelope",
".",
"setSender",
"(",
"new",
"User",
"(",
"facebookMockId",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Sending payload: [\"",
"+",
"payload",
"+",
"\"] as user : [\"",
"+",
"facebookMockId",
"+",
"\"].\"",
")",
";",
"forward",
"(",
"envelope",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Sent!\"",
")",
";",
"}"
] |
Sends a payload to all the registered bots. Used to simulate a user
interacting with buttons.
@param payload
the payload to send.
|
[
"Sends",
"a",
"payload",
"to",
"all",
"the",
"registered",
"bots",
".",
"Used",
"to",
"simulate",
"a",
"user",
"interacting",
"with",
"buttons",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java#L162-L174
|
4,452 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java
|
FbBotMillMockMediator.sendQuickReplyPayload
|
public void sendQuickReplyPayload(String payload) {
MessageEnvelope envelope = new MessageEnvelope();
QuickReply quickReply = new QuickReply("Sample", payload);
ReceivedMessage message = new ReceivedMessage();
message.setQuickReply(quickReply);
envelope.setMessage(message);
envelope.setSender(new User(facebookMockId));
System.out.println("Sending quick reply: [" + message + "] as user : ["
+ facebookMockId + "].");
forward(envelope);
System.out.println("Sent!");
}
|
java
|
public void sendQuickReplyPayload(String payload) {
MessageEnvelope envelope = new MessageEnvelope();
QuickReply quickReply = new QuickReply("Sample", payload);
ReceivedMessage message = new ReceivedMessage();
message.setQuickReply(quickReply);
envelope.setMessage(message);
envelope.setSender(new User(facebookMockId));
System.out.println("Sending quick reply: [" + message + "] as user : ["
+ facebookMockId + "].");
forward(envelope);
System.out.println("Sent!");
}
|
[
"public",
"void",
"sendQuickReplyPayload",
"(",
"String",
"payload",
")",
"{",
"MessageEnvelope",
"envelope",
"=",
"new",
"MessageEnvelope",
"(",
")",
";",
"QuickReply",
"quickReply",
"=",
"new",
"QuickReply",
"(",
"\"Sample\"",
",",
"payload",
")",
";",
"ReceivedMessage",
"message",
"=",
"new",
"ReceivedMessage",
"(",
")",
";",
"message",
".",
"setQuickReply",
"(",
"quickReply",
")",
";",
"envelope",
".",
"setMessage",
"(",
"message",
")",
";",
"envelope",
".",
"setSender",
"(",
"new",
"User",
"(",
"facebookMockId",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Sending quick reply: [\"",
"+",
"message",
"+",
"\"] as user : [\"",
"+",
"facebookMockId",
"+",
"\"].\"",
")",
";",
"forward",
"(",
"envelope",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Sent!\"",
")",
";",
"}"
] |
Sends a quickreply to all the registered bots. Used to simulate a user
interacting with buttons.
@param payload
the payload to send.
|
[
"Sends",
"a",
"quickreply",
"to",
"all",
"the",
"registered",
"bots",
".",
"Used",
"to",
"simulate",
"a",
"user",
"interacting",
"with",
"buttons",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java#L183-L196
|
4,453 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java
|
FbBotMillMockMediator.forward
|
public void forward(MessageEnvelope envelope) {
List<FbBot> bots = FbBotMillContext.getInstance().getRegisteredBots();
for (FbBot b : bots) {
b.processMessage(envelope);
}
}
|
java
|
public void forward(MessageEnvelope envelope) {
List<FbBot> bots = FbBotMillContext.getInstance().getRegisteredBots();
for (FbBot b : bots) {
b.processMessage(envelope);
}
}
|
[
"public",
"void",
"forward",
"(",
"MessageEnvelope",
"envelope",
")",
"{",
"List",
"<",
"FbBot",
">",
"bots",
"=",
"FbBotMillContext",
".",
"getInstance",
"(",
")",
".",
"getRegisteredBots",
"(",
")",
";",
"for",
"(",
"FbBot",
"b",
":",
"bots",
")",
"{",
"b",
".",
"processMessage",
"(",
"envelope",
")",
";",
"}",
"}"
] |
Forwards an envelope to the registered bots.
@param envelope
the envelope to forward.
|
[
"Forwards",
"an",
"envelope",
"to",
"the",
"registered",
"bots",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/support/FbBotMillMockMediator.java#L204-L209
|
4,454 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/json/EnumLowercaseSerializer.java
|
EnumLowercaseSerializer.serialize
|
public JsonElement serialize(Enum<?> src, Type typeOfSrc,
JsonSerializationContext context) {
// Ignore this serializer for enums of class PaymentType.
if (src.getDeclaringClass().equals(PaymentType.class)) {
return context.serialize(src.name());
}
return context.serialize(src.name().toLowerCase());
}
|
java
|
public JsonElement serialize(Enum<?> src, Type typeOfSrc,
JsonSerializationContext context) {
// Ignore this serializer for enums of class PaymentType.
if (src.getDeclaringClass().equals(PaymentType.class)) {
return context.serialize(src.name());
}
return context.serialize(src.name().toLowerCase());
}
|
[
"public",
"JsonElement",
"serialize",
"(",
"Enum",
"<",
"?",
">",
"src",
",",
"Type",
"typeOfSrc",
",",
"JsonSerializationContext",
"context",
")",
"{",
"// Ignore this serializer for enums of class PaymentType.",
"if",
"(",
"src",
".",
"getDeclaringClass",
"(",
")",
".",
"equals",
"(",
"PaymentType",
".",
"class",
")",
")",
"{",
"return",
"context",
".",
"serialize",
"(",
"src",
".",
"name",
"(",
")",
")",
";",
"}",
"return",
"context",
".",
"serialize",
"(",
"src",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] |
Serializes an Enum as its lowercase name.
@param src
the src.
@param typeOfSrc
the type of src.
@param context
the context.
@return the json element.
|
[
"Serializes",
"an",
"Enum",
"as",
"its",
"lowercase",
"name",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/json/EnumLowercaseSerializer.java#L53-L62
|
4,455 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/event/base/BasePatternEvent.java
|
BasePatternEvent.verifyPatternMatch
|
protected boolean verifyPatternMatch(String text) {
if (this.expectedPattern == null) {
return false;
}
return this.expectedPattern.matcher(text).matches();
}
|
java
|
protected boolean verifyPatternMatch(String text) {
if (this.expectedPattern == null) {
return false;
}
return this.expectedPattern.matcher(text).matches();
}
|
[
"protected",
"boolean",
"verifyPatternMatch",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"this",
".",
"expectedPattern",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"this",
".",
"expectedPattern",
".",
"matcher",
"(",
"text",
")",
".",
"matches",
"(",
")",
";",
"}"
] |
Verify pattern match.
@param text
the string that we match against the {@link #expectedPattern}
object.
@return true, if successful
|
[
"Verify",
"pattern",
"match",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/event/base/BasePatternEvent.java#L75-L80
|
4,456 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/json/FbBotMillJsonUtils.java
|
FbBotMillJsonUtils.getGson
|
private static Gson getGson() {
if (gson == null) {
// Creates the Gson object which will manage the information
// received
GsonBuilder builder = new GsonBuilder();
// Serializes enums as lower-case.
builder.registerTypeHierarchyAdapter(Enum.class,
new EnumLowercaseSerializer());
// Serializes calendar in format YYYY-MM-DDThh:mm.
builder.registerTypeHierarchyAdapter(Calendar.class,
new CalendarSerializer());
// Deserializes payloads from interface.
builder.registerTypeAdapter(Attachment.class,
new AttachmentDeserializer());
// Serializes/deserializes buttons from interface.
builder.registerTypeAdapter(Button.class, new ButtonSerializer());
// Deserializes incoming messages from interface.
builder.registerTypeAdapter(IncomingMessage.class,
new IncomingMessageDeserializer());
// Deserializes timestamp as Calendar.
builder.registerTypeAdapter(Calendar.class,
new CalendarFromTimestampJsonDeserializer());
gson = builder.create();
}
return gson;
}
|
java
|
private static Gson getGson() {
if (gson == null) {
// Creates the Gson object which will manage the information
// received
GsonBuilder builder = new GsonBuilder();
// Serializes enums as lower-case.
builder.registerTypeHierarchyAdapter(Enum.class,
new EnumLowercaseSerializer());
// Serializes calendar in format YYYY-MM-DDThh:mm.
builder.registerTypeHierarchyAdapter(Calendar.class,
new CalendarSerializer());
// Deserializes payloads from interface.
builder.registerTypeAdapter(Attachment.class,
new AttachmentDeserializer());
// Serializes/deserializes buttons from interface.
builder.registerTypeAdapter(Button.class, new ButtonSerializer());
// Deserializes incoming messages from interface.
builder.registerTypeAdapter(IncomingMessage.class,
new IncomingMessageDeserializer());
// Deserializes timestamp as Calendar.
builder.registerTypeAdapter(Calendar.class,
new CalendarFromTimestampJsonDeserializer());
gson = builder.create();
}
return gson;
}
|
[
"private",
"static",
"Gson",
"getGson",
"(",
")",
"{",
"if",
"(",
"gson",
"==",
"null",
")",
"{",
"// Creates the Gson object which will manage the information",
"// received",
"GsonBuilder",
"builder",
"=",
"new",
"GsonBuilder",
"(",
")",
";",
"// Serializes enums as lower-case.",
"builder",
".",
"registerTypeHierarchyAdapter",
"(",
"Enum",
".",
"class",
",",
"new",
"EnumLowercaseSerializer",
"(",
")",
")",
";",
"// Serializes calendar in format YYYY-MM-DDThh:mm.",
"builder",
".",
"registerTypeHierarchyAdapter",
"(",
"Calendar",
".",
"class",
",",
"new",
"CalendarSerializer",
"(",
")",
")",
";",
"// Deserializes payloads from interface.",
"builder",
".",
"registerTypeAdapter",
"(",
"Attachment",
".",
"class",
",",
"new",
"AttachmentDeserializer",
"(",
")",
")",
";",
"// Serializes/deserializes buttons from interface.",
"builder",
".",
"registerTypeAdapter",
"(",
"Button",
".",
"class",
",",
"new",
"ButtonSerializer",
"(",
")",
")",
";",
"// Deserializes incoming messages from interface.",
"builder",
".",
"registerTypeAdapter",
"(",
"IncomingMessage",
".",
"class",
",",
"new",
"IncomingMessageDeserializer",
"(",
")",
")",
";",
"// Deserializes timestamp as Calendar.",
"builder",
".",
"registerTypeAdapter",
"(",
"Calendar",
".",
"class",
",",
"new",
"CalendarFromTimestampJsonDeserializer",
"(",
")",
")",
";",
"gson",
"=",
"builder",
".",
"create",
"(",
")",
";",
"}",
"return",
"gson",
";",
"}"
] |
Initializes the current Gson object if null and returns it. The Gson
object has custom adapters to manage datatypes according to Facebook
formats.
@return the current instance of Gson.
|
[
"Initializes",
"the",
"current",
"Gson",
"object",
"if",
"null",
"and",
"returns",
"it",
".",
"The",
"Gson",
"object",
"has",
"custom",
"adapters",
"to",
"manage",
"datatypes",
"according",
"to",
"Facebook",
"formats",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/json/FbBotMillJsonUtils.java#L62-L94
|
4,457 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/internal/util/json/FbBotMillJsonUtils.java
|
FbBotMillJsonUtils.fromJson
|
public static <T> T fromJson(String json, Class<T> T) {
return getGson().fromJson(json, T);
}
|
java
|
public static <T> T fromJson(String json, Class<T> T) {
return getGson().fromJson(json, T);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"fromJson",
"(",
"String",
"json",
",",
"Class",
"<",
"T",
">",
"T",
")",
"{",
"return",
"getGson",
"(",
")",
".",
"fromJson",
"(",
"json",
",",
"T",
")",
";",
"}"
] |
From json.
@param <T>
the generic type
@param json
the string from which the object is to be deserialized.
@param T
the type of the desired object.
@return an object of type T from the string. Returns null if json is
null.
@see Gson#fromJson(String, Class)
|
[
"From",
"json",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/internal/util/json/FbBotMillJsonUtils.java#L109-L111
|
4,458 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/FbBot.java
|
FbBot.buildAnnotatedInitBehaviour
|
private void buildAnnotatedInitBehaviour() {
Method[] methods = this.getClass().getMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(FbBotMillInit.class)) {
try {
method.invoke(this);
} catch (Exception e) {
logger.error(e.getMessage());
}
}
}
}
|
java
|
private void buildAnnotatedInitBehaviour() {
Method[] methods = this.getClass().getMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(FbBotMillInit.class)) {
try {
method.invoke(this);
} catch (Exception e) {
logger.error(e.getMessage());
}
}
}
}
|
[
"private",
"void",
"buildAnnotatedInitBehaviour",
"(",
")",
"{",
"Method",
"[",
"]",
"methods",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getMethods",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"methods",
")",
"{",
"if",
"(",
"method",
".",
"isAnnotationPresent",
"(",
"FbBotMillInit",
".",
"class",
")",
")",
"{",
"try",
"{",
"method",
".",
"invoke",
"(",
"this",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Builds the annotated init behaviour.
|
[
"Builds",
"the",
"annotated",
"init",
"behaviour",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/FbBot.java#L176-L187
|
4,459 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/FbBot.java
|
FbBot.addReply
|
protected void addReply(AutoReply reply) {
if(actionFrame == null) {
actionFrame = new ActionFrame(this.getEvent());
}
actionFrame.addReply(reply);
}
|
java
|
protected void addReply(AutoReply reply) {
if(actionFrame == null) {
actionFrame = new ActionFrame(this.getEvent());
}
actionFrame.addReply(reply);
}
|
[
"protected",
"void",
"addReply",
"(",
"AutoReply",
"reply",
")",
"{",
"if",
"(",
"actionFrame",
"==",
"null",
")",
"{",
"actionFrame",
"=",
"new",
"ActionFrame",
"(",
"this",
".",
"getEvent",
"(",
")",
")",
";",
"}",
"actionFrame",
".",
"addReply",
"(",
"reply",
")",
";",
"}"
] |
Adds the reply.
@param reply the reply
|
[
"Adds",
"the",
"reply",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/FbBot.java#L225-L230
|
4,460 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/FbBot.java
|
FbBot.executeReplies
|
protected void executeReplies() {
if(actionFrame.getEvent().verifyEventCondition(this.getEnvelope())) {
if (actionFrame.getReplies() != null && actionFrame.getReplies().size() > 0) {
if (actionFrame.processMultipleReply(envelope)
&& this.botMillPolicy.equals(BotMillPolicy.FIRST_ONLY)) {
}
} else {
if (actionFrame.process(envelope)
&& this.botMillPolicy.equals(BotMillPolicy.FIRST_ONLY)) {
}
}
}
actionFrame = null;
}
|
java
|
protected void executeReplies() {
if(actionFrame.getEvent().verifyEventCondition(this.getEnvelope())) {
if (actionFrame.getReplies() != null && actionFrame.getReplies().size() > 0) {
if (actionFrame.processMultipleReply(envelope)
&& this.botMillPolicy.equals(BotMillPolicy.FIRST_ONLY)) {
}
} else {
if (actionFrame.process(envelope)
&& this.botMillPolicy.equals(BotMillPolicy.FIRST_ONLY)) {
}
}
}
actionFrame = null;
}
|
[
"protected",
"void",
"executeReplies",
"(",
")",
"{",
"if",
"(",
"actionFrame",
".",
"getEvent",
"(",
")",
".",
"verifyEventCondition",
"(",
"this",
".",
"getEnvelope",
"(",
")",
")",
")",
"{",
"if",
"(",
"actionFrame",
".",
"getReplies",
"(",
")",
"!=",
"null",
"&&",
"actionFrame",
".",
"getReplies",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"actionFrame",
".",
"processMultipleReply",
"(",
"envelope",
")",
"&&",
"this",
".",
"botMillPolicy",
".",
"equals",
"(",
"BotMillPolicy",
".",
"FIRST_ONLY",
")",
")",
"{",
"}",
"}",
"else",
"{",
"if",
"(",
"actionFrame",
".",
"process",
"(",
"envelope",
")",
"&&",
"this",
".",
"botMillPolicy",
".",
"equals",
"(",
"BotMillPolicy",
".",
"FIRST_ONLY",
")",
")",
"{",
"}",
"}",
"}",
"actionFrame",
"=",
"null",
";",
"}"
] |
Execute replies.
|
[
"Execute",
"replies",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/FbBot.java#L235-L248
|
4,461 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java
|
ReplyFactory.getReusableImageAttachment
|
public static AttachmentMessageBuilder getReusableImageAttachment(String attachmentId) {
AttachmentPayload payload = new AttachmentPayload();
payload.setAttachmentId(attachmentId);
return new AttachmentMessageBuilder(AttachmentType.IMAGE, payload);
}
|
java
|
public static AttachmentMessageBuilder getReusableImageAttachment(String attachmentId) {
AttachmentPayload payload = new AttachmentPayload();
payload.setAttachmentId(attachmentId);
return new AttachmentMessageBuilder(AttachmentType.IMAGE, payload);
}
|
[
"public",
"static",
"AttachmentMessageBuilder",
"getReusableImageAttachment",
"(",
"String",
"attachmentId",
")",
"{",
"AttachmentPayload",
"payload",
"=",
"new",
"AttachmentPayload",
"(",
")",
";",
"payload",
".",
"setAttachmentId",
"(",
"attachmentId",
")",
";",
"return",
"new",
"AttachmentMessageBuilder",
"(",
"AttachmentType",
".",
"IMAGE",
",",
"payload",
")",
";",
"}"
] |
Get the reusable image attachment
@param attachmentId
the attachment id generated by the upload api
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment"
> Facebook's Messenger Platform Image Attachment Documentation</a>
|
[
"Get",
"the",
"reusable",
"image",
"attachment"
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java#L139-L143
|
4,462 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java
|
ReplyFactory.getReusableAudioAttachment
|
public static AttachmentMessageBuilder getReusableAudioAttachment(String attachmentId) {
AttachmentPayload payload = new AttachmentPayload();
payload.setAttachmentId(attachmentId);
return new AttachmentMessageBuilder(AttachmentType.AUDIO, payload);
}
|
java
|
public static AttachmentMessageBuilder getReusableAudioAttachment(String attachmentId) {
AttachmentPayload payload = new AttachmentPayload();
payload.setAttachmentId(attachmentId);
return new AttachmentMessageBuilder(AttachmentType.AUDIO, payload);
}
|
[
"public",
"static",
"AttachmentMessageBuilder",
"getReusableAudioAttachment",
"(",
"String",
"attachmentId",
")",
"{",
"AttachmentPayload",
"payload",
"=",
"new",
"AttachmentPayload",
"(",
")",
";",
"payload",
".",
"setAttachmentId",
"(",
"attachmentId",
")",
";",
"return",
"new",
"AttachmentMessageBuilder",
"(",
"AttachmentType",
".",
"AUDIO",
",",
"payload",
")",
";",
"}"
] |
Get the reusable audio attachment
@param attachmentId
the attachment id generated by the upload api
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/audio-attachment"
> Facebook's Messenger Platform Audio Attachment Documentation</a>
|
[
"Get",
"the",
"reusable",
"audio",
"attachment"
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java#L169-L173
|
4,463 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java
|
ReplyFactory.getReusableFileAttachment
|
public static AttachmentMessageBuilder getReusableFileAttachment(String attachmentId) {
AttachmentPayload payload = new AttachmentPayload();
payload.setAttachmentId(attachmentId);
return new AttachmentMessageBuilder(AttachmentType.VIDEO, payload);
}
|
java
|
public static AttachmentMessageBuilder getReusableFileAttachment(String attachmentId) {
AttachmentPayload payload = new AttachmentPayload();
payload.setAttachmentId(attachmentId);
return new AttachmentMessageBuilder(AttachmentType.VIDEO, payload);
}
|
[
"public",
"static",
"AttachmentMessageBuilder",
"getReusableFileAttachment",
"(",
"String",
"attachmentId",
")",
"{",
"AttachmentPayload",
"payload",
"=",
"new",
"AttachmentPayload",
"(",
")",
";",
"payload",
".",
"setAttachmentId",
"(",
"attachmentId",
")",
";",
"return",
"new",
"AttachmentMessageBuilder",
"(",
"AttachmentType",
".",
"VIDEO",
",",
"payload",
")",
";",
"}"
] |
Get the reusable file attachment
@param attachmentId
the attachment id generated by the upload api
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/file-attachment"
> Facebook's Messenger Platform File Attachment Documentation</a>
|
[
"Get",
"the",
"reusable",
"file",
"attachment"
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java#L229-L233
|
4,464 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java
|
ReplyFactory.addAirlineItineraryTemplate
|
public static AirlineItineraryTemplateBuilder addAirlineItineraryTemplate(
String introMessage, String locale, String pnrNumber,
BigDecimal totalPrice, String currency) {
return new AirlineItineraryTemplateBuilder(introMessage, locale,
pnrNumber, totalPrice, currency);
}
|
java
|
public static AirlineItineraryTemplateBuilder addAirlineItineraryTemplate(
String introMessage, String locale, String pnrNumber,
BigDecimal totalPrice, String currency) {
return new AirlineItineraryTemplateBuilder(introMessage, locale,
pnrNumber, totalPrice, currency);
}
|
[
"public",
"static",
"AirlineItineraryTemplateBuilder",
"addAirlineItineraryTemplate",
"(",
"String",
"introMessage",
",",
"String",
"locale",
",",
"String",
"pnrNumber",
",",
"BigDecimal",
"totalPrice",
",",
"String",
"currency",
")",
"{",
"return",
"new",
"AirlineItineraryTemplateBuilder",
"(",
"introMessage",
",",
"locale",
",",
"pnrNumber",
",",
"totalPrice",
",",
"currency",
")",
";",
"}"
] |
Adds an Airline Itinerary Template to the response.
@param introMessage
the message to send before the template. It can't be empty.
@param locale
the current locale. It can't be empty and must be in format
[a-z]{2}_[A-Z]{2}. Locale must be in format [a-z]{2}_[A-Z]{2}.
For more information see<a href=
"https://developers.facebook.com/docs/internationalization#locales"
> Facebook's locale support</a>.
@param pnrNumber
the Passenger Name Record number (Booking Number). It can't be
empty.
@param totalPrice
the total price of the itinerary.
@param currency
the currency for the price. It can't be empty. The currency
must be a three digit ISO-4217-3 code in format [A-Z]{3}. For
more information see <a href=
"https://developers.facebook.com/docs/payments/reference/supportedcurrencies"
> Facebook's currency support</a>
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-itinerary-template"
> Facebook's Messenger Platform Airline Itinerary Template
Documentation</a>
|
[
"Adds",
"an",
"Airline",
"Itinerary",
"Template",
"to",
"the",
"response",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java#L294-L299
|
4,465 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java
|
ReplyFactory.addAirlineCheckinTemplate
|
public static AirlineCheckinTemplateBuilder addAirlineCheckinTemplate(
String introMessage, String locale, String pnrNumber,
String checkinUrl) {
return new AirlineCheckinTemplateBuilder(introMessage, locale,
pnrNumber, checkinUrl);
}
|
java
|
public static AirlineCheckinTemplateBuilder addAirlineCheckinTemplate(
String introMessage, String locale, String pnrNumber,
String checkinUrl) {
return new AirlineCheckinTemplateBuilder(introMessage, locale,
pnrNumber, checkinUrl);
}
|
[
"public",
"static",
"AirlineCheckinTemplateBuilder",
"addAirlineCheckinTemplate",
"(",
"String",
"introMessage",
",",
"String",
"locale",
",",
"String",
"pnrNumber",
",",
"String",
"checkinUrl",
")",
"{",
"return",
"new",
"AirlineCheckinTemplateBuilder",
"(",
"introMessage",
",",
"locale",
",",
"pnrNumber",
",",
"checkinUrl",
")",
";",
"}"
] |
Adds an Airline Checkin Template to the response.
@param introMessage
the message to send before the template. It can't be empty.
@param locale
the current locale. It can't be empty and must be in format
[a-z]{2}_[A-Z]{2}. Locale must be in format [a-z]{2}_[A-Z]{2}.
For more information see<a href=
"https://developers.facebook.com/docs/internationalization#locales"
> Facebook's locale support</a>.
@param pnrNumber
the Passenger Name Record number (Booking Number). It can't be
empty.
@param checkinUrl
the url for the checkin. It can't be empty.
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-checkin-template"
> Facebook's Messenger Platform Airline Checkin Template
Documentation</a>
|
[
"Adds",
"an",
"Airline",
"Checkin",
"Template",
"to",
"the",
"response",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java#L323-L328
|
4,466 |
BotMill/fb-botmill
|
src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java
|
ReplyFactory.addAirlineFlightUpdateTemplate
|
public static AirlineFlightUpdateTemplateBuilder addAirlineFlightUpdateTemplate(
String introMessage, String locale, String pnrNumber,
UpdateType updateType) {
return new AirlineFlightUpdateTemplateBuilder(introMessage, locale,
pnrNumber, updateType);
}
|
java
|
public static AirlineFlightUpdateTemplateBuilder addAirlineFlightUpdateTemplate(
String introMessage, String locale, String pnrNumber,
UpdateType updateType) {
return new AirlineFlightUpdateTemplateBuilder(introMessage, locale,
pnrNumber, updateType);
}
|
[
"public",
"static",
"AirlineFlightUpdateTemplateBuilder",
"addAirlineFlightUpdateTemplate",
"(",
"String",
"introMessage",
",",
"String",
"locale",
",",
"String",
"pnrNumber",
",",
"UpdateType",
"updateType",
")",
"{",
"return",
"new",
"AirlineFlightUpdateTemplateBuilder",
"(",
"introMessage",
",",
"locale",
",",
"pnrNumber",
",",
"updateType",
")",
";",
"}"
] |
Adds an Airline Flight Update Template to the response.
@param introMessage
the message to send before the template. It can't be empty.
@param locale
the current locale. It can't be empty and must be in format
[a-z]{2}_[A-Z]{2}. Locale must be in format [a-z]{2}_[A-Z]{2}.
For more information see<a href=
"https://developers.facebook.com/docs/internationalization#locales"
> Facebook's locale support</a>.
@param pnrNumber
the Passenger Name Record number (Booking Number). It can't be
empty.
@param updateType
an {@link UpdateType} object that represents the kind of
status update of the flight. It can't be null.
@return a builder for the response.
@see <a href=
"https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-update-template"
> Facebook's Messenger Platform Airline Flight Update Template
Documentation</a>
|
[
"Adds",
"an",
"Airline",
"Flight",
"Update",
"Template",
"to",
"the",
"response",
"."
] |
d94da3615a7339822c137ef75c92a03d791ee969
|
https://github.com/BotMill/fb-botmill/blob/d94da3615a7339822c137ef75c92a03d791ee969/src/main/java/co/aurasphere/botmill/fb/model/outcoming/factory/ReplyFactory.java#L375-L380
|
4,467 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java
|
FirmataMessageFactory.i2cConfigRequest
|
public static byte[] i2cConfigRequest(int delayInMicroseconds) {
if (delayInMicroseconds < 0) {
throw new IllegalArgumentException("Delay cannot be less than 0 microseconds.");
}
if (delayInMicroseconds > 255) {
throw new IllegalArgumentException("Delay cannot be greater than 255 microseconds.");
}
byte delayLsb = (byte) (delayInMicroseconds & 0x7F);
byte delayMsb = 0;
if (delayInMicroseconds > 128) {
delayMsb = 1;
}
return new byte[]{START_SYSEX, I2C_CONFIG, delayLsb, delayMsb, END_SYSEX};
}
|
java
|
public static byte[] i2cConfigRequest(int delayInMicroseconds) {
if (delayInMicroseconds < 0) {
throw new IllegalArgumentException("Delay cannot be less than 0 microseconds.");
}
if (delayInMicroseconds > 255) {
throw new IllegalArgumentException("Delay cannot be greater than 255 microseconds.");
}
byte delayLsb = (byte) (delayInMicroseconds & 0x7F);
byte delayMsb = 0;
if (delayInMicroseconds > 128) {
delayMsb = 1;
}
return new byte[]{START_SYSEX, I2C_CONFIG, delayLsb, delayMsb, END_SYSEX};
}
|
[
"public",
"static",
"byte",
"[",
"]",
"i2cConfigRequest",
"(",
"int",
"delayInMicroseconds",
")",
"{",
"if",
"(",
"delayInMicroseconds",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Delay cannot be less than 0 microseconds.\"",
")",
";",
"}",
"if",
"(",
"delayInMicroseconds",
">",
"255",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Delay cannot be greater than 255 microseconds.\"",
")",
";",
"}",
"byte",
"delayLsb",
"=",
"(",
"byte",
")",
"(",
"delayInMicroseconds",
"&",
"0x7F",
")",
";",
"byte",
"delayMsb",
"=",
"0",
";",
"if",
"(",
"delayInMicroseconds",
">",
"128",
")",
"{",
"delayMsb",
"=",
"1",
";",
"}",
"return",
"new",
"byte",
"[",
"]",
"{",
"START_SYSEX",
",",
"I2C_CONFIG",
",",
"delayLsb",
",",
"delayMsb",
",",
"END_SYSEX",
"}",
";",
"}"
] |
Creates SysEx message that configures I2C setup.
@param delayInMicroseconds delay between the moment a register is written
to and the moment when the data can be read from that register (optional,
when I2C device requires a delay)
@return message that configures I2C
|
[
"Creates",
"SysEx",
"message",
"that",
"configures",
"I2C",
"setup",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java#L62-L75
|
4,468 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java
|
FirmataMessageFactory.analogReport
|
public static byte[] analogReport(boolean enable) {
byte[] result = new byte[32];
byte flag = (byte) (enable ? 1 : 0);
for (byte i = 0, j = 0; i < 16; i++) {
result[j++] = (byte) (REPORT_ANALOG | i);
result[j++] = flag;
}
return result;
}
|
java
|
public static byte[] analogReport(boolean enable) {
byte[] result = new byte[32];
byte flag = (byte) (enable ? 1 : 0);
for (byte i = 0, j = 0; i < 16; i++) {
result[j++] = (byte) (REPORT_ANALOG | i);
result[j++] = flag;
}
return result;
}
|
[
"public",
"static",
"byte",
"[",
"]",
"analogReport",
"(",
"boolean",
"enable",
")",
"{",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"32",
"]",
";",
"byte",
"flag",
"=",
"(",
"byte",
")",
"(",
"enable",
"?",
"1",
":",
"0",
")",
";",
"for",
"(",
"byte",
"i",
"=",
"0",
",",
"j",
"=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
")",
"{",
"result",
"[",
"j",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"REPORT_ANALOG",
"|",
"i",
")",
";",
"result",
"[",
"j",
"++",
"]",
"=",
"flag",
";",
"}",
"return",
"result",
";",
"}"
] |
Builds message to enable or disable reporting from Firmata device on
change of analog input.
@param enable message enables analog reporting if true and disable if
false
@return message that enables or disables analog reporting
|
[
"Builds",
"message",
"to",
"enable",
"or",
"disable",
"reporting",
"from",
"Firmata",
"device",
"on",
"change",
"of",
"analog",
"input",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java#L172-L180
|
4,469 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java
|
FirmataMessageFactory.digitalReport
|
public static byte[] digitalReport(boolean enable) {
byte[] result = new byte[32];
byte flag = (byte) (enable ? 1 : 0);
for (byte i = 0, j = 0; i < 16; i++) {
result[j++] = (byte) (REPORT_DIGITAL | i);
result[j++] = flag;
}
return result;
}
|
java
|
public static byte[] digitalReport(boolean enable) {
byte[] result = new byte[32];
byte flag = (byte) (enable ? 1 : 0);
for (byte i = 0, j = 0; i < 16; i++) {
result[j++] = (byte) (REPORT_DIGITAL | i);
result[j++] = flag;
}
return result;
}
|
[
"public",
"static",
"byte",
"[",
"]",
"digitalReport",
"(",
"boolean",
"enable",
")",
"{",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"32",
"]",
";",
"byte",
"flag",
"=",
"(",
"byte",
")",
"(",
"enable",
"?",
"1",
":",
"0",
")",
";",
"for",
"(",
"byte",
"i",
"=",
"0",
",",
"j",
"=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
")",
"{",
"result",
"[",
"j",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"REPORT_DIGITAL",
"|",
"i",
")",
";",
"result",
"[",
"j",
"++",
"]",
"=",
"flag",
";",
"}",
"return",
"result",
";",
"}"
] |
Builds message to enable or disable reporting from Firmata device on
change of digital input.
@param enable message enables digital reporting if true and disable if
false
@return message that enables or disables digital reporting
|
[
"Builds",
"message",
"to",
"enable",
"or",
"disable",
"reporting",
"from",
"Firmata",
"device",
"on",
"change",
"of",
"digital",
"input",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java#L190-L198
|
4,470 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java
|
FirmataMessageFactory.setMode
|
public static byte[] setMode(byte pinId, Pin.Mode mode) {
if (mode == Pin.Mode.UNSUPPORTED) {
throw new IllegalArgumentException("Cannot set unsupported mode to pin " + pinId);
}
return new byte[]{SET_PIN_MODE, pinId, (byte) mode.ordinal()};
}
|
java
|
public static byte[] setMode(byte pinId, Pin.Mode mode) {
if (mode == Pin.Mode.UNSUPPORTED) {
throw new IllegalArgumentException("Cannot set unsupported mode to pin " + pinId);
}
return new byte[]{SET_PIN_MODE, pinId, (byte) mode.ordinal()};
}
|
[
"public",
"static",
"byte",
"[",
"]",
"setMode",
"(",
"byte",
"pinId",
",",
"Pin",
".",
"Mode",
"mode",
")",
"{",
"if",
"(",
"mode",
"==",
"Pin",
".",
"Mode",
".",
"UNSUPPORTED",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot set unsupported mode to pin \"",
"+",
"pinId",
")",
";",
"}",
"return",
"new",
"byte",
"[",
"]",
"{",
"SET_PIN_MODE",
",",
"pinId",
",",
"(",
"byte",
")",
"mode",
".",
"ordinal",
"(",
")",
"}",
";",
"}"
] |
Creates the message that assigns particular mode to specified pin.
@param pinId index of the pin
@param mode mode
@return message that assigns particular mode to specified pin
|
[
"Creates",
"the",
"message",
"that",
"assigns",
"particular",
"mode",
"to",
"specified",
"pin",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java#L207-L212
|
4,471 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java
|
FirmataMessageFactory.stringMessage
|
public static byte[] stringMessage(String message) {
byte[] bytes = message.getBytes();
byte[] result = new byte[bytes.length * 2 + 3];
result[0] = START_SYSEX;
result[1] = STRING_DATA;
result[result.length - 1] = END_SYSEX;
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
result[i * 2 + 2] = (byte) (b & 0x7F);
result[i * 2 + 3] = (byte) ((b >> 7) & 0x7F);
}
return result;
}
|
java
|
public static byte[] stringMessage(String message) {
byte[] bytes = message.getBytes();
byte[] result = new byte[bytes.length * 2 + 3];
result[0] = START_SYSEX;
result[1] = STRING_DATA;
result[result.length - 1] = END_SYSEX;
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
result[i * 2 + 2] = (byte) (b & 0x7F);
result[i * 2 + 3] = (byte) ((b >> 7) & 0x7F);
}
return result;
}
|
[
"public",
"static",
"byte",
"[",
"]",
"stringMessage",
"(",
"String",
"message",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"message",
".",
"getBytes",
"(",
")",
";",
"byte",
"[",
"]",
"result",
"=",
"new",
"byte",
"[",
"bytes",
".",
"length",
"*",
"2",
"+",
"3",
"]",
";",
"result",
"[",
"0",
"]",
"=",
"START_SYSEX",
";",
"result",
"[",
"1",
"]",
"=",
"STRING_DATA",
";",
"result",
"[",
"result",
".",
"length",
"-",
"1",
"]",
"=",
"END_SYSEX",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"byte",
"b",
"=",
"bytes",
"[",
"i",
"]",
";",
"result",
"[",
"i",
"*",
"2",
"+",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"b",
"&",
"0x7F",
")",
";",
"result",
"[",
"i",
"*",
"2",
"+",
"3",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"b",
">>",
"7",
")",
"&",
"0x7F",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Encodes the string as a SysEx message.
@param message string message
@return SysEx message
|
[
"Encodes",
"the",
"string",
"as",
"a",
"SysEx",
"message",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/firmata/FirmataMessageFactory.java#L303-L315
|
4,472 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/ssd1306/SSD1306MessageFactory.java
|
SSD1306MessageFactory.setDisplayClock
|
public static byte[] setDisplayClock(byte divideRatio, byte oscillatorFrequency) {
if (divideRatio < 0 || oscillatorFrequency < 0) {
throw new IllegalArgumentException("Divide ratio and oscillator frequency must be non-negative.");
}
byte param = (byte) ((oscillatorFrequency << 4) & divideRatio);
return new byte[]{COMMAND_CONTROL_BYTE, SET_DISPLAY_CLOCK, COMMAND_CONTROL_BYTE, param};
}
|
java
|
public static byte[] setDisplayClock(byte divideRatio, byte oscillatorFrequency) {
if (divideRatio < 0 || oscillatorFrequency < 0) {
throw new IllegalArgumentException("Divide ratio and oscillator frequency must be non-negative.");
}
byte param = (byte) ((oscillatorFrequency << 4) & divideRatio);
return new byte[]{COMMAND_CONTROL_BYTE, SET_DISPLAY_CLOCK, COMMAND_CONTROL_BYTE, param};
}
|
[
"public",
"static",
"byte",
"[",
"]",
"setDisplayClock",
"(",
"byte",
"divideRatio",
",",
"byte",
"oscillatorFrequency",
")",
"{",
"if",
"(",
"divideRatio",
"<",
"0",
"||",
"oscillatorFrequency",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Divide ratio and oscillator frequency must be non-negative.\"",
")",
";",
"}",
"byte",
"param",
"=",
"(",
"byte",
")",
"(",
"(",
"oscillatorFrequency",
"<<",
"4",
")",
"&",
"divideRatio",
")",
";",
"return",
"new",
"byte",
"[",
"]",
"{",
"COMMAND_CONTROL_BYTE",
",",
"SET_DISPLAY_CLOCK",
",",
"COMMAND_CONTROL_BYTE",
",",
"param",
"}",
";",
"}"
] |
timing configuration commands
|
[
"timing",
"configuration",
"commands"
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/ssd1306/SSD1306MessageFactory.java#L297-L303
|
4,473 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/fsm/AbstractState.java
|
AbstractState.bufferize
|
protected void bufferize(byte b) {
if (index == buffer.length) {
byte[] newBuffer = new byte[buffer.length * 2];
System.arraycopy(buffer, 0, newBuffer, 0, index);
buffer = newBuffer;
}
buffer[index++] = b;
}
|
java
|
protected void bufferize(byte b) {
if (index == buffer.length) {
byte[] newBuffer = new byte[buffer.length * 2];
System.arraycopy(buffer, 0, newBuffer, 0, index);
buffer = newBuffer;
}
buffer[index++] = b;
}
|
[
"protected",
"void",
"bufferize",
"(",
"byte",
"b",
")",
"{",
"if",
"(",
"index",
"==",
"buffer",
".",
"length",
")",
"{",
"byte",
"[",
"]",
"newBuffer",
"=",
"new",
"byte",
"[",
"buffer",
".",
"length",
"*",
"2",
"]",
";",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"0",
",",
"newBuffer",
",",
"0",
",",
"index",
")",
";",
"buffer",
"=",
"newBuffer",
";",
"}",
"buffer",
"[",
"index",
"++",
"]",
"=",
"b",
";",
"}"
] |
Stores the byte to the internal buffer in order to get a chunk of data
latter.
@param b the byte
|
[
"Stores",
"the",
"byte",
"to",
"the",
"internal",
"buffer",
"in",
"order",
"to",
"get",
"a",
"chunk",
"of",
"data",
"latter",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/fsm/AbstractState.java#L88-L95
|
4,474 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/firmata/FirmataDevice.java
|
FirmataDevice.shutdown
|
private void shutdown() throws IOException {
ready.set(false);
sendMessage(FirmataMessageFactory.analogReport(false));
sendMessage(FirmataMessageFactory.digitalReport(false));
parser.stop();
transport.stop();
}
|
java
|
private void shutdown() throws IOException {
ready.set(false);
sendMessage(FirmataMessageFactory.analogReport(false));
sendMessage(FirmataMessageFactory.digitalReport(false));
parser.stop();
transport.stop();
}
|
[
"private",
"void",
"shutdown",
"(",
")",
"throws",
"IOException",
"{",
"ready",
".",
"set",
"(",
"false",
")",
";",
"sendMessage",
"(",
"FirmataMessageFactory",
".",
"analogReport",
"(",
"false",
")",
")",
";",
"sendMessage",
"(",
"FirmataMessageFactory",
".",
"digitalReport",
"(",
"false",
")",
")",
";",
"parser",
".",
"stop",
"(",
")",
";",
"transport",
".",
"stop",
"(",
")",
";",
"}"
] |
Tries to release all resources and properly terminate the connection to
the hardware.
@throws IOException when communication could not be stopped properly
|
[
"Tries",
"to",
"release",
"all",
"resources",
"and",
"properly",
"terminate",
"the",
"connection",
"to",
"the",
"hardware",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/firmata/FirmataDevice.java#L307-L313
|
4,475 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/ssd1306/SSD1306.java
|
SSD1306.init
|
public void init() {
turnOff();
// initialization
command(setDisplayClock((byte) 0, (byte) 8));
command(setMultiplexRatio(size.height));
command(setDisplayOffset(0)); // no offset
command(setDisplayStartLine(0)); // line #0
command(setMemoryAddressingMode(MemoryAddressingMode.HORIZONTAL));
command(setHorizontalFlip(false));
command(setVerticalFlip(false));
if (vccState == VCC.EXTERNAL) {
command(setChargePump(false));
} else {
command(setChargePump(true));
}
int contrast = 0;
boolean sequentialPins = true;
boolean leftRightPinsRemap = false;
if (size == Size.SSD1306_128_32) {
contrast = 0x8F;
} else if (size == Size.SSD1306_128_64) {
if (vccState == VCC.EXTERNAL) {
contrast = 0x9F;
} else {
contrast = 0xCF;
}
sequentialPins = false;
} else if (size == Size.SSD1306_96_16) {
if (vccState == VCC.EXTERNAL) {
contrast = 0x10;
} else {
contrast = 0xAF;
}
}
command(setCOMPinsConfig(sequentialPins, leftRightPinsRemap));
command(setContrast((byte) contrast));
if (vccState == VCC.EXTERNAL) {
command(setPrechargePeriod((byte) 2, (byte) 2));
} else {
command(setPrechargePeriod((byte) 1, (byte) 15));
}
command(setVcomhDeselectLevel((byte) 3));
command(DISPLAY_RESUME);
command(setDisplayInverse(false));
stopScrolling();
display(); // synchronize canvas with display's internal buffer
turnOn();
}
|
java
|
public void init() {
turnOff();
// initialization
command(setDisplayClock((byte) 0, (byte) 8));
command(setMultiplexRatio(size.height));
command(setDisplayOffset(0)); // no offset
command(setDisplayStartLine(0)); // line #0
command(setMemoryAddressingMode(MemoryAddressingMode.HORIZONTAL));
command(setHorizontalFlip(false));
command(setVerticalFlip(false));
if (vccState == VCC.EXTERNAL) {
command(setChargePump(false));
} else {
command(setChargePump(true));
}
int contrast = 0;
boolean sequentialPins = true;
boolean leftRightPinsRemap = false;
if (size == Size.SSD1306_128_32) {
contrast = 0x8F;
} else if (size == Size.SSD1306_128_64) {
if (vccState == VCC.EXTERNAL) {
contrast = 0x9F;
} else {
contrast = 0xCF;
}
sequentialPins = false;
} else if (size == Size.SSD1306_96_16) {
if (vccState == VCC.EXTERNAL) {
contrast = 0x10;
} else {
contrast = 0xAF;
}
}
command(setCOMPinsConfig(sequentialPins, leftRightPinsRemap));
command(setContrast((byte) contrast));
if (vccState == VCC.EXTERNAL) {
command(setPrechargePeriod((byte) 2, (byte) 2));
} else {
command(setPrechargePeriod((byte) 1, (byte) 15));
}
command(setVcomhDeselectLevel((byte) 3));
command(DISPLAY_RESUME);
command(setDisplayInverse(false));
stopScrolling();
display(); // synchronize canvas with display's internal buffer
turnOn();
}
|
[
"public",
"void",
"init",
"(",
")",
"{",
"turnOff",
"(",
")",
";",
"// initialization",
"command",
"(",
"setDisplayClock",
"(",
"(",
"byte",
")",
"0",
",",
"(",
"byte",
")",
"8",
")",
")",
";",
"command",
"(",
"setMultiplexRatio",
"(",
"size",
".",
"height",
")",
")",
";",
"command",
"(",
"setDisplayOffset",
"(",
"0",
")",
")",
";",
"// no offset",
"command",
"(",
"setDisplayStartLine",
"(",
"0",
")",
")",
";",
"// line #0",
"command",
"(",
"setMemoryAddressingMode",
"(",
"MemoryAddressingMode",
".",
"HORIZONTAL",
")",
")",
";",
"command",
"(",
"setHorizontalFlip",
"(",
"false",
")",
")",
";",
"command",
"(",
"setVerticalFlip",
"(",
"false",
")",
")",
";",
"if",
"(",
"vccState",
"==",
"VCC",
".",
"EXTERNAL",
")",
"{",
"command",
"(",
"setChargePump",
"(",
"false",
")",
")",
";",
"}",
"else",
"{",
"command",
"(",
"setChargePump",
"(",
"true",
")",
")",
";",
"}",
"int",
"contrast",
"=",
"0",
";",
"boolean",
"sequentialPins",
"=",
"true",
";",
"boolean",
"leftRightPinsRemap",
"=",
"false",
";",
"if",
"(",
"size",
"==",
"Size",
".",
"SSD1306_128_32",
")",
"{",
"contrast",
"=",
"0x8F",
";",
"}",
"else",
"if",
"(",
"size",
"==",
"Size",
".",
"SSD1306_128_64",
")",
"{",
"if",
"(",
"vccState",
"==",
"VCC",
".",
"EXTERNAL",
")",
"{",
"contrast",
"=",
"0x9F",
";",
"}",
"else",
"{",
"contrast",
"=",
"0xCF",
";",
"}",
"sequentialPins",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"size",
"==",
"Size",
".",
"SSD1306_96_16",
")",
"{",
"if",
"(",
"vccState",
"==",
"VCC",
".",
"EXTERNAL",
")",
"{",
"contrast",
"=",
"0x10",
";",
"}",
"else",
"{",
"contrast",
"=",
"0xAF",
";",
"}",
"}",
"command",
"(",
"setCOMPinsConfig",
"(",
"sequentialPins",
",",
"leftRightPinsRemap",
")",
")",
";",
"command",
"(",
"setContrast",
"(",
"(",
"byte",
")",
"contrast",
")",
")",
";",
"if",
"(",
"vccState",
"==",
"VCC",
".",
"EXTERNAL",
")",
"{",
"command",
"(",
"setPrechargePeriod",
"(",
"(",
"byte",
")",
"2",
",",
"(",
"byte",
")",
"2",
")",
")",
";",
"}",
"else",
"{",
"command",
"(",
"setPrechargePeriod",
"(",
"(",
"byte",
")",
"1",
",",
"(",
"byte",
")",
"15",
")",
")",
";",
"}",
"command",
"(",
"setVcomhDeselectLevel",
"(",
"(",
"byte",
")",
"3",
")",
")",
";",
"command",
"(",
"DISPLAY_RESUME",
")",
";",
"command",
"(",
"setDisplayInverse",
"(",
"false",
")",
")",
";",
"stopScrolling",
"(",
")",
";",
"display",
"(",
")",
";",
"// synchronize canvas with display's internal buffer",
"turnOn",
"(",
")",
";",
"}"
] |
Prepares the device to operation.
|
[
"Prepares",
"the",
"device",
"to",
"operation",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/ssd1306/SSD1306.java#L85-L132
|
4,476 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/ssd1306/SSD1306.java
|
SSD1306.dim
|
public void dim(boolean dim) {
byte contrast;
if (dim) {
contrast = 0; // Dimmed display
} else {
if (vccState == VCC.EXTERNAL) {
contrast = (byte) 0x9F;
} else {
contrast = (byte) 0xCF;
}
}
// the range of contrast to too small to be really useful
// it is useful to dim the display
command(setContrast(contrast));
}
|
java
|
public void dim(boolean dim) {
byte contrast;
if (dim) {
contrast = 0; // Dimmed display
} else {
if (vccState == VCC.EXTERNAL) {
contrast = (byte) 0x9F;
} else {
contrast = (byte) 0xCF;
}
}
// the range of contrast to too small to be really useful
// it is useful to dim the display
command(setContrast(contrast));
}
|
[
"public",
"void",
"dim",
"(",
"boolean",
"dim",
")",
"{",
"byte",
"contrast",
";",
"if",
"(",
"dim",
")",
"{",
"contrast",
"=",
"0",
";",
"// Dimmed display",
"}",
"else",
"{",
"if",
"(",
"vccState",
"==",
"VCC",
".",
"EXTERNAL",
")",
"{",
"contrast",
"=",
"(",
"byte",
")",
"0x9F",
";",
"}",
"else",
"{",
"contrast",
"=",
"(",
"byte",
")",
"0xCF",
";",
"}",
"}",
"// the range of contrast to too small to be really useful",
"// it is useful to dim the display",
"command",
"(",
"setContrast",
"(",
"contrast",
")",
")",
";",
"}"
] |
Dims the display
@param dim true - display is dimmed, false - display is normal
|
[
"Dims",
"the",
"display"
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/ssd1306/SSD1306.java#L170-L185
|
4,477 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/firmata/parser/ParsingI2CMessageState.java
|
ParsingI2CMessageState.process
|
@Override
public void process(byte b) {
if (b == END_SYSEX) {
byte[] buffer = convertI2CBuffer(getBuffer());
byte address = buffer[0];
byte register = buffer[1];
byte[] message = new byte[buffer.length - 2];
System.arraycopy(buffer, 2, message, 0, buffer.length - 2);
Event event = new Event(I2C_MESSAGE);
event.setBodyItem(I2C_ADDRESS, address);
event.setBodyItem(I2C_REGISTER, register);
event.setBodyItem(I2C_MESSAGE, message);
transitTo(WaitingForMessageState.class);
publish(event);
} else {
bufferize(b);
}
}
|
java
|
@Override
public void process(byte b) {
if (b == END_SYSEX) {
byte[] buffer = convertI2CBuffer(getBuffer());
byte address = buffer[0];
byte register = buffer[1];
byte[] message = new byte[buffer.length - 2];
System.arraycopy(buffer, 2, message, 0, buffer.length - 2);
Event event = new Event(I2C_MESSAGE);
event.setBodyItem(I2C_ADDRESS, address);
event.setBodyItem(I2C_REGISTER, register);
event.setBodyItem(I2C_MESSAGE, message);
transitTo(WaitingForMessageState.class);
publish(event);
} else {
bufferize(b);
}
}
|
[
"@",
"Override",
"public",
"void",
"process",
"(",
"byte",
"b",
")",
"{",
"if",
"(",
"b",
"==",
"END_SYSEX",
")",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"convertI2CBuffer",
"(",
"getBuffer",
"(",
")",
")",
";",
"byte",
"address",
"=",
"buffer",
"[",
"0",
"]",
";",
"byte",
"register",
"=",
"buffer",
"[",
"1",
"]",
";",
"byte",
"[",
"]",
"message",
"=",
"new",
"byte",
"[",
"buffer",
".",
"length",
"-",
"2",
"]",
";",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"2",
",",
"message",
",",
"0",
",",
"buffer",
".",
"length",
"-",
"2",
")",
";",
"Event",
"event",
"=",
"new",
"Event",
"(",
"I2C_MESSAGE",
")",
";",
"event",
".",
"setBodyItem",
"(",
"I2C_ADDRESS",
",",
"address",
")",
";",
"event",
".",
"setBodyItem",
"(",
"I2C_REGISTER",
",",
"register",
")",
";",
"event",
".",
"setBodyItem",
"(",
"I2C_MESSAGE",
",",
"message",
")",
";",
"transitTo",
"(",
"WaitingForMessageState",
".",
"class",
")",
";",
"publish",
"(",
"event",
")",
";",
"}",
"else",
"{",
"bufferize",
"(",
"b",
")",
";",
"}",
"}"
] |
Collects I2C message from individual bytes.
@param b the input byte
|
[
"Collects",
"I2C",
"message",
"from",
"individual",
"bytes",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/firmata/parser/ParsingI2CMessageState.java#L58-L75
|
4,478 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/ssd1306/MonochromeCanvas.java
|
MonochromeCanvas.drawRect
|
public void drawRect(int x, int y, int w, int h, Color color) {
drawHorizontalLine(x, y, w, color);
drawHorizontalLine(x, y + h - 1, w, color);
drawVerticalLine(x, y, h, color);
drawVerticalLine(x + w - 1, y, h, color);
}
|
java
|
public void drawRect(int x, int y, int w, int h, Color color) {
drawHorizontalLine(x, y, w, color);
drawHorizontalLine(x, y + h - 1, w, color);
drawVerticalLine(x, y, h, color);
drawVerticalLine(x + w - 1, y, h, color);
}
|
[
"public",
"void",
"drawRect",
"(",
"int",
"x",
",",
"int",
"y",
",",
"int",
"w",
",",
"int",
"h",
",",
"Color",
"color",
")",
"{",
"drawHorizontalLine",
"(",
"x",
",",
"y",
",",
"w",
",",
"color",
")",
";",
"drawHorizontalLine",
"(",
"x",
",",
"y",
"+",
"h",
"-",
"1",
",",
"w",
",",
"color",
")",
";",
"drawVerticalLine",
"(",
"x",
",",
"y",
",",
"h",
",",
"color",
")",
";",
"drawVerticalLine",
"(",
"x",
"+",
"w",
"-",
"1",
",",
"y",
",",
"h",
",",
"color",
")",
";",
"}"
] |
Draw a rectangle
|
[
"Draw",
"a",
"rectangle"
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/ssd1306/MonochromeCanvas.java#L164-L169
|
4,479 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/ssd1306/MonochromeCanvas.java
|
MonochromeCanvas.drawBitmap
|
public void drawBitmap(int x, int y, byte[][] bitmap, boolean opaque) {
int h = bitmap.length;
if (h == 0) {
return;
}
int w = bitmap[0].length;
if (w == 0) {
return;
}
for (int i = 0; i < h; i++) {
if (y + i >= 0 && y + i < height) {
for (int j = 0; j < w; j++) {
if (x + j * 8 >= 0 && x + j * 8 < width) {
byte b = bitmap[i][j];
for (int shift = 7; shift >= 0; shift--) {
int mask = 1 << shift;
if ((b & mask) != 0) {
setPixel(x + j * 8 + (7 - shift), y + i, color);
} else if (opaque) {
setPixel(x + j * 8 + (7 - shift), y + i, bgcolor);
}
}
}
}
}
}
}
|
java
|
public void drawBitmap(int x, int y, byte[][] bitmap, boolean opaque) {
int h = bitmap.length;
if (h == 0) {
return;
}
int w = bitmap[0].length;
if (w == 0) {
return;
}
for (int i = 0; i < h; i++) {
if (y + i >= 0 && y + i < height) {
for (int j = 0; j < w; j++) {
if (x + j * 8 >= 0 && x + j * 8 < width) {
byte b = bitmap[i][j];
for (int shift = 7; shift >= 0; shift--) {
int mask = 1 << shift;
if ((b & mask) != 0) {
setPixel(x + j * 8 + (7 - shift), y + i, color);
} else if (opaque) {
setPixel(x + j * 8 + (7 - shift), y + i, bgcolor);
}
}
}
}
}
}
}
|
[
"public",
"void",
"drawBitmap",
"(",
"int",
"x",
",",
"int",
"y",
",",
"byte",
"[",
"]",
"[",
"]",
"bitmap",
",",
"boolean",
"opaque",
")",
"{",
"int",
"h",
"=",
"bitmap",
".",
"length",
";",
"if",
"(",
"h",
"==",
"0",
")",
"{",
"return",
";",
"}",
"int",
"w",
"=",
"bitmap",
"[",
"0",
"]",
".",
"length",
";",
"if",
"(",
"w",
"==",
"0",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"h",
";",
"i",
"++",
")",
"{",
"if",
"(",
"y",
"+",
"i",
">=",
"0",
"&&",
"y",
"+",
"i",
"<",
"height",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"w",
";",
"j",
"++",
")",
"{",
"if",
"(",
"x",
"+",
"j",
"*",
"8",
">=",
"0",
"&&",
"x",
"+",
"j",
"*",
"8",
"<",
"width",
")",
"{",
"byte",
"b",
"=",
"bitmap",
"[",
"i",
"]",
"[",
"j",
"]",
";",
"for",
"(",
"int",
"shift",
"=",
"7",
";",
"shift",
">=",
"0",
";",
"shift",
"--",
")",
"{",
"int",
"mask",
"=",
"1",
"<<",
"shift",
";",
"if",
"(",
"(",
"b",
"&",
"mask",
")",
"!=",
"0",
")",
"{",
"setPixel",
"(",
"x",
"+",
"j",
"*",
"8",
"+",
"(",
"7",
"-",
"shift",
")",
",",
"y",
"+",
"i",
",",
"color",
")",
";",
"}",
"else",
"if",
"(",
"opaque",
")",
"{",
"setPixel",
"(",
"x",
"+",
"j",
"*",
"8",
"+",
"(",
"7",
"-",
"shift",
")",
",",
"y",
"+",
"i",
",",
"bgcolor",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}"
] |
Draws a bitmap. Each byte of data contains values for 8 consecutive
pixels in a row.
@param x
@param y
@param bitmap data to display. Each bit stands for a pixel.
@param opaque if true, 0 - bits is drawn in background color, if false -
the color of corresponding pixel doesn't change
|
[
"Draws",
"a",
"bitmap",
".",
"Each",
"byte",
"of",
"data",
"contains",
"values",
"for",
"8",
"consecutive",
"pixels",
"in",
"a",
"row",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/ssd1306/MonochromeCanvas.java#L527-L553
|
4,480 |
kurbatov/firmata4j
|
src/main/java/org/firmata4j/ssd1306/MonochromeCanvas.java
|
MonochromeCanvas.drawImage
|
public void drawImage(int x, int y, BufferedImage image, boolean opaque, boolean invert) {
drawBitmap(x, y, convertToBitmap(image, invert), opaque);
}
|
java
|
public void drawImage(int x, int y, BufferedImage image, boolean opaque, boolean invert) {
drawBitmap(x, y, convertToBitmap(image, invert), opaque);
}
|
[
"public",
"void",
"drawImage",
"(",
"int",
"x",
",",
"int",
"y",
",",
"BufferedImage",
"image",
",",
"boolean",
"opaque",
",",
"boolean",
"invert",
")",
"{",
"drawBitmap",
"(",
"x",
",",
"y",
",",
"convertToBitmap",
"(",
"image",
",",
"invert",
")",
",",
"opaque",
")",
";",
"}"
] |
Draws an image. The image is grayscalled before drawing.
@param x
@param y
@param image an image to draw
@param opaque if true, 0 - bits is drawn in background color, if false -
the color of corresponding pixel doesn't change
@param invert true to make dark pixels of the image be drawn as bright
pixels on screen
|
[
"Draws",
"an",
"image",
".",
"The",
"image",
"is",
"grayscalled",
"before",
"drawing",
"."
] |
1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea
|
https://github.com/kurbatov/firmata4j/blob/1bf75cd7f4f8d11dc2a91cf2bc6808f583d9a4ea/src/main/java/org/firmata4j/ssd1306/MonochromeCanvas.java#L566-L568
|
4,481 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.bsf
|
public final void bsf(Register dst, Register src)
{
assert(!dst.isRegType(REG_GPB));
emitX86(INST_BSF, dst, src);
}
|
java
|
public final void bsf(Register dst, Register src)
{
assert(!dst.isRegType(REG_GPB));
emitX86(INST_BSF, dst, src);
}
|
[
"public",
"final",
"void",
"bsf",
"(",
"Register",
"dst",
",",
"Register",
"src",
")",
"{",
"assert",
"(",
"!",
"dst",
".",
"isRegType",
"(",
"REG_GPB",
")",
")",
";",
"emitX86",
"(",
"INST_BSF",
",",
"dst",
",",
"src",
")",
";",
"}"
] |
Bit Scan Forward.
|
[
"Bit",
"Scan",
"Forward",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L155-L159
|
4,482 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.bsr
|
public final void bsr(Register dst, Mem src)
{
assert(!dst.isRegType(REG_GPB));
emitX86(INST_BSR, dst, src);
}
|
java
|
public final void bsr(Register dst, Mem src)
{
assert(!dst.isRegType(REG_GPB));
emitX86(INST_BSR, dst, src);
}
|
[
"public",
"final",
"void",
"bsr",
"(",
"Register",
"dst",
",",
"Mem",
"src",
")",
"{",
"assert",
"(",
"!",
"dst",
".",
"isRegType",
"(",
"REG_GPB",
")",
")",
";",
"emitX86",
"(",
"INST_BSR",
",",
"dst",
",",
"src",
")",
";",
"}"
] |
Bit Scan Reverse.
|
[
"Bit",
"Scan",
"Reverse",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L174-L178
|
4,483 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.call
|
public final void call(Register dst)
{
assert(dst.isRegType(is64() ? REG_GPQ : REG_GPD));
emitX86(INST_CALL, dst);
}
|
java
|
public final void call(Register dst)
{
assert(dst.isRegType(is64() ? REG_GPQ : REG_GPD));
emitX86(INST_CALL, dst);
}
|
[
"public",
"final",
"void",
"call",
"(",
"Register",
"dst",
")",
"{",
"assert",
"(",
"dst",
".",
"isRegType",
"(",
"is64",
"(",
")",
"?",
"REG_GPQ",
":",
"REG_GPD",
")",
")",
";",
"emitX86",
"(",
"INST_CALL",
",",
"dst",
")",
";",
"}"
] |
Call Procedure.
|
[
"Call",
"Procedure",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L272-L276
|
4,484 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.cmov
|
public final void cmov(CONDITION cc, Register dst, Register src)
{
emitX86(conditionToCMovCC(cc), dst, src);
}
|
java
|
public final void cmov(CONDITION cc, Register dst, Register src)
{
emitX86(conditionToCMovCC(cc), dst, src);
}
|
[
"public",
"final",
"void",
"cmov",
"(",
"CONDITION",
"cc",
",",
"Register",
"dst",
",",
"Register",
"src",
")",
"{",
"emitX86",
"(",
"conditionToCMovCC",
"(",
"cc",
")",
",",
"dst",
",",
"src",
")",
";",
"}"
] |
Conditional Move.
|
[
"Conditional",
"Move",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L350-L353
|
4,485 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.mov_ptr
|
public final void mov_ptr(Register dst, long src)
{
assert dst.index() == 0;
emitX86(INST_MOV_PTR, dst, Immediate.imm(src));
}
|
java
|
public final void mov_ptr(Register dst, long src)
{
assert dst.index() == 0;
emitX86(INST_MOV_PTR, dst, Immediate.imm(src));
}
|
[
"public",
"final",
"void",
"mov_ptr",
"(",
"Register",
"dst",
",",
"long",
"src",
")",
"{",
"assert",
"dst",
".",
"index",
"(",
")",
"==",
"0",
";",
"emitX86",
"(",
"INST_MOV_PTR",
",",
"dst",
",",
"Immediate",
".",
"imm",
"(",
"src",
")",
")",
";",
"}"
] |
Move byte, word, dword or qword from absolute address @a src to
AL, AX, EAX or RAX register.
|
[
"Move",
"byte",
"word",
"dword",
"or",
"qword",
"from",
"absolute",
"address"
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L971-L975
|
4,486 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.pop
|
public final void pop(Register dst)
{
assert(dst.isRegType(REG_GPW) || dst.isRegType(is64() ? REG_GPQ : REG_GPD));
emitX86(INST_POP, dst);
}
|
java
|
public final void pop(Register dst)
{
assert(dst.isRegType(REG_GPW) || dst.isRegType(is64() ? REG_GPQ : REG_GPD));
emitX86(INST_POP, dst);
}
|
[
"public",
"final",
"void",
"pop",
"(",
"Register",
"dst",
")",
"{",
"assert",
"(",
"dst",
".",
"isRegType",
"(",
"REG_GPW",
")",
"||",
"dst",
".",
"isRegType",
"(",
"is64",
"(",
")",
"?",
"REG_GPQ",
":",
"REG_GPD",
")",
")",
";",
"emitX86",
"(",
"INST_POP",
",",
"dst",
")",
";",
"}"
] |
! or segment register.
|
[
"!",
"or",
"segment",
"register",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L1114-L1118
|
4,487 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.shld
|
public final void shld(Mem dst, Register src1, Immediate src2)
{
emitX86(INST_SHLD, dst, src1, src2);
}
|
java
|
public final void shld(Mem dst, Register src1, Immediate src2)
{
emitX86(INST_SHLD, dst, src1, src2);
}
|
[
"public",
"final",
"void",
"shld",
"(",
"Mem",
"dst",
",",
"Register",
"src1",
",",
"Immediate",
"src2",
")",
"{",
"emitX86",
"(",
"INST_SHLD",
",",
"dst",
",",
"src1",
",",
"src2",
")",
";",
"}"
] |
Double Precision Shift Left.
|
[
"Double",
"Precision",
"Shift",
"Left",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L1588-L1591
|
4,488 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.fild
|
public final void fild(Mem src)
{
assert(src.size() == 2 || src.size() == 4 || src.size() == 8);
emitX86(INST_FILD, src);
}
|
java
|
public final void fild(Mem src)
{
assert(src.size() == 2 || src.size() == 4 || src.size() == 8);
emitX86(INST_FILD, src);
}
|
[
"public",
"final",
"void",
"fild",
"(",
"Mem",
"src",
")",
"{",
"assert",
"(",
"src",
".",
"size",
"(",
")",
"==",
"2",
"||",
"src",
".",
"size",
"(",
")",
"==",
"4",
"||",
"src",
".",
"size",
"(",
")",
"==",
"8",
")",
";",
"emitX86",
"(",
"INST_FILD",
",",
"src",
")",
";",
"}"
] |
! preserved.
|
[
"!",
"preserved",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L2029-L2033
|
4,489 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.fstp
|
public final void fstp(Mem dst)
{
assert(dst.size() == 4 || dst.size() == 8 || dst.size() == 10);
emitX86(INST_FSTP, dst);
}
|
java
|
public final void fstp(Mem dst)
{
assert(dst.size() == 4 || dst.size() == 8 || dst.size() == 10);
emitX86(INST_FSTP, dst);
}
|
[
"public",
"final",
"void",
"fstp",
"(",
"Mem",
"dst",
")",
"{",
"assert",
"(",
"dst",
".",
"size",
"(",
")",
"==",
"4",
"||",
"dst",
".",
"size",
"(",
")",
"==",
"8",
"||",
"dst",
".",
"size",
"(",
")",
"==",
"10",
")",
";",
"emitX86",
"(",
"INST_FSTP",
",",
"dst",
")",
";",
"}"
] |
! and pop register stack.
|
[
"!",
"and",
"pop",
"register",
"stack",
"."
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L2376-L2380
|
4,490 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.extractps
|
public final void extractps(XMMRegister dst, XMMRegister src, Immediate imm8)
{
emitX86(INST_EXTRACTPS, dst, src, imm8);
}
|
java
|
public final void extractps(XMMRegister dst, XMMRegister src, Immediate imm8)
{
emitX86(INST_EXTRACTPS, dst, src, imm8);
}
|
[
"public",
"final",
"void",
"extractps",
"(",
"XMMRegister",
"dst",
",",
"XMMRegister",
"src",
",",
"Immediate",
"imm8",
")",
"{",
"emitX86",
"(",
"INST_EXTRACTPS",
",",
"dst",
",",
"src",
",",
"imm8",
")",
";",
"}"
] |
Extract Packed SP-FP Value @brief (SSE4.1).
|
[
"Extract",
"Packed",
"SP",
"-",
"FP",
"Value"
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L6044-L6047
|
4,491 |
jnr/jnr-x86asm
|
src/main/java/jnr/x86asm/SerializerIntrinsics.java
|
SerializerIntrinsics.roundps
|
public final void roundps(XMMRegister dst, XMMRegister src, Immediate imm8)
{
emitX86(INST_ROUNDPS, dst, src, imm8);
}
|
java
|
public final void roundps(XMMRegister dst, XMMRegister src, Immediate imm8)
{
emitX86(INST_ROUNDPS, dst, src, imm8);
}
|
[
"public",
"final",
"void",
"roundps",
"(",
"XMMRegister",
"dst",
",",
"XMMRegister",
"src",
",",
"Immediate",
"imm8",
")",
"{",
"emitX86",
"(",
"INST_ROUNDPS",
",",
"dst",
",",
"src",
",",
"imm8",
")",
";",
"}"
] |
! Round Packed SP-FP Values @brief (SSE4.1).
|
[
"!",
"Round",
"Packed",
"SP",
"-",
"FP",
"Values"
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/jnr/x86asm/SerializerIntrinsics.java#L6468-L6471
|
4,492 |
jnr/jnr-x86asm
|
src/main/java/com/kenai/jnr/x86asm/TrampolineWriter.java
|
TrampolineWriter.writeTrampoline
|
static void writeTrampoline(ByteBuffer buf, long target) {
// Jmp.
buf.put((byte) 0xFF);
// ModM (RIP addressing).
buf.put((byte) 0x25);
// Offset (zero).
buf.putInt(0);
// Absolute address.
buf.putLong(target);
}
|
java
|
static void writeTrampoline(ByteBuffer buf, long target) {
// Jmp.
buf.put((byte) 0xFF);
// ModM (RIP addressing).
buf.put((byte) 0x25);
// Offset (zero).
buf.putInt(0);
// Absolute address.
buf.putLong(target);
}
|
[
"static",
"void",
"writeTrampoline",
"(",
"ByteBuffer",
"buf",
",",
"long",
"target",
")",
"{",
"// Jmp.",
"buf",
".",
"put",
"(",
"(",
"byte",
")",
"0xFF",
")",
";",
"// ModM (RIP addressing).",
"buf",
".",
"put",
"(",
"(",
"byte",
")",
"0x25",
")",
";",
"// Offset (zero).",
"buf",
".",
"putInt",
"(",
"0",
")",
";",
"// Absolute address.",
"buf",
".",
"putLong",
"(",
"target",
")",
";",
"}"
] |
Write trampoline into code at address @a code that will jump to @a target.
|
[
"Write",
"trampoline",
"into",
"code",
"at",
"address"
] |
fdcf68fb3dae49e607a49e33399e3dad1ada5536
|
https://github.com/jnr/jnr-x86asm/blob/fdcf68fb3dae49e607a49e33399e3dad1ada5536/src/main/java/com/kenai/jnr/x86asm/TrampolineWriter.java#L42-L52
|
4,493 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/type/CommonTypeFactory.java
|
CommonTypeFactory.mergeWildcardTypes
|
private static void mergeWildcardTypes(final List<Type> types, final Type... addition) {
if (types.isEmpty()) {
Collections.addAll(types, addition);
return;
}
for (Type add : addition) {
final Class<?> addClass = GenericsUtils.resolveClass(add);
final Iterator<Type> it = types.iterator();
boolean additionApproved = true;
while (it.hasNext()) {
final Type type = it.next();
// it can't contain incompatible generics just because of sane sense (type system will not allow)
final Class<?> typeClass = GenericsUtils.resolveClass(type);
if (addClass.isAssignableFrom(typeClass)) {
if (TypeUtils.isMoreSpecific(add, type)) {
// replace
it.remove();
} else {
// more specific type already contained
additionApproved = false;
}
break;
}
}
if (additionApproved) {
types.add(add);
}
}
}
|
java
|
private static void mergeWildcardTypes(final List<Type> types, final Type... addition) {
if (types.isEmpty()) {
Collections.addAll(types, addition);
return;
}
for (Type add : addition) {
final Class<?> addClass = GenericsUtils.resolveClass(add);
final Iterator<Type> it = types.iterator();
boolean additionApproved = true;
while (it.hasNext()) {
final Type type = it.next();
// it can't contain incompatible generics just because of sane sense (type system will not allow)
final Class<?> typeClass = GenericsUtils.resolveClass(type);
if (addClass.isAssignableFrom(typeClass)) {
if (TypeUtils.isMoreSpecific(add, type)) {
// replace
it.remove();
} else {
// more specific type already contained
additionApproved = false;
}
break;
}
}
if (additionApproved) {
types.add(add);
}
}
}
|
[
"private",
"static",
"void",
"mergeWildcardTypes",
"(",
"final",
"List",
"<",
"Type",
">",
"types",
",",
"final",
"Type",
"...",
"addition",
")",
"{",
"if",
"(",
"types",
".",
"isEmpty",
"(",
")",
")",
"{",
"Collections",
".",
"addAll",
"(",
"types",
",",
"addition",
")",
";",
"return",
";",
"}",
"for",
"(",
"Type",
"add",
":",
"addition",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"addClass",
"=",
"GenericsUtils",
".",
"resolveClass",
"(",
"add",
")",
";",
"final",
"Iterator",
"<",
"Type",
">",
"it",
"=",
"types",
".",
"iterator",
"(",
")",
";",
"boolean",
"additionApproved",
"=",
"true",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"Type",
"type",
"=",
"it",
".",
"next",
"(",
")",
";",
"// it can't contain incompatible generics just because of sane sense (type system will not allow)",
"final",
"Class",
"<",
"?",
">",
"typeClass",
"=",
"GenericsUtils",
".",
"resolveClass",
"(",
"type",
")",
";",
"if",
"(",
"addClass",
".",
"isAssignableFrom",
"(",
"typeClass",
")",
")",
"{",
"if",
"(",
"TypeUtils",
".",
"isMoreSpecific",
"(",
"add",
",",
"type",
")",
")",
"{",
"// replace",
"it",
".",
"remove",
"(",
")",
";",
"}",
"else",
"{",
"// more specific type already contained",
"additionApproved",
"=",
"false",
";",
"}",
"break",
";",
"}",
"}",
"if",
"(",
"additionApproved",
")",
"{",
"types",
".",
"add",
"(",
"add",
")",
";",
"}",
"}",
"}"
] |
Adds new types to wildcard if types are not already contained. If added type is more specific then
already contained type then it replace such type.
@param types current wildcard types
@param addition new types to append to wildcard
|
[
"Adds",
"new",
"types",
"to",
"wildcard",
"if",
"types",
"are",
"not",
"already",
"contained",
".",
"If",
"added",
"type",
"is",
"more",
"specific",
"then",
"already",
"contained",
"type",
"then",
"it",
"replace",
"such",
"type",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/type/CommonTypeFactory.java#L230-L258
|
4,494 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/type/CommonTypeFactory.java
|
CommonTypeFactory.removeDuplicateContracts
|
private static void removeDuplicateContracts(final Class<?> type, final Set<Class<?>> contracts) {
if (contracts.isEmpty()) {
return;
}
// remove interfaces already included in common type (e.g. Number and Serializable)
Iterator<Class<?>> it = contracts.iterator();
while (it.hasNext()) {
if (it.next().isAssignableFrom(type)) {
it.remove();
}
}
// remove duplicate interfaces (e.g. List already include Collection and Iterable)
it = contracts.iterator();
while (it.hasNext()) {
final Class<?> current = it.next();
for (Class<?> iface : contracts) {
if (!current.equals(iface) && current.isAssignableFrom(iface)) {
it.remove();
break;
}
}
}
}
|
java
|
private static void removeDuplicateContracts(final Class<?> type, final Set<Class<?>> contracts) {
if (contracts.isEmpty()) {
return;
}
// remove interfaces already included in common type (e.g. Number and Serializable)
Iterator<Class<?>> it = contracts.iterator();
while (it.hasNext()) {
if (it.next().isAssignableFrom(type)) {
it.remove();
}
}
// remove duplicate interfaces (e.g. List already include Collection and Iterable)
it = contracts.iterator();
while (it.hasNext()) {
final Class<?> current = it.next();
for (Class<?> iface : contracts) {
if (!current.equals(iface) && current.isAssignableFrom(iface)) {
it.remove();
break;
}
}
}
}
|
[
"private",
"static",
"void",
"removeDuplicateContracts",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"contracts",
")",
"{",
"if",
"(",
"contracts",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"// remove interfaces already included in common type (e.g. Number and Serializable)",
"Iterator",
"<",
"Class",
"<",
"?",
">",
">",
"it",
"=",
"contracts",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"it",
".",
"next",
"(",
")",
".",
"isAssignableFrom",
"(",
"type",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}",
"// remove duplicate interfaces (e.g. List already include Collection and Iterable)",
"it",
"=",
"contracts",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"current",
"=",
"it",
".",
"next",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"iface",
":",
"contracts",
")",
"{",
"if",
"(",
"!",
"current",
".",
"equals",
"(",
"iface",
")",
"&&",
"current",
".",
"isAssignableFrom",
"(",
"iface",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
After common types resolution we have some base class and set of common interfaces.
These interfaces may contain duplicates or be already covered by base class.
@param type base class
@param contracts common interfaces (to cleanup)
|
[
"After",
"common",
"types",
"resolution",
"we",
"have",
"some",
"base",
"class",
"and",
"set",
"of",
"common",
"interfaces",
".",
"These",
"interfaces",
"may",
"contain",
"duplicates",
"or",
"be",
"already",
"covered",
"by",
"base",
"class",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/type/CommonTypeFactory.java#L373-L397
|
4,495 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/GenericsResolutionUtils.java
|
GenericsResolutionUtils.resolve
|
public static Map<Class<?>, LinkedHashMap<String, Type>> resolve(
final Class<?> type,
final LinkedHashMap<String, Type> rootGenerics,
final Class<?>... ignoreClasses) {
return resolve(type,
rootGenerics,
Collections.<Class<?>, LinkedHashMap<String, Type>>emptyMap(),
Arrays.asList(ignoreClasses));
}
|
java
|
public static Map<Class<?>, LinkedHashMap<String, Type>> resolve(
final Class<?> type,
final LinkedHashMap<String, Type> rootGenerics,
final Class<?>... ignoreClasses) {
return resolve(type,
rootGenerics,
Collections.<Class<?>, LinkedHashMap<String, Type>>emptyMap(),
Arrays.asList(ignoreClasses));
}
|
[
"public",
"static",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
">",
"resolve",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
"rootGenerics",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"ignoreClasses",
")",
"{",
"return",
"resolve",
"(",
"type",
",",
"rootGenerics",
",",
"Collections",
".",
"<",
"Class",
"<",
"?",
">",
",",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
">",
"emptyMap",
"(",
")",
",",
"Arrays",
".",
"asList",
"(",
"ignoreClasses",
")",
")",
";",
"}"
] |
Analyze class hierarchy and resolve actual generic values for all composing types. Root type generics
are known.
@param type type to resolve generics for
@param rootGenerics resolved root type generics (including owner type generics); must not be null!
@param ignoreClasses classes to ignore (if required
@return resolved generics for all types in class hierarchy
|
[
"Analyze",
"class",
"hierarchy",
"and",
"resolve",
"actual",
"generic",
"values",
"for",
"all",
"composing",
"types",
".",
"Root",
"type",
"generics",
"are",
"known",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/GenericsResolutionUtils.java#L84-L92
|
4,496 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/GenericsUtils.java
|
GenericsUtils.createGenericsMap
|
@SuppressWarnings("PMD.LooseCoupling")
public static LinkedHashMap<String, Type> createGenericsMap(final Class<?> type,
final List<? extends Type> generics) {
final TypeVariable<? extends Class<?>>[] params = type.getTypeParameters();
if (params.length != generics.size()) {
throw new IllegalArgumentException(String.format(
"Can't build generics map for %s with %s because of incorrect generics count",
type.getSimpleName(), Arrays.toString(generics.toArray())));
}
final LinkedHashMap<String, Type> res = new LinkedHashMap<String, Type>();
int i = 0;
for (TypeVariable var : params) {
res.put(var.getName(), generics.get(i++));
}
// add possible outer class generics to avoid unknown generics
return GenericsResolutionUtils.fillOuterGenerics(type, res, null);
}
|
java
|
@SuppressWarnings("PMD.LooseCoupling")
public static LinkedHashMap<String, Type> createGenericsMap(final Class<?> type,
final List<? extends Type> generics) {
final TypeVariable<? extends Class<?>>[] params = type.getTypeParameters();
if (params.length != generics.size()) {
throw new IllegalArgumentException(String.format(
"Can't build generics map for %s with %s because of incorrect generics count",
type.getSimpleName(), Arrays.toString(generics.toArray())));
}
final LinkedHashMap<String, Type> res = new LinkedHashMap<String, Type>();
int i = 0;
for (TypeVariable var : params) {
res.put(var.getName(), generics.get(i++));
}
// add possible outer class generics to avoid unknown generics
return GenericsResolutionUtils.fillOuterGenerics(type, res, null);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"PMD.LooseCoupling\"",
")",
"public",
"static",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
"createGenericsMap",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
",",
"final",
"List",
"<",
"?",
"extends",
"Type",
">",
"generics",
")",
"{",
"final",
"TypeVariable",
"<",
"?",
"extends",
"Class",
"<",
"?",
">",
">",
"[",
"]",
"params",
"=",
"type",
".",
"getTypeParameters",
"(",
")",
";",
"if",
"(",
"params",
".",
"length",
"!=",
"generics",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Can't build generics map for %s with %s because of incorrect generics count\"",
",",
"type",
".",
"getSimpleName",
"(",
")",
",",
"Arrays",
".",
"toString",
"(",
"generics",
".",
"toArray",
"(",
")",
")",
")",
")",
";",
"}",
"final",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
"res",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
"(",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"TypeVariable",
"var",
":",
"params",
")",
"{",
"res",
".",
"put",
"(",
"var",
".",
"getName",
"(",
")",
",",
"generics",
".",
"get",
"(",
"i",
"++",
")",
")",
";",
"}",
"// add possible outer class generics to avoid unknown generics",
"return",
"GenericsResolutionUtils",
".",
"fillOuterGenerics",
"(",
"type",
",",
"res",
",",
"null",
")",
";",
"}"
] |
LinkedHashMap indicates stored order, important for context
|
[
"LinkedHashMap",
"indicates",
"stored",
"order",
"important",
"for",
"context"
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/GenericsUtils.java#L451-L467
|
4,497 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/GenericsUtils.java
|
GenericsUtils.resolveGenericArrayTypeVariables
|
private static Type resolveGenericArrayTypeVariables(final GenericArrayType type,
final Map<String, Type> generics,
final boolean countPreservedVariables) {
final Type componentType = resolveTypeVariables(
type.getGenericComponentType(), generics, countPreservedVariables);
return ArrayTypeUtils.toArrayType(componentType);
}
|
java
|
private static Type resolveGenericArrayTypeVariables(final GenericArrayType type,
final Map<String, Type> generics,
final boolean countPreservedVariables) {
final Type componentType = resolveTypeVariables(
type.getGenericComponentType(), generics, countPreservedVariables);
return ArrayTypeUtils.toArrayType(componentType);
}
|
[
"private",
"static",
"Type",
"resolveGenericArrayTypeVariables",
"(",
"final",
"GenericArrayType",
"type",
",",
"final",
"Map",
"<",
"String",
",",
"Type",
">",
"generics",
",",
"final",
"boolean",
"countPreservedVariables",
")",
"{",
"final",
"Type",
"componentType",
"=",
"resolveTypeVariables",
"(",
"type",
".",
"getGenericComponentType",
"(",
")",
",",
"generics",
",",
"countPreservedVariables",
")",
";",
"return",
"ArrayTypeUtils",
".",
"toArrayType",
"(",
"componentType",
")",
";",
"}"
] |
May produce array class instead of generic array type. This is possible due to wildcard or parameterized type
shrinking.
@param type type to repackage
@param generics known generics
@param countPreservedVariables true to replace {@link ExplicitTypeVariable} too
@return type without {@link TypeVariable}'s
|
[
"May",
"produce",
"array",
"class",
"instead",
"of",
"generic",
"array",
"type",
".",
"This",
"is",
"possible",
"due",
"to",
"wildcard",
"or",
"parameterized",
"type",
"shrinking",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/GenericsUtils.java#L707-L713
|
4,498 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/TypeUtils.java
|
TypeUtils.getMoreSpecificType
|
public static Type getMoreSpecificType(final Type one, final Type two) {
return isMoreSpecific(one, two) ? one : two;
}
|
java
|
public static Type getMoreSpecificType(final Type one, final Type two) {
return isMoreSpecific(one, two) ? one : two;
}
|
[
"public",
"static",
"Type",
"getMoreSpecificType",
"(",
"final",
"Type",
"one",
",",
"final",
"Type",
"two",
")",
"{",
"return",
"isMoreSpecific",
"(",
"one",
",",
"two",
")",
"?",
"one",
":",
"two",
";",
"}"
] |
Not resolved type variables are resolved to Object.
@param one first type
@param two second type
@return more specific type or first type if they are equal
@see #isMoreSpecific(Type, Type)
|
[
"Not",
"resolved",
"type",
"variables",
"are",
"resolved",
"to",
"Object",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/TypeUtils.java#L185-L187
|
4,499 |
xvik/generics-resolver
|
src/main/java/ru/vyarus/java/generics/resolver/util/walk/TypesWalker.java
|
TypesWalker.walk
|
public static void walk(final Type one, final Type two, final TypesVisitor visitor) {
// Use possibly more specific generics (otherwise root class generics would be used as Object and this
// way it could be used as upper bound)
// Also, types could contain outer class generics declarations, which must be preserved
// e.g. (Outer<String>.Inner field).getGenericType() == ParameterizedType with parametrized owner
// Wrapped into ignore map for very specific case, when type is TypeVariable
final Map<String, Type> oneKnownGenerics =
new IgnoreGenericsMap(GenericsResolutionUtils.resolveGenerics(one, IGNORE_VARS));
final Map<String, Type> twoKnownGenerics =
new IgnoreGenericsMap(GenericsResolutionUtils.resolveGenerics(two, IGNORE_VARS));
// Resolve variables mainly to simplify empty wildcards (? extends Object and ? super Object) to Object
// Still have to pass map because of possibly declared outer class generics. Note that for all
// types operations ignoring map could be used as we already replaced all variables. These generics
// are required only for type context building (on some level to resolve comparable type)
doWalk(GenericsUtils.resolveTypeVariables(one, oneKnownGenerics), oneKnownGenerics,
GenericsUtils.resolveTypeVariables(two, twoKnownGenerics), twoKnownGenerics, visitor);
}
|
java
|
public static void walk(final Type one, final Type two, final TypesVisitor visitor) {
// Use possibly more specific generics (otherwise root class generics would be used as Object and this
// way it could be used as upper bound)
// Also, types could contain outer class generics declarations, which must be preserved
// e.g. (Outer<String>.Inner field).getGenericType() == ParameterizedType with parametrized owner
// Wrapped into ignore map for very specific case, when type is TypeVariable
final Map<String, Type> oneKnownGenerics =
new IgnoreGenericsMap(GenericsResolutionUtils.resolveGenerics(one, IGNORE_VARS));
final Map<String, Type> twoKnownGenerics =
new IgnoreGenericsMap(GenericsResolutionUtils.resolveGenerics(two, IGNORE_VARS));
// Resolve variables mainly to simplify empty wildcards (? extends Object and ? super Object) to Object
// Still have to pass map because of possibly declared outer class generics. Note that for all
// types operations ignoring map could be used as we already replaced all variables. These generics
// are required only for type context building (on some level to resolve comparable type)
doWalk(GenericsUtils.resolveTypeVariables(one, oneKnownGenerics), oneKnownGenerics,
GenericsUtils.resolveTypeVariables(two, twoKnownGenerics), twoKnownGenerics, visitor);
}
|
[
"public",
"static",
"void",
"walk",
"(",
"final",
"Type",
"one",
",",
"final",
"Type",
"two",
",",
"final",
"TypesVisitor",
"visitor",
")",
"{",
"// Use possibly more specific generics (otherwise root class generics would be used as Object and this",
"// way it could be used as upper bound)",
"// Also, types could contain outer class generics declarations, which must be preserved",
"// e.g. (Outer<String>.Inner field).getGenericType() == ParameterizedType with parametrized owner",
"// Wrapped into ignore map for very specific case, when type is TypeVariable",
"final",
"Map",
"<",
"String",
",",
"Type",
">",
"oneKnownGenerics",
"=",
"new",
"IgnoreGenericsMap",
"(",
"GenericsResolutionUtils",
".",
"resolveGenerics",
"(",
"one",
",",
"IGNORE_VARS",
")",
")",
";",
"final",
"Map",
"<",
"String",
",",
"Type",
">",
"twoKnownGenerics",
"=",
"new",
"IgnoreGenericsMap",
"(",
"GenericsResolutionUtils",
".",
"resolveGenerics",
"(",
"two",
",",
"IGNORE_VARS",
")",
")",
";",
"// Resolve variables mainly to simplify empty wildcards (? extends Object and ? super Object) to Object",
"// Still have to pass map because of possibly declared outer class generics. Note that for all",
"// types operations ignoring map could be used as we already replaced all variables. These generics",
"// are required only for type context building (on some level to resolve comparable type)",
"doWalk",
"(",
"GenericsUtils",
".",
"resolveTypeVariables",
"(",
"one",
",",
"oneKnownGenerics",
")",
",",
"oneKnownGenerics",
",",
"GenericsUtils",
".",
"resolveTypeVariables",
"(",
"two",
",",
"twoKnownGenerics",
")",
",",
"twoKnownGenerics",
",",
"visitor",
")",
";",
"}"
] |
Walk will stop if visitor tells it's enough or when hierarchy incompatibility will be found.
@param one first type
@param two second type
@param visitor visitor
|
[
"Walk",
"will",
"stop",
"if",
"visitor",
"tells",
"it",
"s",
"enough",
"or",
"when",
"hierarchy",
"incompatibility",
"will",
"be",
"found",
"."
] |
d7d9d2783265df1178230e8f0b7cb6d853b67a7b
|
https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/walk/TypesWalker.java#L59-L75
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.