hexsha
stringlengths 40
40
| repo
stringlengths 4
114
| path
stringlengths 6
369
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
123
| original_docstring
stringlengths 8
49.2k
| docstring
stringlengths 5
8.63k
| docstring_tokens
sequence | code
stringlengths 25
988k
| code_tokens
sequence | short_docstring
stringlengths 0
6.18k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8b8064dc152424b61c0d915c11e7f56779b3b831 | kupci/team-explorer-everywhere | source/com.microsoft.tfs.core/src/com/microsoft/tfs/core/clients/versioncontrol/soapextensions/ItemSet.java | [
"MIT"
] | Java | ItemSet | /**
* A collection of {@link Item}s, with some additional information about the
* query that retrieved the set.
*
* @since TEE-SDK-10.1
*/ | A collection of Items, with some additional information about the
query that retrieved the set.
| [
"A",
"collection",
"of",
"Items",
"with",
"some",
"additional",
"information",
"about",
"the",
"query",
"that",
"retrieved",
"the",
"set",
"."
] | public final class ItemSet extends WebServiceObjectWrapper {
public ItemSet() {
this(new _ItemSet());
}
public ItemSet(final _ItemSet set) {
super(set);
}
/**
* @param queryPath
* the path where this set is rooted (server usually supplies this),
* may not be null.
* @param pattern
* the name pattern represented by this set (server usually supplies
* this); may be null.
* @param items
* server items to add to this set, may not be null.
*/
public ItemSet(final String queryPath, final String pattern, final Item[] items) {
super(new _ItemSet(queryPath, pattern, (_Item[]) WrapperUtils.unwrap(_Item.class, items)));
}
/**
* Gets the web service object this class wraps. The returned object should
* not be modified.
*
* @return the web service object this class wraps.
*/
public _ItemSet getWebServiceObject() {
return (_ItemSet) webServiceObject;
}
/**
* Gets a copy of the items in this item set.
*
* @return a copy of the items in this item set.
*/
public Item[] getItems() {
return (Item[]) WrapperUtils.wrap(Item.class, getWebServiceObject().getItems());
}
/**
* Sets the items in this item set.
*
* @param items
* the items to set (must not be <code>null</code>)
*/
public void setItems(final Item[] items) {
Check.notNull(items, "items"); //$NON-NLS-1$
getWebServiceObject().setItems((_Item[]) WrapperUtils.unwrap(_Item.class, items));
}
public String getQueryPath() {
return getWebServiceObject().getQueryPath();
}
public String getPattern() {
return getWebServiceObject().getPattern();
}
} | [
"public",
"final",
"class",
"ItemSet",
"extends",
"WebServiceObjectWrapper",
"{",
"public",
"ItemSet",
"(",
")",
"{",
"this",
"(",
"new",
"_ItemSet",
"(",
")",
")",
";",
"}",
"public",
"ItemSet",
"(",
"final",
"_ItemSet",
"set",
")",
"{",
"super",
"(",
"set",
")",
";",
"}",
"/**\n * @param queryPath\n * the path where this set is rooted (server usually supplies this),\n * may not be null.\n * @param pattern\n * the name pattern represented by this set (server usually supplies\n * this); may be null.\n * @param items\n * server items to add to this set, may not be null.\n */",
"public",
"ItemSet",
"(",
"final",
"String",
"queryPath",
",",
"final",
"String",
"pattern",
",",
"final",
"Item",
"[",
"]",
"items",
")",
"{",
"super",
"(",
"new",
"_ItemSet",
"(",
"queryPath",
",",
"pattern",
",",
"(",
"_Item",
"[",
"]",
")",
"WrapperUtils",
".",
"unwrap",
"(",
"_Item",
".",
"class",
",",
"items",
")",
")",
")",
";",
"}",
"/**\n * Gets the web service object this class wraps. The returned object should\n * not be modified.\n *\n * @return the web service object this class wraps.\n */",
"public",
"_ItemSet",
"getWebServiceObject",
"(",
")",
"{",
"return",
"(",
"_ItemSet",
")",
"webServiceObject",
";",
"}",
"/**\n * Gets a copy of the items in this item set.\n *\n * @return a copy of the items in this item set.\n */",
"public",
"Item",
"[",
"]",
"getItems",
"(",
")",
"{",
"return",
"(",
"Item",
"[",
"]",
")",
"WrapperUtils",
".",
"wrap",
"(",
"Item",
".",
"class",
",",
"getWebServiceObject",
"(",
")",
".",
"getItems",
"(",
")",
")",
";",
"}",
"/**\n * Sets the items in this item set.\n *\n * @param items\n * the items to set (must not be <code>null</code>)\n */",
"public",
"void",
"setItems",
"(",
"final",
"Item",
"[",
"]",
"items",
")",
"{",
"Check",
".",
"notNull",
"(",
"items",
",",
"\"",
"items",
"\"",
")",
";",
"getWebServiceObject",
"(",
")",
".",
"setItems",
"(",
"(",
"_Item",
"[",
"]",
")",
"WrapperUtils",
".",
"unwrap",
"(",
"_Item",
".",
"class",
",",
"items",
")",
")",
";",
"}",
"public",
"String",
"getQueryPath",
"(",
")",
"{",
"return",
"getWebServiceObject",
"(",
")",
".",
"getQueryPath",
"(",
")",
";",
"}",
"public",
"String",
"getPattern",
"(",
")",
"{",
"return",
"getWebServiceObject",
"(",
")",
".",
"getPattern",
"(",
")",
";",
"}",
"}"
] | A collection of {@link Item}s, with some additional information about the
query that retrieved the set. | [
"A",
"collection",
"of",
"{",
"@link",
"Item",
"}",
"s",
"with",
"some",
"additional",
"information",
"about",
"the",
"query",
"that",
"retrieved",
"the",
"set",
"."
] | [
"//$NON-NLS-1$"
] | [
{
"param": "WebServiceObjectWrapper",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "WebServiceObjectWrapper",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8b8589b6b8799e2a9f8bc889641e2b2549320def | kingrom/jstarcraft-ai | jstarcraft-ai-jsat/src/test/java/com/jstarcraft/ai/jsat/clustering/EMGaussianMixtureTest.java | [
"Apache-2.0"
] | Java | EMGaussianMixtureTest | /**
*
* @author Edward Raff
*/ | @author Edward Raff | [
"@author",
"Edward",
"Raff"
] | public class EMGaussianMixtureTest {
static private SimpleDataSet easyData;
public EMGaussianMixtureTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
@Test
public void testCluster_3args_2() {
System.out.println("cluster(dataset, int, threadpool)");
boolean good = false;
int count = 0;
do {
GridDataGenerator gdg = new GridDataGenerator(new NormalClampedSample(0, 0.05), RandomUtil.getRandom(), 2, 2);
easyData = gdg.generateData(50);
good = true;
for (boolean parallel : new boolean[] { true, false }) {
EMGaussianMixture em = new EMGaussianMixture(SeedSelectionMethods.SeedSelection.FARTHEST_FIRST);
List<List<DataPoint>> clusters = em.cluster(easyData, 4, parallel);
assertEquals(4, clusters.size());
good = good & checkClusteringByCat(clusters);
}
} while (!good && count++ < 3);
assertTrue(good);
}
} | [
"public",
"class",
"EMGaussianMixtureTest",
"{",
"static",
"private",
"SimpleDataSet",
"easyData",
";",
"public",
"EMGaussianMixtureTest",
"(",
")",
"{",
"}",
"@",
"BeforeClass",
"public",
"static",
"void",
"setUpClass",
"(",
")",
"{",
"}",
"@",
"AfterClass",
"public",
"static",
"void",
"tearDownClass",
"(",
")",
"{",
"}",
"@",
"Before",
"public",
"void",
"setUp",
"(",
")",
"{",
"}",
"@",
"After",
"public",
"void",
"tearDown",
"(",
")",
"{",
"}",
"@",
"Test",
"public",
"void",
"testCluster_3args_2",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"cluster(dataset, int, threadpool)",
"\"",
")",
";",
"boolean",
"good",
"=",
"false",
";",
"int",
"count",
"=",
"0",
";",
"do",
"{",
"GridDataGenerator",
"gdg",
"=",
"new",
"GridDataGenerator",
"(",
"new",
"NormalClampedSample",
"(",
"0",
",",
"0.05",
")",
",",
"RandomUtil",
".",
"getRandom",
"(",
")",
",",
"2",
",",
"2",
")",
";",
"easyData",
"=",
"gdg",
".",
"generateData",
"(",
"50",
")",
";",
"good",
"=",
"true",
";",
"for",
"(",
"boolean",
"parallel",
":",
"new",
"boolean",
"[",
"]",
"{",
"true",
",",
"false",
"}",
")",
"{",
"EMGaussianMixture",
"em",
"=",
"new",
"EMGaussianMixture",
"(",
"SeedSelectionMethods",
".",
"SeedSelection",
".",
"FARTHEST_FIRST",
")",
";",
"List",
"<",
"List",
"<",
"DataPoint",
">",
">",
"clusters",
"=",
"em",
".",
"cluster",
"(",
"easyData",
",",
"4",
",",
"parallel",
")",
";",
"assertEquals",
"(",
"4",
",",
"clusters",
".",
"size",
"(",
")",
")",
";",
"good",
"=",
"good",
"&",
"checkClusteringByCat",
"(",
"clusters",
")",
";",
"}",
"}",
"while",
"(",
"!",
"good",
"&&",
"count",
"++",
"<",
"3",
")",
";",
"assertTrue",
"(",
"good",
")",
";",
"}",
"}"
] | @author Edward Raff | [
"@author",
"Edward",
"Raff"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8b895a186f35b712386279a7cbb20c99cf346358 | scraft-official/MundoSK | src/com/pie/tlatoani/Tablist/Player/PlayerTablist.java | [
"MIT"
] | Java | PlayerTablist | /**
* Created by Tlatoani on 4/14/17.
* Used to manage the player-connected tabs of the tablist.
*/ | Created by Tlatoani on 4/14/17.
Used to manage the player-connected tabs of the tablist. | [
"Created",
"by",
"Tlatoani",
"on",
"4",
"/",
"14",
"/",
"17",
".",
"Used",
"to",
"manage",
"the",
"player",
"-",
"connected",
"tabs",
"of",
"the",
"tablist",
"."
] | public class PlayerTablist {
public final Tablist tablist;
private Optional<Map<Player, Optional<Tab>>> tabs = Optional.of(new HashMap<>());
/**
* Should only be called by the constructor {@link Tablist}, specifically, constructing {@code tablist}.
* Initializes a PlayerTablist to be contained within {@code tablist}.
*/
public PlayerTablist(Tablist tablist) {
this.tablist = tablist;
}
/**
* Returns the {@link Tab} corresponding to {@code player} to be used as a view of the tab's attributes.
* If {@code player}'s tab is hidden or does not contain any nonempty attributes, {@link Optional#empty()} is returned.
* @param player The player whose tab is desired
* @return An {@link Optional} containing the corresponding {@link Tab}, or {@link Optional#empty()} as specified above
*/
public Optional<Tab> getTabIfModified(Player player) {
return tabs.flatMap(map -> Optional.ofNullable(map.computeIfPresent(player, (__, tabOptional) -> {
if (tabOptional.isPresent() && tabOptional.get().isDefault()) {
return null;
} else {
return tabOptional;
}
})).orElse(Optional.empty()));
}
//Used to force creation of a Tab in cases where no attributes of a player's display in the tablist have been modified
/**
* Returns the {@link Tab} corresponding to {@code player} to be used to mainpulate the tab's attributes.
* If {@code player}'s tab is hidden, {@link Optional#empty()} is returned.
* @param player The player whose tab is desired
* @return An {@link Optional} containing the corresponding {@link Tab}, or {@link Optional#empty()} as specified above
*/
public Optional<Tab> getTab(Player player) {
return tabs.flatMap(map -> map.computeIfAbsent(player, __ -> Optional.of(new PlayerTab(this, player))));
}
/**
* @return {@code true} if {@code player} is visible in the target's tablist, {@code false} otherwise
*/
public boolean isPlayerVisible(Player player) {
return tabs.map(
map -> Optional.ofNullable(map.get(player))
.map(Optional::isPresent)
.orElse(true)
).orElse(false);
}
/**
* Makes {@code player} visible in the target's tablist if they are not already so.
*/
public void showPlayer(Player player) {
if (!tabs.isPresent()) {
tabs = Optional.of(new HashMap<>());
tabs.ifPresent(map -> {
for (Player player1 : Bukkit.getOnlinePlayers()) {
map.put(player1, Optional.empty());
}
});
}
tabs.ifPresent(map -> map.computeIfPresent(player, (__, tabOptional) -> {
if (!tabOptional.isPresent()) {
tablist.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.ADD_PLAYER), this);
if (tablist.areScoresEnabled()) {
tablist.sendPacket(
PacketUtil.scorePacket(
player.getName(),
Tablist.OBJECTIVE_NAME,
0,
EnumWrappers.ScoreboardAction.CHANGE
),
this
);
}
return null;
}
return tabOptional;
}));
}
/**
* Makes {@code player} hidden in the target's tablist if they are not already so.
*/
public void hidePlayer(Player player) {
tabs.ifPresent(map -> map.compute(player, (__, tabOptional) -> {
if (tabOptional == null || tabOptional.isPresent()) {
tablist.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER), this);
}
return Optional.empty();
}));
}
/**
* Returns {@code true} if it is possible for players to be visible in the target's tablist
* (i. e. if a player joins, they won't be automatically hidden by MundoSK itself)
* @return {@code true} if players might be visible in the target's tablist, {@code false} otherwise
*/
public boolean arePlayersVisible() {
return tabs.isPresent();
}
/**
* Calls {@link #showPlayer(Player)} on all online players.
*/
public void showAllPlayers() {
for (Player player : Bukkit.getOnlinePlayers()) {
showPlayer(player);
}
}
/**
* Makes it so that no player can be seen in the tablist.
* If a player joins, they will be automatically hidden.
*/
public void hideAllPlayers() {
tabs.ifPresent(map -> {
for (Player player : Bukkit.getOnlinePlayers()) {
Optional<Tab> playerTabOptional = map.get(player);
if (playerTabOptional == null || playerTabOptional.isPresent()) {
tablist.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER), this);
}
}
tabs = Optional.empty();
});
}
/**
* Returns the tablist to its natural state with respect to player-connected tabs.
*/
public void clearModifications() {
OptionalUtil.consume(tabs, this::showAllPlayers, map -> {
tabs = Optional.of(new HashMap<>());
Logging.debug(PlayerTablist.class, "#clearModifications(): map = " + map);
map.forEach((player, tabOptional) -> {
Logging.debug(PlayerTablist.class, "#clearModifications(): player = " + player + ", tabOpt = " + tabOptional);
OptionalUtil.consume(
tabOptional,
() -> tablist.sendPacket(
PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.ADD_PLAYER),
this
), tab -> {
tab.setDisplayName(null);
tab.setLatencyBars(null);
tab.setScore(null);
});
Logging.debug(PlayerTablist.class, "#clearModifications(): through player = " + player);
});
Logging.debug(PlayerTablist.class, "#clearModifications(): clearing map");
map.clear();
Logging.debug(PlayerTablist.class, "#clearModifications(): map cleared");
});
}
/**
* Called only by {@link TablistManager#onJoin(Player)}.
* Currently only serves to hide {@code player} if {@link #arePlayersVisible()} is {@code false}.
* @param player The player who joined
*/
public void onJoin(Player player) {
if (!tabs.isPresent()) {
Scheduling.syncDelay(Config.TABLIST_SPAWN_REMOVE_TAB_DELAY.getCurrentValue(), () ->
tablist.sendPacket(PacketUtil.playerInfoPacket(player, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER), this));
}
}
/**
* Called only by {@link TablistManager#onQuit(Player)}.
* Removes all information relating to {@code player}
* (no packets need to be sent since Minecraft/Bukkit will remove the player from tablist on their own
* and no other modification is necessary).
* @param player The player who quit
*/
public void onQuit(Player player) {
tabs.ifPresent(map -> map.remove(player));
}
/**
* Applies all changes made to player-connected tabs in this tablist to {@code playerTablist}.
* This method is called by {@link Tablist#applyChanges(Tablist)}.
* @param playerTablist
*/
public void applyChanges(PlayerTablist playerTablist) {
OptionalUtil.consume(tabs, playerTablist::hideAllPlayers, tabMap ->
tabMap.forEach((player, tabOptional) ->
OptionalUtil.consume(tabOptional, () -> playerTablist.hidePlayer(player), tab -> {
playerTablist.showPlayer(player);
tab.applyChanges(playerTablist.getTab(player).get());
}))
);
}
} | [
"public",
"class",
"PlayerTablist",
"{",
"public",
"final",
"Tablist",
"tablist",
";",
"private",
"Optional",
"<",
"Map",
"<",
"Player",
",",
"Optional",
"<",
"Tab",
">",
">",
">",
"tabs",
"=",
"Optional",
".",
"of",
"(",
"new",
"HashMap",
"<",
">",
"(",
")",
")",
";",
"/**\n * Should only be called by the constructor {@link Tablist}, specifically, constructing {@code tablist}.\n * Initializes a PlayerTablist to be contained within {@code tablist}.\n */",
"public",
"PlayerTablist",
"(",
"Tablist",
"tablist",
")",
"{",
"this",
".",
"tablist",
"=",
"tablist",
";",
"}",
"/**\n * Returns the {@link Tab} corresponding to {@code player} to be used as a view of the tab's attributes.\n * If {@code player}'s tab is hidden or does not contain any nonempty attributes, {@link Optional#empty()} is returned.\n * @param player The player whose tab is desired\n * @return An {@link Optional} containing the corresponding {@link Tab}, or {@link Optional#empty()} as specified above\n */",
"public",
"Optional",
"<",
"Tab",
">",
"getTabIfModified",
"(",
"Player",
"player",
")",
"{",
"return",
"tabs",
".",
"flatMap",
"(",
"map",
"->",
"Optional",
".",
"ofNullable",
"(",
"map",
".",
"computeIfPresent",
"(",
"player",
",",
"(",
"__",
",",
"tabOptional",
")",
"->",
"{",
"if",
"(",
"tabOptional",
".",
"isPresent",
"(",
")",
"&&",
"tabOptional",
".",
"get",
"(",
")",
".",
"isDefault",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"tabOptional",
";",
"}",
"}",
")",
")",
".",
"orElse",
"(",
"Optional",
".",
"empty",
"(",
")",
")",
")",
";",
"}",
"/**\n * Returns the {@link Tab} corresponding to {@code player} to be used to mainpulate the tab's attributes.\n * If {@code player}'s tab is hidden, {@link Optional#empty()} is returned.\n * @param player The player whose tab is desired\n * @return An {@link Optional} containing the corresponding {@link Tab}, or {@link Optional#empty()} as specified above\n */",
"public",
"Optional",
"<",
"Tab",
">",
"getTab",
"(",
"Player",
"player",
")",
"{",
"return",
"tabs",
".",
"flatMap",
"(",
"map",
"->",
"map",
".",
"computeIfAbsent",
"(",
"player",
",",
"__",
"->",
"Optional",
".",
"of",
"(",
"new",
"PlayerTab",
"(",
"this",
",",
"player",
")",
")",
")",
")",
";",
"}",
"/**\n * @return {@code true} if {@code player} is visible in the target's tablist, {@code false} otherwise\n */",
"public",
"boolean",
"isPlayerVisible",
"(",
"Player",
"player",
")",
"{",
"return",
"tabs",
".",
"map",
"(",
"map",
"->",
"Optional",
".",
"ofNullable",
"(",
"map",
".",
"get",
"(",
"player",
")",
")",
".",
"map",
"(",
"Optional",
"::",
"isPresent",
")",
".",
"orElse",
"(",
"true",
")",
")",
".",
"orElse",
"(",
"false",
")",
";",
"}",
"/**\n * Makes {@code player} visible in the target's tablist if they are not already so.\n */",
"public",
"void",
"showPlayer",
"(",
"Player",
"player",
")",
"{",
"if",
"(",
"!",
"tabs",
".",
"isPresent",
"(",
")",
")",
"{",
"tabs",
"=",
"Optional",
".",
"of",
"(",
"new",
"HashMap",
"<",
">",
"(",
")",
")",
";",
"tabs",
".",
"ifPresent",
"(",
"map",
"->",
"{",
"for",
"(",
"Player",
"player1",
":",
"Bukkit",
".",
"getOnlinePlayers",
"(",
")",
")",
"{",
"map",
".",
"put",
"(",
"player1",
",",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"tabs",
".",
"ifPresent",
"(",
"map",
"->",
"map",
".",
"computeIfPresent",
"(",
"player",
",",
"(",
"__",
",",
"tabOptional",
")",
"->",
"{",
"if",
"(",
"!",
"tabOptional",
".",
"isPresent",
"(",
")",
")",
"{",
"tablist",
".",
"sendPacket",
"(",
"PacketUtil",
".",
"playerInfoPacket",
"(",
"player",
",",
"EnumWrappers",
".",
"PlayerInfoAction",
".",
"ADD_PLAYER",
")",
",",
"this",
")",
";",
"if",
"(",
"tablist",
".",
"areScoresEnabled",
"(",
")",
")",
"{",
"tablist",
".",
"sendPacket",
"(",
"PacketUtil",
".",
"scorePacket",
"(",
"player",
".",
"getName",
"(",
")",
",",
"Tablist",
".",
"OBJECTIVE_NAME",
",",
"0",
",",
"EnumWrappers",
".",
"ScoreboardAction",
".",
"CHANGE",
")",
",",
"this",
")",
";",
"}",
"return",
"null",
";",
"}",
"return",
"tabOptional",
";",
"}",
")",
")",
";",
"}",
"/**\n * Makes {@code player} hidden in the target's tablist if they are not already so.\n */",
"public",
"void",
"hidePlayer",
"(",
"Player",
"player",
")",
"{",
"tabs",
".",
"ifPresent",
"(",
"map",
"->",
"map",
".",
"compute",
"(",
"player",
",",
"(",
"__",
",",
"tabOptional",
")",
"->",
"{",
"if",
"(",
"tabOptional",
"==",
"null",
"||",
"tabOptional",
".",
"isPresent",
"(",
")",
")",
"{",
"tablist",
".",
"sendPacket",
"(",
"PacketUtil",
".",
"playerInfoPacket",
"(",
"player",
",",
"EnumWrappers",
".",
"PlayerInfoAction",
".",
"REMOVE_PLAYER",
")",
",",
"this",
")",
";",
"}",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
")",
")",
";",
"}",
"/**\n * Returns {@code true} if it is possible for players to be visible in the target's tablist\n * (i. e. if a player joins, they won't be automatically hidden by MundoSK itself)\n * @return {@code true} if players might be visible in the target's tablist, {@code false} otherwise\n */",
"public",
"boolean",
"arePlayersVisible",
"(",
")",
"{",
"return",
"tabs",
".",
"isPresent",
"(",
")",
";",
"}",
"/**\n * Calls {@link #showPlayer(Player)} on all online players.\n */",
"public",
"void",
"showAllPlayers",
"(",
")",
"{",
"for",
"(",
"Player",
"player",
":",
"Bukkit",
".",
"getOnlinePlayers",
"(",
")",
")",
"{",
"showPlayer",
"(",
"player",
")",
";",
"}",
"}",
"/**\n * Makes it so that no player can be seen in the tablist.\n * If a player joins, they will be automatically hidden.\n */",
"public",
"void",
"hideAllPlayers",
"(",
")",
"{",
"tabs",
".",
"ifPresent",
"(",
"map",
"->",
"{",
"for",
"(",
"Player",
"player",
":",
"Bukkit",
".",
"getOnlinePlayers",
"(",
")",
")",
"{",
"Optional",
"<",
"Tab",
">",
"playerTabOptional",
"=",
"map",
".",
"get",
"(",
"player",
")",
";",
"if",
"(",
"playerTabOptional",
"==",
"null",
"||",
"playerTabOptional",
".",
"isPresent",
"(",
")",
")",
"{",
"tablist",
".",
"sendPacket",
"(",
"PacketUtil",
".",
"playerInfoPacket",
"(",
"player",
",",
"EnumWrappers",
".",
"PlayerInfoAction",
".",
"REMOVE_PLAYER",
")",
",",
"this",
")",
";",
"}",
"}",
"tabs",
"=",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
")",
";",
"}",
"/**\n * Returns the tablist to its natural state with respect to player-connected tabs.\n */",
"public",
"void",
"clearModifications",
"(",
")",
"{",
"OptionalUtil",
".",
"consume",
"(",
"tabs",
",",
"this",
"::",
"showAllPlayers",
",",
"map",
"->",
"{",
"tabs",
"=",
"Optional",
".",
"of",
"(",
"new",
"HashMap",
"<",
">",
"(",
")",
")",
";",
"Logging",
".",
"debug",
"(",
"PlayerTablist",
".",
"class",
",",
"\"",
"#clearModifications(): map = ",
"\"",
"+",
"map",
")",
";",
"map",
".",
"forEach",
"(",
"(",
"player",
",",
"tabOptional",
")",
"->",
"{",
"Logging",
".",
"debug",
"(",
"PlayerTablist",
".",
"class",
",",
"\"",
"#clearModifications(): player = ",
"\"",
"+",
"player",
"+",
"\"",
", tabOpt = ",
"\"",
"+",
"tabOptional",
")",
";",
"OptionalUtil",
".",
"consume",
"(",
"tabOptional",
",",
"(",
")",
"->",
"tablist",
".",
"sendPacket",
"(",
"PacketUtil",
".",
"playerInfoPacket",
"(",
"player",
",",
"EnumWrappers",
".",
"PlayerInfoAction",
".",
"ADD_PLAYER",
")",
",",
"this",
")",
",",
"tab",
"->",
"{",
"tab",
".",
"setDisplayName",
"(",
"null",
")",
";",
"tab",
".",
"setLatencyBars",
"(",
"null",
")",
";",
"tab",
".",
"setScore",
"(",
"null",
")",
";",
"}",
")",
";",
"Logging",
".",
"debug",
"(",
"PlayerTablist",
".",
"class",
",",
"\"",
"#clearModifications(): through player = ",
"\"",
"+",
"player",
")",
";",
"}",
")",
";",
"Logging",
".",
"debug",
"(",
"PlayerTablist",
".",
"class",
",",
"\"",
"#clearModifications(): clearing map",
"\"",
")",
";",
"map",
".",
"clear",
"(",
")",
";",
"Logging",
".",
"debug",
"(",
"PlayerTablist",
".",
"class",
",",
"\"",
"#clearModifications(): map cleared",
"\"",
")",
";",
"}",
")",
";",
"}",
"/**\n * Called only by {@link TablistManager#onJoin(Player)}.\n * Currently only serves to hide {@code player} if {@link #arePlayersVisible()} is {@code false}.\n * @param player The player who joined\n */",
"public",
"void",
"onJoin",
"(",
"Player",
"player",
")",
"{",
"if",
"(",
"!",
"tabs",
".",
"isPresent",
"(",
")",
")",
"{",
"Scheduling",
".",
"syncDelay",
"(",
"Config",
".",
"TABLIST_SPAWN_REMOVE_TAB_DELAY",
".",
"getCurrentValue",
"(",
")",
",",
"(",
")",
"->",
"tablist",
".",
"sendPacket",
"(",
"PacketUtil",
".",
"playerInfoPacket",
"(",
"player",
",",
"EnumWrappers",
".",
"PlayerInfoAction",
".",
"REMOVE_PLAYER",
")",
",",
"this",
")",
")",
";",
"}",
"}",
"/**\n * Called only by {@link TablistManager#onQuit(Player)}.\n * Removes all information relating to {@code player}\n * (no packets need to be sent since Minecraft/Bukkit will remove the player from tablist on their own\n * and no other modification is necessary).\n * @param player The player who quit\n */",
"public",
"void",
"onQuit",
"(",
"Player",
"player",
")",
"{",
"tabs",
".",
"ifPresent",
"(",
"map",
"->",
"map",
".",
"remove",
"(",
"player",
")",
")",
";",
"}",
"/**\n * Applies all changes made to player-connected tabs in this tablist to {@code playerTablist}.\n * This method is called by {@link Tablist#applyChanges(Tablist)}.\n * @param playerTablist\n */",
"public",
"void",
"applyChanges",
"(",
"PlayerTablist",
"playerTablist",
")",
"{",
"OptionalUtil",
".",
"consume",
"(",
"tabs",
",",
"playerTablist",
"::",
"hideAllPlayers",
",",
"tabMap",
"->",
"tabMap",
".",
"forEach",
"(",
"(",
"player",
",",
"tabOptional",
")",
"->",
"OptionalUtil",
".",
"consume",
"(",
"tabOptional",
",",
"(",
")",
"->",
"playerTablist",
".",
"hidePlayer",
"(",
"player",
")",
",",
"tab",
"->",
"{",
"playerTablist",
".",
"showPlayer",
"(",
"player",
")",
";",
"tab",
".",
"applyChanges",
"(",
"playerTablist",
".",
"getTab",
"(",
"player",
")",
".",
"get",
"(",
")",
")",
";",
"}",
")",
")",
")",
";",
"}",
"}"
] | Created by Tlatoani on 4/14/17. | [
"Created",
"by",
"Tlatoani",
"on",
"4",
"/",
"14",
"/",
"17",
"."
] | [
"//Used to force creation of a Tab in cases where no attributes of a player's display in the tablist have been modified"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8b8da5a15faa69d1b8e779aabb736ef90dc6b354 | platinumRondo/shavedwords | src/main/java/com/github/platinumrondo/shavedwords/gui/cards/MatchCard.java | [
"BSD-3-Clause"
] | Java | MatchCard | /**
* Show a list of possible words similar to the one provided by the user.
*/ | Show a list of possible words similar to the one provided by the user. | [
"Show",
"a",
"list",
"of",
"possible",
"words",
"similar",
"to",
"the",
"one",
"provided",
"by",
"the",
"user",
"."
] | public class MatchCard extends JPanel {
private JList<String> matchList;
private JScrollPane scrollPane;
public MatchCard() {
initComponents();
}
private void initComponents() {
setLayout(new BorderLayout());
matchList = new JList<>();
scrollPane = new JScrollPane(matchList);
add(scrollPane, BorderLayout.CENTER);
}
public void setList(Set<MatchResult> strs) {
//TODO think of something better
List<String> strl = new ArrayList<>();
for (MatchResult mr : strs) {
strl.add(mr.getWord());
}
matchList.setListData(strl.toArray(new String[strl.size()]));
scrollPane.getHorizontalScrollBar().setValue(scrollPane.getHorizontalScrollBar().getMinimum());
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMinimum());
}
} | [
"public",
"class",
"MatchCard",
"extends",
"JPanel",
"{",
"private",
"JList",
"<",
"String",
">",
"matchList",
";",
"private",
"JScrollPane",
"scrollPane",
";",
"public",
"MatchCard",
"(",
")",
"{",
"initComponents",
"(",
")",
";",
"}",
"private",
"void",
"initComponents",
"(",
")",
"{",
"setLayout",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"matchList",
"=",
"new",
"JList",
"<",
">",
"(",
")",
";",
"scrollPane",
"=",
"new",
"JScrollPane",
"(",
"matchList",
")",
";",
"add",
"(",
"scrollPane",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"}",
"public",
"void",
"setList",
"(",
"Set",
"<",
"MatchResult",
">",
"strs",
")",
"{",
"List",
"<",
"String",
">",
"strl",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"for",
"(",
"MatchResult",
"mr",
":",
"strs",
")",
"{",
"strl",
".",
"add",
"(",
"mr",
".",
"getWord",
"(",
")",
")",
";",
"}",
"matchList",
".",
"setListData",
"(",
"strl",
".",
"toArray",
"(",
"new",
"String",
"[",
"strl",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"scrollPane",
".",
"getHorizontalScrollBar",
"(",
")",
".",
"setValue",
"(",
"scrollPane",
".",
"getHorizontalScrollBar",
"(",
")",
".",
"getMinimum",
"(",
")",
")",
";",
"scrollPane",
".",
"getVerticalScrollBar",
"(",
")",
".",
"setValue",
"(",
"scrollPane",
".",
"getVerticalScrollBar",
"(",
")",
".",
"getMinimum",
"(",
")",
")",
";",
"}",
"}"
] | Show a list of possible words similar to the one provided by the user. | [
"Show",
"a",
"list",
"of",
"possible",
"words",
"similar",
"to",
"the",
"one",
"provided",
"by",
"the",
"user",
"."
] | [
"//TODO think of something better"
] | [
{
"param": "JPanel",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "JPanel",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8b911806f510370f45e88f0b11053e25255a96eb | preetipanwar/teach-java | src/com/teachjava/labs/WordFrequency.java | [
"MIT"
] | Java | WordFrequency | // 7. Write a program to make frequency count of words in a text. | 7. Write a program to make frequency count of words in a text. | [
"7",
".",
"Write",
"a",
"program",
"to",
"make",
"frequency",
"count",
"of",
"words",
"in",
"a",
"text",
"."
] | public class WordFrequency {
// method to add a word to an array of String
// arguments required --> (array, word)
static String[] addWord(String[] arr, String word){
String[] printedWordArray = new String[arr.length + 1];
// copy every element of arr to printedWordArray
for(int x=0; x < arr.length; x++){
printedWordArray[x] = arr[x];
}
// add the word to the last position
printedWordArray[arr.length] = word;
return printedWordArray; // return new array
}
public static void main(String[] args) {
String paragraph =
"Nory was a Catholic because her mother was a Catholic " +
"and Nory’s mother was a Catholic because her father was a Catholic " +
"and her father was a Catholic because his mother was a Catholic or had been";
// convert paragraph to para (array), split the words with whitespace.
String[] para = paragraph.split(" ");
String printedWordArray[] = new String[1]; // holding 1 word to for loop initially
String word; // initialize word variable
int count = 0; // initialize counter
for(int x=0; x < para.length; x++){
word = para[x]; // pick a word on each iteration
for ( int y = 0; y < para.length; y++){
if (word.equals(para[y])){ // if picked word found again
count++; // increase the counter
}
}
// traverse through array to see if the word is already printed before
for (int j=0; j < printedWordArray.length; j++){
// if same word is found in array then word count is already printed
// break since we don't want to print the word count again
if(word.equals(printedWordArray[j])){
break;
}
// if the word is not found in array print it and add it to printedWord array
if (j == printedWordArray.length - 1){
System.out.println(word + ": " + count);
printedWordArray = WordFrequency.addWord(printedWordArray, word);
}
}
count = 0; // reset count for the next word
}
}
} | [
"public",
"class",
"WordFrequency",
"{",
"static",
"String",
"[",
"]",
"addWord",
"(",
"String",
"[",
"]",
"arr",
",",
"String",
"word",
")",
"{",
"String",
"[",
"]",
"printedWordArray",
"=",
"new",
"String",
"[",
"arr",
".",
"length",
"+",
"1",
"]",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"arr",
".",
"length",
";",
"x",
"++",
")",
"{",
"printedWordArray",
"[",
"x",
"]",
"=",
"arr",
"[",
"x",
"]",
";",
"}",
"printedWordArray",
"[",
"arr",
".",
"length",
"]",
"=",
"word",
";",
"return",
"printedWordArray",
";",
"}",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"String",
"paragraph",
"=",
"\"",
"Nory was a Catholic because her mother was a Catholic ",
"\"",
"+",
"\"",
"and Nory’s mother was a Catholic because her father was a Catholic \" ",
"+",
"",
"\"",
"and her father was a Catholic because his mother was a Catholic or had been",
"\"",
";",
"String",
"[",
"]",
"para",
"=",
"paragraph",
".",
"split",
"(",
"\"",
" ",
"\"",
")",
";",
"String",
"printedWordArray",
"[",
"]",
"=",
"new",
"String",
"[",
"1",
"]",
";",
"String",
"word",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"para",
".",
"length",
";",
"x",
"++",
")",
"{",
"word",
"=",
"para",
"[",
"x",
"]",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"para",
".",
"length",
";",
"y",
"++",
")",
"{",
"if",
"(",
"word",
".",
"equals",
"(",
"para",
"[",
"y",
"]",
")",
")",
"{",
"count",
"++",
";",
"}",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"printedWordArray",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"word",
".",
"equals",
"(",
"printedWordArray",
"[",
"j",
"]",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"j",
"==",
"printedWordArray",
".",
"length",
"-",
"1",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"word",
"+",
"\"",
": ",
"\"",
"+",
"count",
")",
";",
"printedWordArray",
"=",
"WordFrequency",
".",
"addWord",
"(",
"printedWordArray",
",",
"word",
")",
";",
"}",
"}",
"count",
"=",
"0",
";",
"}",
"}",
"}"
] | 7. | [
"7",
"."
] | [
"// method to add a word to an array of String",
"// arguments required --> (array, word)",
"// copy every element of arr to printedWordArray",
"// add the word to the last position",
"// return new array",
"// convert paragraph to para (array), split the words with whitespace.",
"// holding 1 word to for loop initially",
"// initialize word variable",
"// initialize counter",
"// pick a word on each iteration",
"// if picked word found again",
"// increase the counter",
"// traverse through array to see if the word is already printed before",
"// if same word is found in array then word count is already printed",
"// break since we don't want to print the word count again",
"// if the word is not found in array print it and add it to printedWord array",
"// reset count for the next word"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8b911806f510370f45e88f0b11053e25255a96eb | preetipanwar/teach-java | src/com/teachjava/labs/WordFrequency.java | [
"MIT"
] | Java | WordFrequencyAlternative | // Below I have used ArrayList<> to solve the same problem. | Below I have used ArrayList<> to solve the same problem. | [
"Below",
"I",
"have",
"used",
"ArrayList<",
">",
"to",
"solve",
"the",
"same",
"problem",
"."
] | class WordFrequencyAlternative {
// replacing for with for-each loop
// which is easier to read
public static void main(String[] args) {
String paragraph =
"Nory was a Catholic because her mother was a Catholic " +
"and Nory’s mother was a Catholic because her father was a Catholic " +
"and her father was a Catholic because his mother was a Catholic or had been";
// convert paragraph to para (array), split the words with whitespace.
String[] para = paragraph.split(" ");
// make a dynamic array, which will keep track of printed words
ArrayList<String> printedWord = new ArrayList<String>();
printedWord.add("");
String word; // initialize word variable
int count = 0; // initialize counter
for (String x : para) {
word = x;
for (String y : para) {
if (word.equals(y)) {
count++;
}
}
for (int j = 0; j < printedWord.size(); j++) {
if (word.equals(printedWord.get(j))) {
break;
}
// if the word is not found in array print it and add it to printedWord array
if (j == printedWord.size() - 1) {
System.out.println(word + ": " + count);
printedWord.add(word);
}
}
count = 0; // reset count for the next word
}
}
} | [
"class",
"WordFrequencyAlternative",
"{",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"String",
"paragraph",
"=",
"\"",
"Nory was a Catholic because her mother was a Catholic ",
"\"",
"+",
"\"",
"and Nory’s mother was a Catholic because her father was a Catholic \" ",
"+",
"",
"\"",
"and her father was a Catholic because his mother was a Catholic or had been",
"\"",
";",
"String",
"[",
"]",
"para",
"=",
"paragraph",
".",
"split",
"(",
"\"",
" ",
"\"",
")",
";",
"ArrayList",
"<",
"String",
">",
"printedWord",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"printedWord",
".",
"add",
"(",
"\"",
"\"",
")",
";",
"String",
"word",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"String",
"x",
":",
"para",
")",
"{",
"word",
"=",
"x",
";",
"for",
"(",
"String",
"y",
":",
"para",
")",
"{",
"if",
"(",
"word",
".",
"equals",
"(",
"y",
")",
")",
"{",
"count",
"++",
";",
"}",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"printedWord",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"word",
".",
"equals",
"(",
"printedWord",
".",
"get",
"(",
"j",
")",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"j",
"==",
"printedWord",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"word",
"+",
"\"",
": ",
"\"",
"+",
"count",
")",
";",
"printedWord",
".",
"add",
"(",
"word",
")",
";",
"}",
"}",
"count",
"=",
"0",
";",
"}",
"}",
"}"
] | Below I have used ArrayList<> to solve the same problem. | [
"Below",
"I",
"have",
"used",
"ArrayList<",
">",
"to",
"solve",
"the",
"same",
"problem",
"."
] | [
"// replacing for with for-each loop",
"// which is easier to read",
"// convert paragraph to para (array), split the words with whitespace.",
"// make a dynamic array, which will keep track of printed words",
"// initialize word variable",
"// initialize counter",
"// if the word is not found in array print it and add it to printedWord array",
"// reset count for the next word"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8b93b52cd7febcfd60cfc32a0e1fc9a79f63e8c6 | kalaspuffar/JavaCNN | src/org/ea/javacnn/data/OutputDefinition.java | [
"MIT"
] | Java | OutputDefinition | /**
* This class will hold the definitions that bridge two layers.
* So you can set values in one layer and use them in the next layer.
*
* @author Daniel Persson ([email protected])
*/ | This class will hold the definitions that bridge two layers.
So you can set values in one layer and use them in the next layer.
| [
"This",
"class",
"will",
"hold",
"the",
"definitions",
"that",
"bridge",
"two",
"layers",
".",
"So",
"you",
"can",
"set",
"values",
"in",
"one",
"layer",
"and",
"use",
"them",
"in",
"the",
"next",
"layer",
"."
] | public class OutputDefinition {
private int out_sx;
private int out_sy;
private int depth;
public int getOutX() {
return out_sx;
}
public void setOutX(int out_sx) {
this.out_sx = out_sx;
}
public int getOutY() {
return out_sy;
}
public void setOutY(int out_sy) {
this.out_sy = out_sy;
}
public int getDepth() {
return depth;
}
public void setDepth(int depth) {
this.depth = depth;
}
} | [
"public",
"class",
"OutputDefinition",
"{",
"private",
"int",
"out_sx",
";",
"private",
"int",
"out_sy",
";",
"private",
"int",
"depth",
";",
"public",
"int",
"getOutX",
"(",
")",
"{",
"return",
"out_sx",
";",
"}",
"public",
"void",
"setOutX",
"(",
"int",
"out_sx",
")",
"{",
"this",
".",
"out_sx",
"=",
"out_sx",
";",
"}",
"public",
"int",
"getOutY",
"(",
")",
"{",
"return",
"out_sy",
";",
"}",
"public",
"void",
"setOutY",
"(",
"int",
"out_sy",
")",
"{",
"this",
".",
"out_sy",
"=",
"out_sy",
";",
"}",
"public",
"int",
"getDepth",
"(",
")",
"{",
"return",
"depth",
";",
"}",
"public",
"void",
"setDepth",
"(",
"int",
"depth",
")",
"{",
"this",
".",
"depth",
"=",
"depth",
";",
"}",
"}"
] | This class will hold the definitions that bridge two layers. | [
"This",
"class",
"will",
"hold",
"the",
"definitions",
"that",
"bridge",
"two",
"layers",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8b94ebf9bfd1b17bf5264190f693e1cfe909938a | ib-da-ncirl/Weather_analysis | src/main/java/ie/ibuttimer/weather/sma/SmaTableReducer.java | [
"MIT"
] | Java | SmaTableReducer | /**
* Reducer to perform Simple Moving Average functionality
*/ | Reducer to perform Simple Moving Average functionality | [
"Reducer",
"to",
"perform",
"Simple",
"Moving",
"Average",
"functionality"
] | public class SmaTableReducer extends AbstractTableReducer<CompositeKey, TimeSeriesData, Text>
implements SmaReducerEngine.ISmaReduceOutput<CompositeKey, TimeSeriesData, Text, Mutation> {
// public abstract class TableReducer<KEYIN, VALUEIN, KEYOUT> extends Reducer<KEYIN, VALUEIN, KEYOUT, Mutation>
private SmaReducerEngine<CompositeKey, TimeSeriesData, Text, Mutation> engine;
private ErrorTracker errorTracker;
@Override
protected void setup(Context context) throws IOException, InterruptedException {
this.engine = new SmaReducerEngine<>(context.getConfiguration(), this);
this.errorTracker = new ErrorTracker();
}
@Override
protected void reduce(CompositeKey key, Iterable<TimeSeriesData> values, Context context) {
engine.reduce(key, values, context);
// only param is window size
addModelMetrics(context, key.getMainKey(), errorTracker,1, (int)engine.getCount(), engine.getParams());
}
@Override
public void reduce(CompositeKey key, String dateTime, double value, double movingAvg, double error, Context context)
throws IOException, InterruptedException {
String row = Utils.getRowName(key.getSubKey());
Put put = new Put(Bytes.toBytes(row))
.addColumn(FAMILY_BYTES, Constants.ACTUAL, storeValueAsString(value))
.addColumn(FAMILY_BYTES, Constants.MOVING_AVG, storeValueAsString(movingAvg))
.addColumn(FAMILY_BYTES, Constants.ERROR, storeValueAsString(error))
.addColumn(FAMILY_BYTES, Constants.SQ_ERROR, storeValueAsString(Math.pow(error, 2)));
errorTracker.addError(value, error);
write(context, put);
}
} | [
"public",
"class",
"SmaTableReducer",
"extends",
"AbstractTableReducer",
"<",
"CompositeKey",
",",
"TimeSeriesData",
",",
"Text",
">",
"implements",
"SmaReducerEngine",
".",
"ISmaReduceOutput",
"<",
"CompositeKey",
",",
"TimeSeriesData",
",",
"Text",
",",
"Mutation",
">",
"{",
"private",
"SmaReducerEngine",
"<",
"CompositeKey",
",",
"TimeSeriesData",
",",
"Text",
",",
"Mutation",
">",
"engine",
";",
"private",
"ErrorTracker",
"errorTracker",
";",
"@",
"Override",
"protected",
"void",
"setup",
"(",
"Context",
"context",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"this",
".",
"engine",
"=",
"new",
"SmaReducerEngine",
"<",
">",
"(",
"context",
".",
"getConfiguration",
"(",
")",
",",
"this",
")",
";",
"this",
".",
"errorTracker",
"=",
"new",
"ErrorTracker",
"(",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"reduce",
"(",
"CompositeKey",
"key",
",",
"Iterable",
"<",
"TimeSeriesData",
">",
"values",
",",
"Context",
"context",
")",
"{",
"engine",
".",
"reduce",
"(",
"key",
",",
"values",
",",
"context",
")",
";",
"addModelMetrics",
"(",
"context",
",",
"key",
".",
"getMainKey",
"(",
")",
",",
"errorTracker",
",",
"1",
",",
"(",
"int",
")",
"engine",
".",
"getCount",
"(",
")",
",",
"engine",
".",
"getParams",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"reduce",
"(",
"CompositeKey",
"key",
",",
"String",
"dateTime",
",",
"double",
"value",
",",
"double",
"movingAvg",
",",
"double",
"error",
",",
"Context",
"context",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"String",
"row",
"=",
"Utils",
".",
"getRowName",
"(",
"key",
".",
"getSubKey",
"(",
")",
")",
";",
"Put",
"put",
"=",
"new",
"Put",
"(",
"Bytes",
".",
"toBytes",
"(",
"row",
")",
")",
".",
"addColumn",
"(",
"FAMILY_BYTES",
",",
"Constants",
".",
"ACTUAL",
",",
"storeValueAsString",
"(",
"value",
")",
")",
".",
"addColumn",
"(",
"FAMILY_BYTES",
",",
"Constants",
".",
"MOVING_AVG",
",",
"storeValueAsString",
"(",
"movingAvg",
")",
")",
".",
"addColumn",
"(",
"FAMILY_BYTES",
",",
"Constants",
".",
"ERROR",
",",
"storeValueAsString",
"(",
"error",
")",
")",
".",
"addColumn",
"(",
"FAMILY_BYTES",
",",
"Constants",
".",
"SQ_ERROR",
",",
"storeValueAsString",
"(",
"Math",
".",
"pow",
"(",
"error",
",",
"2",
")",
")",
")",
";",
"errorTracker",
".",
"addError",
"(",
"value",
",",
"error",
")",
";",
"write",
"(",
"context",
",",
"put",
")",
";",
"}",
"}"
] | Reducer to perform Simple Moving Average functionality | [
"Reducer",
"to",
"perform",
"Simple",
"Moving",
"Average",
"functionality"
] | [
"// public abstract class TableReducer<KEYIN, VALUEIN, KEYOUT> extends Reducer<KEYIN, VALUEIN, KEYOUT, Mutation>",
"// only param is window size"
] | [
{
"param": "SmaReducerEngine.ISmaReduceOutput<CompositeKey, TimeSeriesData, Text, Mutation>",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "SmaReducerEngine.ISmaReduceOutput<CompositeKey, TimeSeriesData, Text, Mutation>",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8b9977f9fc152a6b47fe87605e68878138640a6f | efluid/datagate | efluid-datagate-app/src/main/java/fr/uem/efluid/config/ExportTargetConfig.java | [
"Apache-2.0"
] | Java | ExportTargetConfig | /**
* <p>
* Configuration of target for export from API (each "target" is a configuration "place"
* where the export file will be copied</p>
* <p>
* <strong>Configuration model</strong> :
* <pre>
* exports:
* api-targets:
* filename-pattern: datagate_export_<type>_<time>.par
* supported-types: file
* file:
* folder: C:\\Temp\\export-datagate
* ftp:
* server-url:
* username:
* password:
* artifactory:
* server-url:
* username:
* password:
* </pre>
* </p>
* <p>
* Export on targets will be active if they are both specified with <code>supported-types</code>
* and with specified properties
* </p>
*
* @author elecomte
* @version 1
* @since v5.1
*/ |
@author elecomte
@version 1
@since v5.1 | [
"@author",
"elecomte",
"@version",
"1",
"@since",
"v5",
".",
"1"
] | @Configuration
@EnableConfigurationProperties(ExportTargetConfig.ExportTargetProperties.class)
public class ExportTargetConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(ExportTargetConfig.class);
@Bean
public ExportTargetDispatcher targetDispatcher(@Autowired ExportTargetProperties properties) {
ExportTargetDispatcher dispatcher = new ExportTargetDispatcher(properties.getFilenamePattern());
Set<String> enabledTypes = Stream.of(properties.getSupportedTypes().split(","))
.map(String::trim).collect(Collectors.toSet());
if (enabledTypes.contains("artifactory") && properties.getArtifactory() != null && StringUtils.hasText(properties.getArtifactory().getServerUrl())) {
LOGGER.info("[PUSH] Configured export target : copy to artifactory \"{}\"", properties.getArtifactory().getServerUrl());
dispatcher.addExportTarget(new ArtifactoryExportTarget(properties.getArtifactory()));
}
if (enabledTypes.contains("ftp") && properties.getFtp() != null && StringUtils.hasText(properties.getFtp().getServerUrl())) {
LOGGER.info("[PUSH] Configured export target : copy to ftp \"{}\"", properties.getFtp().getServerUrl());
dispatcher.addExportTarget(new FtpExportTarget(properties.getFtp()));
}
if (enabledTypes.contains("file") && properties.getFile() != null && StringUtils.hasText(properties.getFile().getFolder())) {
LOGGER.info("[PUSH] Configured export target : copy to local folder \"{}\"", properties.getFile().getFolder());
dispatcher.addExportTarget(new LocalFileExportTarget(properties.getFile()));
}
return dispatcher;
}
@ConfigurationProperties(prefix = "datagate-efluid.exports.api-targets")
public static class ExportTargetProperties {
private String filenamePattern;
private String supportedTypes;
private LocalFileExportTarget.LocalFileExportTargetProperties file;
private RemoteServiceExportTarget.RemoteServiceExportTargetProperties ftp;
private ArtifactoryExportTarget.ArtifactoryExportTargetProperties artifactory;
public ExportTargetProperties() {
super();
}
public String getSupportedTypes() {
return this.supportedTypes;
}
public void setSupportedTypes(String supportedTypes) {
this.supportedTypes = supportedTypes;
}
public String getFilenamePattern() {
return this.filenamePattern;
}
public void setFilenamePattern(String filenamePattern) {
this.filenamePattern = filenamePattern;
}
public LocalFileExportTarget.LocalFileExportTargetProperties getFile() {
return this.file;
}
public void setFile(LocalFileExportTarget.LocalFileExportTargetProperties file) {
this.file = file;
}
public RemoteServiceExportTarget.RemoteServiceExportTargetProperties getFtp() {
return this.ftp;
}
public void setFtp(RemoteServiceExportTarget.RemoteServiceExportTargetProperties ftp) {
this.ftp = ftp;
}
public ArtifactoryExportTarget.ArtifactoryExportTargetProperties getArtifactory() {
return this.artifactory;
}
public void setArtifactory(ArtifactoryExportTarget.ArtifactoryExportTargetProperties artifactory) {
this.artifactory = artifactory;
}
}
} | [
"@",
"Configuration",
"@",
"EnableConfigurationProperties",
"(",
"ExportTargetConfig",
".",
"ExportTargetProperties",
".",
"class",
")",
"public",
"class",
"ExportTargetConfig",
"{",
"private",
"static",
"final",
"Logger",
"LOGGER",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"ExportTargetConfig",
".",
"class",
")",
";",
"@",
"Bean",
"public",
"ExportTargetDispatcher",
"targetDispatcher",
"(",
"@",
"Autowired",
"ExportTargetProperties",
"properties",
")",
"{",
"ExportTargetDispatcher",
"dispatcher",
"=",
"new",
"ExportTargetDispatcher",
"(",
"properties",
".",
"getFilenamePattern",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"enabledTypes",
"=",
"Stream",
".",
"of",
"(",
"properties",
".",
"getSupportedTypes",
"(",
")",
".",
"split",
"(",
"\"",
",",
"\"",
")",
")",
".",
"map",
"(",
"String",
"::",
"trim",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"if",
"(",
"enabledTypes",
".",
"contains",
"(",
"\"",
"artifactory",
"\"",
")",
"&&",
"properties",
".",
"getArtifactory",
"(",
")",
"!=",
"null",
"&&",
"StringUtils",
".",
"hasText",
"(",
"properties",
".",
"getArtifactory",
"(",
")",
".",
"getServerUrl",
"(",
")",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"",
"[PUSH] Configured export target : copy to artifactory ",
"\\\"",
"{}",
"\\\"",
"\"",
",",
"properties",
".",
"getArtifactory",
"(",
")",
".",
"getServerUrl",
"(",
")",
")",
";",
"dispatcher",
".",
"addExportTarget",
"(",
"new",
"ArtifactoryExportTarget",
"(",
"properties",
".",
"getArtifactory",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"enabledTypes",
".",
"contains",
"(",
"\"",
"ftp",
"\"",
")",
"&&",
"properties",
".",
"getFtp",
"(",
")",
"!=",
"null",
"&&",
"StringUtils",
".",
"hasText",
"(",
"properties",
".",
"getFtp",
"(",
")",
".",
"getServerUrl",
"(",
")",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"",
"[PUSH] Configured export target : copy to ftp ",
"\\\"",
"{}",
"\\\"",
"\"",
",",
"properties",
".",
"getFtp",
"(",
")",
".",
"getServerUrl",
"(",
")",
")",
";",
"dispatcher",
".",
"addExportTarget",
"(",
"new",
"FtpExportTarget",
"(",
"properties",
".",
"getFtp",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"enabledTypes",
".",
"contains",
"(",
"\"",
"file",
"\"",
")",
"&&",
"properties",
".",
"getFile",
"(",
")",
"!=",
"null",
"&&",
"StringUtils",
".",
"hasText",
"(",
"properties",
".",
"getFile",
"(",
")",
".",
"getFolder",
"(",
")",
")",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"",
"[PUSH] Configured export target : copy to local folder ",
"\\\"",
"{}",
"\\\"",
"\"",
",",
"properties",
".",
"getFile",
"(",
")",
".",
"getFolder",
"(",
")",
")",
";",
"dispatcher",
".",
"addExportTarget",
"(",
"new",
"LocalFileExportTarget",
"(",
"properties",
".",
"getFile",
"(",
")",
")",
")",
";",
"}",
"return",
"dispatcher",
";",
"}",
"@",
"ConfigurationProperties",
"(",
"prefix",
"=",
"\"",
"datagate-efluid.exports.api-targets",
"\"",
")",
"public",
"static",
"class",
"ExportTargetProperties",
"{",
"private",
"String",
"filenamePattern",
";",
"private",
"String",
"supportedTypes",
";",
"private",
"LocalFileExportTarget",
".",
"LocalFileExportTargetProperties",
"file",
";",
"private",
"RemoteServiceExportTarget",
".",
"RemoteServiceExportTargetProperties",
"ftp",
";",
"private",
"ArtifactoryExportTarget",
".",
"ArtifactoryExportTargetProperties",
"artifactory",
";",
"public",
"ExportTargetProperties",
"(",
")",
"{",
"super",
"(",
")",
";",
"}",
"public",
"String",
"getSupportedTypes",
"(",
")",
"{",
"return",
"this",
".",
"supportedTypes",
";",
"}",
"public",
"void",
"setSupportedTypes",
"(",
"String",
"supportedTypes",
")",
"{",
"this",
".",
"supportedTypes",
"=",
"supportedTypes",
";",
"}",
"public",
"String",
"getFilenamePattern",
"(",
")",
"{",
"return",
"this",
".",
"filenamePattern",
";",
"}",
"public",
"void",
"setFilenamePattern",
"(",
"String",
"filenamePattern",
")",
"{",
"this",
".",
"filenamePattern",
"=",
"filenamePattern",
";",
"}",
"public",
"LocalFileExportTarget",
".",
"LocalFileExportTargetProperties",
"getFile",
"(",
")",
"{",
"return",
"this",
".",
"file",
";",
"}",
"public",
"void",
"setFile",
"(",
"LocalFileExportTarget",
".",
"LocalFileExportTargetProperties",
"file",
")",
"{",
"this",
".",
"file",
"=",
"file",
";",
"}",
"public",
"RemoteServiceExportTarget",
".",
"RemoteServiceExportTargetProperties",
"getFtp",
"(",
")",
"{",
"return",
"this",
".",
"ftp",
";",
"}",
"public",
"void",
"setFtp",
"(",
"RemoteServiceExportTarget",
".",
"RemoteServiceExportTargetProperties",
"ftp",
")",
"{",
"this",
".",
"ftp",
"=",
"ftp",
";",
"}",
"public",
"ArtifactoryExportTarget",
".",
"ArtifactoryExportTargetProperties",
"getArtifactory",
"(",
")",
"{",
"return",
"this",
".",
"artifactory",
";",
"}",
"public",
"void",
"setArtifactory",
"(",
"ArtifactoryExportTarget",
".",
"ArtifactoryExportTargetProperties",
"artifactory",
")",
"{",
"this",
".",
"artifactory",
"=",
"artifactory",
";",
"}",
"}",
"}"
] | <p>
Configuration of target for export from API (each "target" is a configuration "place"
where the export file will be copied</p>
<p>
<strong>Configuration model</strong> :
<pre>
exports:
api-targets:
filename-pattern: datagate_export_<type>_<time>.par
supported-types: file
file:
folder: C:\\Temp\\export-datagate
ftp:
server-url:
username:
password:
artifactory:
server-url:
username:
password:
</pre>
</p>
<p>
Export on targets will be active if they are both specified with <code>supported-types</code>
and with specified properties
</p> | [
"<p",
">",
"Configuration",
"of",
"target",
"for",
"export",
"from",
"API",
"(",
"each",
"\"",
"target",
"\"",
"is",
"a",
"configuration",
"\"",
"place",
"\"",
"where",
"the",
"export",
"file",
"will",
"be",
"copied<",
"/",
"p",
">",
"<p",
">",
"<strong",
">",
"Configuration",
"model<",
"/",
"strong",
">",
":",
"<pre",
">",
"exports",
":",
"api",
"-",
"targets",
":",
"filename",
"-",
"pattern",
":",
"datagate_export_<type",
">",
"_<time",
">",
".",
"par",
"supported",
"-",
"types",
":",
"file",
"file",
":",
"folder",
":",
"C",
":",
"\\\\",
"Temp",
"\\\\",
"export",
"-",
"datagate",
"ftp",
":",
"server",
"-",
"url",
":",
"username",
":",
"password",
":",
"artifactory",
":",
"server",
"-",
"url",
":",
"username",
":",
"password",
":",
"<",
"/",
"pre",
">",
"<",
"/",
"p",
">",
"<p",
">",
"Export",
"on",
"targets",
"will",
"be",
"active",
"if",
"they",
"are",
"both",
"specified",
"with",
"<code",
">",
"supported",
"-",
"types<",
"/",
"code",
">",
"and",
"with",
"specified",
"properties",
"<",
"/",
"p",
">"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8b99a139a00d7c3b52adb508fe04087bbdf9868d | EricHyh/DemoCollection | library-download/src/main/java/com/hyh/tools/download/db/DatabaseFactory.java | [
"MIT"
] | Java | DatabaseFactory | /**
* @author Administrator
* @description
* @data 2018/2/26
*/ | @author Administrator
@description
@data 2018/2/26 | [
"@author",
"Administrator",
"@description",
"@data",
"2018",
"/",
"2",
"/",
"26"
] | public class DatabaseFactory {
public static Database create(Context context) {
if (FD_Utils.isClassFound(Constants.ThirdLibraryClassName.GREENDAO_CLASS_NAME)) {
return new GreendaoDatabase(context);
} else {
return new DefaultDatabase(context);
}
}
} | [
"public",
"class",
"DatabaseFactory",
"{",
"public",
"static",
"Database",
"create",
"(",
"Context",
"context",
")",
"{",
"if",
"(",
"FD_Utils",
".",
"isClassFound",
"(",
"Constants",
".",
"ThirdLibraryClassName",
".",
"GREENDAO_CLASS_NAME",
")",
")",
"{",
"return",
"new",
"GreendaoDatabase",
"(",
"context",
")",
";",
"}",
"else",
"{",
"return",
"new",
"DefaultDatabase",
"(",
"context",
")",
";",
"}",
"}",
"}"
] | @author Administrator
@description
@data 2018/2/26 | [
"@author",
"Administrator",
"@description",
"@data",
"2018",
"/",
"2",
"/",
"26"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8ba32058e3c156f502fa277e5e73ad6690580771 | bwittman/shadow | src/main/java/shadow/typecheck/type/AttributeInvocation.java | [
"Apache-2.0"
] | Java | AttributeInvocation | /**
* Represents a particular invocation of an attribute type, including any fields set during that
* invocation. E.g. {@code SomeAttribute(a = "alpha", b = 5)}.
*/ | Represents a particular invocation of an attribute type, including any fields set during that
invocation. | [
"Represents",
"a",
"particular",
"invocation",
"of",
"an",
"attribute",
"type",
"including",
"any",
"fields",
"set",
"during",
"that",
"invocation",
"."
] | public class AttributeInvocation {
private final AttributeType type;
private final AttributeInvocationContext invocationCtx; // The AST node for this invocation
private final Type enclosingType;
// Note that this does not contain the default expressions provided in the attribute declaration
private final Map<String, ShadowParser.VariableDeclaratorContext> fieldExpressions =
new HashMap<>();
public AttributeInvocation(
AttributeInvocationContext ctx, ErrorReporter errorReporter, MethodSignature attachedTo) {
// TypeUpdater.visitClassOrInterfaceType() should guarantee this is an AttributeType
type = (AttributeType) ctx.getType();
invocationCtx = ctx;
enclosingType = attachedTo.getOuter();
for (ShadowParser.VariableDeclaratorContext assignmentCtx : ctx.variableDeclarator()) {
addFieldAssignment(assignmentCtx, errorReporter);
}
}
/**
* Associates the given field assignment with its parent attribute invocation and performs sanity
* checks.
*/
public void addFieldAssignment(
ShadowParser.VariableDeclaratorContext ctx, ErrorReporter errorReporter) {
String fieldName = ctx.generalIdentifier().getText();
// Repeated field assignment
if (fieldExpressions.containsKey(fieldName)) {
errorReporter.addError(
ctx,
Error.REPEATED_ASSIGNMENT,
"Field \"" + fieldName + "\" was assigned more than once",
type);
return;
}
fieldExpressions.put(fieldName, ctx);
}
/** Must be called after type updating to ensure the fields of the AttributeType are populated. */
public void updateFieldTypes(ErrorReporter errorReporter) {
for (String fieldName : fieldExpressions.keySet()) {
ShadowParser.VariableDeclaratorContext fieldCtx = fieldExpressions.get(fieldName);
// Statement checker reports an error if this isn't true
if (type.containsField(fieldName)) {
// Enclosing type should match the method's enclosing type, not the attribute's
fieldCtx.setEnclosingType(enclosingType);
fieldCtx.setType(type.getField(fieldName).getType());
}
}
// Check for missing fields (i.e. required by AttributeType but not provided in this invocation)
for (String requiredFieldName : type.getUninitializedFields()) {
if (!fieldExpressions.containsKey(requiredFieldName)) {
errorReporter.addError(
invocationCtx,
Error.UNINITIALIZED_FIELD,
"A value must be provided for \""
+ requiredFieldName
+ "\" within "
+ type.getTypeName(),
type);
}
}
}
public Map<String, ShadowParser.VariableDeclaratorContext> getFieldAssignments() {
return Collections.unmodifiableMap(fieldExpressions);
}
public AttributeType getType() {
return type;
}
/**
* Gets the interpreted value of the given field - only safe to call after constant interpretation
* has occurred.
*/
public ShadowValue getFieldValue(String fieldName) {
return fieldExpressions.containsKey(fieldName)
? fieldExpressions.get(fieldName).getInterpretedValue()
: type.getField(fieldName).getInterpretedValue();
}
public String getMetaFileText() {
String text = type.toString(Type.PACKAGES);
if (!fieldExpressions.isEmpty()) {
text += "(";
text +=
fieldExpressions.entrySet().stream()
.map(f -> f.getKey() + " = " + f.getValue().getInterpretedValue().toLiteral())
.collect(Collectors.joining(", "));
text += ")";
}
return text;
}
} | [
"public",
"class",
"AttributeInvocation",
"{",
"private",
"final",
"AttributeType",
"type",
";",
"private",
"final",
"AttributeInvocationContext",
"invocationCtx",
";",
"private",
"final",
"Type",
"enclosingType",
";",
"private",
"final",
"Map",
"<",
"String",
",",
"ShadowParser",
".",
"VariableDeclaratorContext",
">",
"fieldExpressions",
"=",
"new",
"HashMap",
"<",
">",
"(",
")",
";",
"public",
"AttributeInvocation",
"(",
"AttributeInvocationContext",
"ctx",
",",
"ErrorReporter",
"errorReporter",
",",
"MethodSignature",
"attachedTo",
")",
"{",
"type",
"=",
"(",
"AttributeType",
")",
"ctx",
".",
"getType",
"(",
")",
";",
"invocationCtx",
"=",
"ctx",
";",
"enclosingType",
"=",
"attachedTo",
".",
"getOuter",
"(",
")",
";",
"for",
"(",
"ShadowParser",
".",
"VariableDeclaratorContext",
"assignmentCtx",
":",
"ctx",
".",
"variableDeclarator",
"(",
")",
")",
"{",
"addFieldAssignment",
"(",
"assignmentCtx",
",",
"errorReporter",
")",
";",
"}",
"}",
"/**\n * Associates the given field assignment with its parent attribute invocation and performs sanity\n * checks.\n */",
"public",
"void",
"addFieldAssignment",
"(",
"ShadowParser",
".",
"VariableDeclaratorContext",
"ctx",
",",
"ErrorReporter",
"errorReporter",
")",
"{",
"String",
"fieldName",
"=",
"ctx",
".",
"generalIdentifier",
"(",
")",
".",
"getText",
"(",
")",
";",
"if",
"(",
"fieldExpressions",
".",
"containsKey",
"(",
"fieldName",
")",
")",
"{",
"errorReporter",
".",
"addError",
"(",
"ctx",
",",
"Error",
".",
"REPEATED_ASSIGNMENT",
",",
"\"",
"Field ",
"\\\"",
"\"",
"+",
"fieldName",
"+",
"\"",
"\\\"",
" was assigned more than once",
"\"",
",",
"type",
")",
";",
"return",
";",
"}",
"fieldExpressions",
".",
"put",
"(",
"fieldName",
",",
"ctx",
")",
";",
"}",
"/** Must be called after type updating to ensure the fields of the AttributeType are populated. */",
"public",
"void",
"updateFieldTypes",
"(",
"ErrorReporter",
"errorReporter",
")",
"{",
"for",
"(",
"String",
"fieldName",
":",
"fieldExpressions",
".",
"keySet",
"(",
")",
")",
"{",
"ShadowParser",
".",
"VariableDeclaratorContext",
"fieldCtx",
"=",
"fieldExpressions",
".",
"get",
"(",
"fieldName",
")",
";",
"if",
"(",
"type",
".",
"containsField",
"(",
"fieldName",
")",
")",
"{",
"fieldCtx",
".",
"setEnclosingType",
"(",
"enclosingType",
")",
";",
"fieldCtx",
".",
"setType",
"(",
"type",
".",
"getField",
"(",
"fieldName",
")",
".",
"getType",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"String",
"requiredFieldName",
":",
"type",
".",
"getUninitializedFields",
"(",
")",
")",
"{",
"if",
"(",
"!",
"fieldExpressions",
".",
"containsKey",
"(",
"requiredFieldName",
")",
")",
"{",
"errorReporter",
".",
"addError",
"(",
"invocationCtx",
",",
"Error",
".",
"UNINITIALIZED_FIELD",
",",
"\"",
"A value must be provided for ",
"\\\"",
"\"",
"+",
"requiredFieldName",
"+",
"\"",
"\\\"",
" within ",
"\"",
"+",
"type",
".",
"getTypeName",
"(",
")",
",",
"type",
")",
";",
"}",
"}",
"}",
"public",
"Map",
"<",
"String",
",",
"ShadowParser",
".",
"VariableDeclaratorContext",
">",
"getFieldAssignments",
"(",
")",
"{",
"return",
"Collections",
".",
"unmodifiableMap",
"(",
"fieldExpressions",
")",
";",
"}",
"public",
"AttributeType",
"getType",
"(",
")",
"{",
"return",
"type",
";",
"}",
"/**\n * Gets the interpreted value of the given field - only safe to call after constant interpretation\n * has occurred.\n */",
"public",
"ShadowValue",
"getFieldValue",
"(",
"String",
"fieldName",
")",
"{",
"return",
"fieldExpressions",
".",
"containsKey",
"(",
"fieldName",
")",
"?",
"fieldExpressions",
".",
"get",
"(",
"fieldName",
")",
".",
"getInterpretedValue",
"(",
")",
":",
"type",
".",
"getField",
"(",
"fieldName",
")",
".",
"getInterpretedValue",
"(",
")",
";",
"}",
"public",
"String",
"getMetaFileText",
"(",
")",
"{",
"String",
"text",
"=",
"type",
".",
"toString",
"(",
"Type",
".",
"PACKAGES",
")",
";",
"if",
"(",
"!",
"fieldExpressions",
".",
"isEmpty",
"(",
")",
")",
"{",
"text",
"+=",
"\"",
"(",
"\"",
";",
"text",
"+=",
"fieldExpressions",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"f",
"->",
"f",
".",
"getKey",
"(",
")",
"+",
"\"",
" = ",
"\"",
"+",
"f",
".",
"getValue",
"(",
")",
".",
"getInterpretedValue",
"(",
")",
".",
"toLiteral",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\"",
", ",
"\"",
")",
")",
";",
"text",
"+=",
"\"",
")",
"\"",
";",
"}",
"return",
"text",
";",
"}",
"}"
] | Represents a particular invocation of an attribute type, including any fields set during that
invocation. | [
"Represents",
"a",
"particular",
"invocation",
"of",
"an",
"attribute",
"type",
"including",
"any",
"fields",
"set",
"during",
"that",
"invocation",
"."
] | [
"// The AST node for this invocation",
"// Note that this does not contain the default expressions provided in the attribute declaration",
"// TypeUpdater.visitClassOrInterfaceType() should guarantee this is an AttributeType",
"// Repeated field assignment",
"// Statement checker reports an error if this isn't true",
"// Enclosing type should match the method's enclosing type, not the attribute's",
"// Check for missing fields (i.e. required by AttributeType but not provided in this invocation)"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8ba6511efd480a1170c1ea837578c0a35bb0dab6 | ThomasHangstoerfer/HomeControl | app/src/main/java/de/fzi/fhemapi/server/DeviceManager.java | [
"Apache-2.0"
] | Java | DeviceManager | /**
* The DeviceManager is a class which enables all interaction with the server devices.
* @author Can Yumusak
*
*/ | The DeviceManager is a class which enables all interaction with the server devices.
@author Can Yumusak | [
"The",
"DeviceManager",
"is",
"a",
"class",
"which",
"enables",
"all",
"interaction",
"with",
"the",
"server",
"devices",
".",
"@author",
"Can",
"Yumusak"
] | public class DeviceManager {
FHEMServer server;
List<Device> devices;
/**
* default constructor
* @param server an fhem server
*/
protected DeviceManager(FHEMServer server) {
this.server = server;
update();
}
/**
* method called to update all devices from server
*/
public void update() {
List<DeviceResponse> response = server.getAllDevices();
devices = new ArrayList<Device>();
for (DeviceResponse device : response) {
devices.add(DeviceFactory.getDevice(device, server));
}
}
/**
* this method downloads a single device from server and adds it to the manager.
* @param deviceName the name of the device
*/
public void update(String deviceName) {
devices.add(DeviceFactory.getDevice(server.getDevice(deviceName),
server));
}
/**
* prints a list of all devices on the console
*/
public void printAllDevices() {
System.out.println("******* Devices from DeviceManager: ");
for (Device device : devices)
System.out.println(device);
System.out.println("******* End of Devices from DeviceManager");
}
/**
* prints a List<? extends Device> List to the console
* @param deviceList the list to print
*/
public static void printDevices(List<? extends Device> deviceList) {
System.out.println("******* Devices from DeviceManager: ");
for (Device device : deviceList)
System.out.println(device);
System.out.println("******* End of Devices from DeviceManager");
}
/**
* returns all devices from a special device type
* @param clazz the class of the device type
* @return a list containing all devices
*/
@SuppressWarnings("unchecked")
public <T extends Device> List<T> getDevicesFromType(Class<T> clazz) {
List<T> devices = new ArrayList<T>();
for (Device device : this.devices) {
if (clazz.isInstance(device))
devices.add((T) device);
}
return devices;
}
/**
* get a device from the manager with a given name
* @param deviceName the device name
* @return null if the device does not exist
*/
public Device getDevice(String deviceName) {
for (Device device : this.devices) {
if (device.getName().equals(deviceName))
return device;
}
return null;
}
/**
* get devices by their names in the array
* @param deviceName the device names
* @return a list with all the devices
*/
public List<Device> getDevices(String[] deviceName) {
List<Device> devices = new ArrayList<Device>();
for (Device device : this.devices) {
for (String name : deviceName)
if (device.getName().equals(name))
devices.add(device);
}
return devices;
}
/**
* Get all devices whose names start with a string
* @param subName the string to search for
* @return List of matching devices
*/
public List<Device> getDevicesStartsWith(String subName) {
List<Device> devices = new ArrayList<Device>();
for (Device device : this.devices) {
if (device.getName().startsWith(subName))
devices.add(device);
}
return devices;
}
/**
* returns a list with all saved devices
* @return the list of all saved devices
*/
public List<Device> getDevices() {
return devices;
}
/**
* creates a new actuator on the server. The parameters and type of the actuator is determined by the
* ActuatorParamters class. Please use the corresponding class implementing ActuatorParameters to
* generate a new actuator. An example is FS20Parameters.class. Please look up the whole package
* de.fzi.actuatorparameters for details.
*
* The server response is printed on the console and returned.
* @param params the actuator parameters
* @return whether or not the server created the device
*/
public boolean createNewActuator(ActuatorParameters params) {
if (params.checkParams()) {
MessageResponse response = server.newDevice(params);
return response.isTrue("creating actuator "+params.get(FHEMParameters.NAME));
}
System.err.println("Creating device " + params.get(FHEMParameters.NAME)
+ " failed, please use the right FHEMParameters!");
return false;
}
/**
* creates a new actuator on the server. The parameters and type of the actuator is determined by the
* ActuatorParamters class. Please use the corresponding class implementing ActuatorParameters to
* generate a new actuator. An example is FS20Parameters.class. Please look up the whole package
* de.fzi.actuatorparameters for details.
*
* The server response is printed on the console and returned.
* @param params the actuator parameters
* @return the response from server
*/
public MessageResponse createNewActuatorAsMessage(ActuatorParameters params) {
if (params.checkParams()) {
MessageResponse response = server.newDevice(params);
return response;
}
System.err.println("Creating device " + params.get(FHEMParameters.NAME)
+ " failed, please use the right FHEMParameters!");
return new MessageResponse();
}
/**
* deletes a device on the server. The server response is printed on the console.
* @param deviceName name of the device
* @return whether or not the server could delete the device.
*/
public boolean deleteDevice(String deviceName) {
MessageResponse mr = server.deleteDevice(deviceName);
return mr.isTrue("deleting Device "+deviceName);
}
/**
* Reloading Device from the server
* @param deviceName the device name
* @return the device
*/
public Device reloadDevice(String deviceName){
devices.remove(getDevice(deviceName));
Device dev = DeviceFactory.getDevice(server.getDevice(deviceName), server);
devices.add(dev);
return dev;
}
} | [
"public",
"class",
"DeviceManager",
"{",
"FHEMServer",
"server",
";",
"List",
"<",
"Device",
">",
"devices",
";",
"/**\n\t * default constructor\n\t * @param server an fhem server\n\t */",
"protected",
"DeviceManager",
"(",
"FHEMServer",
"server",
")",
"{",
"this",
".",
"server",
"=",
"server",
";",
"update",
"(",
")",
";",
"}",
"/**\n\t * method called to update all devices from server\n\t */",
"public",
"void",
"update",
"(",
")",
"{",
"List",
"<",
"DeviceResponse",
">",
"response",
"=",
"server",
".",
"getAllDevices",
"(",
")",
";",
"devices",
"=",
"new",
"ArrayList",
"<",
"Device",
">",
"(",
")",
";",
"for",
"(",
"DeviceResponse",
"device",
":",
"response",
")",
"{",
"devices",
".",
"add",
"(",
"DeviceFactory",
".",
"getDevice",
"(",
"device",
",",
"server",
")",
")",
";",
"}",
"}",
"/**\n\t * this method downloads a single device from server and adds it to the manager.\n\t * @param deviceName the name of the device\n\t */",
"public",
"void",
"update",
"(",
"String",
"deviceName",
")",
"{",
"devices",
".",
"add",
"(",
"DeviceFactory",
".",
"getDevice",
"(",
"server",
".",
"getDevice",
"(",
"deviceName",
")",
",",
"server",
")",
")",
";",
"}",
"/**\n\t * prints a list of all devices on the console\n\t */",
"public",
"void",
"printAllDevices",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"******* Devices from DeviceManager: ",
"\"",
")",
";",
"for",
"(",
"Device",
"device",
":",
"devices",
")",
"System",
".",
"out",
".",
"println",
"(",
"device",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"******* End of Devices from DeviceManager",
"\"",
")",
";",
"}",
"/**\n\t * prints a List<? extends Device> List to the console\n\t * @param deviceList the list to print\n\t */",
"public",
"static",
"void",
"printDevices",
"(",
"List",
"<",
"?",
"extends",
"Device",
">",
"deviceList",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"******* Devices from DeviceManager: ",
"\"",
")",
";",
"for",
"(",
"Device",
"device",
":",
"deviceList",
")",
"System",
".",
"out",
".",
"println",
"(",
"device",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"******* End of Devices from DeviceManager",
"\"",
")",
";",
"}",
"/**\n\t * returns all devices from a special device type\n\t * @param clazz the class of the device type\n\t * @return a list containing all devices\n\t */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"<",
"T",
"extends",
"Device",
">",
"List",
"<",
"T",
">",
"getDevicesFromType",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"List",
"<",
"T",
">",
"devices",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"Device",
"device",
":",
"this",
".",
"devices",
")",
"{",
"if",
"(",
"clazz",
".",
"isInstance",
"(",
"device",
")",
")",
"devices",
".",
"add",
"(",
"(",
"T",
")",
"device",
")",
";",
"}",
"return",
"devices",
";",
"}",
"/**\n\t * get a device from the manager with a given name\n\t * @param deviceName the device name\n\t * @return null if the device does not exist\n\t */",
"public",
"Device",
"getDevice",
"(",
"String",
"deviceName",
")",
"{",
"for",
"(",
"Device",
"device",
":",
"this",
".",
"devices",
")",
"{",
"if",
"(",
"device",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"deviceName",
")",
")",
"return",
"device",
";",
"}",
"return",
"null",
";",
"}",
"/**\n\t * get devices by their names in the array\n\t * @param deviceName the device names\n\t * @return a list with all the devices\n\t */",
"public",
"List",
"<",
"Device",
">",
"getDevices",
"(",
"String",
"[",
"]",
"deviceName",
")",
"{",
"List",
"<",
"Device",
">",
"devices",
"=",
"new",
"ArrayList",
"<",
"Device",
">",
"(",
")",
";",
"for",
"(",
"Device",
"device",
":",
"this",
".",
"devices",
")",
"{",
"for",
"(",
"String",
"name",
":",
"deviceName",
")",
"if",
"(",
"device",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"devices",
".",
"add",
"(",
"device",
")",
";",
"}",
"return",
"devices",
";",
"}",
"/**\n\t * Get all devices whose names start with a string\n\t * @param subName the string to search for\n\t * @return List of matching devices\n\t */",
"public",
"List",
"<",
"Device",
">",
"getDevicesStartsWith",
"(",
"String",
"subName",
")",
"{",
"List",
"<",
"Device",
">",
"devices",
"=",
"new",
"ArrayList",
"<",
"Device",
">",
"(",
")",
";",
"for",
"(",
"Device",
"device",
":",
"this",
".",
"devices",
")",
"{",
"if",
"(",
"device",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"subName",
")",
")",
"devices",
".",
"add",
"(",
"device",
")",
";",
"}",
"return",
"devices",
";",
"}",
"/**\n\t * returns a list with all saved devices\n\t * @return the list of all saved devices\n\t */",
"public",
"List",
"<",
"Device",
">",
"getDevices",
"(",
")",
"{",
"return",
"devices",
";",
"}",
"/**\n\t * creates a new actuator on the server. The parameters and type of the actuator is determined by the\n\t * ActuatorParamters class. Please use the corresponding class implementing ActuatorParameters to\n\t * generate a new actuator. An example is FS20Parameters.class. Please look up the whole package \n\t * de.fzi.actuatorparameters for details.\n\t * \n\t * The server response is printed on the console and returned.\n\t * @param params the actuator parameters\n\t * @return whether or not the server created the device\n\t */",
"public",
"boolean",
"createNewActuator",
"(",
"ActuatorParameters",
"params",
")",
"{",
"if",
"(",
"params",
".",
"checkParams",
"(",
")",
")",
"{",
"MessageResponse",
"response",
"=",
"server",
".",
"newDevice",
"(",
"params",
")",
";",
"return",
"response",
".",
"isTrue",
"(",
"\"",
"creating actuator ",
"\"",
"+",
"params",
".",
"get",
"(",
"FHEMParameters",
".",
"NAME",
")",
")",
";",
"}",
"System",
".",
"err",
".",
"println",
"(",
"\"",
"Creating device ",
"\"",
"+",
"params",
".",
"get",
"(",
"FHEMParameters",
".",
"NAME",
")",
"+",
"\"",
" failed, please use the right FHEMParameters!",
"\"",
")",
";",
"return",
"false",
";",
"}",
"/**\n\t * creates a new actuator on the server. The parameters and type of the actuator is determined by the\n\t * ActuatorParamters class. Please use the corresponding class implementing ActuatorParameters to\n\t * generate a new actuator. An example is FS20Parameters.class. Please look up the whole package \n\t * de.fzi.actuatorparameters for details.\n\t * \n\t * The server response is printed on the console and returned.\n\t * @param params the actuator parameters\n\t * @return the response from server\n\t */",
"public",
"MessageResponse",
"createNewActuatorAsMessage",
"(",
"ActuatorParameters",
"params",
")",
"{",
"if",
"(",
"params",
".",
"checkParams",
"(",
")",
")",
"{",
"MessageResponse",
"response",
"=",
"server",
".",
"newDevice",
"(",
"params",
")",
";",
"return",
"response",
";",
"}",
"System",
".",
"err",
".",
"println",
"(",
"\"",
"Creating device ",
"\"",
"+",
"params",
".",
"get",
"(",
"FHEMParameters",
".",
"NAME",
")",
"+",
"\"",
" failed, please use the right FHEMParameters!",
"\"",
")",
";",
"return",
"new",
"MessageResponse",
"(",
")",
";",
"}",
"/**\n\t * deletes a device on the server. The server response is printed on the console.\n\t * @param deviceName name of the device\n\t * @return whether or not the server could delete the device. \n\t */",
"public",
"boolean",
"deleteDevice",
"(",
"String",
"deviceName",
")",
"{",
"MessageResponse",
"mr",
"=",
"server",
".",
"deleteDevice",
"(",
"deviceName",
")",
";",
"return",
"mr",
".",
"isTrue",
"(",
"\"",
"deleting Device ",
"\"",
"+",
"deviceName",
")",
";",
"}",
"/**\n\t * Reloading Device from the server\n\t * @param deviceName the device name\n\t * @return the device\n\t */",
"public",
"Device",
"reloadDevice",
"(",
"String",
"deviceName",
")",
"{",
"devices",
".",
"remove",
"(",
"getDevice",
"(",
"deviceName",
")",
")",
";",
"Device",
"dev",
"=",
"DeviceFactory",
".",
"getDevice",
"(",
"server",
".",
"getDevice",
"(",
"deviceName",
")",
",",
"server",
")",
";",
"devices",
".",
"add",
"(",
"dev",
")",
";",
"return",
"dev",
";",
"}",
"}"
] | The DeviceManager is a class which enables all interaction with the server devices. | [
"The",
"DeviceManager",
"is",
"a",
"class",
"which",
"enables",
"all",
"interaction",
"with",
"the",
"server",
"devices",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8baa51c7d3edaa4f4dbcfa0e5ecc3d4232a4161e | BrickStreetSoftware/email-testtools | robocust/src/main/java/brickst/robocust/lib/SimpleCounter.java | [
"Apache-2.0"
] | Java | SimpleCounter | /**
* The Counter class record changes to a counter It can also compute its peak
* "rate" -- the ratio of the current count to the time passed. This rate is
* reset each 1000 objects so we can see peak rates.
* <br>
* As an example, a class could use Counter to record the number of items it
* has processed and the rate of that processing.
* <br>
* Currently the counter is stored as an integer and its rate is expressed in
* number/seconds.
* <br>
* Concurrency: all the public method are synchronized
*/ | The Counter class record changes to a counter It can also compute its peak
"rate" -- the ratio of the current count to the time passed. This rate is
reset each 1000 objects so we can see peak rates.
As an example, a class could use Counter to record the number of items it
has processed and the rate of that processing.
Currently the counter is stored as an integer and its rate is expressed in
number/seconds.
Concurrency: all the public method are synchronized | [
"The",
"Counter",
"class",
"record",
"changes",
"to",
"a",
"counter",
"It",
"can",
"also",
"compute",
"its",
"peak",
"\"",
"rate",
"\"",
"--",
"the",
"ratio",
"of",
"the",
"current",
"count",
"to",
"the",
"time",
"passed",
".",
"This",
"rate",
"is",
"reset",
"each",
"1000",
"objects",
"so",
"we",
"can",
"see",
"peak",
"rates",
".",
"As",
"an",
"example",
"a",
"class",
"could",
"use",
"Counter",
"to",
"record",
"the",
"number",
"of",
"items",
"it",
"has",
"processed",
"and",
"the",
"rate",
"of",
"that",
"processing",
".",
"Currently",
"the",
"counter",
"is",
"stored",
"as",
"an",
"integer",
"and",
"its",
"rate",
"is",
"expressed",
"in",
"number",
"/",
"seconds",
".",
"Concurrency",
":",
"all",
"the",
"public",
"method",
"are",
"synchronized"
] | public class SimpleCounter // extends com.brickstreet.common.lib.CRMObject
implements java.io.Serializable
{
private static final long serialVersionUID = -5336179741333300546L;
/** the current count. */
private int count;
/** the count at last resetRate() -- when msStarted was last reset to
* current. */
private int countRateStart;
/** the name prefix to use when we report a count. */
private String reportingName = null;
/** the interval with which we report count (when count % interval == 0). */
private int countIntervalReport = 0;
/**
* the time (in milliseconds) at which we started counting. Initialized to
* time of construction.
*
* @see Counter#reset.
*/
private long msStarted;
/** Constructs a counter. */
public SimpleCounter()
{
reset(); // Initializes count and msStarted.
}
public synchronized void enableReporting(String reportingName, int countIntervalReport)
{
assert (countIntervalReport >= 0); // 0 == no reporting
this.reportingName = reportingName;
this.countIntervalReport = countIntervalReport;
}
/**
* Adds a value to the counter.
*
* @param addend the value to add to the count.
* @return the resulting count.
*/
public synchronized int add(int addend)
{
assert(count + addend >= 0);
checkReport(addend);
count += addend;
return(count);
}
/**
* Adds one to the counter.
* @return the resulting count.
*/
public synchronized int increment()
{
checkReport(1);
count++;
return(count);
}
/** Reports to Log if adding addend to count will cross a
* countIntervalReport boundary. */
public synchronized void checkReport(int addend)
{
if (reportingName == null || countIntervalReport == 0)
return;
int magNew = (count + addend) / countIntervalReport;
int magOld = count / countIntervalReport;
for (int mag = magOld+1; mag <= magNew; mag++) {
/*
Debug.SC.println("Counter: " + reportingName + ": " +
(mag * countIntervalReport) + " @ " +
getRateString() + "/sec " + " @ " + new Date());
*/
resetRate();
}
}
/**
* Subtracts one from the counter.
* @return the resulting count.
*/
public synchronized int decrement()
{
assert(reportingName == null); // Ill advised if reporting!
count--;
return(count);
}
/**
* Returns the current value of the counter.
* @return the current value of the counter.
*/
public synchronized int getValue()
{
return(count);
}
/**
* Returns the current rate of the counter.
* @return the current rate of the counter.
*/
public synchronized float getRate()
{
long dms = System.currentTimeMillis() - msStarted;
if (dms <= 200) // Avoid strangely high rates when dms near 0.
dms = 200;
return(((float) (count - countRateStart)) * 1000 / dms);
}
/**
* Resets the counter to 0 and the start time to now.
*/
public synchronized void reset()
{
resetRate();
count = 0;
}
/**
* Resets the counter to 0 and the start time to now.
*/
public synchronized void resetRate()
{
countRateStart = count;
msStarted = System.currentTimeMillis();
}
/**
* Determines the rate.
*
* @return the rate, as a string.
*/
public synchronized String getRateString()
{
float rate = getRate();
int prefix = ((int) rate);
int suffix = ((int) (rate * 10)) % 10;
assert(prefix >= 0 && suffix >= 0);
// Don't show decimal precision if more than 3 figures.
boolean showSuffix = (rate < 1000) && (rate != 0);
return("" + prefix + ( showSuffix ? ("." + suffix) : "" ));
}
} | [
"public",
"class",
"SimpleCounter",
"implements",
"java",
".",
"io",
".",
"Serializable",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"-",
"5336179741333300546L",
";",
"/** the current count. */",
"private",
"int",
"count",
";",
"/** the count at last resetRate() -- when msStarted was last reset to\r\n\t * current. */",
"private",
"int",
"countRateStart",
";",
"/** the name prefix to use when we report a count. */",
"private",
"String",
"reportingName",
"=",
"null",
";",
"/** the interval with which we report count (when count % interval == 0). */",
"private",
"int",
"countIntervalReport",
"=",
"0",
";",
"/**\r\n\t * the time (in milliseconds) at which we started counting. Initialized to\r\n\t * time of construction.\r\n\t *\r\n\t * @see Counter#reset.\r\n\t */",
"private",
"long",
"msStarted",
";",
"/** Constructs a counter. */",
"public",
"SimpleCounter",
"(",
")",
"{",
"reset",
"(",
")",
";",
"}",
"public",
"synchronized",
"void",
"enableReporting",
"(",
"String",
"reportingName",
",",
"int",
"countIntervalReport",
")",
"{",
"assert",
"(",
"countIntervalReport",
">=",
"0",
")",
";",
"this",
".",
"reportingName",
"=",
"reportingName",
";",
"this",
".",
"countIntervalReport",
"=",
"countIntervalReport",
";",
"}",
"/**\r\n\t * Adds a value to the counter.\r\n\t *\r\n\t * @param\taddend\tthe value to add to the count.\r\n\t * @return\tthe resulting count.\r\n\t */",
"public",
"synchronized",
"int",
"add",
"(",
"int",
"addend",
")",
"{",
"assert",
"(",
"count",
"+",
"addend",
">=",
"0",
")",
";",
"checkReport",
"(",
"addend",
")",
";",
"count",
"+=",
"addend",
";",
"return",
"(",
"count",
")",
";",
"}",
"/**\r\n\t * Adds one to the counter.\r\n\t * @return the resulting count.\r\n\t */",
"public",
"synchronized",
"int",
"increment",
"(",
")",
"{",
"checkReport",
"(",
"1",
")",
";",
"count",
"++",
";",
"return",
"(",
"count",
")",
";",
"}",
"/** Reports to Log if adding addend to count will cross a\r\n\t * countIntervalReport boundary. */",
"public",
"synchronized",
"void",
"checkReport",
"(",
"int",
"addend",
")",
"{",
"if",
"(",
"reportingName",
"==",
"null",
"||",
"countIntervalReport",
"==",
"0",
")",
"return",
";",
"int",
"magNew",
"=",
"(",
"count",
"+",
"addend",
")",
"/",
"countIntervalReport",
";",
"int",
"magOld",
"=",
"count",
"/",
"countIntervalReport",
";",
"for",
"(",
"int",
"mag",
"=",
"magOld",
"+",
"1",
";",
"mag",
"<=",
"magNew",
";",
"mag",
"++",
")",
"{",
"/*\r\n\t\t\tDebug.SC.println(\"Counter: \" + reportingName + \": \" + \r\n\t\t\t\t\t\t(mag * countIntervalReport) + \" @ \" +\r\n\t\t\t\t\t\tgetRateString() + \"/sec \" + \" @ \" + new Date());\r\n\t\t\t*/",
"resetRate",
"(",
")",
";",
"}",
"}",
"/**\r\n\t * Subtracts one from the counter.\r\n\t * @return the resulting count.\r\n\t */",
"public",
"synchronized",
"int",
"decrement",
"(",
")",
"{",
"assert",
"(",
"reportingName",
"==",
"null",
")",
";",
"count",
"--",
";",
"return",
"(",
"count",
")",
";",
"}",
"/**\r\n\t * Returns the current value of the counter.\r\n\t * @return the current value of the counter.\r\n\t */",
"public",
"synchronized",
"int",
"getValue",
"(",
")",
"{",
"return",
"(",
"count",
")",
";",
"}",
"/**\r\n\t * Returns the current rate of the counter.\r\n\t * @return the current rate of the counter.\r\n\t */",
"public",
"synchronized",
"float",
"getRate",
"(",
")",
"{",
"long",
"dms",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"msStarted",
";",
"if",
"(",
"dms",
"<=",
"200",
")",
"dms",
"=",
"200",
";",
"return",
"(",
"(",
"(",
"float",
")",
"(",
"count",
"-",
"countRateStart",
")",
")",
"*",
"1000",
"/",
"dms",
")",
";",
"}",
"/**\r\n\t * Resets the counter to 0 and the start time to now.\r\n\t */",
"public",
"synchronized",
"void",
"reset",
"(",
")",
"{",
"resetRate",
"(",
")",
";",
"count",
"=",
"0",
";",
"}",
"/**\r\n\t * Resets the counter to 0 and the start time to now.\r\n\t */",
"public",
"synchronized",
"void",
"resetRate",
"(",
")",
"{",
"countRateStart",
"=",
"count",
";",
"msStarted",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"}",
"/**\r\n\t * Determines the rate.\r\n\t *\r\n\t * @return\tthe rate, as a string.\r\n\t */",
"public",
"synchronized",
"String",
"getRateString",
"(",
")",
"{",
"float",
"rate",
"=",
"getRate",
"(",
")",
";",
"int",
"prefix",
"=",
"(",
"(",
"int",
")",
"rate",
")",
";",
"int",
"suffix",
"=",
"(",
"(",
"int",
")",
"(",
"rate",
"*",
"10",
")",
")",
"%",
"10",
";",
"assert",
"(",
"prefix",
">=",
"0",
"&&",
"suffix",
">=",
"0",
")",
";",
"boolean",
"showSuffix",
"=",
"(",
"rate",
"<",
"1000",
")",
"&&",
"(",
"rate",
"!=",
"0",
")",
";",
"return",
"(",
"\"",
"\"",
"+",
"prefix",
"+",
"(",
"showSuffix",
"?",
"(",
"\"",
".",
"\"",
"+",
"suffix",
")",
":",
"\"",
"\"",
")",
")",
";",
"}",
"}"
] | The Counter class record changes to a counter It can also compute its peak
"rate" -- the ratio of the current count to the time passed. | [
"The",
"Counter",
"class",
"record",
"changes",
"to",
"a",
"counter",
"It",
"can",
"also",
"compute",
"its",
"peak",
"\"",
"rate",
"\"",
"--",
"the",
"ratio",
"of",
"the",
"current",
"count",
"to",
"the",
"time",
"passed",
"."
] | [
"// extends com.brickstreet.common.lib.CRMObject\r",
"// Initializes count and msStarted.\r",
"// 0 == no reporting\r",
"// Ill advised if reporting!\r",
"// Avoid strangely high rates when dms near 0.\r",
"// Don't show decimal precision if more than 3 figures.\r"
] | [
{
"param": "java.io.Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "java.io.Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bae487b4d02d2cbd88fd72bfe5599caf2d1c01f | malinghan/java-learning | multithread/src/main/java/multithread/communicate/test19/RunFirst.java | [
"MIT"
] | Java | RunFirst | /**
* @author: linghan.ma
* @DATE: 2018/2/6
* @description:
*/ | @author: linghan.ma
@DATE: 2018/2/6
@description. | [
"@author",
":",
"linghan",
".",
"ma",
"@DATE",
":",
"2018",
"/",
"2",
"/",
"6",
"@description",
"."
] | public class RunFirst {
public static void main(String[] args) {
ThreadB b = new ThreadB();
ThreadA a = new ThreadA(b);
a.start();
b.start();//b总是先抢到锁,a有b的锁,然后等待a运行完。
System.out.println(" main end=" + System.currentTimeMillis());
}
} | [
"public",
"class",
"RunFirst",
"{",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"ThreadB",
"b",
"=",
"new",
"ThreadB",
"(",
")",
";",
"ThreadA",
"a",
"=",
"new",
"ThreadA",
"(",
"b",
")",
";",
"a",
".",
"start",
"(",
")",
";",
"b",
".",
"start",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
" main end=",
"\"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"}",
"}"
] | @author: linghan.ma
@DATE: 2018/2/6
@description: | [
"@author",
":",
"linghan",
".",
"ma",
"@DATE",
":",
"2018",
"/",
"2",
"/",
"6",
"@description",
":"
] | [
"//b总是先抢到锁,a有b的锁,然后等待a运行完。"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8bb3e66585e2d845b1e13b31d3c527add68bd9fa | satyajitg2/TokenService | TokMonitor/src/main/java/com/service/tokenseeder/tokenizer/GenerateToken.java | [
"MIT"
] | Java | GenerateToken | /**
* <p>
* The class <b> GenerateToken <b> is the primary class responsible for generating tokens It implements the rotation
* logic as per the business requirements.
* <p>
*
* @version 1.0
*/ |
The class GenerateToken is the primary class responsible for generating tokens It implements the rotation
logic as per the business requirements.
| [
"The",
"class",
"GenerateToken",
"is",
"the",
"primary",
"class",
"responsible",
"for",
"generating",
"tokens",
"It",
"implements",
"the",
"rotation",
"logic",
"as",
"per",
"the",
"business",
"requirements",
"."
] | public class GenerateToken {
private static final Logger LOGGER = LoggerFactory.getLogger(GenerateToken.class);
Transaction tx = null;
Session session = null;
Query query = null;
ConfigDAO configDAO = null;
TokenDecisionDAO tokenDecisionDAO = null;
TableSetDecisionDAO tokenSetDecisionDAO = null;
/**
* <p>
* This table is responsible for updating the corresponding Set of tables for Integer, DateTime and String are
* updated
* <p>
*
* @return - User friendly message that gets logged in the logger.
* @throws TokenException
*/
// Give Max token to be generated for particular table
private long getMaxValue(long maxIntegerValue, String tableName, int configurationIdentifier) {
long minValue = tokenSetDecisionDAO.getNumberofTokenInTable(tableName, configurationIdentifier);
return maxIntegerValue - minValue;
}// end of method
public void generateTokenInSet(int tableSet, String owningBusinessEntity) {
LOGGER.info("TokenRotation1>>>>>>>>>>>>>>>>>>>>>>>>> In generateTokenInSet()");
String integerTableToUse = null, stringTableToUse = null, datetimeTableToUse = null;
IntegerTokenDAO it = new IntegerTokenDAO();
StringTokenDAO st = new StringTokenDAO();
DateTimeTokenDAO dtt = new DateTimeTokenDAO();
String valueToStartDate;
configDAO = new ConfigDAO(owningBusinessEntity);
Configuration configuration = configDAO.getConfigDetails();
tokenDecisionDAO = new TokenDecisionDAO(configuration.getConfigurationIdentifier());
TokenDecision tokenDecision = tokenDecisionDAO.getTokenDecisionDetails();
tokenSetDecisionDAO = new TableSetDecisionDAO(tableSet);
List<TokenSetDecision> tokenSetDecision = tokenSetDecisionDAO.getSetDecisionDetails();
for (TokenSetDecision tSetDecision : tokenSetDecision) {
integerTableToUse = tSetDecision.getTokenIntegerTable();
stringTableToUse = tSetDecision.getTokenStringTable();
datetimeTableToUse = tSetDecision.getTokenDateTimeTable();
}
SimpleDateFormat dateFormat = new SimpleDateFormat(Constants.REQUEST_DATE_FORMAT);
valueToStartDate = dateFormat.format(tokenDecision.getTokenToStartGenerateDateTime());
int maxIntegerValue = tokenDecision.getMaxTokenToGenerateInteger();
maxIntegerValue = (int) getMaxValue(maxIntegerValue, integerTableToUse,
configuration.getConfigurationIdentifier());
int maxStringValue = tokenDecision.getMaxTokenToGenerateString();
maxStringValue = (int) getMaxValue(maxStringValue, stringTableToUse, configuration.getConfigurationIdentifier());
int maxDateTimeValue = tokenDecision.getMaxTokenToGenerateDateTime();
maxDateTimeValue = (int) getMaxValue(maxDateTimeValue, datetimeTableToUse,
configuration.getConfigurationIdentifier());
long intToken = it.insertTokenToBank(maxIntegerValue, integerTableToUse,
tokenDecision.getTokenToStartGenerateInteger(), configuration.getIntegerTokenEndValue(),
configuration.getIntegerTokenStartValue(), configuration.getConfigurationIdentifier());
String strToken = st.insertTokenToBank(maxStringValue, stringTableToUse,
tokenDecision.getTokenToStartGenerateString(), configuration.getStringVaultIdentifer(),
configuration.getConfigurationIdentifier());
Timestamp dtToken = dtt.insertTokenToBank(maxDateTimeValue, datetimeTableToUse, valueToStartDate,
configuration.getDateTimeTokenYearEnd(), configuration.getDateTimeTokenYearStart(),
configuration.getConfigurationIdentifier());
tokenDecisionDAO.updateTokenDecision(intToken, strToken, dtToken);
}
} | [
"public",
"class",
"GenerateToken",
"{",
"private",
"static",
"final",
"Logger",
"LOGGER",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"GenerateToken",
".",
"class",
")",
";",
"Transaction",
"tx",
"=",
"null",
";",
"Session",
"session",
"=",
"null",
";",
"Query",
"query",
"=",
"null",
";",
"ConfigDAO",
"configDAO",
"=",
"null",
";",
"TokenDecisionDAO",
"tokenDecisionDAO",
"=",
"null",
";",
"TableSetDecisionDAO",
"tokenSetDecisionDAO",
"=",
"null",
";",
"/**\n\t * <p>\n\t * This table is responsible for updating the corresponding Set of tables for Integer, DateTime and String are\n\t * updated\n\t * <p>\n\t * \n\t * @return - User friendly message that gets logged in the logger.\n\t * @throws TokenException\n\t */",
"private",
"long",
"getMaxValue",
"(",
"long",
"maxIntegerValue",
",",
"String",
"tableName",
",",
"int",
"configurationIdentifier",
")",
"{",
"long",
"minValue",
"=",
"tokenSetDecisionDAO",
".",
"getNumberofTokenInTable",
"(",
"tableName",
",",
"configurationIdentifier",
")",
";",
"return",
"maxIntegerValue",
"-",
"minValue",
";",
"}",
"public",
"void",
"generateTokenInSet",
"(",
"int",
"tableSet",
",",
"String",
"owningBusinessEntity",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"",
"TokenRotation1>>>>>>>>>>>>>>>>>>>>>>>>> In generateTokenInSet()",
"\"",
")",
";",
"String",
"integerTableToUse",
"=",
"null",
",",
"stringTableToUse",
"=",
"null",
",",
"datetimeTableToUse",
"=",
"null",
";",
"IntegerTokenDAO",
"it",
"=",
"new",
"IntegerTokenDAO",
"(",
")",
";",
"StringTokenDAO",
"st",
"=",
"new",
"StringTokenDAO",
"(",
")",
";",
"DateTimeTokenDAO",
"dtt",
"=",
"new",
"DateTimeTokenDAO",
"(",
")",
";",
"String",
"valueToStartDate",
";",
"configDAO",
"=",
"new",
"ConfigDAO",
"(",
"owningBusinessEntity",
")",
";",
"Configuration",
"configuration",
"=",
"configDAO",
".",
"getConfigDetails",
"(",
")",
";",
"tokenDecisionDAO",
"=",
"new",
"TokenDecisionDAO",
"(",
"configuration",
".",
"getConfigurationIdentifier",
"(",
")",
")",
";",
"TokenDecision",
"tokenDecision",
"=",
"tokenDecisionDAO",
".",
"getTokenDecisionDetails",
"(",
")",
";",
"tokenSetDecisionDAO",
"=",
"new",
"TableSetDecisionDAO",
"(",
"tableSet",
")",
";",
"List",
"<",
"TokenSetDecision",
">",
"tokenSetDecision",
"=",
"tokenSetDecisionDAO",
".",
"getSetDecisionDetails",
"(",
")",
";",
"for",
"(",
"TokenSetDecision",
"tSetDecision",
":",
"tokenSetDecision",
")",
"{",
"integerTableToUse",
"=",
"tSetDecision",
".",
"getTokenIntegerTable",
"(",
")",
";",
"stringTableToUse",
"=",
"tSetDecision",
".",
"getTokenStringTable",
"(",
")",
";",
"datetimeTableToUse",
"=",
"tSetDecision",
".",
"getTokenDateTimeTable",
"(",
")",
";",
"}",
"SimpleDateFormat",
"dateFormat",
"=",
"new",
"SimpleDateFormat",
"(",
"Constants",
".",
"REQUEST_DATE_FORMAT",
")",
";",
"valueToStartDate",
"=",
"dateFormat",
".",
"format",
"(",
"tokenDecision",
".",
"getTokenToStartGenerateDateTime",
"(",
")",
")",
";",
"int",
"maxIntegerValue",
"=",
"tokenDecision",
".",
"getMaxTokenToGenerateInteger",
"(",
")",
";",
"maxIntegerValue",
"=",
"(",
"int",
")",
"getMaxValue",
"(",
"maxIntegerValue",
",",
"integerTableToUse",
",",
"configuration",
".",
"getConfigurationIdentifier",
"(",
")",
")",
";",
"int",
"maxStringValue",
"=",
"tokenDecision",
".",
"getMaxTokenToGenerateString",
"(",
")",
";",
"maxStringValue",
"=",
"(",
"int",
")",
"getMaxValue",
"(",
"maxStringValue",
",",
"stringTableToUse",
",",
"configuration",
".",
"getConfigurationIdentifier",
"(",
")",
")",
";",
"int",
"maxDateTimeValue",
"=",
"tokenDecision",
".",
"getMaxTokenToGenerateDateTime",
"(",
")",
";",
"maxDateTimeValue",
"=",
"(",
"int",
")",
"getMaxValue",
"(",
"maxDateTimeValue",
",",
"datetimeTableToUse",
",",
"configuration",
".",
"getConfigurationIdentifier",
"(",
")",
")",
";",
"long",
"intToken",
"=",
"it",
".",
"insertTokenToBank",
"(",
"maxIntegerValue",
",",
"integerTableToUse",
",",
"tokenDecision",
".",
"getTokenToStartGenerateInteger",
"(",
")",
",",
"configuration",
".",
"getIntegerTokenEndValue",
"(",
")",
",",
"configuration",
".",
"getIntegerTokenStartValue",
"(",
")",
",",
"configuration",
".",
"getConfigurationIdentifier",
"(",
")",
")",
";",
"String",
"strToken",
"=",
"st",
".",
"insertTokenToBank",
"(",
"maxStringValue",
",",
"stringTableToUse",
",",
"tokenDecision",
".",
"getTokenToStartGenerateString",
"(",
")",
",",
"configuration",
".",
"getStringVaultIdentifer",
"(",
")",
",",
"configuration",
".",
"getConfigurationIdentifier",
"(",
")",
")",
";",
"Timestamp",
"dtToken",
"=",
"dtt",
".",
"insertTokenToBank",
"(",
"maxDateTimeValue",
",",
"datetimeTableToUse",
",",
"valueToStartDate",
",",
"configuration",
".",
"getDateTimeTokenYearEnd",
"(",
")",
",",
"configuration",
".",
"getDateTimeTokenYearStart",
"(",
")",
",",
"configuration",
".",
"getConfigurationIdentifier",
"(",
")",
")",
";",
"tokenDecisionDAO",
".",
"updateTokenDecision",
"(",
"intToken",
",",
"strToken",
",",
"dtToken",
")",
";",
"}",
"}"
] | <p>
The class <b> GenerateToken <b> is the primary class responsible for generating tokens It implements the rotation
logic as per the business requirements. | [
"<p",
">",
"The",
"class",
"<b",
">",
"GenerateToken",
"<b",
">",
"is",
"the",
"primary",
"class",
"responsible",
"for",
"generating",
"tokens",
"It",
"implements",
"the",
"rotation",
"logic",
"as",
"per",
"the",
"business",
"requirements",
"."
] | [
"// Give Max token to be generated for particular table",
"// end of method"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8bb6df5b85a41de6160c00cecb18f4a7d97a4d0e | waelkedi/pacman | src/main/java/model/Position.java | [
"MIT"
] | Java | Position | /**
* The position class represents a point on the map. IT SHOULD NOT BE CONSTRUCTED OUTSIDE THE {@link Map} CLASS.
*
* @author Philipp Winter
* @author Jonas Heidecke
* @author Niklas Kaddatz
*/ | The position class represents a point on the map. IT SHOULD NOT BE CONSTRUCTED OUTSIDE THE Map CLASS. | [
"The",
"position",
"class",
"represents",
"a",
"point",
"on",
"the",
"map",
".",
"IT",
"SHOULD",
"NOT",
"BE",
"CONSTRUCTED",
"OUTSIDE",
"THE",
"Map",
"CLASS",
"."
] | public class Position {
private final int x;
private final int y;
private MapObjectContainer onPosition;
public Position(int x, int y) {
this.x = x;
this.y = y;
this.onPosition = new MapObjectContainer();
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public MapObjectContainer getOnPosition() {
return onPosition;
}
@SuppressWarnings("unused")
public void add(MapObject mapObject) {
assert mapObject.getPosition() != null;
this.onPosition.add(mapObject);
}
@SuppressWarnings("unused")
public void remove(MapObject mapObject) {
this.onPosition.remove(mapObject);
}
public boolean isMoveableTo() {
for (MapObject mO : this.onPosition) {
if (mO instanceof Wall) {
return false;
}
}
return true;
}
public double calcDistance(Position pos) {
if (pos == null) {
throw new IllegalArgumentException("Position cannot be null");
}
// A little bit of math, using Pythagoras' Theorem
return Math.sqrt(
Math.pow(this.getX() - pos.getX(), 2) +
Math.pow(this.getY() - pos.getY(), 2)
);
}
@Override
public boolean equals(Object obj) {
if (obj != null) {
if (obj instanceof Position) {
Position p = (Position) obj;
return p.getX() == this.getX()
&& p.getY() == this.getY();
}
}
return false;
}
public boolean isPlaceHolder(){
for (MapObject object: onPosition){
if (object instanceof Placeholder)
return true;
}
return false;
}
public String toString() {
return x + "|" + y;
}
} | [
"public",
"class",
"Position",
"{",
"private",
"final",
"int",
"x",
";",
"private",
"final",
"int",
"y",
";",
"private",
"MapObjectContainer",
"onPosition",
";",
"public",
"Position",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"this",
".",
"x",
"=",
"x",
";",
"this",
".",
"y",
"=",
"y",
";",
"this",
".",
"onPosition",
"=",
"new",
"MapObjectContainer",
"(",
")",
";",
"}",
"public",
"int",
"getX",
"(",
")",
"{",
"return",
"x",
";",
"}",
"public",
"int",
"getY",
"(",
")",
"{",
"return",
"y",
";",
"}",
"public",
"MapObjectContainer",
"getOnPosition",
"(",
")",
"{",
"return",
"onPosition",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"",
"unused",
"\"",
")",
"public",
"void",
"add",
"(",
"MapObject",
"mapObject",
")",
"{",
"assert",
"mapObject",
".",
"getPosition",
"(",
")",
"!=",
"null",
";",
"this",
".",
"onPosition",
".",
"add",
"(",
"mapObject",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"",
"unused",
"\"",
")",
"public",
"void",
"remove",
"(",
"MapObject",
"mapObject",
")",
"{",
"this",
".",
"onPosition",
".",
"remove",
"(",
"mapObject",
")",
";",
"}",
"public",
"boolean",
"isMoveableTo",
"(",
")",
"{",
"for",
"(",
"MapObject",
"mO",
":",
"this",
".",
"onPosition",
")",
"{",
"if",
"(",
"mO",
"instanceof",
"Wall",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"public",
"double",
"calcDistance",
"(",
"Position",
"pos",
")",
"{",
"if",
"(",
"pos",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Position cannot be null",
"\"",
")",
";",
"}",
"return",
"Math",
".",
"sqrt",
"(",
"Math",
".",
"pow",
"(",
"this",
".",
"getX",
"(",
")",
"-",
"pos",
".",
"getX",
"(",
")",
",",
"2",
")",
"+",
"Math",
".",
"pow",
"(",
"this",
".",
"getY",
"(",
")",
"-",
"pos",
".",
"getY",
"(",
")",
",",
"2",
")",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"!=",
"null",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"Position",
")",
"{",
"Position",
"p",
"=",
"(",
"Position",
")",
"obj",
";",
"return",
"p",
".",
"getX",
"(",
")",
"==",
"this",
".",
"getX",
"(",
")",
"&&",
"p",
".",
"getY",
"(",
")",
"==",
"this",
".",
"getY",
"(",
")",
";",
"}",
"}",
"return",
"false",
";",
"}",
"public",
"boolean",
"isPlaceHolder",
"(",
")",
"{",
"for",
"(",
"MapObject",
"object",
":",
"onPosition",
")",
"{",
"if",
"(",
"object",
"instanceof",
"Placeholder",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"x",
"+",
"\"",
"|",
"\"",
"+",
"y",
";",
"}",
"}"
] | The position class represents a point on the map. | [
"The",
"position",
"class",
"represents",
"a",
"point",
"on",
"the",
"map",
"."
] | [
"// A little bit of math, using Pythagoras' Theorem"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8bb83750a44a2ca5df6c20137c31061defe41d4e | saicone/rtag | src/main/java/com/saicone/rtag/Rtag.java | [
"MIT"
] | Java | Rtag | /**
* <p>Rtag class to edit NBTTagCompound & NBTTagList objects.<br>
* Uses a tree-like path format to find the required tag
* instead of creating multiple classes for deep-tags.<br></p>
*
* <h2>Object conversion</h2>
* <p>The Rtag instance uses a {@link RtagMirror} to convert
* objects between TagBase <-> Object.<br>
* By default it's only compatible with regular Java
* objects like String, Short, Integer, Double, Float,
* Long, Byte, Map and List.<br>
* It also convert Byte, Integer and Long arrays as well.<br></p>
*
* <b>Other Objects</b>
* <p>If you want to add "custom object conversion" just
* register a properly {@link RtagSerializer} and {@link RtagDeserializer}
* that aims the specified object that you want to write and read
* from tag.<br>
* See {@link #putSerializer(Class, RtagSerializer)} and {@link #putDeserializer(RtagDeserializer)} for details.</p>
*
* @author Rubenicos
*/ | Rtag class to edit NBTTagCompound & NBTTagList objects.
Uses a tree-like path format to find the required tag
instead of creating multiple classes for deep-tags.
Object conversion
The Rtag instance uses a RtagMirror to convert
objects between TagBase <-> Object.
By default it's only compatible with regular Java
objects like String, Short, Integer, Double, Float,
Long, Byte, Map and List.
It also convert Byte, Integer and Long arrays as well.
Other Objects
If you want to add "custom object conversion" just
register a properly RtagSerializer and RtagDeserializer
that aims the specified object that you want to write and read
from tag.
See #putSerializer(Class, RtagSerializer) and #putDeserializer(RtagDeserializer) for details.
@author Rubenicos | [
"Rtag",
"class",
"to",
"edit",
"NBTTagCompound",
"&",
"NBTTagList",
"objects",
".",
"Uses",
"a",
"tree",
"-",
"like",
"path",
"format",
"to",
"find",
"the",
"required",
"tag",
"instead",
"of",
"creating",
"multiple",
"classes",
"for",
"deep",
"-",
"tags",
".",
"Object",
"conversion",
"The",
"Rtag",
"instance",
"uses",
"a",
"RtagMirror",
"to",
"convert",
"objects",
"between",
"TagBase",
"<",
"-",
">",
"Object",
".",
"By",
"default",
"it",
"'",
"s",
"only",
"compatible",
"with",
"regular",
"Java",
"objects",
"like",
"String",
"Short",
"Integer",
"Double",
"Float",
"Long",
"Byte",
"Map",
"and",
"List",
".",
"It",
"also",
"convert",
"Byte",
"Integer",
"and",
"Long",
"arrays",
"as",
"well",
".",
"Other",
"Objects",
"If",
"you",
"want",
"to",
"add",
"\"",
"custom",
"object",
"conversion",
"\"",
"just",
"register",
"a",
"properly",
"RtagSerializer",
"and",
"RtagDeserializer",
"that",
"aims",
"the",
"specified",
"object",
"that",
"you",
"want",
"to",
"write",
"and",
"read",
"from",
"tag",
".",
"See",
"#putSerializer",
"(",
"Class",
"RtagSerializer",
")",
"and",
"#putDeserializer",
"(",
"RtagDeserializer",
")",
"for",
"details",
".",
"@author",
"Rubenicos"
] | public class Rtag {
private static final Class<?> tagCompound = EasyLookup.classById("NBTTagCompound");
private static final Class<?> tagList = EasyLookup.classById("NBTTagList");
private static final BiPredicate<Integer, Object[]> addPredicate = (index, path) -> path.length == index || path[index] instanceof Integer;
private static final BiPredicate<Integer, Object[]> setPredicate = (index, path) -> path.length > index && path[index] instanceof Integer;
/**
* Rtag public instance only compatible with regular Java objects.
*/
public static final Rtag INSTANCE = new Rtag();
private final RtagMirror mirror;
private final Map<String, RtagDeserializer<Object>> deserializers = new HashMap<>();
private final Map<Class<?>, RtagSerializer<Object>> serializers = new HashMap<>();
/**
* Constructs an simple Rtag with default {@link RtagMirror} object.
*/
public Rtag() {
this(null);
}
/**
* Constructs an Rtag with specified mirror.
*
* @param mirror Mirror to convert objects.
*/
public Rtag(RtagMirror mirror) {
this.mirror = mirror == null ? new RtagMirror() : mirror;
this.mirror.setRtag(this);
}
/**
* Get current {@link RtagMirror} instance.
*
* @return A RtagMirror instance.
*/
public RtagMirror getMirror() {
return mirror;
}
/**
* Register an {@link RtagDeserializer} for {@link #fromTag(Object)} operations.
*
* @param deserializer Deserializer instance.
* @param <T> Deserializable object type.
* @return Current {@link Rtag} instance.
*/
@SuppressWarnings("unchecked")
public <T> Rtag putDeserializer(RtagDeserializer<T> deserializer) {
deserializers.put(deserializer.getOutID(), (RtagDeserializer<Object>) deserializer);
return this;
}
/**
* Register an {@link RtagSerializer} for {@link #toTag(Object)} operations.
*
* @param type Serializable object class that match with Serializer.
* @param serializer Serializer instance.
* @param <T> Serializable object type.
* @return Current {@link Rtag} instance.
*/
@SuppressWarnings("unchecked")
public <T> Rtag putSerializer(Class<T> type, RtagSerializer<T> serializer) {
serializers.put(type, (RtagSerializer<Object>) serializer);
return this;
}
/**
* Add value to an NBTTagList on specified path inside tag.<br>
* Note that empty path returns false because this method is
* only made for lists inside compounds or lists.<br>
* See {@link #get(Object, Object...)} for path information.
*
* @param tag Tag instance, can be NBTTagCompound or NBTTagList.
* @param value Value to add.
* @param path Final list path to add the specified value.
* @return True if value is added.
* @throws Throwable if any error occurs on reflected method invoking.
*/
public boolean add(Object tag, Object value, Object... path) throws Throwable {
if (path.length == 0) {
return false;
}
Object finalTag = getExactOrCreate(tag, path, addPredicate);
if (tagList.isInstance(finalTag)) {
Object valueTag = toTag(value);
if (valueTag != null) {
TagList.add(finalTag, valueTag);
return true;
}
}
// Incompatible tag or value
return false;
}
/**
* Set value to specified path inside tag.<br>
* Note that empty path returns false because this method is
* only made for tags inside compounds or lists.<br>
* If you want something like "remove", just put a null value.<br>
* See {@link #get(Object, Object...)} for path information.
*
* @param tag Tag instance, can be NBTTagCompound or NBTTagList.
* @param value Value to set.
* @param path Final value path to set.
* @return True if the value is set.
* @throws Throwable if any error occurs on reflected method invoking.
*/
public boolean set(Object tag, Object value, Object... path) throws Throwable {
if (path.length == 0) {
return false;
} else {
int last = path.length - 1;
Object finalTag = getExactOrCreate(tag, Arrays.copyOf(path, last), value == null ? null : setPredicate);
if (finalTag == null) {
return false;
} else if (value == null) {
return removeExact(finalTag, path[last]);
} else {
return setExact(finalTag, value, path[last]);
}
}
}
/**
* Set value to exact NBTTag list or compound.
*
* @param tag Tag instance, can be NBTTagCompound or NBTTagList.
* @param value Value to set.
* @param key Key associated with value.
* @return True if the value is set.
* @throws Throwable if any error occurs on reflected method invoking.
*/
public boolean setExact(Object tag, Object value, Object key) throws Throwable {
if (key instanceof Integer && tagList.isInstance(tag)) {
Object valueTag = toTag(value);
if (valueTag != null) {
TagList.set(tag, (int) key, valueTag);
return true;
}
} else if (tagCompound.isInstance(tag)) {
Object valueTag = toTag(value);
if (valueTag != null) {
TagCompound.set(tag, String.valueOf(key), valueTag);
return true;
}
}
// Incompatible tag or value
return false;
}
/**
* Remove value from exact NBTTag list or compound.
*
* @param tag Tag instance, can be NBTTagCompound or NBTTagList.
* @param key Key associated with value.
* @return True if the value is removed (or don't exist).
* @throws Throwable if any error occurs on reflected method invoking.
*/
public boolean removeExact(Object tag, Object key) throws Throwable {
if (key instanceof Integer && tagList.isInstance(tag)) {
TagList.remove(tag, (int) key);
} else if (tagCompound.isInstance(tag)) {
TagCompound.remove(tag, String.valueOf(key));
} else {
// Incompatible tag
return false;
}
return true;
}
/**
* Get value from the specified path inside tag.<br>
* The value will be cast to the type are you looking for after conversion.<br>
* <br>
* <b>Path format</b>
* <p>Rtag uses a tree-like format for paths, every object inside
* path can be {@link Integer} or {@link String} and will used
* to obtain the last possible NBTBase instance.<br>
* Path like ["normal", "path", "asd"] will look inside the NBTTagCompound
* for "normal" key, if value assigned for that key is instance of
* NBTTagCompound will look inside for the next key in path.<br>
* If current path key is instance of Integer and the current
* value that Rtag looking at is instance of NBTTagList, will get
* list index value for that path key.</p>
*
* @param tag Tag instance, can be NBTTagCompound or NBTTagList.
* @param path Final value path to get.
* @param <T> Object type to cast the value.
* @return The value assigned to specified path, null if not
* exist or a ClassCastException occurs.
* @throws Throwable if any error occurs on reflected method invoking.
*/
public <T> T get(Object tag, Object... path) throws Throwable {
return fromTag(getExact(tag, path));
}
/**
* Get exact NBTBase value without any conversion, from the specified path inside tag.<br>
* See {@link #get(Object, Object...)} for path information.
*
* @param tag Tag instance, can be NBTTagCompound or NBTTagList.
* @param path Final value path to get.
* @return The value assigned to specified path, null if not exist.
* @throws Throwable if any error occurs on reflected method invoking.
*/
public Object getExact(Object tag, Object... path) throws Throwable {
return getExactOrCreate(tag, path, null);
}
/**
* Get exact NBTBase value without any conversion, from the specified path inside tag.<br>
* See {@link #get(Object, Object...)} for path information.
*
* @param tag Tag instance, can be NBTTagCompound or NBTTagList.
* @param path Final value path to get.
* @param listPredicate Predicate to set new NBTTagList if NBTTagCompound doesn't contains key.
* @return The value assigned to specified path or null.
* @throws Throwable if any error occurs on reflected method invoking.
*/
public Object getExactOrCreate(Object tag, Object[] path, BiPredicate<Integer, Object[]> listPredicate) throws Throwable {
Object finalTag = tag;
for (int i = 0; i < path.length; i++) {
Object key = path[i];
if (key instanceof Integer && tagList.isInstance(finalTag)) {
if (TagList.size(finalTag) >= (int) key) {
finalTag = TagList.get(finalTag, (int) key);
} else {
// Out of bounds
return null;
}
} else if (tagCompound.isInstance(finalTag)) {
String keyString = String.valueOf(key);
// Create tag if not exists
if (listPredicate != null && TagCompound.notHasKey(finalTag, keyString)) {
TagCompound.set(finalTag, keyString, listPredicate.test(i + 1, path) ? TagList.newTag() : TagCompound.newTag());
}
finalTag = TagCompound.get(finalTag, keyString);
if (finalTag == null) {
// Unknown path or incompatible tag
return null;
}
} else {
// Incompatible tag
return null;
}
}
return finalTag;
}
/**
* Convert any object to NBTBase tag.<br>
* This method first check for any serializer an then use the current {@link RtagMirror}.
*
* @param object Object to convert.
* @return Converted object instance of NBTBase or null.
*/
public Object toTag(Object object) {
if (object == null) {
return null;
} else if (serializers.containsKey(object.getClass())) {
RtagSerializer<Object> serializer = serializers.get(object.getClass());
Map<String, Object> map = serializer.serialize(object);
map.put("rtag==", serializer.getInID());
return toTag(map);
} else {
return getMirror().toTag(object);
}
}
/**
* Convert any NBTBase tag to regular Java object or custom by deserializer.<br>
* This method will cast the object to the type you looking for.
*
* @param tag NBTBase tag.
* @param <T> Object type to cast the value.
* @return Converted value, null if any error occurs.
*/
@SuppressWarnings("unchecked")
public <T> T fromTag(Object tag) {
try {
return (T) fromTagExact(tag);
} catch (ClassCastException e) {
return null;
}
}
/**
* Convert any NBTBase tag to exact regular Java object
* or custom by deserializer without any cast.
*
* @param tag NBTBase tag.
* @return Converted value or null.
*/
@SuppressWarnings("unchecked")
public Object fromTagExact(Object tag) {
Object object = getMirror().fromTag(tag);
if (object instanceof Map) {
Object type = ((Map<String, Object>) object).get("rtag==");
if (type instanceof String && deserializers.containsKey((String) type)) {
return deserializers.get((String) type).deserialize((Map<String, Object>) object);
}
}
return object;
}
} | [
"public",
"class",
"Rtag",
"{",
"private",
"static",
"final",
"Class",
"<",
"?",
">",
"tagCompound",
"=",
"EasyLookup",
".",
"classById",
"(",
"\"",
"NBTTagCompound",
"\"",
")",
";",
"private",
"static",
"final",
"Class",
"<",
"?",
">",
"tagList",
"=",
"EasyLookup",
".",
"classById",
"(",
"\"",
"NBTTagList",
"\"",
")",
";",
"private",
"static",
"final",
"BiPredicate",
"<",
"Integer",
",",
"Object",
"[",
"]",
">",
"addPredicate",
"=",
"(",
"index",
",",
"path",
")",
"->",
"path",
".",
"length",
"==",
"index",
"||",
"path",
"[",
"index",
"]",
"instanceof",
"Integer",
";",
"private",
"static",
"final",
"BiPredicate",
"<",
"Integer",
",",
"Object",
"[",
"]",
">",
"setPredicate",
"=",
"(",
"index",
",",
"path",
")",
"->",
"path",
".",
"length",
">",
"index",
"&&",
"path",
"[",
"index",
"]",
"instanceof",
"Integer",
";",
"/**\n * Rtag public instance only compatible with regular Java objects.\n */",
"public",
"static",
"final",
"Rtag",
"INSTANCE",
"=",
"new",
"Rtag",
"(",
")",
";",
"private",
"final",
"RtagMirror",
"mirror",
";",
"private",
"final",
"Map",
"<",
"String",
",",
"RtagDeserializer",
"<",
"Object",
">",
">",
"deserializers",
"=",
"new",
"HashMap",
"<",
">",
"(",
")",
";",
"private",
"final",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"RtagSerializer",
"<",
"Object",
">",
">",
"serializers",
"=",
"new",
"HashMap",
"<",
">",
"(",
")",
";",
"/**\n * Constructs an simple Rtag with default {@link RtagMirror} object.\n */",
"public",
"Rtag",
"(",
")",
"{",
"this",
"(",
"null",
")",
";",
"}",
"/**\n * Constructs an Rtag with specified mirror.\n *\n * @param mirror Mirror to convert objects.\n */",
"public",
"Rtag",
"(",
"RtagMirror",
"mirror",
")",
"{",
"this",
".",
"mirror",
"=",
"mirror",
"==",
"null",
"?",
"new",
"RtagMirror",
"(",
")",
":",
"mirror",
";",
"this",
".",
"mirror",
".",
"setRtag",
"(",
"this",
")",
";",
"}",
"/**\n * Get current {@link RtagMirror} instance.\n *\n * @return A RtagMirror instance.\n */",
"public",
"RtagMirror",
"getMirror",
"(",
")",
"{",
"return",
"mirror",
";",
"}",
"/**\n * Register an {@link RtagDeserializer} for {@link #fromTag(Object)} operations.\n *\n * @param deserializer Deserializer instance.\n * @param <T> Deserializable object type.\n * @return Current {@link Rtag} instance.\n */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"<",
"T",
">",
"Rtag",
"putDeserializer",
"(",
"RtagDeserializer",
"<",
"T",
">",
"deserializer",
")",
"{",
"deserializers",
".",
"put",
"(",
"deserializer",
".",
"getOutID",
"(",
")",
",",
"(",
"RtagDeserializer",
"<",
"Object",
">",
")",
"deserializer",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Register an {@link RtagSerializer} for {@link #toTag(Object)} operations.\n *\n * @param type Serializable object class that match with Serializer.\n * @param serializer Serializer instance.\n * @param <T> Serializable object type.\n * @return Current {@link Rtag} instance.\n */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"<",
"T",
">",
"Rtag",
"putSerializer",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"RtagSerializer",
"<",
"T",
">",
"serializer",
")",
"{",
"serializers",
".",
"put",
"(",
"type",
",",
"(",
"RtagSerializer",
"<",
"Object",
">",
")",
"serializer",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Add value to an NBTTagList on specified path inside tag.<br>\n * Note that empty path returns false because this method is\n * only made for lists inside compounds or lists.<br>\n * See {@link #get(Object, Object...)} for path information.\n *\n * @param tag Tag instance, can be NBTTagCompound or NBTTagList.\n * @param value Value to add.\n * @param path Final list path to add the specified value.\n * @return True if value is added.\n * @throws Throwable if any error occurs on reflected method invoking.\n */",
"public",
"boolean",
"add",
"(",
"Object",
"tag",
",",
"Object",
"value",
",",
"Object",
"...",
"path",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"path",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"Object",
"finalTag",
"=",
"getExactOrCreate",
"(",
"tag",
",",
"path",
",",
"addPredicate",
")",
";",
"if",
"(",
"tagList",
".",
"isInstance",
"(",
"finalTag",
")",
")",
"{",
"Object",
"valueTag",
"=",
"toTag",
"(",
"value",
")",
";",
"if",
"(",
"valueTag",
"!=",
"null",
")",
"{",
"TagList",
".",
"add",
"(",
"finalTag",
",",
"valueTag",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"/**\n * Set value to specified path inside tag.<br>\n * Note that empty path returns false because this method is\n * only made for tags inside compounds or lists.<br>\n * If you want something like \"remove\", just put a null value.<br>\n * See {@link #get(Object, Object...)} for path information.\n *\n * @param tag Tag instance, can be NBTTagCompound or NBTTagList.\n * @param value Value to set.\n * @param path Final value path to set.\n * @return True if the value is set.\n * @throws Throwable if any error occurs on reflected method invoking.\n */",
"public",
"boolean",
"set",
"(",
"Object",
"tag",
",",
"Object",
"value",
",",
"Object",
"...",
"path",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"path",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"int",
"last",
"=",
"path",
".",
"length",
"-",
"1",
";",
"Object",
"finalTag",
"=",
"getExactOrCreate",
"(",
"tag",
",",
"Arrays",
".",
"copyOf",
"(",
"path",
",",
"last",
")",
",",
"value",
"==",
"null",
"?",
"null",
":",
"setPredicate",
")",
";",
"if",
"(",
"finalTag",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"removeExact",
"(",
"finalTag",
",",
"path",
"[",
"last",
"]",
")",
";",
"}",
"else",
"{",
"return",
"setExact",
"(",
"finalTag",
",",
"value",
",",
"path",
"[",
"last",
"]",
")",
";",
"}",
"}",
"}",
"/**\n * Set value to exact NBTTag list or compound.\n *\n * @param tag Tag instance, can be NBTTagCompound or NBTTagList.\n * @param value Value to set.\n * @param key Key associated with value.\n * @return True if the value is set.\n * @throws Throwable if any error occurs on reflected method invoking.\n */",
"public",
"boolean",
"setExact",
"(",
"Object",
"tag",
",",
"Object",
"value",
",",
"Object",
"key",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"key",
"instanceof",
"Integer",
"&&",
"tagList",
".",
"isInstance",
"(",
"tag",
")",
")",
"{",
"Object",
"valueTag",
"=",
"toTag",
"(",
"value",
")",
";",
"if",
"(",
"valueTag",
"!=",
"null",
")",
"{",
"TagList",
".",
"set",
"(",
"tag",
",",
"(",
"int",
")",
"key",
",",
"valueTag",
")",
";",
"return",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"tagCompound",
".",
"isInstance",
"(",
"tag",
")",
")",
"{",
"Object",
"valueTag",
"=",
"toTag",
"(",
"value",
")",
";",
"if",
"(",
"valueTag",
"!=",
"null",
")",
"{",
"TagCompound",
".",
"set",
"(",
"tag",
",",
"String",
".",
"valueOf",
"(",
"key",
")",
",",
"valueTag",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"/**\n * Remove value from exact NBTTag list or compound.\n *\n * @param tag Tag instance, can be NBTTagCompound or NBTTagList.\n * @param key Key associated with value.\n * @return True if the value is removed (or don't exist).\n * @throws Throwable if any error occurs on reflected method invoking.\n */",
"public",
"boolean",
"removeExact",
"(",
"Object",
"tag",
",",
"Object",
"key",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"key",
"instanceof",
"Integer",
"&&",
"tagList",
".",
"isInstance",
"(",
"tag",
")",
")",
"{",
"TagList",
".",
"remove",
"(",
"tag",
",",
"(",
"int",
")",
"key",
")",
";",
"}",
"else",
"if",
"(",
"tagCompound",
".",
"isInstance",
"(",
"tag",
")",
")",
"{",
"TagCompound",
".",
"remove",
"(",
"tag",
",",
"String",
".",
"valueOf",
"(",
"key",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"/**\n * Get value from the specified path inside tag.<br>\n * The value will be cast to the type are you looking for after conversion.<br>\n * <br>\n * <b>Path format</b>\n * <p>Rtag uses a tree-like format for paths, every object inside\n * path can be {@link Integer} or {@link String} and will used\n * to obtain the last possible NBTBase instance.<br>\n * Path like [\"normal\", \"path\", \"asd\"] will look inside the NBTTagCompound\n * for \"normal\" key, if value assigned for that key is instance of\n * NBTTagCompound will look inside for the next key in path.<br>\n * If current path key is instance of Integer and the current\n * value that Rtag looking at is instance of NBTTagList, will get\n * list index value for that path key.</p>\n *\n * @param tag Tag instance, can be NBTTagCompound or NBTTagList.\n * @param path Final value path to get.\n * @param <T> Object type to cast the value.\n * @return The value assigned to specified path, null if not\n * exist or a ClassCastException occurs.\n * @throws Throwable if any error occurs on reflected method invoking.\n */",
"public",
"<",
"T",
">",
"T",
"get",
"(",
"Object",
"tag",
",",
"Object",
"...",
"path",
")",
"throws",
"Throwable",
"{",
"return",
"fromTag",
"(",
"getExact",
"(",
"tag",
",",
"path",
")",
")",
";",
"}",
"/**\n * Get exact NBTBase value without any conversion, from the specified path inside tag.<br>\n * See {@link #get(Object, Object...)} for path information.\n *\n * @param tag Tag instance, can be NBTTagCompound or NBTTagList.\n * @param path Final value path to get.\n * @return The value assigned to specified path, null if not exist.\n * @throws Throwable if any error occurs on reflected method invoking.\n */",
"public",
"Object",
"getExact",
"(",
"Object",
"tag",
",",
"Object",
"...",
"path",
")",
"throws",
"Throwable",
"{",
"return",
"getExactOrCreate",
"(",
"tag",
",",
"path",
",",
"null",
")",
";",
"}",
"/**\n * Get exact NBTBase value without any conversion, from the specified path inside tag.<br>\n * See {@link #get(Object, Object...)} for path information.\n *\n * @param tag Tag instance, can be NBTTagCompound or NBTTagList.\n * @param path Final value path to get.\n * @param listPredicate Predicate to set new NBTTagList if NBTTagCompound doesn't contains key.\n * @return The value assigned to specified path or null.\n * @throws Throwable if any error occurs on reflected method invoking.\n */",
"public",
"Object",
"getExactOrCreate",
"(",
"Object",
"tag",
",",
"Object",
"[",
"]",
"path",
",",
"BiPredicate",
"<",
"Integer",
",",
"Object",
"[",
"]",
">",
"listPredicate",
")",
"throws",
"Throwable",
"{",
"Object",
"finalTag",
"=",
"tag",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"path",
".",
"length",
";",
"i",
"++",
")",
"{",
"Object",
"key",
"=",
"path",
"[",
"i",
"]",
";",
"if",
"(",
"key",
"instanceof",
"Integer",
"&&",
"tagList",
".",
"isInstance",
"(",
"finalTag",
")",
")",
"{",
"if",
"(",
"TagList",
".",
"size",
"(",
"finalTag",
")",
">=",
"(",
"int",
")",
"key",
")",
"{",
"finalTag",
"=",
"TagList",
".",
"get",
"(",
"finalTag",
",",
"(",
"int",
")",
"key",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"if",
"(",
"tagCompound",
".",
"isInstance",
"(",
"finalTag",
")",
")",
"{",
"String",
"keyString",
"=",
"String",
".",
"valueOf",
"(",
"key",
")",
";",
"if",
"(",
"listPredicate",
"!=",
"null",
"&&",
"TagCompound",
".",
"notHasKey",
"(",
"finalTag",
",",
"keyString",
")",
")",
"{",
"TagCompound",
".",
"set",
"(",
"finalTag",
",",
"keyString",
",",
"listPredicate",
".",
"test",
"(",
"i",
"+",
"1",
",",
"path",
")",
"?",
"TagList",
".",
"newTag",
"(",
")",
":",
"TagCompound",
".",
"newTag",
"(",
")",
")",
";",
"}",
"finalTag",
"=",
"TagCompound",
".",
"get",
"(",
"finalTag",
",",
"keyString",
")",
";",
"if",
"(",
"finalTag",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"finalTag",
";",
"}",
"/**\n * Convert any object to NBTBase tag.<br>\n * This method first check for any serializer an then use the current {@link RtagMirror}.\n *\n * @param object Object to convert.\n * @return Converted object instance of NBTBase or null.\n */",
"public",
"Object",
"toTag",
"(",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"serializers",
".",
"containsKey",
"(",
"object",
".",
"getClass",
"(",
")",
")",
")",
"{",
"RtagSerializer",
"<",
"Object",
">",
"serializer",
"=",
"serializers",
".",
"get",
"(",
"object",
".",
"getClass",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"serializer",
".",
"serialize",
"(",
"object",
")",
";",
"map",
".",
"put",
"(",
"\"",
"rtag==",
"\"",
",",
"serializer",
".",
"getInID",
"(",
")",
")",
";",
"return",
"toTag",
"(",
"map",
")",
";",
"}",
"else",
"{",
"return",
"getMirror",
"(",
")",
".",
"toTag",
"(",
"object",
")",
";",
"}",
"}",
"/**\n * Convert any NBTBase tag to regular Java object or custom by deserializer.<br>\n * This method will cast the object to the type you looking for.\n *\n * @param tag NBTBase tag.\n * @param <T> Object type to cast the value.\n * @return Converted value, null if any error occurs.\n */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"<",
"T",
">",
"T",
"fromTag",
"(",
"Object",
"tag",
")",
"{",
"try",
"{",
"return",
"(",
"T",
")",
"fromTagExact",
"(",
"tag",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"/**\n * Convert any NBTBase tag to exact regular Java object\n * or custom by deserializer without any cast.\n *\n * @param tag NBTBase tag.\n * @return Converted value or null.\n */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"Object",
"fromTagExact",
"(",
"Object",
"tag",
")",
"{",
"Object",
"object",
"=",
"getMirror",
"(",
")",
".",
"fromTag",
"(",
"tag",
")",
";",
"if",
"(",
"object",
"instanceof",
"Map",
")",
"{",
"Object",
"type",
"=",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"object",
")",
".",
"get",
"(",
"\"",
"rtag==",
"\"",
")",
";",
"if",
"(",
"type",
"instanceof",
"String",
"&&",
"deserializers",
".",
"containsKey",
"(",
"(",
"String",
")",
"type",
")",
")",
"{",
"return",
"deserializers",
".",
"get",
"(",
"(",
"String",
")",
"type",
")",
".",
"deserialize",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"object",
")",
";",
"}",
"}",
"return",
"object",
";",
"}",
"}"
] | <p>Rtag class to edit NBTTagCompound & NBTTagList objects.<br>
Uses a tree-like path format to find the required tag
instead of creating multiple classes for deep-tags.<br></p> | [
"<p",
">",
"Rtag",
"class",
"to",
"edit",
"NBTTagCompound",
"&",
";",
"NBTTagList",
"objects",
".",
"<br",
">",
"Uses",
"a",
"tree",
"-",
"like",
"path",
"format",
"to",
"find",
"the",
"required",
"tag",
"instead",
"of",
"creating",
"multiple",
"classes",
"for",
"deep",
"-",
"tags",
".",
"<br",
">",
"<",
"/",
"p",
">"
] | [
"// Incompatible tag or value",
"// Incompatible tag or value",
"// Incompatible tag",
"// Out of bounds",
"// Create tag if not exists",
"// Unknown path or incompatible tag",
"// Incompatible tag"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8bc248d58835d955784dcb1868d0d95ef984c799 | niko-z/barcode-reader-mobile-samples | android/Performance/ReadRateFirstSettings/app/src/main/java/com/dynamsoft/readratefirstsettings/Camera2BasicFragment.java | [
"OML"
] | Java | CompareSizesByArea | /**
* Compares two {@code Size}s based on their areas.
*/ | Compares two Sizes based on their areas. | [
"Compares",
"two",
"Sizes",
"based",
"on",
"their",
"areas",
"."
] | static class CompareSizesByArea implements Comparator<Size> {
@Override
public int compare(Size lhs, Size rhs) {
// We cast here to ensure the multiplications won't overflow
return Long.signum((long) lhs.getWidth() * lhs.getHeight() -
(long) rhs.getWidth() * rhs.getHeight());
}
} | [
"static",
"class",
"CompareSizesByArea",
"implements",
"Comparator",
"<",
"Size",
">",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"Size",
"lhs",
",",
"Size",
"rhs",
")",
"{",
"return",
"Long",
".",
"signum",
"(",
"(",
"long",
")",
"lhs",
".",
"getWidth",
"(",
")",
"*",
"lhs",
".",
"getHeight",
"(",
")",
"-",
"(",
"long",
")",
"rhs",
".",
"getWidth",
"(",
")",
"*",
"rhs",
".",
"getHeight",
"(",
")",
")",
";",
"}",
"}"
] | Compares two {@code Size}s based on their areas. | [
"Compares",
"two",
"{",
"@code",
"Size",
"}",
"s",
"based",
"on",
"their",
"areas",
"."
] | [
"// We cast here to ensure the multiplications won't overflow"
] | [
{
"param": "Comparator<Size>",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Comparator<Size>",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bc37526fdda6a678018d3688c3e2be78d7416dd | metova/Capuccino | cappuccino/src/main/java/com/metova/cappuccino/animations/SystemAnimations.java | [
"Apache-2.0"
] | Java | SystemAnimations | /**
* Disable animations so that they do not interfere with Espresso tests.
*/ | Disable animations so that they do not interfere with Espresso tests. | [
"Disable",
"animations",
"so",
"that",
"they",
"do",
"not",
"interfere",
"with",
"Espresso",
"tests",
"."
] | public final class SystemAnimations {
private static SystemAnimations sInstance = null;
private PermissionChecker mPermissionChecker = new PermissionChecker();
private WindowManager mWindowManager = new WindowManager();
private static final float DISABLED = 0.0f;
private static final float DEFAULT = 1.0f;
private static final float RESTORE = -1f;
private float[] restoreScale = null;
@VisibleForTesting
SystemAnimations() {
}
private static SystemAnimations getInstance(@NonNull Context context) {
if (sInstance == null) {
synchronized (SystemAnimations.class) {
if (sInstance == null) {
sInstance = new SystemAnimations();
sInstance.checkPermissionStatus(context);
}
}
}
return sInstance;
}
// TODO add a Policy class that allows a warning to be emitted, instead
@VisibleForTesting
void checkPermissionStatus(@NonNull Context context) {
boolean hasPermission = getPermissionChecker().hasAnimationPermission(context);
if (!hasPermission) {
throw new IllegalStateException(getPermissionErrorMessage());
}
}
// region public API
public static void disableAll(@NonNull Context context) {
getInstance(context).disableAll();
}
public static void enableAll(@NonNull Context context) {
getInstance(context).enableAll();
}
public static void restoreAll(@NonNull Context context) {
getInstance(context).restoreAll();
}
// endregion public API
@VisibleForTesting
void disableAll() {
setSystemAnimationsScale(DISABLED);
}
@VisibleForTesting
void enableAll() {
setSystemAnimationsScale(DEFAULT);
}
@VisibleForTesting
void restoreAll() {
if (restoreScale == null) {
throw new IllegalStateException(getRestoreErrorMessage());
}
setSystemAnimationsScale(RESTORE);
}
private void setSystemAnimationsScale(float animationScale) {
try {
float[] currentScales = getWindowManager().getAnimationScales();
float[] oldScales = new float[currentScales.length];
if (restoreScale == null || animationScale != RESTORE) {
restoreScale = new float[currentScales.length];
}
for (int i = 0; i < currentScales.length; i++) {
oldScales[i] = currentScales[i]; // remember for later
// Restoring previous scale
if (animationScale == RESTORE) {
currentScales[i] = restoreScale[i];
}
// Not restoring, so use value passed in
else {
currentScales[i] = animationScale; // set new
}
restoreScale[i] = oldScales[i];
}
getWindowManager().setAnimationScales(currentScales);
} catch (Exception e) {
throw new InternalError(getReflectionErrorMessage(animationScale));
}
}
// region messages
@VisibleForTesting
@NonNull
static String getPermissionErrorMessage() {
return "Application not granted access to animations. Common causes for this exception include:\n"
+ "\tFailure to declare `<uses-permission android:name=\"android.permission.SET_ANIMATION_SCALE\" />` in the manifest;\n"
+ "\tFailure to apply the Cappuccino Animations plugin in your application's build.gradle file; and\n"
+ "\tFailure of the Cappuccino Animations plugin.\n"
+ "\tIf this last is the issue, consider adding a configuration to the `cappuccino {}` closure in the build.gradle file. For example:\n"
+ "\tcappuccino {\n"
+ "\t\texcludedConfigurations = ['badConfiguration', 'otherBadConfiguration', ...]\n"
+ "\t}";
}
@VisibleForTesting
@NonNull
static String getRestoreErrorMessage() {
return "restoreAll() called when there is nothing to restore!";
}
@VisibleForTesting
@NonNull
static String getReflectionErrorMessage(float animationScale) {
return "Could not change animation scale to " + animationScale;
}
// endregion messages
// region methods to make testing easier
private PermissionChecker getPermissionChecker() {
return mPermissionChecker;
}
@VisibleForTesting
void setPermissionChecker(@NonNull PermissionChecker permissionChecker) {
mPermissionChecker = permissionChecker;
}
private WindowManager getWindowManager() {
return mWindowManager;
}
@VisibleForTesting
void setWindowManager(@NonNull WindowManager windowManager) {
mWindowManager = windowManager;
}
// endregion methods to make testing easier
} | [
"public",
"final",
"class",
"SystemAnimations",
"{",
"private",
"static",
"SystemAnimations",
"sInstance",
"=",
"null",
";",
"private",
"PermissionChecker",
"mPermissionChecker",
"=",
"new",
"PermissionChecker",
"(",
")",
";",
"private",
"WindowManager",
"mWindowManager",
"=",
"new",
"WindowManager",
"(",
")",
";",
"private",
"static",
"final",
"float",
"DISABLED",
"=",
"0.0f",
";",
"private",
"static",
"final",
"float",
"DEFAULT",
"=",
"1.0f",
";",
"private",
"static",
"final",
"float",
"RESTORE",
"=",
"-",
"1f",
";",
"private",
"float",
"[",
"]",
"restoreScale",
"=",
"null",
";",
"@",
"VisibleForTesting",
"SystemAnimations",
"(",
")",
"{",
"}",
"private",
"static",
"SystemAnimations",
"getInstance",
"(",
"@",
"NonNull",
"Context",
"context",
")",
"{",
"if",
"(",
"sInstance",
"==",
"null",
")",
"{",
"synchronized",
"(",
"SystemAnimations",
".",
"class",
")",
"{",
"if",
"(",
"sInstance",
"==",
"null",
")",
"{",
"sInstance",
"=",
"new",
"SystemAnimations",
"(",
")",
";",
"sInstance",
".",
"checkPermissionStatus",
"(",
"context",
")",
";",
"}",
"}",
"}",
"return",
"sInstance",
";",
"}",
"@",
"VisibleForTesting",
"void",
"checkPermissionStatus",
"(",
"@",
"NonNull",
"Context",
"context",
")",
"{",
"boolean",
"hasPermission",
"=",
"getPermissionChecker",
"(",
")",
".",
"hasAnimationPermission",
"(",
"context",
")",
";",
"if",
"(",
"!",
"hasPermission",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"getPermissionErrorMessage",
"(",
")",
")",
";",
"}",
"}",
"public",
"static",
"void",
"disableAll",
"(",
"@",
"NonNull",
"Context",
"context",
")",
"{",
"getInstance",
"(",
"context",
")",
".",
"disableAll",
"(",
")",
";",
"}",
"public",
"static",
"void",
"enableAll",
"(",
"@",
"NonNull",
"Context",
"context",
")",
"{",
"getInstance",
"(",
"context",
")",
".",
"enableAll",
"(",
")",
";",
"}",
"public",
"static",
"void",
"restoreAll",
"(",
"@",
"NonNull",
"Context",
"context",
")",
"{",
"getInstance",
"(",
"context",
")",
".",
"restoreAll",
"(",
")",
";",
"}",
"@",
"VisibleForTesting",
"void",
"disableAll",
"(",
")",
"{",
"setSystemAnimationsScale",
"(",
"DISABLED",
")",
";",
"}",
"@",
"VisibleForTesting",
"void",
"enableAll",
"(",
")",
"{",
"setSystemAnimationsScale",
"(",
"DEFAULT",
")",
";",
"}",
"@",
"VisibleForTesting",
"void",
"restoreAll",
"(",
")",
"{",
"if",
"(",
"restoreScale",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"getRestoreErrorMessage",
"(",
")",
")",
";",
"}",
"setSystemAnimationsScale",
"(",
"RESTORE",
")",
";",
"}",
"private",
"void",
"setSystemAnimationsScale",
"(",
"float",
"animationScale",
")",
"{",
"try",
"{",
"float",
"[",
"]",
"currentScales",
"=",
"getWindowManager",
"(",
")",
".",
"getAnimationScales",
"(",
")",
";",
"float",
"[",
"]",
"oldScales",
"=",
"new",
"float",
"[",
"currentScales",
".",
"length",
"]",
";",
"if",
"(",
"restoreScale",
"==",
"null",
"||",
"animationScale",
"!=",
"RESTORE",
")",
"{",
"restoreScale",
"=",
"new",
"float",
"[",
"currentScales",
".",
"length",
"]",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"currentScales",
".",
"length",
";",
"i",
"++",
")",
"{",
"oldScales",
"[",
"i",
"]",
"=",
"currentScales",
"[",
"i",
"]",
";",
"if",
"(",
"animationScale",
"==",
"RESTORE",
")",
"{",
"currentScales",
"[",
"i",
"]",
"=",
"restoreScale",
"[",
"i",
"]",
";",
"}",
"else",
"{",
"currentScales",
"[",
"i",
"]",
"=",
"animationScale",
";",
"}",
"restoreScale",
"[",
"i",
"]",
"=",
"oldScales",
"[",
"i",
"]",
";",
"}",
"getWindowManager",
"(",
")",
".",
"setAnimationScales",
"(",
"currentScales",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"InternalError",
"(",
"getReflectionErrorMessage",
"(",
"animationScale",
")",
")",
";",
"}",
"}",
"@",
"VisibleForTesting",
"@",
"NonNull",
"static",
"String",
"getPermissionErrorMessage",
"(",
")",
"{",
"return",
"\"",
"Application not granted access to animations. Common causes for this exception include:",
"\\n",
"\"",
"+",
"\"",
"\\t",
"Failure to declare `<uses-permission android:name=",
"\\\"",
"android.permission.SET_ANIMATION_SCALE",
"\\\"",
" />` in the manifest;",
"\\n",
"\"",
"+",
"\"",
"\\t",
"Failure to apply the Cappuccino Animations plugin in your application's build.gradle file; and",
"\\n",
"\"",
"+",
"\"",
"\\t",
"Failure of the Cappuccino Animations plugin.",
"\\n",
"\"",
"+",
"\"",
"\\t",
"If this last is the issue, consider adding a configuration to the `cappuccino {}` closure in the build.gradle file. For example:",
"\\n",
"\"",
"+",
"\"",
"\\t",
"cappuccino {",
"\\n",
"\"",
"+",
"\"",
"\\t",
"\\t",
"excludedConfigurations = ['badConfiguration', 'otherBadConfiguration', ...]",
"\\n",
"\"",
"+",
"\"",
"\\t",
"}",
"\"",
";",
"}",
"@",
"VisibleForTesting",
"@",
"NonNull",
"static",
"String",
"getRestoreErrorMessage",
"(",
")",
"{",
"return",
"\"",
"restoreAll() called when there is nothing to restore!",
"\"",
";",
"}",
"@",
"VisibleForTesting",
"@",
"NonNull",
"static",
"String",
"getReflectionErrorMessage",
"(",
"float",
"animationScale",
")",
"{",
"return",
"\"",
"Could not change animation scale to ",
"\"",
"+",
"animationScale",
";",
"}",
"private",
"PermissionChecker",
"getPermissionChecker",
"(",
")",
"{",
"return",
"mPermissionChecker",
";",
"}",
"@",
"VisibleForTesting",
"void",
"setPermissionChecker",
"(",
"@",
"NonNull",
"PermissionChecker",
"permissionChecker",
")",
"{",
"mPermissionChecker",
"=",
"permissionChecker",
";",
"}",
"private",
"WindowManager",
"getWindowManager",
"(",
")",
"{",
"return",
"mWindowManager",
";",
"}",
"@",
"VisibleForTesting",
"void",
"setWindowManager",
"(",
"@",
"NonNull",
"WindowManager",
"windowManager",
")",
"{",
"mWindowManager",
"=",
"windowManager",
";",
"}",
"}"
] | Disable animations so that they do not interfere with Espresso tests. | [
"Disable",
"animations",
"so",
"that",
"they",
"do",
"not",
"interfere",
"with",
"Espresso",
"tests",
"."
] | [
"// TODO add a Policy class that allows a warning to be emitted, instead",
"// region public API",
"// endregion public API",
"// remember for later",
"// Restoring previous scale",
"// Not restoring, so use value passed in",
"// set new",
"// region messages",
"// endregion messages",
"// region methods to make testing easier",
"// endregion methods to make testing easier"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8bc7103111243243ac52f68db9e6034d4c457f69 | tliang1/Java-Practice | Practice/Intro-To-Java-8th-Ed-Daniel-Y.-Liang/Chapter-9/Chapter09P16/src/main/ReformatJavaSourceCode.java | [
"MIT"
] | Java | ReformatJavaSourceCode | /**
* @author Tony Liang
*
*/ | @author Tony Liang | [
"@author",
"Tony",
"Liang"
] | public class ReformatJavaSourceCode
{
/**
* Converts the given Java file written in the next-line brace style to the end-of-line brace style.
* <ul>
* <li>
* If the string array's length is not equal to 1, the program exits.
* </li>
* <li>
* If the Java file does not exist in the given pathname, the program exits.
* </li>
* </ul>
*
* @param args string array of one Java file pathname
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
if (args.length != 1)
{
System.out.println("Usage: java ReformatJavaSourceCode <filename>.java");
System.exit(0);
}
File file = new File(args[0]);
if (!file.exists())
{
System.out.println("File does not exists");
System.exit(0);
}
File oldFile = new File("original.java");
file.renameTo(oldFile);
Scanner input = new Scanner(oldFile);
PrintWriter output = new PrintWriter(file);
boolean isFirstLine = true;
while (input.hasNext())
{
String string = input.nextLine();
if (isFirstLine)
{
isFirstLine = !isFirstLine;
output.print(string);
}
else if (string.matches("\\s*\\{\\s*"))
{
output.print(" {");
}
else
{
output.print("\n" + string);
}
}
input.close();
output.close();
oldFile.delete();
}
} | [
"public",
"class",
"ReformatJavaSourceCode",
"{",
"/**\n\t * Converts the given Java file written in the next-line brace style to the end-of-line brace style.\n\t * <ul>\n\t * \t<li>\n\t * \t\tIf the string array's length is not equal to 1, the program exits.\n\t * \t</li>\n\t * \t<li>\n\t * \t\tIf the Java file does not exist in the given pathname, the program exits.\n\t * \t</li>\n\t * </ul>\n\t * \n\t * @param args\t\t\tstring array of one Java file pathname\n\t * @throws Exception \n\t */",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"1",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Usage: java ReformatJavaSourceCode <filename>.java",
"\"",
")",
";",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"File",
"file",
"=",
"new",
"File",
"(",
"args",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"File does not exists",
"\"",
")",
";",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"File",
"oldFile",
"=",
"new",
"File",
"(",
"\"",
"original.java",
"\"",
")",
";",
"file",
".",
"renameTo",
"(",
"oldFile",
")",
";",
"Scanner",
"input",
"=",
"new",
"Scanner",
"(",
"oldFile",
")",
";",
"PrintWriter",
"output",
"=",
"new",
"PrintWriter",
"(",
"file",
")",
";",
"boolean",
"isFirstLine",
"=",
"true",
";",
"while",
"(",
"input",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"string",
"=",
"input",
".",
"nextLine",
"(",
")",
";",
"if",
"(",
"isFirstLine",
")",
"{",
"isFirstLine",
"=",
"!",
"isFirstLine",
";",
"output",
".",
"print",
"(",
"string",
")",
";",
"}",
"else",
"if",
"(",
"string",
".",
"matches",
"(",
"\"",
"\\\\",
"s*",
"\\\\",
"{",
"\\\\",
"s*",
"\"",
")",
")",
"{",
"output",
".",
"print",
"(",
"\"",
" {",
"\"",
")",
";",
"}",
"else",
"{",
"output",
".",
"print",
"(",
"\"",
"\\n",
"\"",
"+",
"string",
")",
";",
"}",
"}",
"input",
".",
"close",
"(",
")",
";",
"output",
".",
"close",
"(",
")",
";",
"oldFile",
".",
"delete",
"(",
")",
";",
"}",
"}"
] | @author Tony Liang | [
"@author",
"Tony",
"Liang"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1eacae98aae39f8ea3842a6c9c3f56b286fb5f6d | NirBY/jsystem | jsystem-core-projects/jsystemCore/src/main/java/jsystem/utils/ClassSearchUtil.java | [
"Apache-2.0"
] | Java | ClassSearchUtil | /**
* Utility class for classpath related operations.
*
* @author guy.arieli & Golan Derazon
*/ | Utility class for classpath related operations.
@author guy.arieli & Golan Derazon | [
"Utility",
"class",
"for",
"classpath",
"related",
"operations",
".",
"@author",
"guy",
".",
"arieli",
"&",
"Golan",
"Derazon"
] | public class ClassSearchUtil {
/**
* Used to scan a class path (jars and folders) and search for a specific implementation for a class.
* @param ofType the class to search implementations for.
* @param classPath the class path to search in.
* @param filterAbstract if set to true will filter abstract implementations.
* @param ignoreList a list of string that if found in the class path element name will ignore it.
* @return an array with all the class name implementations found.
* @throws Exception when the search process fail.
*/
public static ArrayList<String> searchClasses(Class<?> ofType, String classPath, boolean filterAbstract, String[] ignoreList, String[] includeList) throws Exception{
GeneralCollector gc = new GeneralCollector(ofType, classPath, filterAbstract, ignoreList, includeList);
ArrayList<String> tv = gc.collectTestsVector();
return tv;
}
/**
* Fetches a property from a properties file in the classpath.
* If properties file not founf in class path the method throws an <code>IOException</code>.
* If property doesn't exist in properties file, <code>null</code> is returned.
* @param propertyFileResourcePath path of the properties file in the class path
* @param name of property to fetch
*/
public static String getPropertyFromClassPath(String propertyFileResourcePath,String propertyName ) throws Exception {
Properties p = new Properties();
InputStream inStream = null;
try {
inStream = ClassSearchUtil.class.getClassLoader().getResourceAsStream(propertyFileResourcePath);
if (inStream == null){
throw new IOException("Property file not found in classpath. " + propertyFileResourcePath );
}
p.load(inStream);
} finally{
if (inStream != null){
inStream.close();
}
}
return p.getProperty(propertyName);
}
} | [
"public",
"class",
"ClassSearchUtil",
"{",
"/**\n\t * Used to scan a class path (jars and folders) and search for a specific implementation for a class.\n\t * @param ofType the class to search implementations for.\n\t * @param classPath the class path to search in.\n\t * @param filterAbstract if set to true will filter abstract implementations.\n\t * @param ignoreList a list of string that if found in the class path element name will ignore it.\n\t * @return an array with all the class name implementations found.\n\t * @throws Exception when the search process fail.\n\t */",
"public",
"static",
"ArrayList",
"<",
"String",
">",
"searchClasses",
"(",
"Class",
"<",
"?",
">",
"ofType",
",",
"String",
"classPath",
",",
"boolean",
"filterAbstract",
",",
"String",
"[",
"]",
"ignoreList",
",",
"String",
"[",
"]",
"includeList",
")",
"throws",
"Exception",
"{",
"GeneralCollector",
"gc",
"=",
"new",
"GeneralCollector",
"(",
"ofType",
",",
"classPath",
",",
"filterAbstract",
",",
"ignoreList",
",",
"includeList",
")",
";",
"ArrayList",
"<",
"String",
">",
"tv",
"=",
"gc",
".",
"collectTestsVector",
"(",
")",
";",
"return",
"tv",
";",
"}",
"/**\n\t * Fetches a property from a properties file in the classpath.\n\t * If properties file not founf in class path the method throws an <code>IOException</code>.\n\t * If property doesn't exist in properties file, <code>null</code> is returned.\n\t * @param propertyFileResourcePath path of the properties file in the class path\n\t * @param name of property to fetch\n\t */",
"public",
"static",
"String",
"getPropertyFromClassPath",
"(",
"String",
"propertyFileResourcePath",
",",
"String",
"propertyName",
")",
"throws",
"Exception",
"{",
"Properties",
"p",
"=",
"new",
"Properties",
"(",
")",
";",
"InputStream",
"inStream",
"=",
"null",
";",
"try",
"{",
"inStream",
"=",
"ClassSearchUtil",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"propertyFileResourcePath",
")",
";",
"if",
"(",
"inStream",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"",
"Property file not found in classpath. ",
"\"",
"+",
"propertyFileResourcePath",
")",
";",
"}",
"p",
".",
"load",
"(",
"inStream",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"inStream",
"!=",
"null",
")",
"{",
"inStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"return",
"p",
".",
"getProperty",
"(",
"propertyName",
")",
";",
"}",
"}"
] | Utility class for classpath related operations. | [
"Utility",
"class",
"for",
"classpath",
"related",
"operations",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1eadf1a3c2febdef83481d07646fc86fbcf0cbb6 | amirico/wisematches | modules/web/src/main/java/wisematches/server/web/security/web/WMAuthenticationFailureHandler.java | [
"Apache-2.0"
] | Java | WMAuthenticationFailureHandler | /**
* This is mix of SimpleUrlAuthenticationFailureHandler and ExceptionMappingAuthenticationFailureHandler because
* both of them can't be extended.
* <p/>
* See https://jira.springsource.org/browse/SEC-1821?focusedCommentId=74587#comment-74587 to get more info.
*
* @author Sergey Klimenko ([email protected])
* @see org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
* @see org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler
*/ | This is mix of SimpleUrlAuthenticationFailureHandler and ExceptionMappingAuthenticationFailureHandler because
both of them can't be extended.
| [
"This",
"is",
"mix",
"of",
"SimpleUrlAuthenticationFailureHandler",
"and",
"ExceptionMappingAuthenticationFailureHandler",
"because",
"both",
"of",
"them",
"can",
"'",
"t",
"be",
"extended",
"."
] | public class WMAuthenticationFailureHandler implements AuthenticationFailureHandler {
private String failureUrl;
// private String defaultFailureUrl;
private String defaultCode = "system";
private final Map<Class, String> exceptionCodes = new HashMap<>();
private boolean allowSessionCreation = true;
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
// private final Map<String, String> failureUrlMap = new HashMap<>();
private static final Logger log = LoggerFactory.getLogger("wisematches.web.security.AuthenticationFailureHandler");
public WMAuthenticationFailureHandler() {
}
/**
* Performs the redirect or forward to the {@code defaultFailureUrl} if set, otherwise returns a 401 error code.
* <p/>
* If redirecting or forwarding, {@code saveException} will be called to cache the exception for use in
* the target view.
*/
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException exception) throws IOException, ServletException {
String code = getExceptionCode(exception.getClass());
if (code != null) {
redirect(request, response, failureUrl + code, exception);
} else if (defaultCode != null) {
redirect(request, response, failureUrl + defaultCode, exception);
} else {
log.debug("No failure URL set, sending 401 Unauthorized error");
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authentication Failed: " + exception.getMessage());
}
}
protected void redirect(HttpServletRequest request, HttpServletResponse response, String url, AuthenticationException exception) throws IOException {
saveException(request, exception);
log.debug("Redirecting to {}", url);
redirectStrategy.sendRedirect(request, response, url);
}
protected void saveException(HttpServletRequest request, AuthenticationException exception) {
HttpSession session = request.getSession(false);
if (session != null || allowSessionCreation) {
request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
}
}
public void setFailureUrl(String failureUrl) {
this.failureUrl = failureUrl;
}
public void setDefaultCode(String defaultCode) {
this.defaultCode = defaultCode;
}
protected RedirectStrategy getRedirectStrategy() {
return redirectStrategy;
}
public void setRedirectStrategy(RedirectStrategy redirectStrategy) {
this.redirectStrategy = redirectStrategy;
}
protected boolean isAllowSessionCreation() {
return allowSessionCreation;
}
public void setAllowSessionCreation(boolean allowSessionCreation) {
this.allowSessionCreation = allowSessionCreation;
}
public String getExceptionCode(Class clazz) {
final String s = exceptionCodes.get(clazz);
if (s == null) {
return getExceptionCode(clazz.getSuperclass());
}
return s;
}
public void setExceptionCodes(Map<Class, String> exceptionCodes) {
this.exceptionCodes.clear();
for (Map.Entry<Class, String> entry : exceptionCodes.entrySet()) {
Class clazz = entry.getKey();
String code = entry.getValue();
this.exceptionCodes.put(clazz, code);
}
}
public Map<Class, String> getExceptionCodes() {
return exceptionCodes;
}
} | [
"public",
"class",
"WMAuthenticationFailureHandler",
"implements",
"AuthenticationFailureHandler",
"{",
"private",
"String",
"failureUrl",
";",
"private",
"String",
"defaultCode",
"=",
"\"",
"system",
"\"",
";",
"private",
"final",
"Map",
"<",
"Class",
",",
"String",
">",
"exceptionCodes",
"=",
"new",
"HashMap",
"<",
">",
"(",
")",
";",
"private",
"boolean",
"allowSessionCreation",
"=",
"true",
";",
"private",
"RedirectStrategy",
"redirectStrategy",
"=",
"new",
"DefaultRedirectStrategy",
"(",
")",
";",
"private",
"static",
"final",
"Logger",
"log",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"\"",
"wisematches.web.security.AuthenticationFailureHandler",
"\"",
")",
";",
"public",
"WMAuthenticationFailureHandler",
"(",
")",
"{",
"}",
"/**\r\n\t * Performs the redirect or forward to the {@code defaultFailureUrl} if set, otherwise returns a 401 error code.\r\n\t * <p/>\r\n\t * If redirecting or forwarding, {@code saveException} will be called to cache the exception for use in\r\n\t * the target view.\r\n\t */",
"public",
"void",
"onAuthenticationFailure",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"AuthenticationException",
"exception",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"String",
"code",
"=",
"getExceptionCode",
"(",
"exception",
".",
"getClass",
"(",
")",
")",
";",
"if",
"(",
"code",
"!=",
"null",
")",
"{",
"redirect",
"(",
"request",
",",
"response",
",",
"failureUrl",
"+",
"code",
",",
"exception",
")",
";",
"}",
"else",
"if",
"(",
"defaultCode",
"!=",
"null",
")",
"{",
"redirect",
"(",
"request",
",",
"response",
",",
"failureUrl",
"+",
"defaultCode",
",",
"exception",
")",
";",
"}",
"else",
"{",
"log",
".",
"debug",
"(",
"\"",
"No failure URL set, sending 401 Unauthorized error",
"\"",
")",
";",
"response",
".",
"sendError",
"(",
"HttpServletResponse",
".",
"SC_UNAUTHORIZED",
",",
"\"",
"Authentication Failed: ",
"\"",
"+",
"exception",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"protected",
"void",
"redirect",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"url",
",",
"AuthenticationException",
"exception",
")",
"throws",
"IOException",
"{",
"saveException",
"(",
"request",
",",
"exception",
")",
";",
"log",
".",
"debug",
"(",
"\"",
"Redirecting to {}",
"\"",
",",
"url",
")",
";",
"redirectStrategy",
".",
"sendRedirect",
"(",
"request",
",",
"response",
",",
"url",
")",
";",
"}",
"protected",
"void",
"saveException",
"(",
"HttpServletRequest",
"request",
",",
"AuthenticationException",
"exception",
")",
"{",
"HttpSession",
"session",
"=",
"request",
".",
"getSession",
"(",
"false",
")",
";",
"if",
"(",
"session",
"!=",
"null",
"||",
"allowSessionCreation",
")",
"{",
"request",
".",
"getSession",
"(",
")",
".",
"setAttribute",
"(",
"WebAttributes",
".",
"AUTHENTICATION_EXCEPTION",
",",
"exception",
")",
";",
"}",
"}",
"public",
"void",
"setFailureUrl",
"(",
"String",
"failureUrl",
")",
"{",
"this",
".",
"failureUrl",
"=",
"failureUrl",
";",
"}",
"public",
"void",
"setDefaultCode",
"(",
"String",
"defaultCode",
")",
"{",
"this",
".",
"defaultCode",
"=",
"defaultCode",
";",
"}",
"protected",
"RedirectStrategy",
"getRedirectStrategy",
"(",
")",
"{",
"return",
"redirectStrategy",
";",
"}",
"public",
"void",
"setRedirectStrategy",
"(",
"RedirectStrategy",
"redirectStrategy",
")",
"{",
"this",
".",
"redirectStrategy",
"=",
"redirectStrategy",
";",
"}",
"protected",
"boolean",
"isAllowSessionCreation",
"(",
")",
"{",
"return",
"allowSessionCreation",
";",
"}",
"public",
"void",
"setAllowSessionCreation",
"(",
"boolean",
"allowSessionCreation",
")",
"{",
"this",
".",
"allowSessionCreation",
"=",
"allowSessionCreation",
";",
"}",
"public",
"String",
"getExceptionCode",
"(",
"Class",
"clazz",
")",
"{",
"final",
"String",
"s",
"=",
"exceptionCodes",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"s",
"==",
"null",
")",
"{",
"return",
"getExceptionCode",
"(",
"clazz",
".",
"getSuperclass",
"(",
")",
")",
";",
"}",
"return",
"s",
";",
"}",
"public",
"void",
"setExceptionCodes",
"(",
"Map",
"<",
"Class",
",",
"String",
">",
"exceptionCodes",
")",
"{",
"this",
".",
"exceptionCodes",
".",
"clear",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Class",
",",
"String",
">",
"entry",
":",
"exceptionCodes",
".",
"entrySet",
"(",
")",
")",
"{",
"Class",
"clazz",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"String",
"code",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"this",
".",
"exceptionCodes",
".",
"put",
"(",
"clazz",
",",
"code",
")",
";",
"}",
"}",
"public",
"Map",
"<",
"Class",
",",
"String",
">",
"getExceptionCodes",
"(",
")",
"{",
"return",
"exceptionCodes",
";",
"}",
"}"
] | This is mix of SimpleUrlAuthenticationFailureHandler and ExceptionMappingAuthenticationFailureHandler because
both of them can't be extended. | [
"This",
"is",
"mix",
"of",
"SimpleUrlAuthenticationFailureHandler",
"and",
"ExceptionMappingAuthenticationFailureHandler",
"because",
"both",
"of",
"them",
"can",
"'",
"t",
"be",
"extended",
"."
] | [
"//\tprivate String defaultFailureUrl;\r",
"//\tprivate final Map<String, String> failureUrlMap = new HashMap<>();\r"
] | [
{
"param": "AuthenticationFailureHandler",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AuthenticationFailureHandler",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1eb4d417547d2024e0e4061184790b479a702df6 | kermitt2/grobid-quantities | src/main/java/org/grobid/core/utilities/MeasurementOperations.java | [
"Apache-2.0"
] | Java | MeasurementOperations | /**
* Measurement operations and utilities class
*/ | Measurement operations and utilities class | [
"Measurement",
"operations",
"and",
"utilities",
"class"
] | public class MeasurementOperations {
private static final Logger logger = LoggerFactory.getLogger(MeasurementOperations.class);
private UnitNormalizer un;
public MeasurementOperations() {
un = new UnitNormalizer();
}
public MeasurementOperations(UnitNormalizer un) {
this.un = un;
}
/**
* Check if the given list of measures are well formed:
* In particular, if intervals are not consistent, they are transformed
* in atomic value measurements.
*/
public static List<Measurement> postCorrection(List<Measurement> measurements) {
List<Measurement> newMeasurements = new ArrayList<>();
for (Measurement measurement : measurements) {
if (measurement.getType() == UnitUtilities.Measurement_Type.VALUE) {
Quantity quantity = measurement.getQuantityAtomic();
if (quantity == null)
continue;
// if the unit is too far from the value, the measurement needs to be filtered out
int start = quantity.getOffsetStart();
int end = quantity.getOffsetEnd();
Unit rawUnit = quantity.getRawUnit();
if (rawUnit != null) {
int startU = rawUnit.getOffsetStart();
int endU = rawUnit.getOffsetEnd();
if ((Math.abs(end - startU) < 40) || (Math.abs(endU - start) < 40)) {
newMeasurements.add(measurement);
}
} else
newMeasurements.add(measurement);
} else if ((measurement.getType() == UnitUtilities.Measurement_Type.INTERVAL_MIN_MAX) ||
(measurement.getType() == UnitUtilities.Measurement_Type.INTERVAL_BASE_RANGE)) {
// values of the interval do not matter if min/max or base/range
Quantity quantityLeast = measurement.getQuantityLeast();
if (quantityLeast == null)
quantityLeast = measurement.getQuantityBase();
Quantity quantityMost = measurement.getQuantityMost();
if (quantityMost == null)
quantityMost = measurement.getQuantityRange();
if ((quantityLeast == null) && (quantityMost == null))
continue;
/*if (((quantityLeast != null) && (quantityMost == null)) || ((quantityLeast == null) && (quantityMost != null))) {
Measurement newMeasurement = new Measurement(UnitUtilities.Measurement_Type.VALUES);
Quantity quantity = null;
if (quantityLeast != null) {
quantity = quantityLeast;
} else if (quantityMost != null) {
quantity = quantityMost;
}
if (quantity != null) {
newMeasurement.setAtomicQuantity(quantity);
newMeasurements.add(newMeasurement);
}
} else*/
if ((quantityLeast != null) && (quantityMost != null)) {
// if the interval is expressed over a chunck of text which is too large, it is a recognition error
// and we can replace it by two atomic measurements
int startL = quantityLeast.getOffsetStart();
int endL = quantityLeast.getOffsetEnd();
int startM = quantityMost.getOffsetStart();
int endM = quantityMost.getOffsetEnd();
if ((Math.abs(endL - startM) > 80) && (Math.abs(endM - startL) > 80)) {
// we replace the interval measurement by two atomic measurements
Measurement newMeasurement = new Measurement(UnitUtilities.Measurement_Type.VALUE);
// have to check the position of value and unit for valid atomic measure
Unit rawUnit = quantityLeast.getRawUnit();
if (rawUnit != null) {
int startU = rawUnit.getOffsetStart();
int endU = rawUnit.getOffsetEnd();
if ((Math.abs(endL - startU) < 40) || (Math.abs(endU - startL) < 40)) {
newMeasurement.setAtomicQuantity(quantityLeast);
newMeasurements.add(newMeasurement);
}
} else {
newMeasurement.setAtomicQuantity(quantityLeast);
newMeasurements.add(newMeasurement);
}
newMeasurement = new Measurement(UnitUtilities.Measurement_Type.VALUE);
rawUnit = quantityMost.getRawUnit();
if (rawUnit != null) {
int startU = rawUnit.getOffsetStart();
int endU = rawUnit.getOffsetEnd();
if ((Math.abs(endM - startU) < 40) || (Math.abs(endU - startM) < 40)) {
newMeasurement.setAtomicQuantity(quantityMost);
newMeasurements.add(newMeasurement);
}
} else {
newMeasurement.setAtomicQuantity(quantityMost);
newMeasurements.add(newMeasurement);
}
} else {
newMeasurements.add(measurement);
}
} else {
newMeasurements.add(measurement);
}
} else if (measurement.getType() == UnitUtilities.Measurement_Type.CONJUNCTION) {
// list must be consistent in unit type, and avoid too large chunk
List<Quantity> quantities = measurement.getQuantityList();
if ((quantities == null) || (quantities.size() == 0))
continue;
/* // case actually not seen
Unit currentUnit = null;
Measurement newMeasurement = new Measurement(UnitUtilities.Measurement_Type.CONJUNCTION);
for(Quantity quantity : quantities) {
if (currentUnit == null)
currentUnit = quantity.getRawUnit();
else {
Unit newUnit = quantity.getRawUnit();
// is it a new unit?
if ((currentUnit != null) && (newUnit != null) && (!currentUnit.getRawName().equals(newUnit.getRawName())) ) {
// we have a new unit, so we split the list
if ( (newMeasurement != null) && (newMeasurement.getQuantities() != null) && (newMeasurement.getQuantities().size() > 0) )
newMeasurements.add(newMeasurement);
newMeasurement = new Measurement(UnitUtilities.Measurement_Type.CONJUNCTION);
newMeasurement.addQuantity(quantity);
currentUnit = newUnit;
}
else {
// same unit, we extend the current list
newMeasurement.addQuantity(quantity);
}
}
}
if ( (newMeasurement != null) && (newMeasurement.getQuantities() != null) && (newMeasurement.getQuantities().size() > 0) )
newMeasurements.add(newMeasurement);*/
// the case of atomic values within list should be cover here
// in this case, we have a list followed by an atomic value, then a following list without unit attachment, with possibly
// only one quantity - the correction is to extend the starting list with the remaining list after the atomic value, attaching
// the unit associated to the starting list to the added quantities
newMeasurements.add(measurement);
}
}
return newMeasurements;
}
/**
* Right now, only basic matching of units based on lexicon look-up and value validation
* via regex.
*/
public List<Measurement> resolveMeasurement(List<Measurement> measurements) {
for (Measurement measurement : measurements) {
if (measurement.getType() == null)
continue;
else if (measurement.getType() == UnitUtilities.Measurement_Type.VALUE) {
updateQuantity(measurement.getQuantityAtomic());
} else if (measurement.getType() == UnitUtilities.Measurement_Type.INTERVAL_MIN_MAX) {
updateQuantity(measurement.getQuantityLeast());
updateQuantity(measurement.getQuantityMost());
} else if (measurement.getType() == UnitUtilities.Measurement_Type.INTERVAL_BASE_RANGE) {
updateQuantity(measurement.getQuantityBase());
updateQuantity(measurement.getQuantityRange());
// the two quantities below are normally not yet set-up
//updateQuantity(measurement.getQuantityLeast());
//updateQuantity(measurement.getQuantityMost());
} else if (measurement.getType() == UnitUtilities.Measurement_Type.CONJUNCTION) {
if (measurement.getQuantityList() != null) {
for (Quantity quantity : measurement.getQuantityList()) {
if (quantity == null)
continue;
updateQuantity(quantity);
}
}
}
}
return measurements;
}
private void updateQuantity(Quantity quantity) {
if ((quantity != null) && (!quantity.isEmpty())) {
Unit rawUnit = quantity.getRawUnit();
UnitDefinition foundUnit = un.findDefinition(rawUnit);
if (foundUnit != null) {
rawUnit.setUnitDefinition(foundUnit);
}
}
}
public static int WINDOW_TC = 20;
/* We work with offsets (so no need to increase by size of the text) and we return indexes in the token list */
protected Pair<Integer, Integer> getExtremitiesAsIndex(List<LayoutToken> tokens, int centroidOffsetLower, int centroidOffsetHigher) {
return getExtremitiesAsIndex(tokens, centroidOffsetLower, centroidOffsetHigher, WINDOW_TC);
}
protected Pair<Integer, Integer> getExtremitiesAsIndex(List<LayoutToken> tokens, int centroidOffsetLower, int centroidOffsetHigher, int windowlayoutTokensSize) {
int start = 0;
int end = tokens.size() - 1;
List<LayoutToken> centralTokens = tokens.stream().filter(layoutToken -> layoutToken.getOffset() == centroidOffsetLower || (layoutToken.getOffset() > centroidOffsetLower && layoutToken.getOffset() < centroidOffsetHigher)).collect(Collectors.toList());
if (isNotEmpty(centralTokens)) {
int centroidLayoutTokenIndexStart = tokens.indexOf(centralTokens.get(0));
int centroidLayoutTokenIndexEnd = tokens.indexOf(centralTokens.get(centralTokens.size() - 1));
if (centroidLayoutTokenIndexStart > windowlayoutTokensSize) {
start = centroidLayoutTokenIndexStart - windowlayoutTokensSize;
}
if (end - centroidLayoutTokenIndexEnd > windowlayoutTokensSize) {
end = centroidLayoutTokenIndexEnd + windowlayoutTokensSize + 1;
}
}
return new ImmutablePair(start, end);
}
/**
* Return measurement extremities as the index of the layout token. It's useful if we want to combine
* measurement and layoutToken content.
*/
public Pair<Integer, Integer> calculateQuantityExtremities(List<LayoutToken> tokens, Measurement measurement) {
Pair<Integer, Integer> extremities = null;
switch (measurement.getType()) {
case VALUE:
Quantity quantity = measurement.getQuantityAtomic();
List<LayoutToken> layoutTokens = quantity.getLayoutTokens();
extremities = getExtremitiesAsIndex(tokens, layoutTokens.get(0).getOffset(), layoutTokens.get(layoutTokens.size() - 1).getOffset());
break;
case INTERVAL_BASE_RANGE:
if (measurement.getQuantityBase() != null && measurement.getQuantityRange() != null) {
Quantity quantityBase = measurement.getQuantityBase();
Quantity quantityRange = measurement.getQuantityRange();
extremities = getExtremitiesAsIndex(tokens, quantityBase.getLayoutTokens().get(0).getOffset(), quantityRange.getLayoutTokens().get(quantityRange.getLayoutTokens().size() - 1).getOffset());
} else {
Quantity quantityTmp;
if (measurement.getQuantityBase() == null) {
quantityTmp = measurement.getQuantityRange();
} else {
quantityTmp = measurement.getQuantityBase();
}
extremities = getExtremitiesAsIndex(tokens, quantityTmp.getLayoutTokens().get(0).getOffset(), quantityTmp.getLayoutTokens().get(0).getOffset());
}
break;
case INTERVAL_MIN_MAX:
if (measurement.getQuantityLeast() != null && measurement.getQuantityMost() != null) {
Quantity quantityLeast = measurement.getQuantityLeast();
Quantity quantityMost = measurement.getQuantityMost();
extremities = getExtremitiesAsIndex(tokens, quantityLeast.getLayoutTokens().get(0).getOffset(), quantityMost.getLayoutTokens().get(quantityMost.getLayoutTokens().size() - 1).getOffset());
} else {
Quantity quantityTmp;
if (measurement.getQuantityLeast() == null) {
quantityTmp = measurement.getQuantityMost();
} else {
quantityTmp = measurement.getQuantityLeast();
}
extremities = getExtremitiesAsIndex(tokens, quantityTmp.getLayoutTokens().get(0).getOffset(), quantityTmp.getLayoutTokens().get(quantityTmp.getLayoutTokens().size() - 1).getOffset());
}
break;
case CONJUNCTION:
List<Quantity> quantityList = measurement.getQuantityList();
if (quantityList.size() > 1) {
extremities = getExtremitiesAsIndex(tokens, quantityList.get(0).getLayoutTokens().get(0).getOffset(), quantityList.get(quantityList.size() - 1).getLayoutTokens().get(0).getOffset());
} else {
extremities = getExtremitiesAsIndex(tokens, quantityList.get(0).getLayoutTokens().get(0).getOffset(), quantityList.get(0).getLayoutTokens().get(0).getOffset());
}
break;
}
return extremities;
}
/**
* Return the offset of the measurement - useful for matching into sentences or lexicons
*/
public OffsetPosition calculateExtremitiesOffsets(Measurement measurement) {
List<OffsetPosition> offsets = new ArrayList<>();
switch (measurement.getType()) {
case VALUE:
CollectionUtils.addAll(offsets, QuantityOperations.getOffsets(measurement.getQuantityAtomic()));
break;
case INTERVAL_BASE_RANGE:
CollectionUtils.addAll(offsets, QuantityOperations.getOffsets(measurement.getQuantityBase()));
CollectionUtils.addAll(offsets, QuantityOperations.getOffsets(measurement.getQuantityRange()));
break;
case INTERVAL_MIN_MAX:
CollectionUtils.addAll(offsets, QuantityOperations.getOffsets(measurement.getQuantityLeast()));
CollectionUtils.addAll(offsets, QuantityOperations.getOffsets(measurement.getQuantityMost()));
break;
case CONJUNCTION:
CollectionUtils.addAll(offsets, QuantityOperations.getOffsets(measurement.getQuantityList()));
break;
}
return QuantityOperations.getContainingOffset(offsets);
}
} | [
"public",
"class",
"MeasurementOperations",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"MeasurementOperations",
".",
"class",
")",
";",
"private",
"UnitNormalizer",
"un",
";",
"public",
"MeasurementOperations",
"(",
")",
"{",
"un",
"=",
"new",
"UnitNormalizer",
"(",
")",
";",
"}",
"public",
"MeasurementOperations",
"(",
"UnitNormalizer",
"un",
")",
"{",
"this",
".",
"un",
"=",
"un",
";",
"}",
"/**\n * Check if the given list of measures are well formed:\n * In particular, if intervals are not consistent, they are transformed\n * in atomic value measurements.\n */",
"public",
"static",
"List",
"<",
"Measurement",
">",
"postCorrection",
"(",
"List",
"<",
"Measurement",
">",
"measurements",
")",
"{",
"List",
"<",
"Measurement",
">",
"newMeasurements",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"for",
"(",
"Measurement",
"measurement",
":",
"measurements",
")",
"{",
"if",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"VALUE",
")",
"{",
"Quantity",
"quantity",
"=",
"measurement",
".",
"getQuantityAtomic",
"(",
")",
";",
"if",
"(",
"quantity",
"==",
"null",
")",
"continue",
";",
"int",
"start",
"=",
"quantity",
".",
"getOffsetStart",
"(",
")",
";",
"int",
"end",
"=",
"quantity",
".",
"getOffsetEnd",
"(",
")",
";",
"Unit",
"rawUnit",
"=",
"quantity",
".",
"getRawUnit",
"(",
")",
";",
"if",
"(",
"rawUnit",
"!=",
"null",
")",
"{",
"int",
"startU",
"=",
"rawUnit",
".",
"getOffsetStart",
"(",
")",
";",
"int",
"endU",
"=",
"rawUnit",
".",
"getOffsetEnd",
"(",
")",
";",
"if",
"(",
"(",
"Math",
".",
"abs",
"(",
"end",
"-",
"startU",
")",
"<",
"40",
")",
"||",
"(",
"Math",
".",
"abs",
"(",
"endU",
"-",
"start",
")",
"<",
"40",
")",
")",
"{",
"newMeasurements",
".",
"add",
"(",
"measurement",
")",
";",
"}",
"}",
"else",
"newMeasurements",
".",
"add",
"(",
"measurement",
")",
";",
"}",
"else",
"if",
"(",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"INTERVAL_MIN_MAX",
")",
"||",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"INTERVAL_BASE_RANGE",
")",
")",
"{",
"Quantity",
"quantityLeast",
"=",
"measurement",
".",
"getQuantityLeast",
"(",
")",
";",
"if",
"(",
"quantityLeast",
"==",
"null",
")",
"quantityLeast",
"=",
"measurement",
".",
"getQuantityBase",
"(",
")",
";",
"Quantity",
"quantityMost",
"=",
"measurement",
".",
"getQuantityMost",
"(",
")",
";",
"if",
"(",
"quantityMost",
"==",
"null",
")",
"quantityMost",
"=",
"measurement",
".",
"getQuantityRange",
"(",
")",
";",
"if",
"(",
"(",
"quantityLeast",
"==",
"null",
")",
"&&",
"(",
"quantityMost",
"==",
"null",
")",
")",
"continue",
";",
"/*if (((quantityLeast != null) && (quantityMost == null)) || ((quantityLeast == null) && (quantityMost != null))) {\n Measurement newMeasurement = new Measurement(UnitUtilities.Measurement_Type.VALUES);\n Quantity quantity = null;\n if (quantityLeast != null) {\n quantity = quantityLeast;\n } else if (quantityMost != null) {\n quantity = quantityMost;\n }\n if (quantity != null) {\n newMeasurement.setAtomicQuantity(quantity);\n newMeasurements.add(newMeasurement);\n }\n } else*/",
"if",
"(",
"(",
"quantityLeast",
"!=",
"null",
")",
"&&",
"(",
"quantityMost",
"!=",
"null",
")",
")",
"{",
"int",
"startL",
"=",
"quantityLeast",
".",
"getOffsetStart",
"(",
")",
";",
"int",
"endL",
"=",
"quantityLeast",
".",
"getOffsetEnd",
"(",
")",
";",
"int",
"startM",
"=",
"quantityMost",
".",
"getOffsetStart",
"(",
")",
";",
"int",
"endM",
"=",
"quantityMost",
".",
"getOffsetEnd",
"(",
")",
";",
"if",
"(",
"(",
"Math",
".",
"abs",
"(",
"endL",
"-",
"startM",
")",
">",
"80",
")",
"&&",
"(",
"Math",
".",
"abs",
"(",
"endM",
"-",
"startL",
")",
">",
"80",
")",
")",
"{",
"Measurement",
"newMeasurement",
"=",
"new",
"Measurement",
"(",
"UnitUtilities",
".",
"Measurement_Type",
".",
"VALUE",
")",
";",
"Unit",
"rawUnit",
"=",
"quantityLeast",
".",
"getRawUnit",
"(",
")",
";",
"if",
"(",
"rawUnit",
"!=",
"null",
")",
"{",
"int",
"startU",
"=",
"rawUnit",
".",
"getOffsetStart",
"(",
")",
";",
"int",
"endU",
"=",
"rawUnit",
".",
"getOffsetEnd",
"(",
")",
";",
"if",
"(",
"(",
"Math",
".",
"abs",
"(",
"endL",
"-",
"startU",
")",
"<",
"40",
")",
"||",
"(",
"Math",
".",
"abs",
"(",
"endU",
"-",
"startL",
")",
"<",
"40",
")",
")",
"{",
"newMeasurement",
".",
"setAtomicQuantity",
"(",
"quantityLeast",
")",
";",
"newMeasurements",
".",
"add",
"(",
"newMeasurement",
")",
";",
"}",
"}",
"else",
"{",
"newMeasurement",
".",
"setAtomicQuantity",
"(",
"quantityLeast",
")",
";",
"newMeasurements",
".",
"add",
"(",
"newMeasurement",
")",
";",
"}",
"newMeasurement",
"=",
"new",
"Measurement",
"(",
"UnitUtilities",
".",
"Measurement_Type",
".",
"VALUE",
")",
";",
"rawUnit",
"=",
"quantityMost",
".",
"getRawUnit",
"(",
")",
";",
"if",
"(",
"rawUnit",
"!=",
"null",
")",
"{",
"int",
"startU",
"=",
"rawUnit",
".",
"getOffsetStart",
"(",
")",
";",
"int",
"endU",
"=",
"rawUnit",
".",
"getOffsetEnd",
"(",
")",
";",
"if",
"(",
"(",
"Math",
".",
"abs",
"(",
"endM",
"-",
"startU",
")",
"<",
"40",
")",
"||",
"(",
"Math",
".",
"abs",
"(",
"endU",
"-",
"startM",
")",
"<",
"40",
")",
")",
"{",
"newMeasurement",
".",
"setAtomicQuantity",
"(",
"quantityMost",
")",
";",
"newMeasurements",
".",
"add",
"(",
"newMeasurement",
")",
";",
"}",
"}",
"else",
"{",
"newMeasurement",
".",
"setAtomicQuantity",
"(",
"quantityMost",
")",
";",
"newMeasurements",
".",
"add",
"(",
"newMeasurement",
")",
";",
"}",
"}",
"else",
"{",
"newMeasurements",
".",
"add",
"(",
"measurement",
")",
";",
"}",
"}",
"else",
"{",
"newMeasurements",
".",
"add",
"(",
"measurement",
")",
";",
"}",
"}",
"else",
"if",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"CONJUNCTION",
")",
"{",
"List",
"<",
"Quantity",
">",
"quantities",
"=",
"measurement",
".",
"getQuantityList",
"(",
")",
";",
"if",
"(",
"(",
"quantities",
"==",
"null",
")",
"||",
"(",
"quantities",
".",
"size",
"(",
")",
"==",
"0",
")",
")",
"continue",
";",
"/* // case actually not seen\n Unit currentUnit = null;\n Measurement newMeasurement = new Measurement(UnitUtilities.Measurement_Type.CONJUNCTION);\n for(Quantity quantity : quantities) {\n if (currentUnit == null)\n currentUnit = quantity.getRawUnit();\n else {\n Unit newUnit = quantity.getRawUnit();\n\n // is it a new unit?\n if ((currentUnit != null) && (newUnit != null) && (!currentUnit.getRawName().equals(newUnit.getRawName())) ) {\n // we have a new unit, so we split the list\n if ( (newMeasurement != null) && (newMeasurement.getQuantities() != null) && (newMeasurement.getQuantities().size() > 0) )\n newMeasurements.add(newMeasurement);\n newMeasurement = new Measurement(UnitUtilities.Measurement_Type.CONJUNCTION);\n newMeasurement.addQuantity(quantity);\n currentUnit = newUnit;\n }\n else {\n // same unit, we extend the current list\n newMeasurement.addQuantity(quantity);\n }\n }\n\n }\n if ( (newMeasurement != null) && (newMeasurement.getQuantities() != null) && (newMeasurement.getQuantities().size() > 0) )\n newMeasurements.add(newMeasurement);*/",
"newMeasurements",
".",
"add",
"(",
"measurement",
")",
";",
"}",
"}",
"return",
"newMeasurements",
";",
"}",
"/**\n * Right now, only basic matching of units based on lexicon look-up and value validation\n * via regex.\n */",
"public",
"List",
"<",
"Measurement",
">",
"resolveMeasurement",
"(",
"List",
"<",
"Measurement",
">",
"measurements",
")",
"{",
"for",
"(",
"Measurement",
"measurement",
":",
"measurements",
")",
"{",
"if",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"null",
")",
"continue",
";",
"else",
"if",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"VALUE",
")",
"{",
"updateQuantity",
"(",
"measurement",
".",
"getQuantityAtomic",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"INTERVAL_MIN_MAX",
")",
"{",
"updateQuantity",
"(",
"measurement",
".",
"getQuantityLeast",
"(",
")",
")",
";",
"updateQuantity",
"(",
"measurement",
".",
"getQuantityMost",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"INTERVAL_BASE_RANGE",
")",
"{",
"updateQuantity",
"(",
"measurement",
".",
"getQuantityBase",
"(",
")",
")",
";",
"updateQuantity",
"(",
"measurement",
".",
"getQuantityRange",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"measurement",
".",
"getType",
"(",
")",
"==",
"UnitUtilities",
".",
"Measurement_Type",
".",
"CONJUNCTION",
")",
"{",
"if",
"(",
"measurement",
".",
"getQuantityList",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"Quantity",
"quantity",
":",
"measurement",
".",
"getQuantityList",
"(",
")",
")",
"{",
"if",
"(",
"quantity",
"==",
"null",
")",
"continue",
";",
"updateQuantity",
"(",
"quantity",
")",
";",
"}",
"}",
"}",
"}",
"return",
"measurements",
";",
"}",
"private",
"void",
"updateQuantity",
"(",
"Quantity",
"quantity",
")",
"{",
"if",
"(",
"(",
"quantity",
"!=",
"null",
")",
"&&",
"(",
"!",
"quantity",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"Unit",
"rawUnit",
"=",
"quantity",
".",
"getRawUnit",
"(",
")",
";",
"UnitDefinition",
"foundUnit",
"=",
"un",
".",
"findDefinition",
"(",
"rawUnit",
")",
";",
"if",
"(",
"foundUnit",
"!=",
"null",
")",
"{",
"rawUnit",
".",
"setUnitDefinition",
"(",
"foundUnit",
")",
";",
"}",
"}",
"}",
"public",
"static",
"int",
"WINDOW_TC",
"=",
"20",
";",
"/* We work with offsets (so no need to increase by size of the text) and we return indexes in the token list */",
"protected",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
"getExtremitiesAsIndex",
"(",
"List",
"<",
"LayoutToken",
">",
"tokens",
",",
"int",
"centroidOffsetLower",
",",
"int",
"centroidOffsetHigher",
")",
"{",
"return",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"centroidOffsetLower",
",",
"centroidOffsetHigher",
",",
"WINDOW_TC",
")",
";",
"}",
"protected",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
"getExtremitiesAsIndex",
"(",
"List",
"<",
"LayoutToken",
">",
"tokens",
",",
"int",
"centroidOffsetLower",
",",
"int",
"centroidOffsetHigher",
",",
"int",
"windowlayoutTokensSize",
")",
"{",
"int",
"start",
"=",
"0",
";",
"int",
"end",
"=",
"tokens",
".",
"size",
"(",
")",
"-",
"1",
";",
"List",
"<",
"LayoutToken",
">",
"centralTokens",
"=",
"tokens",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"layoutToken",
"->",
"layoutToken",
".",
"getOffset",
"(",
")",
"==",
"centroidOffsetLower",
"||",
"(",
"layoutToken",
".",
"getOffset",
"(",
")",
">",
"centroidOffsetLower",
"&&",
"layoutToken",
".",
"getOffset",
"(",
")",
"<",
"centroidOffsetHigher",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"if",
"(",
"isNotEmpty",
"(",
"centralTokens",
")",
")",
"{",
"int",
"centroidLayoutTokenIndexStart",
"=",
"tokens",
".",
"indexOf",
"(",
"centralTokens",
".",
"get",
"(",
"0",
")",
")",
";",
"int",
"centroidLayoutTokenIndexEnd",
"=",
"tokens",
".",
"indexOf",
"(",
"centralTokens",
".",
"get",
"(",
"centralTokens",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
";",
"if",
"(",
"centroidLayoutTokenIndexStart",
">",
"windowlayoutTokensSize",
")",
"{",
"start",
"=",
"centroidLayoutTokenIndexStart",
"-",
"windowlayoutTokensSize",
";",
"}",
"if",
"(",
"end",
"-",
"centroidLayoutTokenIndexEnd",
">",
"windowlayoutTokensSize",
")",
"{",
"end",
"=",
"centroidLayoutTokenIndexEnd",
"+",
"windowlayoutTokensSize",
"+",
"1",
";",
"}",
"}",
"return",
"new",
"ImmutablePair",
"(",
"start",
",",
"end",
")",
";",
"}",
"/**\n * Return measurement extremities as the index of the layout token. It's useful if we want to combine\n * measurement and layoutToken content.\n */",
"public",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
"calculateQuantityExtremities",
"(",
"List",
"<",
"LayoutToken",
">",
"tokens",
",",
"Measurement",
"measurement",
")",
"{",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
"extremities",
"=",
"null",
";",
"switch",
"(",
"measurement",
".",
"getType",
"(",
")",
")",
"{",
"case",
"VALUE",
":",
"Quantity",
"quantity",
"=",
"measurement",
".",
"getQuantityAtomic",
"(",
")",
";",
"List",
"<",
"LayoutToken",
">",
"layoutTokens",
"=",
"quantity",
".",
"getLayoutTokens",
"(",
")",
";",
"extremities",
"=",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"layoutTokens",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
",",
"layoutTokens",
".",
"get",
"(",
"layoutTokens",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"getOffset",
"(",
")",
")",
";",
"break",
";",
"case",
"INTERVAL_BASE_RANGE",
":",
"if",
"(",
"measurement",
".",
"getQuantityBase",
"(",
")",
"!=",
"null",
"&&",
"measurement",
".",
"getQuantityRange",
"(",
")",
"!=",
"null",
")",
"{",
"Quantity",
"quantityBase",
"=",
"measurement",
".",
"getQuantityBase",
"(",
")",
";",
"Quantity",
"quantityRange",
"=",
"measurement",
".",
"getQuantityRange",
"(",
")",
";",
"extremities",
"=",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"quantityBase",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
",",
"quantityRange",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"quantityRange",
".",
"getLayoutTokens",
"(",
")",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"getOffset",
"(",
")",
")",
";",
"}",
"else",
"{",
"Quantity",
"quantityTmp",
";",
"if",
"(",
"measurement",
".",
"getQuantityBase",
"(",
")",
"==",
"null",
")",
"{",
"quantityTmp",
"=",
"measurement",
".",
"getQuantityRange",
"(",
")",
";",
"}",
"else",
"{",
"quantityTmp",
"=",
"measurement",
".",
"getQuantityBase",
"(",
")",
";",
"}",
"extremities",
"=",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"quantityTmp",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
",",
"quantityTmp",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
")",
";",
"}",
"break",
";",
"case",
"INTERVAL_MIN_MAX",
":",
"if",
"(",
"measurement",
".",
"getQuantityLeast",
"(",
")",
"!=",
"null",
"&&",
"measurement",
".",
"getQuantityMost",
"(",
")",
"!=",
"null",
")",
"{",
"Quantity",
"quantityLeast",
"=",
"measurement",
".",
"getQuantityLeast",
"(",
")",
";",
"Quantity",
"quantityMost",
"=",
"measurement",
".",
"getQuantityMost",
"(",
")",
";",
"extremities",
"=",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"quantityLeast",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
",",
"quantityMost",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"quantityMost",
".",
"getLayoutTokens",
"(",
")",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"getOffset",
"(",
")",
")",
";",
"}",
"else",
"{",
"Quantity",
"quantityTmp",
";",
"if",
"(",
"measurement",
".",
"getQuantityLeast",
"(",
")",
"==",
"null",
")",
"{",
"quantityTmp",
"=",
"measurement",
".",
"getQuantityMost",
"(",
")",
";",
"}",
"else",
"{",
"quantityTmp",
"=",
"measurement",
".",
"getQuantityLeast",
"(",
")",
";",
"}",
"extremities",
"=",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"quantityTmp",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
",",
"quantityTmp",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"quantityTmp",
".",
"getLayoutTokens",
"(",
")",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"getOffset",
"(",
")",
")",
";",
"}",
"break",
";",
"case",
"CONJUNCTION",
":",
"List",
"<",
"Quantity",
">",
"quantityList",
"=",
"measurement",
".",
"getQuantityList",
"(",
")",
";",
"if",
"(",
"quantityList",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"extremities",
"=",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"quantityList",
".",
"get",
"(",
"0",
")",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
",",
"quantityList",
".",
"get",
"(",
"quantityList",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
")",
";",
"}",
"else",
"{",
"extremities",
"=",
"getExtremitiesAsIndex",
"(",
"tokens",
",",
"quantityList",
".",
"get",
"(",
"0",
")",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
",",
"quantityList",
".",
"get",
"(",
"0",
")",
".",
"getLayoutTokens",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getOffset",
"(",
")",
")",
";",
"}",
"break",
";",
"}",
"return",
"extremities",
";",
"}",
"/**\n * Return the offset of the measurement - useful for matching into sentences or lexicons\n */",
"public",
"OffsetPosition",
"calculateExtremitiesOffsets",
"(",
"Measurement",
"measurement",
")",
"{",
"List",
"<",
"OffsetPosition",
">",
"offsets",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"switch",
"(",
"measurement",
".",
"getType",
"(",
")",
")",
"{",
"case",
"VALUE",
":",
"CollectionUtils",
".",
"addAll",
"(",
"offsets",
",",
"QuantityOperations",
".",
"getOffsets",
"(",
"measurement",
".",
"getQuantityAtomic",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"INTERVAL_BASE_RANGE",
":",
"CollectionUtils",
".",
"addAll",
"(",
"offsets",
",",
"QuantityOperations",
".",
"getOffsets",
"(",
"measurement",
".",
"getQuantityBase",
"(",
")",
")",
")",
";",
"CollectionUtils",
".",
"addAll",
"(",
"offsets",
",",
"QuantityOperations",
".",
"getOffsets",
"(",
"measurement",
".",
"getQuantityRange",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"INTERVAL_MIN_MAX",
":",
"CollectionUtils",
".",
"addAll",
"(",
"offsets",
",",
"QuantityOperations",
".",
"getOffsets",
"(",
"measurement",
".",
"getQuantityLeast",
"(",
")",
")",
")",
";",
"CollectionUtils",
".",
"addAll",
"(",
"offsets",
",",
"QuantityOperations",
".",
"getOffsets",
"(",
"measurement",
".",
"getQuantityMost",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"CONJUNCTION",
":",
"CollectionUtils",
".",
"addAll",
"(",
"offsets",
",",
"QuantityOperations",
".",
"getOffsets",
"(",
"measurement",
".",
"getQuantityList",
"(",
")",
")",
")",
";",
"break",
";",
"}",
"return",
"QuantityOperations",
".",
"getContainingOffset",
"(",
"offsets",
")",
";",
"}",
"}"
] | Measurement operations and utilities class | [
"Measurement",
"operations",
"and",
"utilities",
"class"
] | [
"// if the unit is too far from the value, the measurement needs to be filtered out",
"// values of the interval do not matter if min/max or base/range",
"// if the interval is expressed over a chunck of text which is too large, it is a recognition error",
"// and we can replace it by two atomic measurements",
"// we replace the interval measurement by two atomic measurements",
"// have to check the position of value and unit for valid atomic measure",
"// list must be consistent in unit type, and avoid too large chunk",
"// the case of atomic values within list should be cover here",
"// in this case, we have a list followed by an atomic value, then a following list without unit attachment, with possibly",
"// only one quantity - the correction is to extend the starting list with the remaining list after the atomic value, attaching",
"// the unit associated to the starting list to the added quantities",
"// the two quantities below are normally not yet set-up",
"//updateQuantity(measurement.getQuantityLeast());",
"//updateQuantity(measurement.getQuantityMost());"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1eb559fa701001acca7dce81d379c14a6351a4e5 | marcoromagnolo/ConfigurAll | src/test/java/configurall/test/AutoLoadTest.java | [
"Apache-2.0"
] | Java | AutoLoadTest | /**
* @author Marco Romagnolo
*/ | @author Marco Romagnolo | [
"@author",
"Marco",
"Romagnolo"
] | public class AutoLoadTest extends AbstractTest {
private static ConfigProperties myConfig;
private static FieldTypeBean bean;
@BeforeClass
public static void setUp() throws IOException, IllegalAccessException, InstantiationException {
Configuration configuration = ConfigFactory.getInstance();
myConfig = configuration.getProperties();
Assert.assertNotNull(myConfig);
bean = ConfigContext.newInstance(FieldTypeBean.class);
}
@Test
public void testClass() throws IOException, IllegalAccessException, InstantiationException {
Class<FieldTypeBean> clazz = ConfigContext.getClass(FieldTypeBean.class);
Assert.assertNotNull(clazz);
Object obj = clazz.newInstance();
Assert.assertNotNull(obj);
}
@Test
public void testProperties() {
System.out.print(myConfig.getPropertiesAsString());
}
@Test
public void testStatics() {
super.testStatics();
}
@Test
public void testFields() {
super.testFields(bean);
}
} | [
"public",
"class",
"AutoLoadTest",
"extends",
"AbstractTest",
"{",
"private",
"static",
"ConfigProperties",
"myConfig",
";",
"private",
"static",
"FieldTypeBean",
"bean",
";",
"@",
"BeforeClass",
"public",
"static",
"void",
"setUp",
"(",
")",
"throws",
"IOException",
",",
"IllegalAccessException",
",",
"InstantiationException",
"{",
"Configuration",
"configuration",
"=",
"ConfigFactory",
".",
"getInstance",
"(",
")",
";",
"myConfig",
"=",
"configuration",
".",
"getProperties",
"(",
")",
";",
"Assert",
".",
"assertNotNull",
"(",
"myConfig",
")",
";",
"bean",
"=",
"ConfigContext",
".",
"newInstance",
"(",
"FieldTypeBean",
".",
"class",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testClass",
"(",
")",
"throws",
"IOException",
",",
"IllegalAccessException",
",",
"InstantiationException",
"{",
"Class",
"<",
"FieldTypeBean",
">",
"clazz",
"=",
"ConfigContext",
".",
"getClass",
"(",
"FieldTypeBean",
".",
"class",
")",
";",
"Assert",
".",
"assertNotNull",
"(",
"clazz",
")",
";",
"Object",
"obj",
"=",
"clazz",
".",
"newInstance",
"(",
")",
";",
"Assert",
".",
"assertNotNull",
"(",
"obj",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testProperties",
"(",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"myConfig",
".",
"getPropertiesAsString",
"(",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testStatics",
"(",
")",
"{",
"super",
".",
"testStatics",
"(",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"testFields",
"(",
")",
"{",
"super",
".",
"testFields",
"(",
"bean",
")",
";",
"}",
"}"
] | @author Marco Romagnolo | [
"@author",
"Marco",
"Romagnolo"
] | [] | [
{
"param": "AbstractTest",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractTest",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ebd700da717901c111f6aa3a091c418d80c5acd | ScottZg/AndroidTest | AndroidTest/TestService/app/src/main/java/com/zhanggui/testservice/MyService.java | [
"MIT"
] | Java | MyService | /**
* Created by zhanggui on 2017/2/23.
*/ | Created by zhanggui on 2017/2/23. | [
"Created",
"by",
"zhanggui",
"on",
"2017",
"/",
"2",
"/",
"23",
"."
] | public class MyService extends Service {
private static final String TAG = "MyService";
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
Log.d(TAG, "onCreate: ");
super.onCreate();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand: ");
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
Log.d(TAG, "onDestroy: ");
super.onDestroy();
}
} | [
"public",
"class",
"MyService",
"extends",
"Service",
"{",
"private",
"static",
"final",
"String",
"TAG",
"=",
"\"",
"MyService",
"\"",
";",
"@",
"Override",
"public",
"IBinder",
"onBind",
"(",
"Intent",
"intent",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"void",
"onCreate",
"(",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"",
"onCreate: ",
"\"",
")",
";",
"super",
".",
"onCreate",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"onStartCommand",
"(",
"Intent",
"intent",
",",
"int",
"flags",
",",
"int",
"startId",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"",
"onStartCommand: ",
"\"",
")",
";",
"return",
"super",
".",
"onStartCommand",
"(",
"intent",
",",
"flags",
",",
"startId",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onDestroy",
"(",
")",
"{",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"",
"onDestroy: ",
"\"",
")",
";",
"super",
".",
"onDestroy",
"(",
")",
";",
"}",
"}"
] | Created by zhanggui on 2017/2/23. | [
"Created",
"by",
"zhanggui",
"on",
"2017",
"/",
"2",
"/",
"23",
"."
] | [] | [
{
"param": "Service",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Service",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ebdaa8c82e8504077d00bccba3fc0bba5e3d77b | ga-m3dv/ga-worldwind-suite | Viewer/src/experimental/java/au/gov/ga/worldwind/viewer/exporter/ExporterMessageConstants.java | [
"Apache-2.0"
] | Java | ExporterMessageConstants | /**
* Accesses constants for message keys for the exporter tool
*/ | Accesses constants for message keys for the exporter tool | [
"Accesses",
"constants",
"for",
"message",
"keys",
"for",
"the",
"exporter",
"tool"
] | public class ExporterMessageConstants
{
public static final String getExporterCreateOutputLocationErrorMsgKey() { return "exporter.command.error.missingparameters";}
public static final String getExporterMissingParametersErrorMsgKey() { return "exporter.command.error.createoutput";}
public static final String getExporterOutputLocationExistsMsgKey() { return "exporter.command.warn.outputlocationexists";}
} | [
"public",
"class",
"ExporterMessageConstants",
"{",
"public",
"static",
"final",
"String",
"getExporterCreateOutputLocationErrorMsgKey",
"(",
")",
"{",
"return",
"\"",
"exporter.command.error.missingparameters",
"\"",
";",
"}",
"public",
"static",
"final",
"String",
"getExporterMissingParametersErrorMsgKey",
"(",
")",
"{",
"return",
"\"",
"exporter.command.error.createoutput",
"\"",
";",
"}",
"public",
"static",
"final",
"String",
"getExporterOutputLocationExistsMsgKey",
"(",
")",
"{",
"return",
"\"",
"exporter.command.warn.outputlocationexists",
"\"",
";",
"}",
"}"
] | Accesses constants for message keys for the exporter tool | [
"Accesses",
"constants",
"for",
"message",
"keys",
"for",
"the",
"exporter",
"tool"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ec5c69c8afd798777c6b40bfe08e15c88fcf13b | tynch/minio-plugin | src/main/java/io/jenkins/plugins/minio/config/GlobalMinioConfiguration.java | [
"MIT"
] | Java | GlobalMinioConfiguration | /**
* @author Ronald Kamphuis
*/ | @author Ronald Kamphuis | [
"@author",
"Ronald",
"Kamphuis"
] | @Extension
public class GlobalMinioConfiguration extends GlobalConfiguration {
private MinioConfiguration configuration;
@Nonnull
public static GlobalMinioConfiguration get() {
GlobalMinioConfiguration instance = GlobalConfiguration.all().get(GlobalMinioConfiguration.class);
if (instance == null) {
throw new IllegalStateException();
}
return instance;
}
public GlobalMinioConfiguration() {
// When Jenkins is restarted, load any saved configuration from disk.
load();
}
@DataBoundSetter
public void setConfiguration(MinioConfiguration configuration) {
this.configuration = configuration;
save();
}
public MinioConfiguration getConfiguration() {
return configuration;
}
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
req.bindJSON(this, json);
return true;
}
} | [
"@",
"Extension",
"public",
"class",
"GlobalMinioConfiguration",
"extends",
"GlobalConfiguration",
"{",
"private",
"MinioConfiguration",
"configuration",
";",
"@",
"Nonnull",
"public",
"static",
"GlobalMinioConfiguration",
"get",
"(",
")",
"{",
"GlobalMinioConfiguration",
"instance",
"=",
"GlobalConfiguration",
".",
"all",
"(",
")",
".",
"get",
"(",
"GlobalMinioConfiguration",
".",
"class",
")",
";",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"}",
"return",
"instance",
";",
"}",
"public",
"GlobalMinioConfiguration",
"(",
")",
"{",
"load",
"(",
")",
";",
"}",
"@",
"DataBoundSetter",
"public",
"void",
"setConfiguration",
"(",
"MinioConfiguration",
"configuration",
")",
"{",
"this",
".",
"configuration",
"=",
"configuration",
";",
"save",
"(",
")",
";",
"}",
"public",
"MinioConfiguration",
"getConfiguration",
"(",
")",
"{",
"return",
"configuration",
";",
"}",
"@",
"Override",
"public",
"boolean",
"configure",
"(",
"StaplerRequest",
"req",
",",
"JSONObject",
"json",
")",
"throws",
"FormException",
"{",
"req",
".",
"bindJSON",
"(",
"this",
",",
"json",
")",
";",
"return",
"true",
";",
"}",
"}"
] | @author Ronald Kamphuis | [
"@author",
"Ronald",
"Kamphuis"
] | [
"// When Jenkins is restarted, load any saved configuration from disk."
] | [
{
"param": "GlobalConfiguration",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "GlobalConfiguration",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1eca95f1b0b87a8c58c9f31a5e183e9885bc041d | pmatte1/box-java-sdk | src/main/java/com/box/sdk/BoxCollaborationWhitelist.java | [
"Apache-2.0"
] | Java | BoxCollaborationWhitelist | /**
* Represents a collaboration whitelist between a domain and a Box Enterprise. Collaboration Whitelist enables a Box
* Enterprise(only available if you have Box Governance) to manage a set of approved domains that can collaborate
* with an enterprise.
*
* <p>Unless otherwise noted, the methods in this class can throw an unchecked {@link BoxAPIException} (unchecked
* meaning that the compiler won't force you to handle it) if an error occurs. If you wish to implement custom error
* handling for errors related to the Box REST API, you should capture this exception explicitly.</p>
*/ | Represents a collaboration whitelist between a domain and a Box Enterprise. Collaboration Whitelist enables a Box
Enterprise(only available if you have Box Governance) to manage a set of approved domains that can collaborate
with an enterprise.
Unless otherwise noted, the methods in this class can throw an unchecked BoxAPIException (unchecked
meaning that the compiler won't force you to handle it) if an error occurs. If you wish to implement custom error
handling for errors related to the Box REST API, you should capture this exception explicitly. | [
"Represents",
"a",
"collaboration",
"whitelist",
"between",
"a",
"domain",
"and",
"a",
"Box",
"Enterprise",
".",
"Collaboration",
"Whitelist",
"enables",
"a",
"Box",
"Enterprise",
"(",
"only",
"available",
"if",
"you",
"have",
"Box",
"Governance",
")",
"to",
"manage",
"a",
"set",
"of",
"approved",
"domains",
"that",
"can",
"collaborate",
"with",
"an",
"enterprise",
".",
"Unless",
"otherwise",
"noted",
"the",
"methods",
"in",
"this",
"class",
"can",
"throw",
"an",
"unchecked",
"BoxAPIException",
"(",
"unchecked",
"meaning",
"that",
"the",
"compiler",
"won",
"'",
"t",
"force",
"you",
"to",
"handle",
"it",
")",
"if",
"an",
"error",
"occurs",
".",
"If",
"you",
"wish",
"to",
"implement",
"custom",
"error",
"handling",
"for",
"errors",
"related",
"to",
"the",
"Box",
"REST",
"API",
"you",
"should",
"capture",
"this",
"exception",
"explicitly",
"."
] | @BoxResourceType("collaboration_whitelist_entry")
public class BoxCollaborationWhitelist extends BoxResource {
/**
* Collaboration Whitelist Entries URL Template.
*/
public static final URLTemplate COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE =
new URLTemplate("collaboration_whitelist_entries");
/**
* Collaboration Whitelist Entries URL Template with given ID.
*/
public static final URLTemplate COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE =
new URLTemplate("collaboration_whitelist_entries/%s");
/**
* The default limit of entries per response.
*/
private static final int DEFAULT_LIMIT = 100;
/**
* Constructs a BoxCollaborationWhitelist for a collaboration whitelist with a given ID.
*
* @param api the API connection to be used by the collaboration whitelist.
* @param id the ID of the collaboration whitelist.
*/
public BoxCollaborationWhitelist(BoxAPIConnection api, String id) {
super(api, id);
}
/**
* Creates a new Collaboration Whitelist for a domain.
* @param api the API connection to be used by the resource.
* @param domain the domain to be added to a collaboration whitelist for a Box Enterprise.
* @param direction an enum representing the direction of the collaboration whitelist. Can be set to
* inbound, outbound, or both.
* @return information about the collaboration whitelist created.
*/
public static BoxCollaborationWhitelist.Info create(final BoxAPIConnection api, String domain,
WhitelistDirection direction) {
URL url = COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST);
JsonObject requestJSON = new JsonObject()
.add("domain", domain)
.add("direction", direction.toString());
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxCollaborationWhitelist domainWhitelist =
new BoxCollaborationWhitelist(api, responseJSON.get("id").asString());
return domainWhitelist.new Info(responseJSON);
}
/**
* @return information about this {@link BoxCollaborationWhitelist}.
*/
public BoxCollaborationWhitelist.Info getInfo() {
URL url = COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.GET);
BoxJSONResponse response = (BoxJSONResponse) request.send();
return new Info(JsonObject.readFrom(response.getJSON()));
}
/**
* Returns all the collaboration whitelisting with specified filters.
* @param api the API connection to be used by the resource.
* @param fields the fields to retrieve.
* @return an iterable with all the collaboration whitelists met search conditions.
*/
public static Iterable<BoxCollaborationWhitelist.Info> getAll(final BoxAPIConnection api, String ... fields) {
return getAll(api, DEFAULT_LIMIT, fields);
}
/**
* Returns all the collaboration whitelisting with specified filters.
* @param api the API connection to be used by the resource.
* @param limit the limit of items per single response. The default value is 100.
* @param fields the fields to retrieve.
* @return an iterable with all the collaboration whitelists met search conditions.
*/
public static Iterable<BoxCollaborationWhitelist.Info> getAll(final BoxAPIConnection api, int limit,
String ... fields) {
QueryStringBuilder builder = new QueryStringBuilder();
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
URL url = COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
return new BoxResourceIterable<BoxCollaborationWhitelist.Info>(api, url, limit) {
@Override
protected BoxCollaborationWhitelist.Info factory(JsonObject jsonObject) {
BoxCollaborationWhitelist whitelist = new BoxCollaborationWhitelist(
api, jsonObject.get("id").asString());
return whitelist.new Info(jsonObject);
}
};
}
/**
* Deletes this collaboration whitelist.
*/
public void delete() {
BoxAPIConnection api = this.getAPI();
URL url = COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE.build(api.getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(api, url, HttpMethod.DELETE);
BoxAPIResponse response = request.send();
response.disconnect();
}
/**
* Contains information about a BoxCollaborationWhitelist.
*/
public class Info extends BoxResource.Info {
private String type;
private String domain;
private WhitelistDirection direction;
private BoxEnterprise enterprise;
private Date createdAt;
private Date modifiedAt;
/**
* Constructs an empty Info object.
*/
public Info() {
super();
}
/**
* Constructs an Info object by parsing information from a JSON string.
*
* @param json the JSON string to parse.
*/
public Info(String json) {
super(json);
}
Info(JsonObject jsonObject) {
super(jsonObject);
}
/**
* Gets the type of the collaboration whitelist.
*
* @return the type for the collaboration whitelist.
*/
public String getType() {
return this.type;
}
/**
* Gets the domain added to the collaboration whitelist.
*
* @return the domain in the collaboration whitelist
*/
public String getDomain() {
return this.domain;
}
/**
* Get the direction of the collaboration whitelist. Values can be inbound, outbound, or
* both.
*
* @return the direction set for the collaboration whitelist. Values can be inbound, outbound, or both.
*/
public WhitelistDirection getDirection() {
return this.direction;
}
/**
* Gets the enterprise that the collaboration whitelist belongs to.
*
* @return the enterprise that the collaboration whitelist belongs to.
*/
public BoxEnterprise getEnterprise() {
return this.enterprise;
}
/**
* Gets the time the collaboration whitelist was created.
*
* @return the time the collaboration whitelist was created.
*/
public Date getCreatedAt() {
return this.createdAt;
}
/**
* Gets the time the collaboration whitelist was last modified.
*
* @return the time the collaboration whitelist was last modified.
*/
public Date getModifiedAt() {
return this.modifiedAt;
}
@Override
public BoxCollaborationWhitelist getResource() {
return BoxCollaborationWhitelist.this;
}
@Override
protected void parseJSONMember(JsonObject.Member member) {
super.parseJSONMember(member);
String memberName = member.getName();
JsonValue value = member.getValue();
try {
if (memberName.equals("domain")) {
this.domain = value.asString();
} else if (memberName.equals("type")) {
this.type = value.asString();
} else if (memberName.equals("direction")) {
this.direction = WhitelistDirection.fromDirection(value.asString());
} else if (memberName.equals("enterprise")) {
JsonObject jsonObject = value.asObject();
this.enterprise = new BoxEnterprise(jsonObject);
} else if (memberName.equals("created_at")) {
this.createdAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("modified_at")) {
this.modifiedAt = BoxDateFormat.parse(value.asString());
}
} catch (ParseException e) {
assert false : "Error in parsing BoxCollaborationWhitelist JSON Object";
}
}
}
/**
* Enumerates the direction of the collaboration whitelist.
*/
public enum WhitelistDirection {
/**
* Whitelist inbound collaboration.
*/
INBOUND("inbound"),
/**
* Whitelist outbound collaboration.
*/
OUTBOUND("outbound"),
/**
* Whitelist both inbound and outbound collaboration.
*/
BOTH("both");
private final String direction;
WhitelistDirection(String direction) {
this.direction = direction;
}
static WhitelistDirection fromDirection(String direction) {
if (direction.equals("inbound")) {
return WhitelistDirection.INBOUND;
} else if (direction.equals("outbound")) {
return WhitelistDirection.OUTBOUND;
} else if (direction.equals("both")) {
return WhitelistDirection.BOTH;
} else {
return null;
}
}
/**
* Returns a String containing the current direction of the collaboration whitelisting.
* @return a String containing information about the direction of the collaboration whitelisting.
*/
public String toString() {
return this.direction;
}
}
} | [
"@",
"BoxResourceType",
"(",
"\"",
"collaboration_whitelist_entry",
"\"",
")",
"public",
"class",
"BoxCollaborationWhitelist",
"extends",
"BoxResource",
"{",
"/**\n * Collaboration Whitelist Entries URL Template.\n */",
"public",
"static",
"final",
"URLTemplate",
"COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE",
"=",
"new",
"URLTemplate",
"(",
"\"",
"collaboration_whitelist_entries",
"\"",
")",
";",
"/**\n * Collaboration Whitelist Entries URL Template with given ID.\n */",
"public",
"static",
"final",
"URLTemplate",
"COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE",
"=",
"new",
"URLTemplate",
"(",
"\"",
"collaboration_whitelist_entries/%s",
"\"",
")",
";",
"/**\n * The default limit of entries per response.\n */",
"private",
"static",
"final",
"int",
"DEFAULT_LIMIT",
"=",
"100",
";",
"/**\n * Constructs a BoxCollaborationWhitelist for a collaboration whitelist with a given ID.\n *\n * @param api the API connection to be used by the collaboration whitelist.\n * @param id the ID of the collaboration whitelist.\n */",
"public",
"BoxCollaborationWhitelist",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"id",
")",
"{",
"super",
"(",
"api",
",",
"id",
")",
";",
"}",
"/**\n * Creates a new Collaboration Whitelist for a domain.\n * @param api the API connection to be used by the resource.\n * @param domain the domain to be added to a collaboration whitelist for a Box Enterprise.\n * @param direction an enum representing the direction of the collaboration whitelist. Can be set to\n * inbound, outbound, or both.\n * @return information about the collaboration whitelist created.\n */",
"public",
"static",
"BoxCollaborationWhitelist",
".",
"Info",
"create",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"String",
"domain",
",",
"WhitelistDirection",
"direction",
")",
"{",
"URL",
"url",
"=",
"COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"api",
",",
"url",
",",
"HttpMethod",
".",
"POST",
")",
";",
"JsonObject",
"requestJSON",
"=",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"",
"domain",
"\"",
",",
"domain",
")",
".",
"add",
"(",
"\"",
"direction",
"\"",
",",
"direction",
".",
"toString",
"(",
")",
")",
";",
"request",
".",
"setBody",
"(",
"requestJSON",
".",
"toString",
"(",
")",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"responseJSON",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"BoxCollaborationWhitelist",
"domainWhitelist",
"=",
"new",
"BoxCollaborationWhitelist",
"(",
"api",
",",
"responseJSON",
".",
"get",
"(",
"\"",
"id",
"\"",
")",
".",
"asString",
"(",
")",
")",
";",
"return",
"domainWhitelist",
".",
"new",
"Info",
"(",
"responseJSON",
")",
";",
"}",
"/**\n * @return information about this {@link BoxCollaborationWhitelist}.\n */",
"public",
"BoxCollaborationWhitelist",
".",
"Info",
"getInfo",
"(",
")",
"{",
"URL",
"url",
"=",
"COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"HttpMethod",
".",
"GET",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"return",
"new",
"Info",
"(",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
")",
";",
"}",
"/**\n * Returns all the collaboration whitelisting with specified filters.\n * @param api the API connection to be used by the resource.\n * @param fields the fields to retrieve.\n * @return an iterable with all the collaboration whitelists met search conditions.\n */",
"public",
"static",
"Iterable",
"<",
"BoxCollaborationWhitelist",
".",
"Info",
">",
"getAll",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"String",
"...",
"fields",
")",
"{",
"return",
"getAll",
"(",
"api",
",",
"DEFAULT_LIMIT",
",",
"fields",
")",
";",
"}",
"/**\n * Returns all the collaboration whitelisting with specified filters.\n * @param api the API connection to be used by the resource.\n * @param limit the limit of items per single response. The default value is 100.\n * @param fields the fields to retrieve.\n * @return an iterable with all the collaboration whitelists met search conditions.\n */",
"public",
"static",
"Iterable",
"<",
"BoxCollaborationWhitelist",
".",
"Info",
">",
"getAll",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"int",
"limit",
",",
"String",
"...",
"fields",
")",
"{",
"QueryStringBuilder",
"builder",
"=",
"new",
"QueryStringBuilder",
"(",
")",
";",
"if",
"(",
"fields",
".",
"length",
">",
"0",
")",
"{",
"builder",
".",
"appendParam",
"(",
"\"",
"fields",
"\"",
",",
"fields",
")",
";",
"}",
"URL",
"url",
"=",
"COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE",
".",
"buildWithQuery",
"(",
"api",
".",
"getBaseURL",
"(",
")",
",",
"builder",
".",
"toString",
"(",
")",
")",
";",
"return",
"new",
"BoxResourceIterable",
"<",
"BoxCollaborationWhitelist",
".",
"Info",
">",
"(",
"api",
",",
"url",
",",
"limit",
")",
"{",
"@",
"Override",
"protected",
"BoxCollaborationWhitelist",
".",
"Info",
"factory",
"(",
"JsonObject",
"jsonObject",
")",
"{",
"BoxCollaborationWhitelist",
"whitelist",
"=",
"new",
"BoxCollaborationWhitelist",
"(",
"api",
",",
"jsonObject",
".",
"get",
"(",
"\"",
"id",
"\"",
")",
".",
"asString",
"(",
")",
")",
";",
"return",
"whitelist",
".",
"new",
"Info",
"(",
"jsonObject",
")",
";",
"}",
"}",
";",
"}",
"/**\n * Deletes this collaboration whitelist.\n */",
"public",
"void",
"delete",
"(",
")",
"{",
"BoxAPIConnection",
"api",
"=",
"this",
".",
"getAPI",
"(",
")",
";",
"URL",
"url",
"=",
"COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"api",
",",
"url",
",",
"HttpMethod",
".",
"DELETE",
")",
";",
"BoxAPIResponse",
"response",
"=",
"request",
".",
"send",
"(",
")",
";",
"response",
".",
"disconnect",
"(",
")",
";",
"}",
"/**\n * Contains information about a BoxCollaborationWhitelist.\n */",
"public",
"class",
"Info",
"extends",
"BoxResource",
".",
"Info",
"{",
"private",
"String",
"type",
";",
"private",
"String",
"domain",
";",
"private",
"WhitelistDirection",
"direction",
";",
"private",
"BoxEnterprise",
"enterprise",
";",
"private",
"Date",
"createdAt",
";",
"private",
"Date",
"modifiedAt",
";",
"/**\n * Constructs an empty Info object.\n */",
"public",
"Info",
"(",
")",
"{",
"super",
"(",
")",
";",
"}",
"/**\n * Constructs an Info object by parsing information from a JSON string.\n *\n * @param json the JSON string to parse.\n */",
"public",
"Info",
"(",
"String",
"json",
")",
"{",
"super",
"(",
"json",
")",
";",
"}",
"Info",
"(",
"JsonObject",
"jsonObject",
")",
"{",
"super",
"(",
"jsonObject",
")",
";",
"}",
"/**\n * Gets the type of the collaboration whitelist.\n *\n * @return the type for the collaboration whitelist.\n */",
"public",
"String",
"getType",
"(",
")",
"{",
"return",
"this",
".",
"type",
";",
"}",
"/**\n * Gets the domain added to the collaboration whitelist.\n *\n * @return the domain in the collaboration whitelist\n */",
"public",
"String",
"getDomain",
"(",
")",
"{",
"return",
"this",
".",
"domain",
";",
"}",
"/**\n * Get the direction of the collaboration whitelist. Values can be inbound, outbound, or\n * both.\n *\n * @return the direction set for the collaboration whitelist. Values can be inbound, outbound, or both.\n */",
"public",
"WhitelistDirection",
"getDirection",
"(",
")",
"{",
"return",
"this",
".",
"direction",
";",
"}",
"/**\n * Gets the enterprise that the collaboration whitelist belongs to.\n *\n * @return the enterprise that the collaboration whitelist belongs to.\n */",
"public",
"BoxEnterprise",
"getEnterprise",
"(",
")",
"{",
"return",
"this",
".",
"enterprise",
";",
"}",
"/**\n * Gets the time the collaboration whitelist was created.\n *\n * @return the time the collaboration whitelist was created.\n */",
"public",
"Date",
"getCreatedAt",
"(",
")",
"{",
"return",
"this",
".",
"createdAt",
";",
"}",
"/**\n * Gets the time the collaboration whitelist was last modified.\n *\n * @return the time the collaboration whitelist was last modified.\n */",
"public",
"Date",
"getModifiedAt",
"(",
")",
"{",
"return",
"this",
".",
"modifiedAt",
";",
"}",
"@",
"Override",
"public",
"BoxCollaborationWhitelist",
"getResource",
"(",
")",
"{",
"return",
"BoxCollaborationWhitelist",
".",
"this",
";",
"}",
"@",
"Override",
"protected",
"void",
"parseJSONMember",
"(",
"JsonObject",
".",
"Member",
"member",
")",
"{",
"super",
".",
"parseJSONMember",
"(",
"member",
")",
";",
"String",
"memberName",
"=",
"member",
".",
"getName",
"(",
")",
";",
"JsonValue",
"value",
"=",
"member",
".",
"getValue",
"(",
")",
";",
"try",
"{",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"domain",
"\"",
")",
")",
"{",
"this",
".",
"domain",
"=",
"value",
".",
"asString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"type",
"\"",
")",
")",
"{",
"this",
".",
"type",
"=",
"value",
".",
"asString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"direction",
"\"",
")",
")",
"{",
"this",
".",
"direction",
"=",
"WhitelistDirection",
".",
"fromDirection",
"(",
"value",
".",
"asString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"enterprise",
"\"",
")",
")",
"{",
"JsonObject",
"jsonObject",
"=",
"value",
".",
"asObject",
"(",
")",
";",
"this",
".",
"enterprise",
"=",
"new",
"BoxEnterprise",
"(",
"jsonObject",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"created_at",
"\"",
")",
")",
"{",
"this",
".",
"createdAt",
"=",
"BoxDateFormat",
".",
"parse",
"(",
"value",
".",
"asString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"modified_at",
"\"",
")",
")",
"{",
"this",
".",
"modifiedAt",
"=",
"BoxDateFormat",
".",
"parse",
"(",
"value",
".",
"asString",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"assert",
"false",
":",
"\"",
"Error in parsing BoxCollaborationWhitelist JSON Object",
"\"",
";",
"}",
"}",
"}",
"/**\n * Enumerates the direction of the collaboration whitelist.\n */",
"public",
"enum",
"WhitelistDirection",
"{",
"/**\n * Whitelist inbound collaboration.\n */",
"INBOUND",
"(",
"\"",
"inbound",
"\"",
")",
",",
"/**\n * Whitelist outbound collaboration.\n */",
"OUTBOUND",
"(",
"\"",
"outbound",
"\"",
")",
",",
"/**\n * Whitelist both inbound and outbound collaboration.\n */",
"BOTH",
"(",
"\"",
"both",
"\"",
")",
";",
"private",
"final",
"String",
"direction",
";",
"WhitelistDirection",
"(",
"String",
"direction",
")",
"{",
"this",
".",
"direction",
"=",
"direction",
";",
"}",
"static",
"WhitelistDirection",
"fromDirection",
"(",
"String",
"direction",
")",
"{",
"if",
"(",
"direction",
".",
"equals",
"(",
"\"",
"inbound",
"\"",
")",
")",
"{",
"return",
"WhitelistDirection",
".",
"INBOUND",
";",
"}",
"else",
"if",
"(",
"direction",
".",
"equals",
"(",
"\"",
"outbound",
"\"",
")",
")",
"{",
"return",
"WhitelistDirection",
".",
"OUTBOUND",
";",
"}",
"else",
"if",
"(",
"direction",
".",
"equals",
"(",
"\"",
"both",
"\"",
")",
")",
"{",
"return",
"WhitelistDirection",
".",
"BOTH",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"/**\n * Returns a String containing the current direction of the collaboration whitelisting.\n * @return a String containing information about the direction of the collaboration whitelisting.\n */",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"this",
".",
"direction",
";",
"}",
"}",
"}"
] | Represents a collaboration whitelist between a domain and a Box Enterprise. | [
"Represents",
"a",
"collaboration",
"whitelist",
"between",
"a",
"domain",
"and",
"a",
"Box",
"Enterprise",
"."
] | [] | [
{
"param": "BoxResource",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "BoxResource",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1eca95f1b0b87a8c58c9f31a5e183e9885bc041d | pmatte1/box-java-sdk | src/main/java/com/box/sdk/BoxCollaborationWhitelist.java | [
"Apache-2.0"
] | Java | Info | /**
* Contains information about a BoxCollaborationWhitelist.
*/ | Contains information about a BoxCollaborationWhitelist. | [
"Contains",
"information",
"about",
"a",
"BoxCollaborationWhitelist",
"."
] | public class Info extends BoxResource.Info {
private String type;
private String domain;
private WhitelistDirection direction;
private BoxEnterprise enterprise;
private Date createdAt;
private Date modifiedAt;
/**
* Constructs an empty Info object.
*/
public Info() {
super();
}
/**
* Constructs an Info object by parsing information from a JSON string.
*
* @param json the JSON string to parse.
*/
public Info(String json) {
super(json);
}
Info(JsonObject jsonObject) {
super(jsonObject);
}
/**
* Gets the type of the collaboration whitelist.
*
* @return the type for the collaboration whitelist.
*/
public String getType() {
return this.type;
}
/**
* Gets the domain added to the collaboration whitelist.
*
* @return the domain in the collaboration whitelist
*/
public String getDomain() {
return this.domain;
}
/**
* Get the direction of the collaboration whitelist. Values can be inbound, outbound, or
* both.
*
* @return the direction set for the collaboration whitelist. Values can be inbound, outbound, or both.
*/
public WhitelistDirection getDirection() {
return this.direction;
}
/**
* Gets the enterprise that the collaboration whitelist belongs to.
*
* @return the enterprise that the collaboration whitelist belongs to.
*/
public BoxEnterprise getEnterprise() {
return this.enterprise;
}
/**
* Gets the time the collaboration whitelist was created.
*
* @return the time the collaboration whitelist was created.
*/
public Date getCreatedAt() {
return this.createdAt;
}
/**
* Gets the time the collaboration whitelist was last modified.
*
* @return the time the collaboration whitelist was last modified.
*/
public Date getModifiedAt() {
return this.modifiedAt;
}
@Override
public BoxCollaborationWhitelist getResource() {
return BoxCollaborationWhitelist.this;
}
@Override
protected void parseJSONMember(JsonObject.Member member) {
super.parseJSONMember(member);
String memberName = member.getName();
JsonValue value = member.getValue();
try {
if (memberName.equals("domain")) {
this.domain = value.asString();
} else if (memberName.equals("type")) {
this.type = value.asString();
} else if (memberName.equals("direction")) {
this.direction = WhitelistDirection.fromDirection(value.asString());
} else if (memberName.equals("enterprise")) {
JsonObject jsonObject = value.asObject();
this.enterprise = new BoxEnterprise(jsonObject);
} else if (memberName.equals("created_at")) {
this.createdAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("modified_at")) {
this.modifiedAt = BoxDateFormat.parse(value.asString());
}
} catch (ParseException e) {
assert false : "Error in parsing BoxCollaborationWhitelist JSON Object";
}
}
} | [
"public",
"class",
"Info",
"extends",
"BoxResource",
".",
"Info",
"{",
"private",
"String",
"type",
";",
"private",
"String",
"domain",
";",
"private",
"WhitelistDirection",
"direction",
";",
"private",
"BoxEnterprise",
"enterprise",
";",
"private",
"Date",
"createdAt",
";",
"private",
"Date",
"modifiedAt",
";",
"/**\n * Constructs an empty Info object.\n */",
"public",
"Info",
"(",
")",
"{",
"super",
"(",
")",
";",
"}",
"/**\n * Constructs an Info object by parsing information from a JSON string.\n *\n * @param json the JSON string to parse.\n */",
"public",
"Info",
"(",
"String",
"json",
")",
"{",
"super",
"(",
"json",
")",
";",
"}",
"Info",
"(",
"JsonObject",
"jsonObject",
")",
"{",
"super",
"(",
"jsonObject",
")",
";",
"}",
"/**\n * Gets the type of the collaboration whitelist.\n *\n * @return the type for the collaboration whitelist.\n */",
"public",
"String",
"getType",
"(",
")",
"{",
"return",
"this",
".",
"type",
";",
"}",
"/**\n * Gets the domain added to the collaboration whitelist.\n *\n * @return the domain in the collaboration whitelist\n */",
"public",
"String",
"getDomain",
"(",
")",
"{",
"return",
"this",
".",
"domain",
";",
"}",
"/**\n * Get the direction of the collaboration whitelist. Values can be inbound, outbound, or\n * both.\n *\n * @return the direction set for the collaboration whitelist. Values can be inbound, outbound, or both.\n */",
"public",
"WhitelistDirection",
"getDirection",
"(",
")",
"{",
"return",
"this",
".",
"direction",
";",
"}",
"/**\n * Gets the enterprise that the collaboration whitelist belongs to.\n *\n * @return the enterprise that the collaboration whitelist belongs to.\n */",
"public",
"BoxEnterprise",
"getEnterprise",
"(",
")",
"{",
"return",
"this",
".",
"enterprise",
";",
"}",
"/**\n * Gets the time the collaboration whitelist was created.\n *\n * @return the time the collaboration whitelist was created.\n */",
"public",
"Date",
"getCreatedAt",
"(",
")",
"{",
"return",
"this",
".",
"createdAt",
";",
"}",
"/**\n * Gets the time the collaboration whitelist was last modified.\n *\n * @return the time the collaboration whitelist was last modified.\n */",
"public",
"Date",
"getModifiedAt",
"(",
")",
"{",
"return",
"this",
".",
"modifiedAt",
";",
"}",
"@",
"Override",
"public",
"BoxCollaborationWhitelist",
"getResource",
"(",
")",
"{",
"return",
"BoxCollaborationWhitelist",
".",
"this",
";",
"}",
"@",
"Override",
"protected",
"void",
"parseJSONMember",
"(",
"JsonObject",
".",
"Member",
"member",
")",
"{",
"super",
".",
"parseJSONMember",
"(",
"member",
")",
";",
"String",
"memberName",
"=",
"member",
".",
"getName",
"(",
")",
";",
"JsonValue",
"value",
"=",
"member",
".",
"getValue",
"(",
")",
";",
"try",
"{",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"domain",
"\"",
")",
")",
"{",
"this",
".",
"domain",
"=",
"value",
".",
"asString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"type",
"\"",
")",
")",
"{",
"this",
".",
"type",
"=",
"value",
".",
"asString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"direction",
"\"",
")",
")",
"{",
"this",
".",
"direction",
"=",
"WhitelistDirection",
".",
"fromDirection",
"(",
"value",
".",
"asString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"enterprise",
"\"",
")",
")",
"{",
"JsonObject",
"jsonObject",
"=",
"value",
".",
"asObject",
"(",
")",
";",
"this",
".",
"enterprise",
"=",
"new",
"BoxEnterprise",
"(",
"jsonObject",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"created_at",
"\"",
")",
")",
"{",
"this",
".",
"createdAt",
"=",
"BoxDateFormat",
".",
"parse",
"(",
"value",
".",
"asString",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"memberName",
".",
"equals",
"(",
"\"",
"modified_at",
"\"",
")",
")",
"{",
"this",
".",
"modifiedAt",
"=",
"BoxDateFormat",
".",
"parse",
"(",
"value",
".",
"asString",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"assert",
"false",
":",
"\"",
"Error in parsing BoxCollaborationWhitelist JSON Object",
"\"",
";",
"}",
"}",
"}"
] | Contains information about a BoxCollaborationWhitelist. | [
"Contains",
"information",
"about",
"a",
"BoxCollaborationWhitelist",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ecbabe5e6f751ea4418c312f149850de247a826 | fregaham/KiWi | extensions/admin/src/kiwi/action/admin/AdminGroupAction.java | [
"BSD-3-Clause"
] | Java | AdminGroupAction | /**
* @author Rolf Sint
*
*/ | @author Rolf Sint | [
"@author",
"Rolf",
"Sint"
] | @Scope(ScopeType.CONVERSATION)
@Name("adminGroup")
public class AdminGroupAction implements Serializable {
// @In(value = "kiwi.group", required = false)
// Group group;
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
@DataModel
private List<Group> groups;
@In
GroupService groupService;
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#init()
*/
@Factory("groups")
public void init(){
groups = groupService.getGroups();
}
// @Out
// allGroups is the same as groups, but no datamodel. It is used for
// Outjection
// -->Bijection does not work with DataModels
// private List<Group> allGroups;
@DataModelSelection
@Out(required = false)
private Group selectedGroup;
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#setGroups(java.util.List)
*/
public void setGroups(List<Group> groups) {
this.groups = groups;
}
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#delete()
*/
public String delete() {
groups.remove(selectedGroup);
groupService.remove(selectedGroup);
return "/admin/adminGroup";
}
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#configure()
*/
public String configure() {
return "/admin/editGroup";
}
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#store()
*/
//@Begin(nested = true)
public String store() throws GroupExistsException {
Group group = new Group();
group.setName(name);
groups.add(group);
groupService.store(group);
return "/admin/adminGroup";
}
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#getGroups()
*/
public List<Group> getGroups() {
return groups;
}
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#getSelectedGroup()
*/
public Group getSelectedGroup() {
return selectedGroup;
}
// public void setAllGroups(List<Group> allGroups) {
// this.allGroups = allGroups;
// }
/* (non-Javadoc)
* @see kiwi.action.admin.IAdminGroupAction#destroy()
*/
@Destroy
public void destroy() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} | [
"@",
"Scope",
"(",
"ScopeType",
".",
"CONVERSATION",
")",
"@",
"Name",
"(",
"\"",
"adminGroup",
"\"",
")",
"public",
"class",
"AdminGroupAction",
"implements",
"Serializable",
"{",
"/**\n\t * \n\t */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"private",
"String",
"name",
";",
"@",
"DataModel",
"private",
"List",
"<",
"Group",
">",
"groups",
";",
"@",
"In",
"GroupService",
"groupService",
";",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#init()\n\t */",
"@",
"Factory",
"(",
"\"",
"groups",
"\"",
")",
"public",
"void",
"init",
"(",
")",
"{",
"groups",
"=",
"groupService",
".",
"getGroups",
"(",
")",
";",
"}",
"@",
"DataModelSelection",
"@",
"Out",
"(",
"required",
"=",
"false",
")",
"private",
"Group",
"selectedGroup",
";",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#setGroups(java.util.List)\n\t */",
"public",
"void",
"setGroups",
"(",
"List",
"<",
"Group",
">",
"groups",
")",
"{",
"this",
".",
"groups",
"=",
"groups",
";",
"}",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#delete()\n\t */",
"public",
"String",
"delete",
"(",
")",
"{",
"groups",
".",
"remove",
"(",
"selectedGroup",
")",
";",
"groupService",
".",
"remove",
"(",
"selectedGroup",
")",
";",
"return",
"\"",
"/admin/adminGroup",
"\"",
";",
"}",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#configure()\n\t */",
"public",
"String",
"configure",
"(",
")",
"{",
"return",
"\"",
"/admin/editGroup",
"\"",
";",
"}",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#store()\n\t */",
"public",
"String",
"store",
"(",
")",
"throws",
"GroupExistsException",
"{",
"Group",
"group",
"=",
"new",
"Group",
"(",
")",
";",
"group",
".",
"setName",
"(",
"name",
")",
";",
"groups",
".",
"add",
"(",
"group",
")",
";",
"groupService",
".",
"store",
"(",
"group",
")",
";",
"return",
"\"",
"/admin/adminGroup",
"\"",
";",
"}",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#getGroups()\n\t */",
"public",
"List",
"<",
"Group",
">",
"getGroups",
"(",
")",
"{",
"return",
"groups",
";",
"}",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#getSelectedGroup()\n\t */",
"public",
"Group",
"getSelectedGroup",
"(",
")",
"{",
"return",
"selectedGroup",
";",
"}",
"/* (non-Javadoc)\n\t * @see kiwi.action.admin.IAdminGroupAction#destroy()\n\t */",
"@",
"Destroy",
"public",
"void",
"destroy",
"(",
")",
"{",
"}",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"}"
] | @author Rolf Sint | [
"@author",
"Rolf",
"Sint"
] | [
"//\t@In(value = \"kiwi.group\", required = false)",
"//\tGroup group;",
"// @Out",
"// allGroups is the same as groups, but no datamodel. It is used for",
"// Outjection",
"// -->Bijection does not work with DataModels",
"// private List<Group> allGroups;",
"//@Begin(nested = true)",
"// public void setAllGroups(List<Group> allGroups) {",
"// this.allGroups = allGroups;",
"// }"
] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ed78e98b879a93d518e7a8db8a51c0ac5ad6c1f | RokKos/FRI_Programiranje | PREV/prevNaloga1/srcs/compiler/data/imcode/ImcCONST.java | [
"MIT"
] | Java | ImcCONST | /**
* Constant.
*
* Returns the constant.
*
* @author sliva
*/ | Constant.
Returns the constant.
@author sliva | [
"Constant",
".",
"Returns",
"the",
"constant",
".",
"@author",
"sliva"
] | public class ImcCONST extends ImcExpr {
public final long value;
public ImcCONST(long value) {
this.value = value;
}
@Override
public <Result, Arg> Result accept(ImcVisitor<Result, Arg> visitor, Arg accArg) {
return visitor.visit(this, accArg);
}
} | [
"public",
"class",
"ImcCONST",
"extends",
"ImcExpr",
"{",
"public",
"final",
"long",
"value",
";",
"public",
"ImcCONST",
"(",
"long",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"@",
"Override",
"public",
"<",
"Result",
",",
"Arg",
">",
"Result",
"accept",
"(",
"ImcVisitor",
"<",
"Result",
",",
"Arg",
">",
"visitor",
",",
"Arg",
"accArg",
")",
"{",
"return",
"visitor",
".",
"visit",
"(",
"this",
",",
"accArg",
")",
";",
"}",
"}"
] | Constant. | [
"Constant",
"."
] | [] | [
{
"param": "ImcExpr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ImcExpr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1edc05cad4ab10f654f10e58ad9d83150455dc42 | debian-pkg-android-tools/libscout | src/de/infsec/tpl/utils/AarFile.java | [
"Apache-2.0"
] | Java | AarFile | /**
* The 'aar' bundle is the binary distribution of an Android Library Project.
* The file extension is .aar, and the maven artifact type should be aar as well, but the file itself a simple zip file with the following entries:
* - /AndroidManifest.xml (mandatory)
* - /classes.jar (mandatory)
* - /res/ (mandatory)
* - /R.txt (mandatory)
* - /assets/ (optional)
* - /libs/*.jar (optional)
* - /jni/<abi>/*.so (optional)
* - /proguard.txt (optional)
* - /lint.jar (optional)
* These entries are directly at the root of the zip file.
* The R.txt file is the output of aapt with --output-text-symbols.
*/ | The 'aar' bundle is the binary distribution of an Android Library Project. | [
"The",
"'",
"aar",
"'",
"bundle",
"is",
"the",
"binary",
"distribution",
"of",
"an",
"Android",
"Library",
"Project",
"."
] | public class AarFile extends JarFile {
public static final String CLASSES_JAR = "classes.jar";
public AarFile(File file) throws ZipException, IOException {
super(file);
}
public AarFile(String fileName) throws ZipException, IOException {
super(fileName);
}
public ZipEntry getClassesJar() {
return this.getEntry(CLASSES_JAR);
}
} | [
"public",
"class",
"AarFile",
"extends",
"JarFile",
"{",
"public",
"static",
"final",
"String",
"CLASSES_JAR",
"=",
"\"",
"classes.jar",
"\"",
";",
"public",
"AarFile",
"(",
"File",
"file",
")",
"throws",
"ZipException",
",",
"IOException",
"{",
"super",
"(",
"file",
")",
";",
"}",
"public",
"AarFile",
"(",
"String",
"fileName",
")",
"throws",
"ZipException",
",",
"IOException",
"{",
"super",
"(",
"fileName",
")",
";",
"}",
"public",
"ZipEntry",
"getClassesJar",
"(",
")",
"{",
"return",
"this",
".",
"getEntry",
"(",
"CLASSES_JAR",
")",
";",
"}",
"}"
] | The 'aar' bundle is the binary distribution of an Android Library Project. | [
"The",
"'",
"aar",
"'",
"bundle",
"is",
"the",
"binary",
"distribution",
"of",
"an",
"Android",
"Library",
"Project",
"."
] | [] | [
{
"param": "JarFile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "JarFile",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ede9d08545d3f5d8b99df21934d6cc00c8b870e | Manny27nyc/azure-sdk-for-java | sdk/avs/azure-resourcemanager-avs/src/samples/java/com/azure/resourcemanager/avs/ScriptExecutionsDeleteSamples.java | [
"MIT"
] | Java | ScriptExecutionsDeleteSamples | /** Samples for ScriptExecutions Delete. */ | Samples for ScriptExecutions Delete. | [
"Samples",
"for",
"ScriptExecutions",
"Delete",
"."
] | public final class ScriptExecutionsDeleteSamples {
/**
* Sample code: ScriptExecutions_Delete.
*
* @param avsManager Entry point to AvsManager. Azure VMware Solution API.
*/
public static void scriptExecutionsDelete(com.azure.resourcemanager.avs.AvsManager avsManager) {
avsManager.scriptExecutions().delete("group1", "cloud1", "{scriptExecutionName}", Context.NONE);
}
} | [
"public",
"final",
"class",
"ScriptExecutionsDeleteSamples",
"{",
"/**\n * Sample code: ScriptExecutions_Delete.\n *\n * @param avsManager Entry point to AvsManager. Azure VMware Solution API.\n */",
"public",
"static",
"void",
"scriptExecutionsDelete",
"(",
"com",
".",
"azure",
".",
"resourcemanager",
".",
"avs",
".",
"AvsManager",
"avsManager",
")",
"{",
"avsManager",
".",
"scriptExecutions",
"(",
")",
".",
"delete",
"(",
"\"",
"group1",
"\"",
",",
"\"",
"cloud1",
"\"",
",",
"\"",
"{scriptExecutionName}",
"\"",
",",
"Context",
".",
"NONE",
")",
";",
"}",
"}"
] | Samples for ScriptExecutions Delete. | [
"Samples",
"for",
"ScriptExecutions",
"Delete",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ee1a1e38c5a9b7577964e9b745444b0b7acc646 | nerdammer/spash | core/src/main/java/it/nerdammer/spash/shell/command/CommandFactory.java | [
"Apache-2.0"
] | Java | CommandFactory | /**
* Defines all the commands available on Spash.
*
* @author Nicola Ferraro
*/ | Defines all the commands available on Spash.
@author Nicola Ferraro | [
"Defines",
"all",
"the",
"commands",
"available",
"on",
"Spash",
".",
"@author",
"Nicola",
"Ferraro"
] | public class CommandFactory {
private static final CommandFactory INSTANCE = new CommandFactory();
private Map<String, Class<? extends Command>> commands;
private CommandFactory() {
this.commands = new TreeMap<>();
commands.put(">", WriteCommand.class);
commands.put("cat", CatCommand.class);
commands.put("cd", CdCommand.class);
commands.put("echo", EchoCommand.class);
commands.put("exit", ExitCommand.class);
commands.put("grep", GrepCommand.class);
commands.put("head", HeadCommand.class);
commands.put("ls", LsCommand.class);
commands.put("mkdir", MkDirCommand.class);
commands.put("pwd", PwdCommand.class);
commands.put("rm", RmCommand.class);
commands.put("rmdir", RmDirCommand.class);
commands.put("test", NoOpCommand.class);
}
public static CommandFactory getInstance() {
return INSTANCE;
}
public Set<String> getAvailableCommands() {
return this.commands.keySet();
}
public Command getCommand(String commandStr) {
if(commandStr.trim().equals("")) {
return new NoOpCommand(commandStr);
} else {
String[] args = commandStr.split(" "); // TODO parse
if(commands.containsKey(args[0])) {
try {
Class<? extends Command> commandClass = commands.get(args[0]);
Command c = commandClass.getConstructor(String.class).newInstance(commandStr);
return c;
} catch(InvocationTargetException e) {
Throwable t = e.getCause();
if(t instanceof RuntimeException) {
throw (RuntimeException)t;
} else if(t instanceof Error) {
throw (Error)t;
} else {
throw new IllegalStateException(t);
}
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
throw new IllegalStateException("Unable to create command '" + commandStr + "'", e);
}
}
}
return new UnknownCommand(commandStr);
}
} | [
"public",
"class",
"CommandFactory",
"{",
"private",
"static",
"final",
"CommandFactory",
"INSTANCE",
"=",
"new",
"CommandFactory",
"(",
")",
";",
"private",
"Map",
"<",
"String",
",",
"Class",
"<",
"?",
"extends",
"Command",
">",
">",
"commands",
";",
"private",
"CommandFactory",
"(",
")",
"{",
"this",
".",
"commands",
"=",
"new",
"TreeMap",
"<",
">",
"(",
")",
";",
"commands",
".",
"put",
"(",
"\"",
">",
"\"",
",",
"WriteCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"cat",
"\"",
",",
"CatCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"cd",
"\"",
",",
"CdCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"echo",
"\"",
",",
"EchoCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"exit",
"\"",
",",
"ExitCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"grep",
"\"",
",",
"GrepCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"head",
"\"",
",",
"HeadCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"ls",
"\"",
",",
"LsCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"mkdir",
"\"",
",",
"MkDirCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"pwd",
"\"",
",",
"PwdCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"rm",
"\"",
",",
"RmCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"rmdir",
"\"",
",",
"RmDirCommand",
".",
"class",
")",
";",
"commands",
".",
"put",
"(",
"\"",
"test",
"\"",
",",
"NoOpCommand",
".",
"class",
")",
";",
"}",
"public",
"static",
"CommandFactory",
"getInstance",
"(",
")",
"{",
"return",
"INSTANCE",
";",
"}",
"public",
"Set",
"<",
"String",
">",
"getAvailableCommands",
"(",
")",
"{",
"return",
"this",
".",
"commands",
".",
"keySet",
"(",
")",
";",
"}",
"public",
"Command",
"getCommand",
"(",
"String",
"commandStr",
")",
"{",
"if",
"(",
"commandStr",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"\"",
"\"",
")",
")",
"{",
"return",
"new",
"NoOpCommand",
"(",
"commandStr",
")",
";",
"}",
"else",
"{",
"String",
"[",
"]",
"args",
"=",
"commandStr",
".",
"split",
"(",
"\"",
" ",
"\"",
")",
";",
"if",
"(",
"commands",
".",
"containsKey",
"(",
"args",
"[",
"0",
"]",
")",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
"extends",
"Command",
">",
"commandClass",
"=",
"commands",
".",
"get",
"(",
"args",
"[",
"0",
"]",
")",
";",
"Command",
"c",
"=",
"commandClass",
".",
"getConstructor",
"(",
"String",
".",
"class",
")",
".",
"newInstance",
"(",
"commandStr",
")",
";",
"return",
"c",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"Throwable",
"t",
"=",
"e",
".",
"getCause",
"(",
")",
";",
"if",
"(",
"t",
"instanceof",
"RuntimeException",
")",
"{",
"throw",
"(",
"RuntimeException",
")",
"t",
";",
"}",
"else",
"if",
"(",
"t",
"instanceof",
"Error",
")",
"{",
"throw",
"(",
"Error",
")",
"t",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"t",
")",
";",
"}",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"Unable to create command '",
"\"",
"+",
"commandStr",
"+",
"\"",
"'",
"\"",
",",
"e",
")",
";",
"}",
"}",
"}",
"return",
"new",
"UnknownCommand",
"(",
"commandStr",
")",
";",
"}",
"}"
] | Defines all the commands available on Spash. | [
"Defines",
"all",
"the",
"commands",
"available",
"on",
"Spash",
"."
] | [
"// TODO parse"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ee34df29e0c81442293391c34f8947f08b5311e | Ninja-Squad/faidare | backend/src/main/java/fr/inra/urgi/faidare/domain/data/LocationSitemapVO.java | [
"BSD-3-Clause"
] | Java | LocationSitemapVO | /**
* A minimal view of a location containing only its ID, used to generate sitemaps
*/ | A minimal view of a location containing only its ID, used to generate sitemaps | [
"A",
"minimal",
"view",
"of",
"a",
"location",
"containing",
"only",
"its",
"ID",
"used",
"to",
"generate",
"sitemaps"
] | @Document(type = "location", includedFields = "locationDbId")
public class LocationSitemapVO {
@Id
private String locationDbId;
public LocationSitemapVO() {
}
public LocationSitemapVO(String locationDbId) {
this.locationDbId = locationDbId;
}
public String getLocationDbId() {
return locationDbId;
}
public void setLocationDbId(String locationDbId) {
this.locationDbId = locationDbId;
}
} | [
"@",
"Document",
"(",
"type",
"=",
"\"",
"location",
"\"",
",",
"includedFields",
"=",
"\"",
"locationDbId",
"\"",
")",
"public",
"class",
"LocationSitemapVO",
"{",
"@",
"Id",
"private",
"String",
"locationDbId",
";",
"public",
"LocationSitemapVO",
"(",
")",
"{",
"}",
"public",
"LocationSitemapVO",
"(",
"String",
"locationDbId",
")",
"{",
"this",
".",
"locationDbId",
"=",
"locationDbId",
";",
"}",
"public",
"String",
"getLocationDbId",
"(",
")",
"{",
"return",
"locationDbId",
";",
"}",
"public",
"void",
"setLocationDbId",
"(",
"String",
"locationDbId",
")",
"{",
"this",
".",
"locationDbId",
"=",
"locationDbId",
";",
"}",
"}"
] | A minimal view of a location containing only its ID, used to generate sitemaps | [
"A",
"minimal",
"view",
"of",
"a",
"location",
"containing",
"only",
"its",
"ID",
"used",
"to",
"generate",
"sitemaps"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ee7034059e34922791841abcb180530674e265b | ArtursPark/AP_GameOfLife | src/ap/gameoflife/controller/menubar/GoLMenuBarController.java | [
"MIT"
] | Java | GoLMenuBarController | /**
* Controller connecting the model with the frame, to access the menu bar.
*/ | Controller connecting the model with the frame, to access the menu bar. | [
"Controller",
"connecting",
"the",
"model",
"with",
"the",
"frame",
"to",
"access",
"the",
"menu",
"bar",
"."
] | public class GoLMenuBarController
{
// LOCAL //
private GoLModel golModel;
private GoLFrame golFrame;
// CONSTRUCTORS //
public GoLMenuBarController(GoLFrame in_golFrame, GoLModel in_golModel)
{
golFrame = in_golFrame;
golModel = in_golModel;
golFrame.getMenuItemOpenFile().addActionListener(new GoLOpenFileListener());
golFrame.getMenuItemSaveFile().addActionListener(new GoLSaveFileListener());
golFrame.getMenuItemCloseProgram().addActionListener(new GoLCloseProgramListener());
}
// LISTENERS //
/**
* Menu item listener for open file. This will read the file into a game of life map.
*/
private class GoLOpenFileListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showOpenDialog(golFrame) == JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
int height = 0;
int width = 0;
try
{
FileReader reader = new FileReader(file);
height = reader.read();
width = reader.read();
golModel.newGame(height, width);
golFrame.getGolMainPanel().getGolMenuPanel().getGolFieldPanel().getHeightInput().setText(String.valueOf(height));
golFrame.getGolMainPanel().getGolMenuPanel().getGolFieldPanel().getWidthInput().setText(String.valueOf(width));
for (int i = golModel.getMinHeight(); i <= golModel.getMaxRowIndex(); i++)
{
for (int j = golModel.getMinWidth(); j <= golModel.getMaxColumnIndex(); j++)
{
golModel.setMapValue(i, j, (byte) reader.read());
}
}
}
catch (IOException e)
{
System.out.println("Error, reading game of life file to map.");
e.printStackTrace();
}
}
}
}
/**
* Menu item listener for save file. This will write the game of life map into a file.
*/
private class GoLSaveFileListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showSaveDialog(golFrame) == JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
try
{
FileWriter writer = new FileWriter(file);
GoLCell[][] golMap = golModel.getMap();
writer.write(golModel.getMaxRowIndex());
writer.write(golModel.getMaxColumnIndex());
for (int i = golModel.getMinHeight(); i <= golModel.getMaxRowIndex(); i++)
{
for (int j = golModel.getMinWidth(); j <= golModel.getMaxColumnIndex(); j++)
{
writer.write(golMap[i][j].getCellValue());
}
}
writer.close();
}
catch (IOException e)
{
System.out.println("Error, writing game of life map to file.");
e.printStackTrace();
}
}
}
}
/**
* Menu item listener used to exit from the application.
*/
private static class GoLCloseProgramListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
System.exit(0);
}
}
} | [
"public",
"class",
"GoLMenuBarController",
"{",
"private",
"GoLModel",
"golModel",
";",
"private",
"GoLFrame",
"golFrame",
";",
"public",
"GoLMenuBarController",
"(",
"GoLFrame",
"in_golFrame",
",",
"GoLModel",
"in_golModel",
")",
"{",
"golFrame",
"=",
"in_golFrame",
";",
"golModel",
"=",
"in_golModel",
";",
"golFrame",
".",
"getMenuItemOpenFile",
"(",
")",
".",
"addActionListener",
"(",
"new",
"GoLOpenFileListener",
"(",
")",
")",
";",
"golFrame",
".",
"getMenuItemSaveFile",
"(",
")",
".",
"addActionListener",
"(",
"new",
"GoLSaveFileListener",
"(",
")",
")",
";",
"golFrame",
".",
"getMenuItemCloseProgram",
"(",
")",
".",
"addActionListener",
"(",
"new",
"GoLCloseProgramListener",
"(",
")",
")",
";",
"}",
"/**\n * Menu item listener for open file. This will read the file into a game of life map.\n */",
"private",
"class",
"GoLOpenFileListener",
"implements",
"ActionListener",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"actionEvent",
")",
"{",
"JFileChooser",
"fileChooser",
"=",
"new",
"JFileChooser",
"(",
")",
";",
"if",
"(",
"fileChooser",
".",
"showOpenDialog",
"(",
"golFrame",
")",
"==",
"JFileChooser",
".",
"APPROVE_OPTION",
")",
"{",
"File",
"file",
"=",
"fileChooser",
".",
"getSelectedFile",
"(",
")",
";",
"int",
"height",
"=",
"0",
";",
"int",
"width",
"=",
"0",
";",
"try",
"{",
"FileReader",
"reader",
"=",
"new",
"FileReader",
"(",
"file",
")",
";",
"height",
"=",
"reader",
".",
"read",
"(",
")",
";",
"width",
"=",
"reader",
".",
"read",
"(",
")",
";",
"golModel",
".",
"newGame",
"(",
"height",
",",
"width",
")",
";",
"golFrame",
".",
"getGolMainPanel",
"(",
")",
".",
"getGolMenuPanel",
"(",
")",
".",
"getGolFieldPanel",
"(",
")",
".",
"getHeightInput",
"(",
")",
".",
"setText",
"(",
"String",
".",
"valueOf",
"(",
"height",
")",
")",
";",
"golFrame",
".",
"getGolMainPanel",
"(",
")",
".",
"getGolMenuPanel",
"(",
")",
".",
"getGolFieldPanel",
"(",
")",
".",
"getWidthInput",
"(",
")",
".",
"setText",
"(",
"String",
".",
"valueOf",
"(",
"width",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"golModel",
".",
"getMinHeight",
"(",
")",
";",
"i",
"<=",
"golModel",
".",
"getMaxRowIndex",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"golModel",
".",
"getMinWidth",
"(",
")",
";",
"j",
"<=",
"golModel",
".",
"getMaxColumnIndex",
"(",
")",
";",
"j",
"++",
")",
"{",
"golModel",
".",
"setMapValue",
"(",
"i",
",",
"j",
",",
"(",
"byte",
")",
"reader",
".",
"read",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Error, reading game of life file to map.",
"\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"}",
"/**\n * Menu item listener for save file. This will write the game of life map into a file.\n */",
"private",
"class",
"GoLSaveFileListener",
"implements",
"ActionListener",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"actionEvent",
")",
"{",
"JFileChooser",
"fileChooser",
"=",
"new",
"JFileChooser",
"(",
")",
";",
"if",
"(",
"fileChooser",
".",
"showSaveDialog",
"(",
"golFrame",
")",
"==",
"JFileChooser",
".",
"APPROVE_OPTION",
")",
"{",
"File",
"file",
"=",
"fileChooser",
".",
"getSelectedFile",
"(",
")",
";",
"try",
"{",
"FileWriter",
"writer",
"=",
"new",
"FileWriter",
"(",
"file",
")",
";",
"GoLCell",
"[",
"]",
"[",
"]",
"golMap",
"=",
"golModel",
".",
"getMap",
"(",
")",
";",
"writer",
".",
"write",
"(",
"golModel",
".",
"getMaxRowIndex",
"(",
")",
")",
";",
"writer",
".",
"write",
"(",
"golModel",
".",
"getMaxColumnIndex",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"golModel",
".",
"getMinHeight",
"(",
")",
";",
"i",
"<=",
"golModel",
".",
"getMaxRowIndex",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"golModel",
".",
"getMinWidth",
"(",
")",
";",
"j",
"<=",
"golModel",
".",
"getMaxColumnIndex",
"(",
")",
";",
"j",
"++",
")",
"{",
"writer",
".",
"write",
"(",
"golMap",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getCellValue",
"(",
")",
")",
";",
"}",
"}",
"writer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Error, writing game of life map to file.",
"\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"}",
"/**\n * Menu item listener used to exit from the application.\n */",
"private",
"static",
"class",
"GoLCloseProgramListener",
"implements",
"ActionListener",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"actionEvent",
")",
"{",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"}",
"}"
] | Controller connecting the model with the frame, to access the menu bar. | [
"Controller",
"connecting",
"the",
"model",
"with",
"the",
"frame",
"to",
"access",
"the",
"menu",
"bar",
"."
] | [
"// LOCAL //",
"// CONSTRUCTORS //",
"// LISTENERS //"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ee7034059e34922791841abcb180530674e265b | ArtursPark/AP_GameOfLife | src/ap/gameoflife/controller/menubar/GoLMenuBarController.java | [
"MIT"
] | Java | GoLOpenFileListener | /**
* Menu item listener for open file. This will read the file into a game of life map.
*/ | Menu item listener for open file. This will read the file into a game of life map. | [
"Menu",
"item",
"listener",
"for",
"open",
"file",
".",
"This",
"will",
"read",
"the",
"file",
"into",
"a",
"game",
"of",
"life",
"map",
"."
] | private class GoLOpenFileListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showOpenDialog(golFrame) == JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
int height = 0;
int width = 0;
try
{
FileReader reader = new FileReader(file);
height = reader.read();
width = reader.read();
golModel.newGame(height, width);
golFrame.getGolMainPanel().getGolMenuPanel().getGolFieldPanel().getHeightInput().setText(String.valueOf(height));
golFrame.getGolMainPanel().getGolMenuPanel().getGolFieldPanel().getWidthInput().setText(String.valueOf(width));
for (int i = golModel.getMinHeight(); i <= golModel.getMaxRowIndex(); i++)
{
for (int j = golModel.getMinWidth(); j <= golModel.getMaxColumnIndex(); j++)
{
golModel.setMapValue(i, j, (byte) reader.read());
}
}
}
catch (IOException e)
{
System.out.println("Error, reading game of life file to map.");
e.printStackTrace();
}
}
}
} | [
"private",
"class",
"GoLOpenFileListener",
"implements",
"ActionListener",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"actionEvent",
")",
"{",
"JFileChooser",
"fileChooser",
"=",
"new",
"JFileChooser",
"(",
")",
";",
"if",
"(",
"fileChooser",
".",
"showOpenDialog",
"(",
"golFrame",
")",
"==",
"JFileChooser",
".",
"APPROVE_OPTION",
")",
"{",
"File",
"file",
"=",
"fileChooser",
".",
"getSelectedFile",
"(",
")",
";",
"int",
"height",
"=",
"0",
";",
"int",
"width",
"=",
"0",
";",
"try",
"{",
"FileReader",
"reader",
"=",
"new",
"FileReader",
"(",
"file",
")",
";",
"height",
"=",
"reader",
".",
"read",
"(",
")",
";",
"width",
"=",
"reader",
".",
"read",
"(",
")",
";",
"golModel",
".",
"newGame",
"(",
"height",
",",
"width",
")",
";",
"golFrame",
".",
"getGolMainPanel",
"(",
")",
".",
"getGolMenuPanel",
"(",
")",
".",
"getGolFieldPanel",
"(",
")",
".",
"getHeightInput",
"(",
")",
".",
"setText",
"(",
"String",
".",
"valueOf",
"(",
"height",
")",
")",
";",
"golFrame",
".",
"getGolMainPanel",
"(",
")",
".",
"getGolMenuPanel",
"(",
")",
".",
"getGolFieldPanel",
"(",
")",
".",
"getWidthInput",
"(",
")",
".",
"setText",
"(",
"String",
".",
"valueOf",
"(",
"width",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"golModel",
".",
"getMinHeight",
"(",
")",
";",
"i",
"<=",
"golModel",
".",
"getMaxRowIndex",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"golModel",
".",
"getMinWidth",
"(",
")",
";",
"j",
"<=",
"golModel",
".",
"getMaxColumnIndex",
"(",
")",
";",
"j",
"++",
")",
"{",
"golModel",
".",
"setMapValue",
"(",
"i",
",",
"j",
",",
"(",
"byte",
")",
"reader",
".",
"read",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Error, reading game of life file to map.",
"\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Menu item listener for open file. | [
"Menu",
"item",
"listener",
"for",
"open",
"file",
"."
] | [] | [
{
"param": "ActionListener",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ActionListener",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ee7034059e34922791841abcb180530674e265b | ArtursPark/AP_GameOfLife | src/ap/gameoflife/controller/menubar/GoLMenuBarController.java | [
"MIT"
] | Java | GoLSaveFileListener | /**
* Menu item listener for save file. This will write the game of life map into a file.
*/ | Menu item listener for save file. This will write the game of life map into a file. | [
"Menu",
"item",
"listener",
"for",
"save",
"file",
".",
"This",
"will",
"write",
"the",
"game",
"of",
"life",
"map",
"into",
"a",
"file",
"."
] | private class GoLSaveFileListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showSaveDialog(golFrame) == JFileChooser.APPROVE_OPTION)
{
File file = fileChooser.getSelectedFile();
try
{
FileWriter writer = new FileWriter(file);
GoLCell[][] golMap = golModel.getMap();
writer.write(golModel.getMaxRowIndex());
writer.write(golModel.getMaxColumnIndex());
for (int i = golModel.getMinHeight(); i <= golModel.getMaxRowIndex(); i++)
{
for (int j = golModel.getMinWidth(); j <= golModel.getMaxColumnIndex(); j++)
{
writer.write(golMap[i][j].getCellValue());
}
}
writer.close();
}
catch (IOException e)
{
System.out.println("Error, writing game of life map to file.");
e.printStackTrace();
}
}
}
} | [
"private",
"class",
"GoLSaveFileListener",
"implements",
"ActionListener",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"actionEvent",
")",
"{",
"JFileChooser",
"fileChooser",
"=",
"new",
"JFileChooser",
"(",
")",
";",
"if",
"(",
"fileChooser",
".",
"showSaveDialog",
"(",
"golFrame",
")",
"==",
"JFileChooser",
".",
"APPROVE_OPTION",
")",
"{",
"File",
"file",
"=",
"fileChooser",
".",
"getSelectedFile",
"(",
")",
";",
"try",
"{",
"FileWriter",
"writer",
"=",
"new",
"FileWriter",
"(",
"file",
")",
";",
"GoLCell",
"[",
"]",
"[",
"]",
"golMap",
"=",
"golModel",
".",
"getMap",
"(",
")",
";",
"writer",
".",
"write",
"(",
"golModel",
".",
"getMaxRowIndex",
"(",
")",
")",
";",
"writer",
".",
"write",
"(",
"golModel",
".",
"getMaxColumnIndex",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"golModel",
".",
"getMinHeight",
"(",
")",
";",
"i",
"<=",
"golModel",
".",
"getMaxRowIndex",
"(",
")",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"golModel",
".",
"getMinWidth",
"(",
")",
";",
"j",
"<=",
"golModel",
".",
"getMaxColumnIndex",
"(",
")",
";",
"j",
"++",
")",
"{",
"writer",
".",
"write",
"(",
"golMap",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getCellValue",
"(",
")",
")",
";",
"}",
"}",
"writer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Error, writing game of life map to file.",
"\"",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Menu item listener for save file. | [
"Menu",
"item",
"listener",
"for",
"save",
"file",
"."
] | [] | [
{
"param": "ActionListener",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ActionListener",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ee7034059e34922791841abcb180530674e265b | ArtursPark/AP_GameOfLife | src/ap/gameoflife/controller/menubar/GoLMenuBarController.java | [
"MIT"
] | Java | GoLCloseProgramListener | /**
* Menu item listener used to exit from the application.
*/ | Menu item listener used to exit from the application. | [
"Menu",
"item",
"listener",
"used",
"to",
"exit",
"from",
"the",
"application",
"."
] | private static class GoLCloseProgramListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent actionEvent)
{
System.exit(0);
}
} | [
"private",
"static",
"class",
"GoLCloseProgramListener",
"implements",
"ActionListener",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"actionEvent",
")",
"{",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"}"
] | Menu item listener used to exit from the application. | [
"Menu",
"item",
"listener",
"used",
"to",
"exit",
"from",
"the",
"application",
"."
] | [] | [
{
"param": "ActionListener",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ActionListener",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1eed05fd13302456f12489cc3d818a9820411344 | vvteplygin/ignite | modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryDeploymentToClientTest.java | [
"Apache-2.0"
] | Java | CacheContinuousQueryDeploymentToClientTest | /**
* Tests for continuous query deployment to client nodes.
*/ | Tests for continuous query deployment to client nodes. | [
"Tests",
"for",
"continuous",
"query",
"deployment",
"to",
"client",
"nodes",
"."
] | public class CacheContinuousQueryDeploymentToClientTest extends GridCommonAbstractTest {
/** Cache name. */
private static final String CACHE_NAME = "test_cache";
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setPeerClassLoadingEnabled(true);
cfg.setCacheConfiguration(new CacheConfiguration<>(CACHE_NAME));
return cfg;
}
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
stopAllGrids();
super.afterTest();
}
/**
* Test starts 1 server node and 1 client node. The client node deploys
* CQ for the cache {@link #CACHE_NAME}. After that another client node is started.
* Expected that CQ won't be deployed to the new client, since the client doesn't
* store any data.
*
* @throws Exception If failed.
*/
@Test
public void testDeploymentToNewClient() throws Exception {
startGrid(0);
IgniteEx client1 = startClientGrid(1);
IgniteCache<Integer, String> cache = client1.cache(CACHE_NAME);
AbstractContinuousQuery<Integer, String> qry = new ContinuousQuery<Integer, String>()
.setLocalListener(evts -> {
// No-op.
})
.setRemoteFilterFactory((Factory<CacheEntryEventFilter<Integer, String>>)() -> evt -> true);
cache.query(qry);
IgniteEx client2 = startClientGrid(2);
GridContinuousProcessor proc = client2.context().continuous();
assertEquals(0, ((Map<?, ?>)U.field(proc, "locInfos")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "rmtInfos")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "startFuts")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "stopFuts")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "bufCheckThreads")).size());
}
/**
* Test starts 1 server node and 2 client nodes. The first client node deploys
* CQ for the cache {@link #CACHE_NAME}.
* Expected that CQ won't be deployed to the second client, since the client doesn't
* store any data.
*
* @throws Exception If failed.
*/
@Test
public void testDeploymentToExistingClient() throws Exception {
startGrid(0);
IgniteEx client1 = startClientGrid(1);
IgniteCache<Integer, String> cache = client1.cache(CACHE_NAME);
IgniteEx client2 = startClientGrid(2);
AbstractContinuousQuery<Integer, String> qry = new ContinuousQuery<Integer, String>()
.setLocalListener(evts -> {
// No-op.
})
.setRemoteFilterFactory((Factory<CacheEntryEventFilter<Integer, String>>)() -> evt -> true);
cache.query(qry);
GridContinuousProcessor proc = client2.context().continuous();
assertEquals(0, ((Map<?, ?>)U.field(proc, "locInfos")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "rmtInfos")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "startFuts")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "stopFuts")).size());
assertEquals(0, ((Map<?, ?>)U.field(proc, "bufCheckThreads")).size());
}
} | [
"public",
"class",
"CacheContinuousQueryDeploymentToClientTest",
"extends",
"GridCommonAbstractTest",
"{",
"/** Cache name. */",
"private",
"static",
"final",
"String",
"CACHE_NAME",
"=",
"\"",
"test_cache",
"\"",
";",
"/** {@inheritDoc} */",
"@",
"Override",
"protected",
"IgniteConfiguration",
"getConfiguration",
"(",
"String",
"igniteInstanceName",
")",
"throws",
"Exception",
"{",
"IgniteConfiguration",
"cfg",
"=",
"super",
".",
"getConfiguration",
"(",
"igniteInstanceName",
")",
";",
"cfg",
".",
"setPeerClassLoadingEnabled",
"(",
"true",
")",
";",
"cfg",
".",
"setCacheConfiguration",
"(",
"new",
"CacheConfiguration",
"<",
">",
"(",
"CACHE_NAME",
")",
")",
";",
"return",
"cfg",
";",
"}",
"/** {@inheritDoc} */",
"@",
"Override",
"protected",
"void",
"afterTest",
"(",
")",
"throws",
"Exception",
"{",
"stopAllGrids",
"(",
")",
";",
"super",
".",
"afterTest",
"(",
")",
";",
"}",
"/**\n * Test starts 1 server node and 1 client node. The client node deploys\n * CQ for the cache {@link #CACHE_NAME}. After that another client node is started.\n * Expected that CQ won't be deployed to the new client, since the client doesn't\n * store any data.\n *\n * @throws Exception If failed.\n */",
"@",
"Test",
"public",
"void",
"testDeploymentToNewClient",
"(",
")",
"throws",
"Exception",
"{",
"startGrid",
"(",
"0",
")",
";",
"IgniteEx",
"client1",
"=",
"startClientGrid",
"(",
"1",
")",
";",
"IgniteCache",
"<",
"Integer",
",",
"String",
">",
"cache",
"=",
"client1",
".",
"cache",
"(",
"CACHE_NAME",
")",
";",
"AbstractContinuousQuery",
"<",
"Integer",
",",
"String",
">",
"qry",
"=",
"new",
"ContinuousQuery",
"<",
"Integer",
",",
"String",
">",
"(",
")",
".",
"setLocalListener",
"(",
"evts",
"->",
"{",
"}",
")",
".",
"setRemoteFilterFactory",
"(",
"(",
"Factory",
"<",
"CacheEntryEventFilter",
"<",
"Integer",
",",
"String",
">",
">",
")",
"(",
")",
"->",
"evt",
"->",
"true",
")",
";",
"cache",
".",
"query",
"(",
"qry",
")",
";",
"IgniteEx",
"client2",
"=",
"startClientGrid",
"(",
"2",
")",
";",
"GridContinuousProcessor",
"proc",
"=",
"client2",
".",
"context",
"(",
")",
".",
"continuous",
"(",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"locInfos",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"rmtInfos",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"startFuts",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"stopFuts",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"bufCheckThreads",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"/**\n * Test starts 1 server node and 2 client nodes. The first client node deploys\n * CQ for the cache {@link #CACHE_NAME}.\n * Expected that CQ won't be deployed to the second client, since the client doesn't\n * store any data.\n *\n * @throws Exception If failed.\n */",
"@",
"Test",
"public",
"void",
"testDeploymentToExistingClient",
"(",
")",
"throws",
"Exception",
"{",
"startGrid",
"(",
"0",
")",
";",
"IgniteEx",
"client1",
"=",
"startClientGrid",
"(",
"1",
")",
";",
"IgniteCache",
"<",
"Integer",
",",
"String",
">",
"cache",
"=",
"client1",
".",
"cache",
"(",
"CACHE_NAME",
")",
";",
"IgniteEx",
"client2",
"=",
"startClientGrid",
"(",
"2",
")",
";",
"AbstractContinuousQuery",
"<",
"Integer",
",",
"String",
">",
"qry",
"=",
"new",
"ContinuousQuery",
"<",
"Integer",
",",
"String",
">",
"(",
")",
".",
"setLocalListener",
"(",
"evts",
"->",
"{",
"}",
")",
".",
"setRemoteFilterFactory",
"(",
"(",
"Factory",
"<",
"CacheEntryEventFilter",
"<",
"Integer",
",",
"String",
">",
">",
")",
"(",
")",
"->",
"evt",
"->",
"true",
")",
";",
"cache",
".",
"query",
"(",
"qry",
")",
";",
"GridContinuousProcessor",
"proc",
"=",
"client2",
".",
"context",
"(",
")",
".",
"continuous",
"(",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"locInfos",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"rmtInfos",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"startFuts",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"stopFuts",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"assertEquals",
"(",
"0",
",",
"(",
"(",
"Map",
"<",
"?",
",",
"?",
">",
")",
"U",
".",
"field",
"(",
"proc",
",",
"\"",
"bufCheckThreads",
"\"",
")",
")",
".",
"size",
"(",
")",
")",
";",
"}",
"}"
] | Tests for continuous query deployment to client nodes. | [
"Tests",
"for",
"continuous",
"query",
"deployment",
"to",
"client",
"nodes",
"."
] | [
"// No-op.",
"// No-op."
] | [
{
"param": "GridCommonAbstractTest",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "GridCommonAbstractTest",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1eefe0ac940a7ff7adeedc1b8ec395a8a3d69e48 | saarus72/protege-proof-based-justifications | src/main/java/org/liveontologies/protege/explanation/justification/proof/service/ProverPluginLoader.java | [
"Apache-2.0"
] | Java | ProverPluginLoader | /**
* Load the available specified {@link ProverService} plugins
*
* @author Alexander
* Date: 23/02/2017
*/ | Load the available specified ProverService plugins
@author Alexander
Date: 23/02/2017 | [
"Load",
"the",
"available",
"specified",
"ProverService",
"plugins",
"@author",
"Alexander",
"Date",
":",
"23",
"/",
"02",
"/",
"2017"
] | public class ProverPluginLoader extends AbstractPluginLoader<ProverPlugin> {
/**
* Constructs ProverPluginLoader
*
* @param KEY A string to specify the extension point to find plugins for
* @param ID A string to specify the extension point to find plugins for
*/
public ProverPluginLoader(String KEY, String ID) {
super(KEY, ID);
}
@Override
protected ProverPlugin createInstance(IExtension extension) {
return new ProverPlugin(extension);
}
} | [
"public",
"class",
"ProverPluginLoader",
"extends",
"AbstractPluginLoader",
"<",
"ProverPlugin",
">",
"{",
"/**\n\t * Constructs ProverPluginLoader\n\t * \n\t * @param KEY\tA string to specify the extension point to find plugins for\n\t * @param ID\tA string to specify the extension point to find plugins for\n\t */",
"public",
"ProverPluginLoader",
"(",
"String",
"KEY",
",",
"String",
"ID",
")",
"{",
"super",
"(",
"KEY",
",",
"ID",
")",
";",
"}",
"@",
"Override",
"protected",
"ProverPlugin",
"createInstance",
"(",
"IExtension",
"extension",
")",
"{",
"return",
"new",
"ProverPlugin",
"(",
"extension",
")",
";",
"}",
"}"
] | Load the available specified {@link ProverService} plugins
@author Alexander
Date: 23/02/2017 | [
"Load",
"the",
"available",
"specified",
"{",
"@link",
"ProverService",
"}",
"plugins",
"@author",
"Alexander",
"Date",
":",
"23",
"/",
"02",
"/",
"2017"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ef003da788a4a08bb5794afa95235668c0cd879 | kantoniak/tap-the-map | app/src/main/java/pl/gov/stat/tapthemap/scene/MapRenderer.java | [
"Apache-2.0"
] | Java | MapRenderer | /**
* Class responsible for rendering the map.
*/ | Class responsible for rendering the map. | [
"Class",
"responsible",
"for",
"rendering",
"the",
"map",
"."
] | public class MapRenderer extends Renderer implements OnObjectPickedListener {
private static final Vector2 MAP_SIZE = new Vector2(2.438f, 2.889f);
private static final Vector3 MAP_CORRECTION = new Vector3(-0.005f, 0, 0.005f);
private static final Vector3 MAP_MIDDLE = new Vector3(-MapRenderer.MAP_SIZE.getX(), 0, MapRenderer.MAP_SIZE.getY()).multiply(0.5f);
private final Map map;
private final AssetLoader loader;
private RenderingDelegate renderingDelegate;
private GameActivity mContext;
private ObjectColorPicker objectPicker;
private Plane mapBase;
private boolean visible = true;
private Vector3 worldOffset = getDefaultWorldOffset();
public MapRenderer(Context context, Map map) {
super(context);
this.map = map;
this.loader = new AssetLoader(context, mTextureManager);
this.mContext = (GameActivity) context;
}
/**
* Set rendering delegate.
*
* @param renderingDelegate Rendering delegate
*/
public void setRenderingDelegate(RenderingDelegate renderingDelegate) {
this.renderingDelegate = renderingDelegate;
}
/**
* When render surface created.
*/
@Override
public void onRenderSurfaceCreated(EGLConfig config, GL10 gl, int width, int height) {
super.onRenderSurfaceCreated(config, gl, width, height);
if (renderingDelegate != null) {
renderingDelegate.onSurfaceCreated();
}
}
/**
* When render surface size changed.
*/
@Override
public void onRenderSurfaceSizeChanged(GL10 gl, int width, int height) {
super.onRenderSurfaceSizeChanged(gl, width, height);
if (renderingDelegate != null) {
renderingDelegate.onSurfaceChanged(width, height);
}
}
/**
* Initialize scene.
*/
@Override
protected void initScene() {
setupObjectPicker();
mapBase = new Plane();
mapBase.setDoubleSided(true);
mapBase.setScale(MAP_SIZE.getX(), 1, MAP_SIZE.getY());
mapBase.setPosition(MAP_CORRECTION);
mapBase.rotate(Vector3.Axis.X, +90);
mapBase.setTransparent(true);
getCurrentScene().addChild(mapBase);
try {
Material mapBaseMaterial = new Material();
mapBaseMaterial.setColor(0x00000000);
mapBaseMaterial.addTexture(mTextureManager.addTexture(loader.loadTexture("map_background")));
mapBase.setMaterial(mapBaseMaterial);
} catch (ATexture.TextureException e) {
e.printStackTrace();
}
showMap(false);
}
/**
* Add country instance.
*
* @param countryInstance Which country instance
*/
public void addCountryInstance(CountryInstance countryInstance) {
countryInstance.initPositions(MAP_MIDDLE, map.getCountryMiddle(countryInstance.getCountry()));
countryInstance.registerObject(getCurrentScene(), objectPicker);
countryInstance.resetState();
map.addCountryInstance(countryInstance);
}
/**
* Update visibility.
*/
private void updateVisibility() {
if (mapBase != null) {
mapBase.setVisible(visible);
}
map.setVisible(visible);
}
/**
* Set up object picker.
*/
private void setupObjectPicker() {
objectPicker = new ObjectColorPicker(this);
objectPicker.setOnObjectPickedListener(this);
}
/**
* When offsets changed.
*/
@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
}
/**
* When touch event.
*/
@Override
public void onTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
objectPicker.getObjectAt(event.getX(), event.getY());
}
}
/**
* When object picked.
*
* @param object Which object
*/
@Override
public void onObjectPicked(@NonNull Object3D object) {
for (java.util.Map.Entry<Country, CountryInstance> entry : map.getCountries().entrySet()) {
if (entry.getValue().containsObject(object)) {
entry.getValue().onPicked();
}
}
mContext.runOnUiThread(() -> ((QuestionSeriesFragment) mContext.getSupportFragmentManager().findFragmentByTag("QuestionSeriesFragment")).updateLabels());
}
/**
* When no object picked.
*/
@Override
public void onNoObjectPicked() {
// Do nothing
}
/**
* Set camera.
*
* @param camera Which camera
*/
public void setCamera(Camera camera) {
getCurrentScene().addAndSwitchCamera(camera);
}
/**
* Get loader.
*
* @return Asset loader
*/
public AssetLoader getLoader() {
return loader;
}
/**
* Get map.
*
* @return Map
*/
public Map getMap() {
return map;
}
/**
* Show map.
*
* @param show Whether to show or not
*/
public void showMap(boolean show) {
this.visible = show;
updateVisibility();
}
public void setWorldOffset(Vector3 worldOffset) {
mapBase.setPosition(worldOffset.clone().add(MAP_MIDDLE.clone().multiply(-1.f)).add(MAP_CORRECTION));
map.getCountries().forEach((country, instance) -> instance.setWorldOffset(worldOffset));
this.worldOffset = worldOffset;
}
public Vector3 getWorldOffset() {
return worldOffset;
}
public Vector3 getDefaultWorldOffset() {
return MAP_MIDDLE.clone();
}
public void centerViewAt(final Country country) {
final Vector2 countryMiddle = map.getCountryMiddle(country);
this.setWorldOffset(new Vector3(-countryMiddle.getX(), 0, countryMiddle.getY()));
}
} | [
"public",
"class",
"MapRenderer",
"extends",
"Renderer",
"implements",
"OnObjectPickedListener",
"{",
"private",
"static",
"final",
"Vector2",
"MAP_SIZE",
"=",
"new",
"Vector2",
"(",
"2.438f",
",",
"2.889f",
")",
";",
"private",
"static",
"final",
"Vector3",
"MAP_CORRECTION",
"=",
"new",
"Vector3",
"(",
"-",
"0.005f",
",",
"0",
",",
"0.005f",
")",
";",
"private",
"static",
"final",
"Vector3",
"MAP_MIDDLE",
"=",
"new",
"Vector3",
"(",
"-",
"MapRenderer",
".",
"MAP_SIZE",
".",
"getX",
"(",
")",
",",
"0",
",",
"MapRenderer",
".",
"MAP_SIZE",
".",
"getY",
"(",
")",
")",
".",
"multiply",
"(",
"0.5f",
")",
";",
"private",
"final",
"Map",
"map",
";",
"private",
"final",
"AssetLoader",
"loader",
";",
"private",
"RenderingDelegate",
"renderingDelegate",
";",
"private",
"GameActivity",
"mContext",
";",
"private",
"ObjectColorPicker",
"objectPicker",
";",
"private",
"Plane",
"mapBase",
";",
"private",
"boolean",
"visible",
"=",
"true",
";",
"private",
"Vector3",
"worldOffset",
"=",
"getDefaultWorldOffset",
"(",
")",
";",
"public",
"MapRenderer",
"(",
"Context",
"context",
",",
"Map",
"map",
")",
"{",
"super",
"(",
"context",
")",
";",
"this",
".",
"map",
"=",
"map",
";",
"this",
".",
"loader",
"=",
"new",
"AssetLoader",
"(",
"context",
",",
"mTextureManager",
")",
";",
"this",
".",
"mContext",
"=",
"(",
"GameActivity",
")",
"context",
";",
"}",
"/**\n * Set rendering delegate.\n *\n * @param renderingDelegate Rendering delegate\n */",
"public",
"void",
"setRenderingDelegate",
"(",
"RenderingDelegate",
"renderingDelegate",
")",
"{",
"this",
".",
"renderingDelegate",
"=",
"renderingDelegate",
";",
"}",
"/**\n * When render surface created.\n */",
"@",
"Override",
"public",
"void",
"onRenderSurfaceCreated",
"(",
"EGLConfig",
"config",
",",
"GL10",
"gl",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"super",
".",
"onRenderSurfaceCreated",
"(",
"config",
",",
"gl",
",",
"width",
",",
"height",
")",
";",
"if",
"(",
"renderingDelegate",
"!=",
"null",
")",
"{",
"renderingDelegate",
".",
"onSurfaceCreated",
"(",
")",
";",
"}",
"}",
"/**\n * When render surface size changed.\n */",
"@",
"Override",
"public",
"void",
"onRenderSurfaceSizeChanged",
"(",
"GL10",
"gl",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"super",
".",
"onRenderSurfaceSizeChanged",
"(",
"gl",
",",
"width",
",",
"height",
")",
";",
"if",
"(",
"renderingDelegate",
"!=",
"null",
")",
"{",
"renderingDelegate",
".",
"onSurfaceChanged",
"(",
"width",
",",
"height",
")",
";",
"}",
"}",
"/**\n * Initialize scene.\n */",
"@",
"Override",
"protected",
"void",
"initScene",
"(",
")",
"{",
"setupObjectPicker",
"(",
")",
";",
"mapBase",
"=",
"new",
"Plane",
"(",
")",
";",
"mapBase",
".",
"setDoubleSided",
"(",
"true",
")",
";",
"mapBase",
".",
"setScale",
"(",
"MAP_SIZE",
".",
"getX",
"(",
")",
",",
"1",
",",
"MAP_SIZE",
".",
"getY",
"(",
")",
")",
";",
"mapBase",
".",
"setPosition",
"(",
"MAP_CORRECTION",
")",
";",
"mapBase",
".",
"rotate",
"(",
"Vector3",
".",
"Axis",
".",
"X",
",",
"+",
"90",
")",
";",
"mapBase",
".",
"setTransparent",
"(",
"true",
")",
";",
"getCurrentScene",
"(",
")",
".",
"addChild",
"(",
"mapBase",
")",
";",
"try",
"{",
"Material",
"mapBaseMaterial",
"=",
"new",
"Material",
"(",
")",
";",
"mapBaseMaterial",
".",
"setColor",
"(",
"0x00000000",
")",
";",
"mapBaseMaterial",
".",
"addTexture",
"(",
"mTextureManager",
".",
"addTexture",
"(",
"loader",
".",
"loadTexture",
"(",
"\"",
"map_background",
"\"",
")",
")",
")",
";",
"mapBase",
".",
"setMaterial",
"(",
"mapBaseMaterial",
")",
";",
"}",
"catch",
"(",
"ATexture",
".",
"TextureException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"showMap",
"(",
"false",
")",
";",
"}",
"/**\n * Add country instance.\n *\n * @param countryInstance Which country instance\n */",
"public",
"void",
"addCountryInstance",
"(",
"CountryInstance",
"countryInstance",
")",
"{",
"countryInstance",
".",
"initPositions",
"(",
"MAP_MIDDLE",
",",
"map",
".",
"getCountryMiddle",
"(",
"countryInstance",
".",
"getCountry",
"(",
")",
")",
")",
";",
"countryInstance",
".",
"registerObject",
"(",
"getCurrentScene",
"(",
")",
",",
"objectPicker",
")",
";",
"countryInstance",
".",
"resetState",
"(",
")",
";",
"map",
".",
"addCountryInstance",
"(",
"countryInstance",
")",
";",
"}",
"/**\n * Update visibility.\n */",
"private",
"void",
"updateVisibility",
"(",
")",
"{",
"if",
"(",
"mapBase",
"!=",
"null",
")",
"{",
"mapBase",
".",
"setVisible",
"(",
"visible",
")",
";",
"}",
"map",
".",
"setVisible",
"(",
"visible",
")",
";",
"}",
"/**\n * Set up object picker.\n */",
"private",
"void",
"setupObjectPicker",
"(",
")",
"{",
"objectPicker",
"=",
"new",
"ObjectColorPicker",
"(",
"this",
")",
";",
"objectPicker",
".",
"setOnObjectPickedListener",
"(",
"this",
")",
";",
"}",
"/**\n * When offsets changed.\n */",
"@",
"Override",
"public",
"void",
"onOffsetsChanged",
"(",
"float",
"xOffset",
",",
"float",
"yOffset",
",",
"float",
"xOffsetStep",
",",
"float",
"yOffsetStep",
",",
"int",
"xPixelOffset",
",",
"int",
"yPixelOffset",
")",
"{",
"}",
"/**\n * When touch event.\n */",
"@",
"Override",
"public",
"void",
"onTouchEvent",
"(",
"MotionEvent",
"event",
")",
"{",
"if",
"(",
"event",
".",
"getActionMasked",
"(",
")",
"==",
"MotionEvent",
".",
"ACTION_UP",
")",
"{",
"objectPicker",
".",
"getObjectAt",
"(",
"event",
".",
"getX",
"(",
")",
",",
"event",
".",
"getY",
"(",
")",
")",
";",
"}",
"}",
"/**\n * When object picked.\n *\n * @param object Which object\n */",
"@",
"Override",
"public",
"void",
"onObjectPicked",
"(",
"@",
"NonNull",
"Object3D",
"object",
")",
"{",
"for",
"(",
"java",
".",
"util",
".",
"Map",
".",
"Entry",
"<",
"Country",
",",
"CountryInstance",
">",
"entry",
":",
"map",
".",
"getCountries",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"containsObject",
"(",
"object",
")",
")",
"{",
"entry",
".",
"getValue",
"(",
")",
".",
"onPicked",
"(",
")",
";",
"}",
"}",
"mContext",
".",
"runOnUiThread",
"(",
"(",
")",
"->",
"(",
"(",
"QuestionSeriesFragment",
")",
"mContext",
".",
"getSupportFragmentManager",
"(",
")",
".",
"findFragmentByTag",
"(",
"\"",
"QuestionSeriesFragment",
"\"",
")",
")",
".",
"updateLabels",
"(",
")",
")",
";",
"}",
"/**\n * When no object picked.\n */",
"@",
"Override",
"public",
"void",
"onNoObjectPicked",
"(",
")",
"{",
"}",
"/**\n * Set camera.\n *\n * @param camera Which camera\n */",
"public",
"void",
"setCamera",
"(",
"Camera",
"camera",
")",
"{",
"getCurrentScene",
"(",
")",
".",
"addAndSwitchCamera",
"(",
"camera",
")",
";",
"}",
"/**\n * Get loader.\n *\n * @return Asset loader\n */",
"public",
"AssetLoader",
"getLoader",
"(",
")",
"{",
"return",
"loader",
";",
"}",
"/**\n * Get map.\n *\n * @return Map\n */",
"public",
"Map",
"getMap",
"(",
")",
"{",
"return",
"map",
";",
"}",
"/**\n * Show map.\n *\n * @param show Whether to show or not\n */",
"public",
"void",
"showMap",
"(",
"boolean",
"show",
")",
"{",
"this",
".",
"visible",
"=",
"show",
";",
"updateVisibility",
"(",
")",
";",
"}",
"public",
"void",
"setWorldOffset",
"(",
"Vector3",
"worldOffset",
")",
"{",
"mapBase",
".",
"setPosition",
"(",
"worldOffset",
".",
"clone",
"(",
")",
".",
"add",
"(",
"MAP_MIDDLE",
".",
"clone",
"(",
")",
".",
"multiply",
"(",
"-",
"1.f",
")",
")",
".",
"add",
"(",
"MAP_CORRECTION",
")",
")",
";",
"map",
".",
"getCountries",
"(",
")",
".",
"forEach",
"(",
"(",
"country",
",",
"instance",
")",
"->",
"instance",
".",
"setWorldOffset",
"(",
"worldOffset",
")",
")",
";",
"this",
".",
"worldOffset",
"=",
"worldOffset",
";",
"}",
"public",
"Vector3",
"getWorldOffset",
"(",
")",
"{",
"return",
"worldOffset",
";",
"}",
"public",
"Vector3",
"getDefaultWorldOffset",
"(",
")",
"{",
"return",
"MAP_MIDDLE",
".",
"clone",
"(",
")",
";",
"}",
"public",
"void",
"centerViewAt",
"(",
"final",
"Country",
"country",
")",
"{",
"final",
"Vector2",
"countryMiddle",
"=",
"map",
".",
"getCountryMiddle",
"(",
"country",
")",
";",
"this",
".",
"setWorldOffset",
"(",
"new",
"Vector3",
"(",
"-",
"countryMiddle",
".",
"getX",
"(",
")",
",",
"0",
",",
"countryMiddle",
".",
"getY",
"(",
")",
")",
")",
";",
"}",
"}"
] | Class responsible for rendering the map. | [
"Class",
"responsible",
"for",
"rendering",
"the",
"map",
"."
] | [
"// Do nothing"
] | [
{
"param": "Renderer",
"type": null
},
{
"param": "OnObjectPickedListener",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Renderer",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "OnObjectPickedListener",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ef751d84ac17959c93f8d9423ea65450395c7a4 | Fiware/i2nd.FIWARE-OFNIC | src/main/java/org/opendaylight/controller/switchmanager/northbound/NodeProperties.java | [
"Apache-2.0"
] | Java | NodeProperties | /**
* The class describes set of properties attached to a node
*/ | The class describes set of properties attached to a node | [
"The",
"class",
"describes",
"set",
"of",
"properties",
"attached",
"to",
"a",
"node"
] | @javax.xml.bind.annotation.XmlType (
name = "nodeProperties",
namespace = ""
)
@javax.xml.bind.annotation.XmlRootElement (
name = "nodeProperties",
namespace = ""
)
public class NodeProperties implements java.io.Serializable {
private org.opendaylight.controller.sal.core.Node _node;
private java.util.Collection<org.opendaylight.controller.sal.core.Property> _properties;
/**
* (no documentation provided)
*/
@javax.xml.bind.annotation.XmlElement (
name = "node",
namespace = ""
)
public org.opendaylight.controller.sal.core.Node getNode() {
return this._node;
}
/**
* (no documentation provided)
*/
public void setNode(org.opendaylight.controller.sal.core.Node _node) {
this._node = _node;
}
/**
* (no documentation provided)
*/
@javax.xml.bind.annotation.XmlElement (
name = "property",
namespace = ""
)
@javax.xml.bind.annotation.XmlElementWrapper (
name = "properties",
namespace = ""
)
public java.util.Collection<org.opendaylight.controller.sal.core.Property> getProperties() {
return this._properties;
}
/**
* (no documentation provided)
*/
public void setProperties(java.util.Collection<org.opendaylight.controller.sal.core.Property> _properties) {
this._properties = _properties;
}
} | [
"@",
"javax",
".",
"xml",
".",
"bind",
".",
"annotation",
".",
"XmlType",
"(",
"name",
"=",
"\"",
"nodeProperties",
"\"",
",",
"namespace",
"=",
"\"",
"\"",
")",
"@",
"javax",
".",
"xml",
".",
"bind",
".",
"annotation",
".",
"XmlRootElement",
"(",
"name",
"=",
"\"",
"nodeProperties",
"\"",
",",
"namespace",
"=",
"\"",
"\"",
")",
"public",
"class",
"NodeProperties",
"implements",
"java",
".",
"io",
".",
"Serializable",
"{",
"private",
"org",
".",
"opendaylight",
".",
"controller",
".",
"sal",
".",
"core",
".",
"Node",
"_node",
";",
"private",
"java",
".",
"util",
".",
"Collection",
"<",
"org",
".",
"opendaylight",
".",
"controller",
".",
"sal",
".",
"core",
".",
"Property",
">",
"_properties",
";",
"/**\n * (no documentation provided)\n */",
"@",
"javax",
".",
"xml",
".",
"bind",
".",
"annotation",
".",
"XmlElement",
"(",
"name",
"=",
"\"",
"node",
"\"",
",",
"namespace",
"=",
"\"",
"\"",
")",
"public",
"org",
".",
"opendaylight",
".",
"controller",
".",
"sal",
".",
"core",
".",
"Node",
"getNode",
"(",
")",
"{",
"return",
"this",
".",
"_node",
";",
"}",
"/**\n * (no documentation provided)\n */",
"public",
"void",
"setNode",
"(",
"org",
".",
"opendaylight",
".",
"controller",
".",
"sal",
".",
"core",
".",
"Node",
"_node",
")",
"{",
"this",
".",
"_node",
"=",
"_node",
";",
"}",
"/**\n * (no documentation provided)\n */",
"@",
"javax",
".",
"xml",
".",
"bind",
".",
"annotation",
".",
"XmlElement",
"(",
"name",
"=",
"\"",
"property",
"\"",
",",
"namespace",
"=",
"\"",
"\"",
")",
"@",
"javax",
".",
"xml",
".",
"bind",
".",
"annotation",
".",
"XmlElementWrapper",
"(",
"name",
"=",
"\"",
"properties",
"\"",
",",
"namespace",
"=",
"\"",
"\"",
")",
"public",
"java",
".",
"util",
".",
"Collection",
"<",
"org",
".",
"opendaylight",
".",
"controller",
".",
"sal",
".",
"core",
".",
"Property",
">",
"getProperties",
"(",
")",
"{",
"return",
"this",
".",
"_properties",
";",
"}",
"/**\n * (no documentation provided)\n */",
"public",
"void",
"setProperties",
"(",
"java",
".",
"util",
".",
"Collection",
"<",
"org",
".",
"opendaylight",
".",
"controller",
".",
"sal",
".",
"core",
".",
"Property",
">",
"_properties",
")",
"{",
"this",
".",
"_properties",
"=",
"_properties",
";",
"}",
"}"
] | The class describes set of properties attached to a node | [
"The",
"class",
"describes",
"set",
"of",
"properties",
"attached",
"to",
"a",
"node"
] | [] | [
{
"param": "java.io.Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "java.io.Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ef892356361a6a2ffb2b478f1df282a44e3fe97 | jranjith3316/liferay-tomcat-6.2 | tomcat-7.0.62/webapps/kaleo-web/WEB-INF/src/com/liferay/portal/workflow/kaleo/model/impl/KaleoTaskAssignmentInstanceModelImpl.java | [
"Unlicense"
] | Java | KaleoTaskAssignmentInstanceModelImpl | /**
* The base model implementation for the KaleoTaskAssignmentInstance service. Represents a row in the "KaleoTaskAssignmentInstance" database table, with each column mapped to a property of this class.
*
* <p>
* This implementation and its corresponding interface {@link com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstanceModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link KaleoTaskAssignmentInstanceImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see KaleoTaskAssignmentInstanceImpl
* @see com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance
* @see com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstanceModel
* @generated
*/ | The base model implementation for the KaleoTaskAssignmentInstance service. Represents a row in the "KaleoTaskAssignmentInstance" database table, with each column mapped to a property of this class.
This implementation and its corresponding interface com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstanceModel exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in KaleoTaskAssignmentInstanceImpl.
| [
"The",
"base",
"model",
"implementation",
"for",
"the",
"KaleoTaskAssignmentInstance",
"service",
".",
"Represents",
"a",
"row",
"in",
"the",
"\"",
"KaleoTaskAssignmentInstance",
"\"",
"database",
"table",
"with",
"each",
"column",
"mapped",
"to",
"a",
"property",
"of",
"this",
"class",
".",
"This",
"implementation",
"and",
"its",
"corresponding",
"interface",
"com",
".",
"liferay",
".",
"portal",
".",
"workflow",
".",
"kaleo",
".",
"model",
".",
"KaleoTaskAssignmentInstanceModel",
"exist",
"only",
"as",
"a",
"container",
"for",
"the",
"default",
"property",
"accessors",
"generated",
"by",
"ServiceBuilder",
".",
"Helper",
"methods",
"and",
"all",
"application",
"logic",
"should",
"be",
"put",
"in",
"KaleoTaskAssignmentInstanceImpl",
"."
] | public class KaleoTaskAssignmentInstanceModelImpl extends BaseModelImpl<KaleoTaskAssignmentInstance>
implements KaleoTaskAssignmentInstanceModel {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a kaleo task assignment instance model instance should use the {@link com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance} interface instead.
*/
public static final String TABLE_NAME = "KaleoTaskAssignmentInstance";
public static final Object[][] TABLE_COLUMNS = {
{ "kaleoTaskAssignmentInstanceId", Types.BIGINT },
{ "groupId", Types.BIGINT },
{ "companyId", Types.BIGINT },
{ "userId", Types.BIGINT },
{ "userName", Types.VARCHAR },
{ "createDate", Types.TIMESTAMP },
{ "modifiedDate", Types.TIMESTAMP },
{ "kaleoDefinitionId", Types.BIGINT },
{ "kaleoInstanceId", Types.BIGINT },
{ "kaleoInstanceTokenId", Types.BIGINT },
{ "kaleoTaskInstanceTokenId", Types.BIGINT },
{ "kaleoTaskId", Types.BIGINT },
{ "kaleoTaskName", Types.VARCHAR },
{ "assigneeClassName", Types.VARCHAR },
{ "assigneeClassPK", Types.BIGINT },
{ "completed", Types.BOOLEAN },
{ "completionDate", Types.TIMESTAMP }
};
public static final String TABLE_SQL_CREATE = "create table KaleoTaskAssignmentInstance (kaleoTaskAssignmentInstanceId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(200) null,createDate DATE null,modifiedDate DATE null,kaleoDefinitionId LONG,kaleoInstanceId LONG,kaleoInstanceTokenId LONG,kaleoTaskInstanceTokenId LONG,kaleoTaskId LONG,kaleoTaskName VARCHAR(200) null,assigneeClassName VARCHAR(200) null,assigneeClassPK LONG,completed BOOLEAN,completionDate DATE null)";
public static final String TABLE_SQL_DROP = "drop table KaleoTaskAssignmentInstance";
public static final String ORDER_BY_JPQL = " ORDER BY kaleoTaskAssignmentInstance.kaleoTaskAssignmentInstanceId ASC";
public static final String ORDER_BY_SQL = " ORDER BY KaleoTaskAssignmentInstance.kaleoTaskAssignmentInstanceId ASC";
public static final String DATA_SOURCE = "liferayDataSource";
public static final String SESSION_FACTORY = "liferaySessionFactory";
public static final String TX_MANAGER = "liferayTransactionManager";
public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.entity.cache.enabled.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance"),
true);
public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.finder.cache.enabled.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance"),
true);
public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.column.bitmask.enabled.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance"),
true);
public static long ASSIGNEECLASSNAME_COLUMN_BITMASK = 1L;
public static long ASSIGNEECLASSPK_COLUMN_BITMASK = 2L;
public static long COMPANYID_COLUMN_BITMASK = 4L;
public static long GROUPID_COLUMN_BITMASK = 8L;
public static long KALEODEFINITIONID_COLUMN_BITMASK = 16L;
public static long KALEOINSTANCEID_COLUMN_BITMASK = 32L;
public static long KALEOTASKINSTANCETOKENID_COLUMN_BITMASK = 64L;
public static long KALEOTASKASSIGNMENTINSTANCEID_COLUMN_BITMASK = 128L;
public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
"lock.expiration.time.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance"));
public KaleoTaskAssignmentInstanceModelImpl() {
}
public long getPrimaryKey() {
return _kaleoTaskAssignmentInstanceId;
}
public void setPrimaryKey(long primaryKey) {
setKaleoTaskAssignmentInstanceId(primaryKey);
}
public Serializable getPrimaryKeyObj() {
return _kaleoTaskAssignmentInstanceId;
}
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
public Class<?> getModelClass() {
return KaleoTaskAssignmentInstance.class;
}
public String getModelClassName() {
return KaleoTaskAssignmentInstance.class.getName();
}
public Map<String, Object> getModelAttributes() {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("kaleoTaskAssignmentInstanceId",
getKaleoTaskAssignmentInstanceId());
attributes.put("groupId", getGroupId());
attributes.put("companyId", getCompanyId());
attributes.put("userId", getUserId());
attributes.put("userName", getUserName());
attributes.put("createDate", getCreateDate());
attributes.put("modifiedDate", getModifiedDate());
attributes.put("kaleoDefinitionId", getKaleoDefinitionId());
attributes.put("kaleoInstanceId", getKaleoInstanceId());
attributes.put("kaleoInstanceTokenId", getKaleoInstanceTokenId());
attributes.put("kaleoTaskInstanceTokenId", getKaleoTaskInstanceTokenId());
attributes.put("kaleoTaskId", getKaleoTaskId());
attributes.put("kaleoTaskName", getKaleoTaskName());
attributes.put("assigneeClassName", getAssigneeClassName());
attributes.put("assigneeClassPK", getAssigneeClassPK());
attributes.put("completed", getCompleted());
attributes.put("completionDate", getCompletionDate());
return attributes;
}
public void setModelAttributes(Map<String, Object> attributes) {
Long kaleoTaskAssignmentInstanceId = (Long)attributes.get(
"kaleoTaskAssignmentInstanceId");
if (kaleoTaskAssignmentInstanceId != null) {
setKaleoTaskAssignmentInstanceId(kaleoTaskAssignmentInstanceId);
}
Long groupId = (Long)attributes.get("groupId");
if (groupId != null) {
setGroupId(groupId);
}
Long companyId = (Long)attributes.get("companyId");
if (companyId != null) {
setCompanyId(companyId);
}
Long userId = (Long)attributes.get("userId");
if (userId != null) {
setUserId(userId);
}
String userName = (String)attributes.get("userName");
if (userName != null) {
setUserName(userName);
}
Date createDate = (Date)attributes.get("createDate");
if (createDate != null) {
setCreateDate(createDate);
}
Date modifiedDate = (Date)attributes.get("modifiedDate");
if (modifiedDate != null) {
setModifiedDate(modifiedDate);
}
Long kaleoDefinitionId = (Long)attributes.get("kaleoDefinitionId");
if (kaleoDefinitionId != null) {
setKaleoDefinitionId(kaleoDefinitionId);
}
Long kaleoInstanceId = (Long)attributes.get("kaleoInstanceId");
if (kaleoInstanceId != null) {
setKaleoInstanceId(kaleoInstanceId);
}
Long kaleoInstanceTokenId = (Long)attributes.get("kaleoInstanceTokenId");
if (kaleoInstanceTokenId != null) {
setKaleoInstanceTokenId(kaleoInstanceTokenId);
}
Long kaleoTaskInstanceTokenId = (Long)attributes.get(
"kaleoTaskInstanceTokenId");
if (kaleoTaskInstanceTokenId != null) {
setKaleoTaskInstanceTokenId(kaleoTaskInstanceTokenId);
}
Long kaleoTaskId = (Long)attributes.get("kaleoTaskId");
if (kaleoTaskId != null) {
setKaleoTaskId(kaleoTaskId);
}
String kaleoTaskName = (String)attributes.get("kaleoTaskName");
if (kaleoTaskName != null) {
setKaleoTaskName(kaleoTaskName);
}
String assigneeClassName = (String)attributes.get("assigneeClassName");
if (assigneeClassName != null) {
setAssigneeClassName(assigneeClassName);
}
Long assigneeClassPK = (Long)attributes.get("assigneeClassPK");
if (assigneeClassPK != null) {
setAssigneeClassPK(assigneeClassPK);
}
Boolean completed = (Boolean)attributes.get("completed");
if (completed != null) {
setCompleted(completed);
}
Date completionDate = (Date)attributes.get("completionDate");
if (completionDate != null) {
setCompletionDate(completionDate);
}
}
public long getKaleoTaskAssignmentInstanceId() {
return _kaleoTaskAssignmentInstanceId;
}
public void setKaleoTaskAssignmentInstanceId(
long kaleoTaskAssignmentInstanceId) {
_columnBitmask = -1L;
_kaleoTaskAssignmentInstanceId = kaleoTaskAssignmentInstanceId;
}
public long getGroupId() {
return _groupId;
}
public void setGroupId(long groupId) {
_columnBitmask |= GROUPID_COLUMN_BITMASK;
if (!_setOriginalGroupId) {
_setOriginalGroupId = true;
_originalGroupId = _groupId;
}
_groupId = groupId;
}
public long getOriginalGroupId() {
return _originalGroupId;
}
public long getCompanyId() {
return _companyId;
}
public void setCompanyId(long companyId) {
_columnBitmask |= COMPANYID_COLUMN_BITMASK;
if (!_setOriginalCompanyId) {
_setOriginalCompanyId = true;
_originalCompanyId = _companyId;
}
_companyId = companyId;
}
public long getOriginalCompanyId() {
return _originalCompanyId;
}
public long getUserId() {
return _userId;
}
public void setUserId(long userId) {
_userId = userId;
}
public String getUserUuid() throws SystemException {
return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
}
public void setUserUuid(String userUuid) {
_userUuid = userUuid;
}
public String getUserName() {
if (_userName == null) {
return StringPool.BLANK;
}
else {
return _userName;
}
}
public void setUserName(String userName) {
_userName = userName;
}
public Date getCreateDate() {
return _createDate;
}
public void setCreateDate(Date createDate) {
_createDate = createDate;
}
public Date getModifiedDate() {
return _modifiedDate;
}
public void setModifiedDate(Date modifiedDate) {
_modifiedDate = modifiedDate;
}
public long getKaleoDefinitionId() {
return _kaleoDefinitionId;
}
public void setKaleoDefinitionId(long kaleoDefinitionId) {
_columnBitmask |= KALEODEFINITIONID_COLUMN_BITMASK;
if (!_setOriginalKaleoDefinitionId) {
_setOriginalKaleoDefinitionId = true;
_originalKaleoDefinitionId = _kaleoDefinitionId;
}
_kaleoDefinitionId = kaleoDefinitionId;
}
public long getOriginalKaleoDefinitionId() {
return _originalKaleoDefinitionId;
}
public long getKaleoInstanceId() {
return _kaleoInstanceId;
}
public void setKaleoInstanceId(long kaleoInstanceId) {
_columnBitmask |= KALEOINSTANCEID_COLUMN_BITMASK;
if (!_setOriginalKaleoInstanceId) {
_setOriginalKaleoInstanceId = true;
_originalKaleoInstanceId = _kaleoInstanceId;
}
_kaleoInstanceId = kaleoInstanceId;
}
public long getOriginalKaleoInstanceId() {
return _originalKaleoInstanceId;
}
public long getKaleoInstanceTokenId() {
return _kaleoInstanceTokenId;
}
public void setKaleoInstanceTokenId(long kaleoInstanceTokenId) {
_kaleoInstanceTokenId = kaleoInstanceTokenId;
}
public long getKaleoTaskInstanceTokenId() {
return _kaleoTaskInstanceTokenId;
}
public void setKaleoTaskInstanceTokenId(long kaleoTaskInstanceTokenId) {
_columnBitmask |= KALEOTASKINSTANCETOKENID_COLUMN_BITMASK;
if (!_setOriginalKaleoTaskInstanceTokenId) {
_setOriginalKaleoTaskInstanceTokenId = true;
_originalKaleoTaskInstanceTokenId = _kaleoTaskInstanceTokenId;
}
_kaleoTaskInstanceTokenId = kaleoTaskInstanceTokenId;
}
public long getOriginalKaleoTaskInstanceTokenId() {
return _originalKaleoTaskInstanceTokenId;
}
public long getKaleoTaskId() {
return _kaleoTaskId;
}
public void setKaleoTaskId(long kaleoTaskId) {
_kaleoTaskId = kaleoTaskId;
}
public String getKaleoTaskName() {
if (_kaleoTaskName == null) {
return StringPool.BLANK;
}
else {
return _kaleoTaskName;
}
}
public void setKaleoTaskName(String kaleoTaskName) {
_kaleoTaskName = kaleoTaskName;
}
public String getAssigneeClassName() {
if (_assigneeClassName == null) {
return StringPool.BLANK;
}
else {
return _assigneeClassName;
}
}
public void setAssigneeClassName(String assigneeClassName) {
_columnBitmask |= ASSIGNEECLASSNAME_COLUMN_BITMASK;
if (_originalAssigneeClassName == null) {
_originalAssigneeClassName = _assigneeClassName;
}
_assigneeClassName = assigneeClassName;
}
public String getOriginalAssigneeClassName() {
return GetterUtil.getString(_originalAssigneeClassName);
}
public long getAssigneeClassPK() {
return _assigneeClassPK;
}
public void setAssigneeClassPK(long assigneeClassPK) {
_columnBitmask |= ASSIGNEECLASSPK_COLUMN_BITMASK;
if (!_setOriginalAssigneeClassPK) {
_setOriginalAssigneeClassPK = true;
_originalAssigneeClassPK = _assigneeClassPK;
}
_assigneeClassPK = assigneeClassPK;
}
public long getOriginalAssigneeClassPK() {
return _originalAssigneeClassPK;
}
public boolean getCompleted() {
return _completed;
}
public boolean isCompleted() {
return _completed;
}
public void setCompleted(boolean completed) {
_completed = completed;
}
public Date getCompletionDate() {
return _completionDate;
}
public void setCompletionDate(Date completionDate) {
_completionDate = completionDate;
}
public long getColumnBitmask() {
return _columnBitmask;
}
public ExpandoBridge getExpandoBridge() {
return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
KaleoTaskAssignmentInstance.class.getName(), getPrimaryKey());
}
public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
ExpandoBridge expandoBridge = getExpandoBridge();
expandoBridge.setAttributes(serviceContext);
}
public KaleoTaskAssignmentInstance toEscapedModel() {
if (_escapedModel == null) {
_escapedModel = (KaleoTaskAssignmentInstance)ProxyUtil.newProxyInstance(_classLoader,
_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
}
return _escapedModel;
}
public Object clone() {
KaleoTaskAssignmentInstanceImpl kaleoTaskAssignmentInstanceImpl = new KaleoTaskAssignmentInstanceImpl();
kaleoTaskAssignmentInstanceImpl.setKaleoTaskAssignmentInstanceId(getKaleoTaskAssignmentInstanceId());
kaleoTaskAssignmentInstanceImpl.setGroupId(getGroupId());
kaleoTaskAssignmentInstanceImpl.setCompanyId(getCompanyId());
kaleoTaskAssignmentInstanceImpl.setUserId(getUserId());
kaleoTaskAssignmentInstanceImpl.setUserName(getUserName());
kaleoTaskAssignmentInstanceImpl.setCreateDate(getCreateDate());
kaleoTaskAssignmentInstanceImpl.setModifiedDate(getModifiedDate());
kaleoTaskAssignmentInstanceImpl.setKaleoDefinitionId(getKaleoDefinitionId());
kaleoTaskAssignmentInstanceImpl.setKaleoInstanceId(getKaleoInstanceId());
kaleoTaskAssignmentInstanceImpl.setKaleoInstanceTokenId(getKaleoInstanceTokenId());
kaleoTaskAssignmentInstanceImpl.setKaleoTaskInstanceTokenId(getKaleoTaskInstanceTokenId());
kaleoTaskAssignmentInstanceImpl.setKaleoTaskId(getKaleoTaskId());
kaleoTaskAssignmentInstanceImpl.setKaleoTaskName(getKaleoTaskName());
kaleoTaskAssignmentInstanceImpl.setAssigneeClassName(getAssigneeClassName());
kaleoTaskAssignmentInstanceImpl.setAssigneeClassPK(getAssigneeClassPK());
kaleoTaskAssignmentInstanceImpl.setCompleted(getCompleted());
kaleoTaskAssignmentInstanceImpl.setCompletionDate(getCompletionDate());
kaleoTaskAssignmentInstanceImpl.resetOriginalValues();
return kaleoTaskAssignmentInstanceImpl;
}
public int compareTo(
KaleoTaskAssignmentInstance kaleoTaskAssignmentInstance) {
int value = 0;
if (getKaleoTaskAssignmentInstanceId() < kaleoTaskAssignmentInstance.getKaleoTaskAssignmentInstanceId()) {
value = -1;
}
else if (getKaleoTaskAssignmentInstanceId() > kaleoTaskAssignmentInstance.getKaleoTaskAssignmentInstanceId()) {
value = 1;
}
else {
value = 0;
}
if (value != 0) {
return value;
}
return 0;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof KaleoTaskAssignmentInstance)) {
return false;
}
KaleoTaskAssignmentInstance kaleoTaskAssignmentInstance = (KaleoTaskAssignmentInstance)obj;
long primaryKey = kaleoTaskAssignmentInstance.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
}
else {
return false;
}
}
public int hashCode() {
return (int)getPrimaryKey();
}
public void resetOriginalValues() {
KaleoTaskAssignmentInstanceModelImpl kaleoTaskAssignmentInstanceModelImpl =
this;
kaleoTaskAssignmentInstanceModelImpl._originalGroupId = kaleoTaskAssignmentInstanceModelImpl._groupId;
kaleoTaskAssignmentInstanceModelImpl._setOriginalGroupId = false;
kaleoTaskAssignmentInstanceModelImpl._originalCompanyId = kaleoTaskAssignmentInstanceModelImpl._companyId;
kaleoTaskAssignmentInstanceModelImpl._setOriginalCompanyId = false;
kaleoTaskAssignmentInstanceModelImpl._originalKaleoDefinitionId = kaleoTaskAssignmentInstanceModelImpl._kaleoDefinitionId;
kaleoTaskAssignmentInstanceModelImpl._setOriginalKaleoDefinitionId = false;
kaleoTaskAssignmentInstanceModelImpl._originalKaleoInstanceId = kaleoTaskAssignmentInstanceModelImpl._kaleoInstanceId;
kaleoTaskAssignmentInstanceModelImpl._setOriginalKaleoInstanceId = false;
kaleoTaskAssignmentInstanceModelImpl._originalKaleoTaskInstanceTokenId = kaleoTaskAssignmentInstanceModelImpl._kaleoTaskInstanceTokenId;
kaleoTaskAssignmentInstanceModelImpl._setOriginalKaleoTaskInstanceTokenId = false;
kaleoTaskAssignmentInstanceModelImpl._originalAssigneeClassName = kaleoTaskAssignmentInstanceModelImpl._assigneeClassName;
kaleoTaskAssignmentInstanceModelImpl._originalAssigneeClassPK = kaleoTaskAssignmentInstanceModelImpl._assigneeClassPK;
kaleoTaskAssignmentInstanceModelImpl._setOriginalAssigneeClassPK = false;
kaleoTaskAssignmentInstanceModelImpl._columnBitmask = 0;
}
public CacheModel<KaleoTaskAssignmentInstance> toCacheModel() {
KaleoTaskAssignmentInstanceCacheModel kaleoTaskAssignmentInstanceCacheModel =
new KaleoTaskAssignmentInstanceCacheModel();
kaleoTaskAssignmentInstanceCacheModel.kaleoTaskAssignmentInstanceId = getKaleoTaskAssignmentInstanceId();
kaleoTaskAssignmentInstanceCacheModel.groupId = getGroupId();
kaleoTaskAssignmentInstanceCacheModel.companyId = getCompanyId();
kaleoTaskAssignmentInstanceCacheModel.userId = getUserId();
kaleoTaskAssignmentInstanceCacheModel.userName = getUserName();
String userName = kaleoTaskAssignmentInstanceCacheModel.userName;
if ((userName != null) && (userName.length() == 0)) {
kaleoTaskAssignmentInstanceCacheModel.userName = null;
}
Date createDate = getCreateDate();
if (createDate != null) {
kaleoTaskAssignmentInstanceCacheModel.createDate = createDate.getTime();
}
else {
kaleoTaskAssignmentInstanceCacheModel.createDate = Long.MIN_VALUE;
}
Date modifiedDate = getModifiedDate();
if (modifiedDate != null) {
kaleoTaskAssignmentInstanceCacheModel.modifiedDate = modifiedDate.getTime();
}
else {
kaleoTaskAssignmentInstanceCacheModel.modifiedDate = Long.MIN_VALUE;
}
kaleoTaskAssignmentInstanceCacheModel.kaleoDefinitionId = getKaleoDefinitionId();
kaleoTaskAssignmentInstanceCacheModel.kaleoInstanceId = getKaleoInstanceId();
kaleoTaskAssignmentInstanceCacheModel.kaleoInstanceTokenId = getKaleoInstanceTokenId();
kaleoTaskAssignmentInstanceCacheModel.kaleoTaskInstanceTokenId = getKaleoTaskInstanceTokenId();
kaleoTaskAssignmentInstanceCacheModel.kaleoTaskId = getKaleoTaskId();
kaleoTaskAssignmentInstanceCacheModel.kaleoTaskName = getKaleoTaskName();
String kaleoTaskName = kaleoTaskAssignmentInstanceCacheModel.kaleoTaskName;
if ((kaleoTaskName != null) && (kaleoTaskName.length() == 0)) {
kaleoTaskAssignmentInstanceCacheModel.kaleoTaskName = null;
}
kaleoTaskAssignmentInstanceCacheModel.assigneeClassName = getAssigneeClassName();
String assigneeClassName = kaleoTaskAssignmentInstanceCacheModel.assigneeClassName;
if ((assigneeClassName != null) && (assigneeClassName.length() == 0)) {
kaleoTaskAssignmentInstanceCacheModel.assigneeClassName = null;
}
kaleoTaskAssignmentInstanceCacheModel.assigneeClassPK = getAssigneeClassPK();
kaleoTaskAssignmentInstanceCacheModel.completed = getCompleted();
Date completionDate = getCompletionDate();
if (completionDate != null) {
kaleoTaskAssignmentInstanceCacheModel.completionDate = completionDate.getTime();
}
else {
kaleoTaskAssignmentInstanceCacheModel.completionDate = Long.MIN_VALUE;
}
return kaleoTaskAssignmentInstanceCacheModel;
}
public String toString() {
StringBundler sb = new StringBundler(35);
sb.append("{kaleoTaskAssignmentInstanceId=");
sb.append(getKaleoTaskAssignmentInstanceId());
sb.append(", groupId=");
sb.append(getGroupId());
sb.append(", companyId=");
sb.append(getCompanyId());
sb.append(", userId=");
sb.append(getUserId());
sb.append(", userName=");
sb.append(getUserName());
sb.append(", createDate=");
sb.append(getCreateDate());
sb.append(", modifiedDate=");
sb.append(getModifiedDate());
sb.append(", kaleoDefinitionId=");
sb.append(getKaleoDefinitionId());
sb.append(", kaleoInstanceId=");
sb.append(getKaleoInstanceId());
sb.append(", kaleoInstanceTokenId=");
sb.append(getKaleoInstanceTokenId());
sb.append(", kaleoTaskInstanceTokenId=");
sb.append(getKaleoTaskInstanceTokenId());
sb.append(", kaleoTaskId=");
sb.append(getKaleoTaskId());
sb.append(", kaleoTaskName=");
sb.append(getKaleoTaskName());
sb.append(", assigneeClassName=");
sb.append(getAssigneeClassName());
sb.append(", assigneeClassPK=");
sb.append(getAssigneeClassPK());
sb.append(", completed=");
sb.append(getCompleted());
sb.append(", completionDate=");
sb.append(getCompletionDate());
sb.append("}");
return sb.toString();
}
public String toXmlString() {
StringBundler sb = new StringBundler(55);
sb.append("<model><model-name>");
sb.append(
"com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance");
sb.append("</model-name>");
sb.append(
"<column><column-name>kaleoTaskAssignmentInstanceId</column-name><column-value><![CDATA[");
sb.append(getKaleoTaskAssignmentInstanceId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>groupId</column-name><column-value><![CDATA[");
sb.append(getGroupId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>companyId</column-name><column-value><![CDATA[");
sb.append(getCompanyId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>userId</column-name><column-value><![CDATA[");
sb.append(getUserId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>userName</column-name><column-value><![CDATA[");
sb.append(getUserName());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>createDate</column-name><column-value><![CDATA[");
sb.append(getCreateDate());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
sb.append(getModifiedDate());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>kaleoDefinitionId</column-name><column-value><![CDATA[");
sb.append(getKaleoDefinitionId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>kaleoInstanceId</column-name><column-value><![CDATA[");
sb.append(getKaleoInstanceId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>kaleoInstanceTokenId</column-name><column-value><![CDATA[");
sb.append(getKaleoInstanceTokenId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>kaleoTaskInstanceTokenId</column-name><column-value><![CDATA[");
sb.append(getKaleoTaskInstanceTokenId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>kaleoTaskId</column-name><column-value><![CDATA[");
sb.append(getKaleoTaskId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>kaleoTaskName</column-name><column-value><![CDATA[");
sb.append(getKaleoTaskName());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>assigneeClassName</column-name><column-value><![CDATA[");
sb.append(getAssigneeClassName());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>assigneeClassPK</column-name><column-value><![CDATA[");
sb.append(getAssigneeClassPK());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>completed</column-name><column-value><![CDATA[");
sb.append(getCompleted());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>completionDate</column-name><column-value><![CDATA[");
sb.append(getCompletionDate());
sb.append("]]></column-value></column>");
sb.append("</model>");
return sb.toString();
}
private static ClassLoader _classLoader = KaleoTaskAssignmentInstance.class.getClassLoader();
private static Class<?>[] _escapedModelInterfaces = new Class[] {
KaleoTaskAssignmentInstance.class
};
private long _kaleoTaskAssignmentInstanceId;
private long _groupId;
private long _originalGroupId;
private boolean _setOriginalGroupId;
private long _companyId;
private long _originalCompanyId;
private boolean _setOriginalCompanyId;
private long _userId;
private String _userUuid;
private String _userName;
private Date _createDate;
private Date _modifiedDate;
private long _kaleoDefinitionId;
private long _originalKaleoDefinitionId;
private boolean _setOriginalKaleoDefinitionId;
private long _kaleoInstanceId;
private long _originalKaleoInstanceId;
private boolean _setOriginalKaleoInstanceId;
private long _kaleoInstanceTokenId;
private long _kaleoTaskInstanceTokenId;
private long _originalKaleoTaskInstanceTokenId;
private boolean _setOriginalKaleoTaskInstanceTokenId;
private long _kaleoTaskId;
private String _kaleoTaskName;
private String _assigneeClassName;
private String _originalAssigneeClassName;
private long _assigneeClassPK;
private long _originalAssigneeClassPK;
private boolean _setOriginalAssigneeClassPK;
private boolean _completed;
private Date _completionDate;
private long _columnBitmask;
private KaleoTaskAssignmentInstance _escapedModel;
} | [
"public",
"class",
"KaleoTaskAssignmentInstanceModelImpl",
"extends",
"BaseModelImpl",
"<",
"KaleoTaskAssignmentInstance",
">",
"implements",
"KaleoTaskAssignmentInstanceModel",
"{",
"/*\n\t * NOTE FOR DEVELOPERS:\n\t *\n\t * Never modify or reference this class directly. All methods that expect a kaleo task assignment instance model instance should use the {@link com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance} interface instead.\n\t */",
"public",
"static",
"final",
"String",
"TABLE_NAME",
"=",
"\"",
"KaleoTaskAssignmentInstance",
"\"",
";",
"public",
"static",
"final",
"Object",
"[",
"]",
"[",
"]",
"TABLE_COLUMNS",
"=",
"{",
"{",
"\"",
"kaleoTaskAssignmentInstanceId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"groupId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"companyId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"userId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"userName",
"\"",
",",
"Types",
".",
"VARCHAR",
"}",
",",
"{",
"\"",
"createDate",
"\"",
",",
"Types",
".",
"TIMESTAMP",
"}",
",",
"{",
"\"",
"modifiedDate",
"\"",
",",
"Types",
".",
"TIMESTAMP",
"}",
",",
"{",
"\"",
"kaleoDefinitionId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"kaleoInstanceId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"kaleoInstanceTokenId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"kaleoTaskInstanceTokenId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"kaleoTaskId",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"kaleoTaskName",
"\"",
",",
"Types",
".",
"VARCHAR",
"}",
",",
"{",
"\"",
"assigneeClassName",
"\"",
",",
"Types",
".",
"VARCHAR",
"}",
",",
"{",
"\"",
"assigneeClassPK",
"\"",
",",
"Types",
".",
"BIGINT",
"}",
",",
"{",
"\"",
"completed",
"\"",
",",
"Types",
".",
"BOOLEAN",
"}",
",",
"{",
"\"",
"completionDate",
"\"",
",",
"Types",
".",
"TIMESTAMP",
"}",
"}",
";",
"public",
"static",
"final",
"String",
"TABLE_SQL_CREATE",
"=",
"\"",
"create table KaleoTaskAssignmentInstance (kaleoTaskAssignmentInstanceId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(200) null,createDate DATE null,modifiedDate DATE null,kaleoDefinitionId LONG,kaleoInstanceId LONG,kaleoInstanceTokenId LONG,kaleoTaskInstanceTokenId LONG,kaleoTaskId LONG,kaleoTaskName VARCHAR(200) null,assigneeClassName VARCHAR(200) null,assigneeClassPK LONG,completed BOOLEAN,completionDate DATE null)",
"\"",
";",
"public",
"static",
"final",
"String",
"TABLE_SQL_DROP",
"=",
"\"",
"drop table KaleoTaskAssignmentInstance",
"\"",
";",
"public",
"static",
"final",
"String",
"ORDER_BY_JPQL",
"=",
"\"",
" ORDER BY kaleoTaskAssignmentInstance.kaleoTaskAssignmentInstanceId ASC",
"\"",
";",
"public",
"static",
"final",
"String",
"ORDER_BY_SQL",
"=",
"\"",
" ORDER BY KaleoTaskAssignmentInstance.kaleoTaskAssignmentInstanceId ASC",
"\"",
";",
"public",
"static",
"final",
"String",
"DATA_SOURCE",
"=",
"\"",
"liferayDataSource",
"\"",
";",
"public",
"static",
"final",
"String",
"SESSION_FACTORY",
"=",
"\"",
"liferaySessionFactory",
"\"",
";",
"public",
"static",
"final",
"String",
"TX_MANAGER",
"=",
"\"",
"liferayTransactionManager",
"\"",
";",
"public",
"static",
"final",
"boolean",
"ENTITY_CACHE_ENABLED",
"=",
"GetterUtil",
".",
"getBoolean",
"(",
"com",
".",
"liferay",
".",
"util",
".",
"service",
".",
"ServiceProps",
".",
"get",
"(",
"\"",
"value.object.entity.cache.enabled.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance",
"\"",
")",
",",
"true",
")",
";",
"public",
"static",
"final",
"boolean",
"FINDER_CACHE_ENABLED",
"=",
"GetterUtil",
".",
"getBoolean",
"(",
"com",
".",
"liferay",
".",
"util",
".",
"service",
".",
"ServiceProps",
".",
"get",
"(",
"\"",
"value.object.finder.cache.enabled.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance",
"\"",
")",
",",
"true",
")",
";",
"public",
"static",
"final",
"boolean",
"COLUMN_BITMASK_ENABLED",
"=",
"GetterUtil",
".",
"getBoolean",
"(",
"com",
".",
"liferay",
".",
"util",
".",
"service",
".",
"ServiceProps",
".",
"get",
"(",
"\"",
"value.object.column.bitmask.enabled.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance",
"\"",
")",
",",
"true",
")",
";",
"public",
"static",
"long",
"ASSIGNEECLASSNAME_COLUMN_BITMASK",
"=",
"1L",
";",
"public",
"static",
"long",
"ASSIGNEECLASSPK_COLUMN_BITMASK",
"=",
"2L",
";",
"public",
"static",
"long",
"COMPANYID_COLUMN_BITMASK",
"=",
"4L",
";",
"public",
"static",
"long",
"GROUPID_COLUMN_BITMASK",
"=",
"8L",
";",
"public",
"static",
"long",
"KALEODEFINITIONID_COLUMN_BITMASK",
"=",
"16L",
";",
"public",
"static",
"long",
"KALEOINSTANCEID_COLUMN_BITMASK",
"=",
"32L",
";",
"public",
"static",
"long",
"KALEOTASKINSTANCETOKENID_COLUMN_BITMASK",
"=",
"64L",
";",
"public",
"static",
"long",
"KALEOTASKASSIGNMENTINSTANCEID_COLUMN_BITMASK",
"=",
"128L",
";",
"public",
"static",
"final",
"long",
"LOCK_EXPIRATION_TIME",
"=",
"GetterUtil",
".",
"getLong",
"(",
"com",
".",
"liferay",
".",
"util",
".",
"service",
".",
"ServiceProps",
".",
"get",
"(",
"\"",
"lock.expiration.time.com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance",
"\"",
")",
")",
";",
"public",
"KaleoTaskAssignmentInstanceModelImpl",
"(",
")",
"{",
"}",
"public",
"long",
"getPrimaryKey",
"(",
")",
"{",
"return",
"_kaleoTaskAssignmentInstanceId",
";",
"}",
"public",
"void",
"setPrimaryKey",
"(",
"long",
"primaryKey",
")",
"{",
"setKaleoTaskAssignmentInstanceId",
"(",
"primaryKey",
")",
";",
"}",
"public",
"Serializable",
"getPrimaryKeyObj",
"(",
")",
"{",
"return",
"_kaleoTaskAssignmentInstanceId",
";",
"}",
"public",
"void",
"setPrimaryKeyObj",
"(",
"Serializable",
"primaryKeyObj",
")",
"{",
"setPrimaryKey",
"(",
"(",
"(",
"Long",
")",
"primaryKeyObj",
")",
".",
"longValue",
"(",
")",
")",
";",
"}",
"public",
"Class",
"<",
"?",
">",
"getModelClass",
"(",
")",
"{",
"return",
"KaleoTaskAssignmentInstance",
".",
"class",
";",
"}",
"public",
"String",
"getModelClassName",
"(",
")",
"{",
"return",
"KaleoTaskAssignmentInstance",
".",
"class",
".",
"getName",
"(",
")",
";",
"}",
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getModelAttributes",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"kaleoTaskAssignmentInstanceId",
"\"",
",",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"groupId",
"\"",
",",
"getGroupId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"companyId",
"\"",
",",
"getCompanyId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"userId",
"\"",
",",
"getUserId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"userName",
"\"",
",",
"getUserName",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"createDate",
"\"",
",",
"getCreateDate",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"modifiedDate",
"\"",
",",
"getModifiedDate",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"kaleoDefinitionId",
"\"",
",",
"getKaleoDefinitionId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"kaleoInstanceId",
"\"",
",",
"getKaleoInstanceId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"kaleoInstanceTokenId",
"\"",
",",
"getKaleoInstanceTokenId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"kaleoTaskInstanceTokenId",
"\"",
",",
"getKaleoTaskInstanceTokenId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"kaleoTaskId",
"\"",
",",
"getKaleoTaskId",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"kaleoTaskName",
"\"",
",",
"getKaleoTaskName",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"assigneeClassName",
"\"",
",",
"getAssigneeClassName",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"assigneeClassPK",
"\"",
",",
"getAssigneeClassPK",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"completed",
"\"",
",",
"getCompleted",
"(",
")",
")",
";",
"attributes",
".",
"put",
"(",
"\"",
"completionDate",
"\"",
",",
"getCompletionDate",
"(",
")",
")",
";",
"return",
"attributes",
";",
"}",
"public",
"void",
"setModelAttributes",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
")",
"{",
"Long",
"kaleoTaskAssignmentInstanceId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"kaleoTaskAssignmentInstanceId",
"\"",
")",
";",
"if",
"(",
"kaleoTaskAssignmentInstanceId",
"!=",
"null",
")",
"{",
"setKaleoTaskAssignmentInstanceId",
"(",
"kaleoTaskAssignmentInstanceId",
")",
";",
"}",
"Long",
"groupId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"groupId",
"\"",
")",
";",
"if",
"(",
"groupId",
"!=",
"null",
")",
"{",
"setGroupId",
"(",
"groupId",
")",
";",
"}",
"Long",
"companyId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"companyId",
"\"",
")",
";",
"if",
"(",
"companyId",
"!=",
"null",
")",
"{",
"setCompanyId",
"(",
"companyId",
")",
";",
"}",
"Long",
"userId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"userId",
"\"",
")",
";",
"if",
"(",
"userId",
"!=",
"null",
")",
"{",
"setUserId",
"(",
"userId",
")",
";",
"}",
"String",
"userName",
"=",
"(",
"String",
")",
"attributes",
".",
"get",
"(",
"\"",
"userName",
"\"",
")",
";",
"if",
"(",
"userName",
"!=",
"null",
")",
"{",
"setUserName",
"(",
"userName",
")",
";",
"}",
"Date",
"createDate",
"=",
"(",
"Date",
")",
"attributes",
".",
"get",
"(",
"\"",
"createDate",
"\"",
")",
";",
"if",
"(",
"createDate",
"!=",
"null",
")",
"{",
"setCreateDate",
"(",
"createDate",
")",
";",
"}",
"Date",
"modifiedDate",
"=",
"(",
"Date",
")",
"attributes",
".",
"get",
"(",
"\"",
"modifiedDate",
"\"",
")",
";",
"if",
"(",
"modifiedDate",
"!=",
"null",
")",
"{",
"setModifiedDate",
"(",
"modifiedDate",
")",
";",
"}",
"Long",
"kaleoDefinitionId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"kaleoDefinitionId",
"\"",
")",
";",
"if",
"(",
"kaleoDefinitionId",
"!=",
"null",
")",
"{",
"setKaleoDefinitionId",
"(",
"kaleoDefinitionId",
")",
";",
"}",
"Long",
"kaleoInstanceId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"kaleoInstanceId",
"\"",
")",
";",
"if",
"(",
"kaleoInstanceId",
"!=",
"null",
")",
"{",
"setKaleoInstanceId",
"(",
"kaleoInstanceId",
")",
";",
"}",
"Long",
"kaleoInstanceTokenId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"kaleoInstanceTokenId",
"\"",
")",
";",
"if",
"(",
"kaleoInstanceTokenId",
"!=",
"null",
")",
"{",
"setKaleoInstanceTokenId",
"(",
"kaleoInstanceTokenId",
")",
";",
"}",
"Long",
"kaleoTaskInstanceTokenId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"kaleoTaskInstanceTokenId",
"\"",
")",
";",
"if",
"(",
"kaleoTaskInstanceTokenId",
"!=",
"null",
")",
"{",
"setKaleoTaskInstanceTokenId",
"(",
"kaleoTaskInstanceTokenId",
")",
";",
"}",
"Long",
"kaleoTaskId",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"kaleoTaskId",
"\"",
")",
";",
"if",
"(",
"kaleoTaskId",
"!=",
"null",
")",
"{",
"setKaleoTaskId",
"(",
"kaleoTaskId",
")",
";",
"}",
"String",
"kaleoTaskName",
"=",
"(",
"String",
")",
"attributes",
".",
"get",
"(",
"\"",
"kaleoTaskName",
"\"",
")",
";",
"if",
"(",
"kaleoTaskName",
"!=",
"null",
")",
"{",
"setKaleoTaskName",
"(",
"kaleoTaskName",
")",
";",
"}",
"String",
"assigneeClassName",
"=",
"(",
"String",
")",
"attributes",
".",
"get",
"(",
"\"",
"assigneeClassName",
"\"",
")",
";",
"if",
"(",
"assigneeClassName",
"!=",
"null",
")",
"{",
"setAssigneeClassName",
"(",
"assigneeClassName",
")",
";",
"}",
"Long",
"assigneeClassPK",
"=",
"(",
"Long",
")",
"attributes",
".",
"get",
"(",
"\"",
"assigneeClassPK",
"\"",
")",
";",
"if",
"(",
"assigneeClassPK",
"!=",
"null",
")",
"{",
"setAssigneeClassPK",
"(",
"assigneeClassPK",
")",
";",
"}",
"Boolean",
"completed",
"=",
"(",
"Boolean",
")",
"attributes",
".",
"get",
"(",
"\"",
"completed",
"\"",
")",
";",
"if",
"(",
"completed",
"!=",
"null",
")",
"{",
"setCompleted",
"(",
"completed",
")",
";",
"}",
"Date",
"completionDate",
"=",
"(",
"Date",
")",
"attributes",
".",
"get",
"(",
"\"",
"completionDate",
"\"",
")",
";",
"if",
"(",
"completionDate",
"!=",
"null",
")",
"{",
"setCompletionDate",
"(",
"completionDate",
")",
";",
"}",
"}",
"public",
"long",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
"{",
"return",
"_kaleoTaskAssignmentInstanceId",
";",
"}",
"public",
"void",
"setKaleoTaskAssignmentInstanceId",
"(",
"long",
"kaleoTaskAssignmentInstanceId",
")",
"{",
"_columnBitmask",
"=",
"-",
"1L",
";",
"_kaleoTaskAssignmentInstanceId",
"=",
"kaleoTaskAssignmentInstanceId",
";",
"}",
"public",
"long",
"getGroupId",
"(",
")",
"{",
"return",
"_groupId",
";",
"}",
"public",
"void",
"setGroupId",
"(",
"long",
"groupId",
")",
"{",
"_columnBitmask",
"|=",
"GROUPID_COLUMN_BITMASK",
";",
"if",
"(",
"!",
"_setOriginalGroupId",
")",
"{",
"_setOriginalGroupId",
"=",
"true",
";",
"_originalGroupId",
"=",
"_groupId",
";",
"}",
"_groupId",
"=",
"groupId",
";",
"}",
"public",
"long",
"getOriginalGroupId",
"(",
")",
"{",
"return",
"_originalGroupId",
";",
"}",
"public",
"long",
"getCompanyId",
"(",
")",
"{",
"return",
"_companyId",
";",
"}",
"public",
"void",
"setCompanyId",
"(",
"long",
"companyId",
")",
"{",
"_columnBitmask",
"|=",
"COMPANYID_COLUMN_BITMASK",
";",
"if",
"(",
"!",
"_setOriginalCompanyId",
")",
"{",
"_setOriginalCompanyId",
"=",
"true",
";",
"_originalCompanyId",
"=",
"_companyId",
";",
"}",
"_companyId",
"=",
"companyId",
";",
"}",
"public",
"long",
"getOriginalCompanyId",
"(",
")",
"{",
"return",
"_originalCompanyId",
";",
"}",
"public",
"long",
"getUserId",
"(",
")",
"{",
"return",
"_userId",
";",
"}",
"public",
"void",
"setUserId",
"(",
"long",
"userId",
")",
"{",
"_userId",
"=",
"userId",
";",
"}",
"public",
"String",
"getUserUuid",
"(",
")",
"throws",
"SystemException",
"{",
"return",
"PortalUtil",
".",
"getUserValue",
"(",
"getUserId",
"(",
")",
",",
"\"",
"uuid",
"\"",
",",
"_userUuid",
")",
";",
"}",
"public",
"void",
"setUserUuid",
"(",
"String",
"userUuid",
")",
"{",
"_userUuid",
"=",
"userUuid",
";",
"}",
"public",
"String",
"getUserName",
"(",
")",
"{",
"if",
"(",
"_userName",
"==",
"null",
")",
"{",
"return",
"StringPool",
".",
"BLANK",
";",
"}",
"else",
"{",
"return",
"_userName",
";",
"}",
"}",
"public",
"void",
"setUserName",
"(",
"String",
"userName",
")",
"{",
"_userName",
"=",
"userName",
";",
"}",
"public",
"Date",
"getCreateDate",
"(",
")",
"{",
"return",
"_createDate",
";",
"}",
"public",
"void",
"setCreateDate",
"(",
"Date",
"createDate",
")",
"{",
"_createDate",
"=",
"createDate",
";",
"}",
"public",
"Date",
"getModifiedDate",
"(",
")",
"{",
"return",
"_modifiedDate",
";",
"}",
"public",
"void",
"setModifiedDate",
"(",
"Date",
"modifiedDate",
")",
"{",
"_modifiedDate",
"=",
"modifiedDate",
";",
"}",
"public",
"long",
"getKaleoDefinitionId",
"(",
")",
"{",
"return",
"_kaleoDefinitionId",
";",
"}",
"public",
"void",
"setKaleoDefinitionId",
"(",
"long",
"kaleoDefinitionId",
")",
"{",
"_columnBitmask",
"|=",
"KALEODEFINITIONID_COLUMN_BITMASK",
";",
"if",
"(",
"!",
"_setOriginalKaleoDefinitionId",
")",
"{",
"_setOriginalKaleoDefinitionId",
"=",
"true",
";",
"_originalKaleoDefinitionId",
"=",
"_kaleoDefinitionId",
";",
"}",
"_kaleoDefinitionId",
"=",
"kaleoDefinitionId",
";",
"}",
"public",
"long",
"getOriginalKaleoDefinitionId",
"(",
")",
"{",
"return",
"_originalKaleoDefinitionId",
";",
"}",
"public",
"long",
"getKaleoInstanceId",
"(",
")",
"{",
"return",
"_kaleoInstanceId",
";",
"}",
"public",
"void",
"setKaleoInstanceId",
"(",
"long",
"kaleoInstanceId",
")",
"{",
"_columnBitmask",
"|=",
"KALEOINSTANCEID_COLUMN_BITMASK",
";",
"if",
"(",
"!",
"_setOriginalKaleoInstanceId",
")",
"{",
"_setOriginalKaleoInstanceId",
"=",
"true",
";",
"_originalKaleoInstanceId",
"=",
"_kaleoInstanceId",
";",
"}",
"_kaleoInstanceId",
"=",
"kaleoInstanceId",
";",
"}",
"public",
"long",
"getOriginalKaleoInstanceId",
"(",
")",
"{",
"return",
"_originalKaleoInstanceId",
";",
"}",
"public",
"long",
"getKaleoInstanceTokenId",
"(",
")",
"{",
"return",
"_kaleoInstanceTokenId",
";",
"}",
"public",
"void",
"setKaleoInstanceTokenId",
"(",
"long",
"kaleoInstanceTokenId",
")",
"{",
"_kaleoInstanceTokenId",
"=",
"kaleoInstanceTokenId",
";",
"}",
"public",
"long",
"getKaleoTaskInstanceTokenId",
"(",
")",
"{",
"return",
"_kaleoTaskInstanceTokenId",
";",
"}",
"public",
"void",
"setKaleoTaskInstanceTokenId",
"(",
"long",
"kaleoTaskInstanceTokenId",
")",
"{",
"_columnBitmask",
"|=",
"KALEOTASKINSTANCETOKENID_COLUMN_BITMASK",
";",
"if",
"(",
"!",
"_setOriginalKaleoTaskInstanceTokenId",
")",
"{",
"_setOriginalKaleoTaskInstanceTokenId",
"=",
"true",
";",
"_originalKaleoTaskInstanceTokenId",
"=",
"_kaleoTaskInstanceTokenId",
";",
"}",
"_kaleoTaskInstanceTokenId",
"=",
"kaleoTaskInstanceTokenId",
";",
"}",
"public",
"long",
"getOriginalKaleoTaskInstanceTokenId",
"(",
")",
"{",
"return",
"_originalKaleoTaskInstanceTokenId",
";",
"}",
"public",
"long",
"getKaleoTaskId",
"(",
")",
"{",
"return",
"_kaleoTaskId",
";",
"}",
"public",
"void",
"setKaleoTaskId",
"(",
"long",
"kaleoTaskId",
")",
"{",
"_kaleoTaskId",
"=",
"kaleoTaskId",
";",
"}",
"public",
"String",
"getKaleoTaskName",
"(",
")",
"{",
"if",
"(",
"_kaleoTaskName",
"==",
"null",
")",
"{",
"return",
"StringPool",
".",
"BLANK",
";",
"}",
"else",
"{",
"return",
"_kaleoTaskName",
";",
"}",
"}",
"public",
"void",
"setKaleoTaskName",
"(",
"String",
"kaleoTaskName",
")",
"{",
"_kaleoTaskName",
"=",
"kaleoTaskName",
";",
"}",
"public",
"String",
"getAssigneeClassName",
"(",
")",
"{",
"if",
"(",
"_assigneeClassName",
"==",
"null",
")",
"{",
"return",
"StringPool",
".",
"BLANK",
";",
"}",
"else",
"{",
"return",
"_assigneeClassName",
";",
"}",
"}",
"public",
"void",
"setAssigneeClassName",
"(",
"String",
"assigneeClassName",
")",
"{",
"_columnBitmask",
"|=",
"ASSIGNEECLASSNAME_COLUMN_BITMASK",
";",
"if",
"(",
"_originalAssigneeClassName",
"==",
"null",
")",
"{",
"_originalAssigneeClassName",
"=",
"_assigneeClassName",
";",
"}",
"_assigneeClassName",
"=",
"assigneeClassName",
";",
"}",
"public",
"String",
"getOriginalAssigneeClassName",
"(",
")",
"{",
"return",
"GetterUtil",
".",
"getString",
"(",
"_originalAssigneeClassName",
")",
";",
"}",
"public",
"long",
"getAssigneeClassPK",
"(",
")",
"{",
"return",
"_assigneeClassPK",
";",
"}",
"public",
"void",
"setAssigneeClassPK",
"(",
"long",
"assigneeClassPK",
")",
"{",
"_columnBitmask",
"|=",
"ASSIGNEECLASSPK_COLUMN_BITMASK",
";",
"if",
"(",
"!",
"_setOriginalAssigneeClassPK",
")",
"{",
"_setOriginalAssigneeClassPK",
"=",
"true",
";",
"_originalAssigneeClassPK",
"=",
"_assigneeClassPK",
";",
"}",
"_assigneeClassPK",
"=",
"assigneeClassPK",
";",
"}",
"public",
"long",
"getOriginalAssigneeClassPK",
"(",
")",
"{",
"return",
"_originalAssigneeClassPK",
";",
"}",
"public",
"boolean",
"getCompleted",
"(",
")",
"{",
"return",
"_completed",
";",
"}",
"public",
"boolean",
"isCompleted",
"(",
")",
"{",
"return",
"_completed",
";",
"}",
"public",
"void",
"setCompleted",
"(",
"boolean",
"completed",
")",
"{",
"_completed",
"=",
"completed",
";",
"}",
"public",
"Date",
"getCompletionDate",
"(",
")",
"{",
"return",
"_completionDate",
";",
"}",
"public",
"void",
"setCompletionDate",
"(",
"Date",
"completionDate",
")",
"{",
"_completionDate",
"=",
"completionDate",
";",
"}",
"public",
"long",
"getColumnBitmask",
"(",
")",
"{",
"return",
"_columnBitmask",
";",
"}",
"public",
"ExpandoBridge",
"getExpandoBridge",
"(",
")",
"{",
"return",
"ExpandoBridgeFactoryUtil",
".",
"getExpandoBridge",
"(",
"getCompanyId",
"(",
")",
",",
"KaleoTaskAssignmentInstance",
".",
"class",
".",
"getName",
"(",
")",
",",
"getPrimaryKey",
"(",
")",
")",
";",
"}",
"public",
"void",
"setExpandoBridgeAttributes",
"(",
"ServiceContext",
"serviceContext",
")",
"{",
"ExpandoBridge",
"expandoBridge",
"=",
"getExpandoBridge",
"(",
")",
";",
"expandoBridge",
".",
"setAttributes",
"(",
"serviceContext",
")",
";",
"}",
"public",
"KaleoTaskAssignmentInstance",
"toEscapedModel",
"(",
")",
"{",
"if",
"(",
"_escapedModel",
"==",
"null",
")",
"{",
"_escapedModel",
"=",
"(",
"KaleoTaskAssignmentInstance",
")",
"ProxyUtil",
".",
"newProxyInstance",
"(",
"_classLoader",
",",
"_escapedModelInterfaces",
",",
"new",
"AutoEscapeBeanHandler",
"(",
"this",
")",
")",
";",
"}",
"return",
"_escapedModel",
";",
"}",
"public",
"Object",
"clone",
"(",
")",
"{",
"KaleoTaskAssignmentInstanceImpl",
"kaleoTaskAssignmentInstanceImpl",
"=",
"new",
"KaleoTaskAssignmentInstanceImpl",
"(",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setKaleoTaskAssignmentInstanceId",
"(",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setGroupId",
"(",
"getGroupId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setCompanyId",
"(",
"getCompanyId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setUserId",
"(",
"getUserId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setUserName",
"(",
"getUserName",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setCreateDate",
"(",
"getCreateDate",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setModifiedDate",
"(",
"getModifiedDate",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setKaleoDefinitionId",
"(",
"getKaleoDefinitionId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setKaleoInstanceId",
"(",
"getKaleoInstanceId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setKaleoInstanceTokenId",
"(",
"getKaleoInstanceTokenId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setKaleoTaskInstanceTokenId",
"(",
"getKaleoTaskInstanceTokenId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setKaleoTaskId",
"(",
"getKaleoTaskId",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setKaleoTaskName",
"(",
"getKaleoTaskName",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setAssigneeClassName",
"(",
"getAssigneeClassName",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setAssigneeClassPK",
"(",
"getAssigneeClassPK",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setCompleted",
"(",
"getCompleted",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"setCompletionDate",
"(",
"getCompletionDate",
"(",
")",
")",
";",
"kaleoTaskAssignmentInstanceImpl",
".",
"resetOriginalValues",
"(",
")",
";",
"return",
"kaleoTaskAssignmentInstanceImpl",
";",
"}",
"public",
"int",
"compareTo",
"(",
"KaleoTaskAssignmentInstance",
"kaleoTaskAssignmentInstance",
")",
"{",
"int",
"value",
"=",
"0",
";",
"if",
"(",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
"<",
"kaleoTaskAssignmentInstance",
".",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
")",
"{",
"value",
"=",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
">",
"kaleoTaskAssignmentInstance",
".",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
")",
"{",
"value",
"=",
"1",
";",
"}",
"else",
"{",
"value",
"=",
"0",
";",
"}",
"if",
"(",
"value",
"!=",
"0",
")",
"{",
"return",
"value",
";",
"}",
"return",
"0",
";",
"}",
"public",
"boolean",
"equals",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"this",
"==",
"obj",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"(",
"obj",
"instanceof",
"KaleoTaskAssignmentInstance",
")",
")",
"{",
"return",
"false",
";",
"}",
"KaleoTaskAssignmentInstance",
"kaleoTaskAssignmentInstance",
"=",
"(",
"KaleoTaskAssignmentInstance",
")",
"obj",
";",
"long",
"primaryKey",
"=",
"kaleoTaskAssignmentInstance",
".",
"getPrimaryKey",
"(",
")",
";",
"if",
"(",
"getPrimaryKey",
"(",
")",
"==",
"primaryKey",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"public",
"int",
"hashCode",
"(",
")",
"{",
"return",
"(",
"int",
")",
"getPrimaryKey",
"(",
")",
";",
"}",
"public",
"void",
"resetOriginalValues",
"(",
")",
"{",
"KaleoTaskAssignmentInstanceModelImpl",
"kaleoTaskAssignmentInstanceModelImpl",
"=",
"this",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_originalGroupId",
"=",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_groupId",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_setOriginalGroupId",
"=",
"false",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_originalCompanyId",
"=",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_companyId",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_setOriginalCompanyId",
"=",
"false",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_originalKaleoDefinitionId",
"=",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_kaleoDefinitionId",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_setOriginalKaleoDefinitionId",
"=",
"false",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_originalKaleoInstanceId",
"=",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_kaleoInstanceId",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_setOriginalKaleoInstanceId",
"=",
"false",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_originalKaleoTaskInstanceTokenId",
"=",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_kaleoTaskInstanceTokenId",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_setOriginalKaleoTaskInstanceTokenId",
"=",
"false",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_originalAssigneeClassName",
"=",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_assigneeClassName",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_originalAssigneeClassPK",
"=",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_assigneeClassPK",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_setOriginalAssigneeClassPK",
"=",
"false",
";",
"kaleoTaskAssignmentInstanceModelImpl",
".",
"_columnBitmask",
"=",
"0",
";",
"}",
"public",
"CacheModel",
"<",
"KaleoTaskAssignmentInstance",
">",
"toCacheModel",
"(",
")",
"{",
"KaleoTaskAssignmentInstanceCacheModel",
"kaleoTaskAssignmentInstanceCacheModel",
"=",
"new",
"KaleoTaskAssignmentInstanceCacheModel",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoTaskAssignmentInstanceId",
"=",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"groupId",
"=",
"getGroupId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"companyId",
"=",
"getCompanyId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"userId",
"=",
"getUserId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"userName",
"=",
"getUserName",
"(",
")",
";",
"String",
"userName",
"=",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"userName",
";",
"if",
"(",
"(",
"userName",
"!=",
"null",
")",
"&&",
"(",
"userName",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"userName",
"=",
"null",
";",
"}",
"Date",
"createDate",
"=",
"getCreateDate",
"(",
")",
";",
"if",
"(",
"createDate",
"!=",
"null",
")",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"createDate",
"=",
"createDate",
".",
"getTime",
"(",
")",
";",
"}",
"else",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"createDate",
"=",
"Long",
".",
"MIN_VALUE",
";",
"}",
"Date",
"modifiedDate",
"=",
"getModifiedDate",
"(",
")",
";",
"if",
"(",
"modifiedDate",
"!=",
"null",
")",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"modifiedDate",
"=",
"modifiedDate",
".",
"getTime",
"(",
")",
";",
"}",
"else",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"modifiedDate",
"=",
"Long",
".",
"MIN_VALUE",
";",
"}",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoDefinitionId",
"=",
"getKaleoDefinitionId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoInstanceId",
"=",
"getKaleoInstanceId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoInstanceTokenId",
"=",
"getKaleoInstanceTokenId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoTaskInstanceTokenId",
"=",
"getKaleoTaskInstanceTokenId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoTaskId",
"=",
"getKaleoTaskId",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoTaskName",
"=",
"getKaleoTaskName",
"(",
")",
";",
"String",
"kaleoTaskName",
"=",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoTaskName",
";",
"if",
"(",
"(",
"kaleoTaskName",
"!=",
"null",
")",
"&&",
"(",
"kaleoTaskName",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"kaleoTaskName",
"=",
"null",
";",
"}",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"assigneeClassName",
"=",
"getAssigneeClassName",
"(",
")",
";",
"String",
"assigneeClassName",
"=",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"assigneeClassName",
";",
"if",
"(",
"(",
"assigneeClassName",
"!=",
"null",
")",
"&&",
"(",
"assigneeClassName",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"assigneeClassName",
"=",
"null",
";",
"}",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"assigneeClassPK",
"=",
"getAssigneeClassPK",
"(",
")",
";",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"completed",
"=",
"getCompleted",
"(",
")",
";",
"Date",
"completionDate",
"=",
"getCompletionDate",
"(",
")",
";",
"if",
"(",
"completionDate",
"!=",
"null",
")",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"completionDate",
"=",
"completionDate",
".",
"getTime",
"(",
")",
";",
"}",
"else",
"{",
"kaleoTaskAssignmentInstanceCacheModel",
".",
"completionDate",
"=",
"Long",
".",
"MIN_VALUE",
";",
"}",
"return",
"kaleoTaskAssignmentInstanceCacheModel",
";",
"}",
"public",
"String",
"toString",
"(",
")",
"{",
"StringBundler",
"sb",
"=",
"new",
"StringBundler",
"(",
"35",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"{kaleoTaskAssignmentInstanceId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", groupId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getGroupId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", companyId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCompanyId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", userId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getUserId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", userName=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getUserName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", createDate=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCreateDate",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", modifiedDate=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getModifiedDate",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", kaleoDefinitionId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoDefinitionId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", kaleoInstanceId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoInstanceId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", kaleoInstanceTokenId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoInstanceTokenId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", kaleoTaskInstanceTokenId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskInstanceTokenId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", kaleoTaskId=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", kaleoTaskName=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", assigneeClassName=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getAssigneeClassName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", assigneeClassPK=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getAssigneeClassPK",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", completed=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCompleted",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
", completionDate=",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCompletionDate",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"}",
"\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"public",
"String",
"toXmlString",
"(",
")",
"{",
"StringBundler",
"sb",
"=",
"new",
"StringBundler",
"(",
"55",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<model><model-name>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignmentInstance",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"</model-name>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>kaleoTaskAssignmentInstanceId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskAssignmentInstanceId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>groupId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getGroupId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>companyId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCompanyId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>userId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getUserId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>userName</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getUserName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>createDate</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCreateDate",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>modifiedDate</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getModifiedDate",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>kaleoDefinitionId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoDefinitionId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>kaleoInstanceId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoInstanceId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>kaleoInstanceTokenId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoInstanceTokenId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>kaleoTaskInstanceTokenId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskInstanceTokenId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>kaleoTaskId</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskId",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>kaleoTaskName</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getKaleoTaskName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>assigneeClassName</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getAssigneeClassName",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>assigneeClassPK</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getAssigneeClassPK",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>completed</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCompleted",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"<column><column-name>completionDate</column-name><column-value><![CDATA[",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"getCompletionDate",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"]]></column-value></column>",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"</model>",
"\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"private",
"static",
"ClassLoader",
"_classLoader",
"=",
"KaleoTaskAssignmentInstance",
".",
"class",
".",
"getClassLoader",
"(",
")",
";",
"private",
"static",
"Class",
"<",
"?",
">",
"[",
"]",
"_escapedModelInterfaces",
"=",
"new",
"Class",
"[",
"]",
"{",
"KaleoTaskAssignmentInstance",
".",
"class",
"}",
";",
"private",
"long",
"_kaleoTaskAssignmentInstanceId",
";",
"private",
"long",
"_groupId",
";",
"private",
"long",
"_originalGroupId",
";",
"private",
"boolean",
"_setOriginalGroupId",
";",
"private",
"long",
"_companyId",
";",
"private",
"long",
"_originalCompanyId",
";",
"private",
"boolean",
"_setOriginalCompanyId",
";",
"private",
"long",
"_userId",
";",
"private",
"String",
"_userUuid",
";",
"private",
"String",
"_userName",
";",
"private",
"Date",
"_createDate",
";",
"private",
"Date",
"_modifiedDate",
";",
"private",
"long",
"_kaleoDefinitionId",
";",
"private",
"long",
"_originalKaleoDefinitionId",
";",
"private",
"boolean",
"_setOriginalKaleoDefinitionId",
";",
"private",
"long",
"_kaleoInstanceId",
";",
"private",
"long",
"_originalKaleoInstanceId",
";",
"private",
"boolean",
"_setOriginalKaleoInstanceId",
";",
"private",
"long",
"_kaleoInstanceTokenId",
";",
"private",
"long",
"_kaleoTaskInstanceTokenId",
";",
"private",
"long",
"_originalKaleoTaskInstanceTokenId",
";",
"private",
"boolean",
"_setOriginalKaleoTaskInstanceTokenId",
";",
"private",
"long",
"_kaleoTaskId",
";",
"private",
"String",
"_kaleoTaskName",
";",
"private",
"String",
"_assigneeClassName",
";",
"private",
"String",
"_originalAssigneeClassName",
";",
"private",
"long",
"_assigneeClassPK",
";",
"private",
"long",
"_originalAssigneeClassPK",
";",
"private",
"boolean",
"_setOriginalAssigneeClassPK",
";",
"private",
"boolean",
"_completed",
";",
"private",
"Date",
"_completionDate",
";",
"private",
"long",
"_columnBitmask",
";",
"private",
"KaleoTaskAssignmentInstance",
"_escapedModel",
";",
"}"
] | The base model implementation for the KaleoTaskAssignmentInstance service. | [
"The",
"base",
"model",
"implementation",
"for",
"the",
"KaleoTaskAssignmentInstance",
"service",
"."
] | [] | [
{
"param": "KaleoTaskAssignmentInstanceModel",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "KaleoTaskAssignmentInstanceModel",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1efcdbbd2449b6b7e32e5ad43356ddc12cdf3dcb | akritiko/personal-archive | 01. BSc - Coursework/Code - JAVA - Databases/SmallDBMS/src/dbms/bplus/Node.java | [
"MIT"
] | Java | Node | /**
* This class implements an abstract class of a node of a B+ Tree. This
* is a superclass for the <code>InnerNode</code>,
* <code>PrimaryLeaf</code> and <code>SecondaryLeaf</code> classes.
* @see dbms.bplus.InnerNode
* @see dbms.bplus.PrimaryLeaf
* @see dbms.bplus.SecondaryLeaf
*/ | This class implements an abstract class of a node of a B+ Tree. This
is a superclass for the InnerNode,
PrimaryLeaf and SecondaryLeaf classes. | [
"This",
"class",
"implements",
"an",
"abstract",
"class",
"of",
"a",
"node",
"of",
"a",
"B",
"+",
"Tree",
".",
"This",
"is",
"a",
"superclass",
"for",
"the",
"InnerNode",
"PrimaryLeaf",
"and",
"SecondaryLeaf",
"classes",
"."
] | public abstract class Node implements Serializable {
/**
* The parent node.
*/
private InnerNode parent;
/**
* The type of the node.
*/
private NodeType type;
/**
* Creates a node with <code>type</code>.
*/
public Node(final NodeType type) {
this.type = type;
this.parent = null;
} // end method Node
/**
* Retrieves the type of the node.
*
* @return The <code>type</code> of the <code>Node</code>.
*/
public NodeType getNodeType() {
return this.type;
} // end method getNodeType
/**
* Retrieves the parent of the <code>Node</code>.
* @return The parent of the Node.
*/
public InnerNode getParent() {
return this.parent;
} // end method getParentNode
/**
* Sets the parent of the <code>Node</code>.
*
* @param parent
* the parent <code>Node</code>.
*/
public void setParent(final InnerNode parent) {
this.parent = parent;
} // end method setParentNode
/**
* Checks if the <code>Node</code> is replete or not
*
* @return <code>true</code> If the Node is replete and
* <code>false</code> otherwise.
*/
public abstract boolean isReplete();
} | [
"public",
"abstract",
"class",
"Node",
"implements",
"Serializable",
"{",
"/**\r\n\t * The parent node.\r\n\t */",
"private",
"InnerNode",
"parent",
";",
"/**\r\n\t * The type of the node.\r\n\t */",
"private",
"NodeType",
"type",
";",
"/**\r\n\t * Creates a node with <code>type</code>.\r\n\t */",
"public",
"Node",
"(",
"final",
"NodeType",
"type",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"parent",
"=",
"null",
";",
"}",
"/**\r\n\t * Retrieves the type of the node.\r\n\t * \r\n\t * @return The <code>type</code> of the <code>Node</code>.\r\n\t */",
"public",
"NodeType",
"getNodeType",
"(",
")",
"{",
"return",
"this",
".",
"type",
";",
"}",
"/**\r\n\t * Retrieves the parent of the <code>Node</code>.\r\n\t * @return The parent of the Node.\r\n\t */",
"public",
"InnerNode",
"getParent",
"(",
")",
"{",
"return",
"this",
".",
"parent",
";",
"}",
"/**\r\n\t * Sets the parent of the <code>Node</code>.\r\n\t * \r\n\t * @param parent \r\n\t * the parent <code>Node</code>.\r\n\t */",
"public",
"void",
"setParent",
"(",
"final",
"InnerNode",
"parent",
")",
"{",
"this",
".",
"parent",
"=",
"parent",
";",
"}",
"/**\r\n\t * Checks if the <code>Node</code> is replete or not\r\n\t * \r\n\t * @return <code>true</code> If the Node is replete and\r\n\t * <code>false</code> otherwise.\r\n\t */",
"public",
"abstract",
"boolean",
"isReplete",
"(",
")",
";",
"}"
] | This class implements an abstract class of a node of a B+ Tree. | [
"This",
"class",
"implements",
"an",
"abstract",
"class",
"of",
"a",
"node",
"of",
"a",
"B",
"+",
"Tree",
"."
] | [
"// end method Node\r",
"// end method getNodeType\r",
"// end method getParentNode\r",
"// end method setParentNode\r"
] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
48029ce9e05da40523f2d32bdeb92c466cba9c8e | mattl-netflix/Priam | priam/src/main/java/com/netflix/priam/cluster/management/SchemaConstant.java | [
"Apache-2.0"
] | Java | SchemaConstant | /** Created by aagrawal on 3/6/18. */ | Created by aagrawal on 3/6/18. | [
"Created",
"by",
"aagrawal",
"on",
"3",
"/",
"6",
"/",
"18",
"."
] | class SchemaConstant {
private static final String SYSTEM_KEYSPACE_NAME = "system";
private static final String SCHEMA_KEYSPACE_NAME = "system_schema";
private static final String TRACE_KEYSPACE_NAME = "system_traces";
private static final String AUTH_KEYSPACE_NAME = "system_auth";
private static final String DISTRIBUTED_KEYSPACE_NAME = "system_distributed";
private static final String DSE_SYSTEM = "dse_system";
private static final Set<String> SYSTEM_KEYSPACE_NAMES =
ImmutableSet.of(
SYSTEM_KEYSPACE_NAME,
SCHEMA_KEYSPACE_NAME,
TRACE_KEYSPACE_NAME,
AUTH_KEYSPACE_NAME,
DISTRIBUTED_KEYSPACE_NAME,
DSE_SYSTEM);
public static final boolean isSystemKeyspace(String keyspace) {
return SYSTEM_KEYSPACE_NAMES.contains(keyspace.toLowerCase());
}
} | [
"class",
"SchemaConstant",
"{",
"private",
"static",
"final",
"String",
"SYSTEM_KEYSPACE_NAME",
"=",
"\"",
"system",
"\"",
";",
"private",
"static",
"final",
"String",
"SCHEMA_KEYSPACE_NAME",
"=",
"\"",
"system_schema",
"\"",
";",
"private",
"static",
"final",
"String",
"TRACE_KEYSPACE_NAME",
"=",
"\"",
"system_traces",
"\"",
";",
"private",
"static",
"final",
"String",
"AUTH_KEYSPACE_NAME",
"=",
"\"",
"system_auth",
"\"",
";",
"private",
"static",
"final",
"String",
"DISTRIBUTED_KEYSPACE_NAME",
"=",
"\"",
"system_distributed",
"\"",
";",
"private",
"static",
"final",
"String",
"DSE_SYSTEM",
"=",
"\"",
"dse_system",
"\"",
";",
"private",
"static",
"final",
"Set",
"<",
"String",
">",
"SYSTEM_KEYSPACE_NAMES",
"=",
"ImmutableSet",
".",
"of",
"(",
"SYSTEM_KEYSPACE_NAME",
",",
"SCHEMA_KEYSPACE_NAME",
",",
"TRACE_KEYSPACE_NAME",
",",
"AUTH_KEYSPACE_NAME",
",",
"DISTRIBUTED_KEYSPACE_NAME",
",",
"DSE_SYSTEM",
")",
";",
"public",
"static",
"final",
"boolean",
"isSystemKeyspace",
"(",
"String",
"keyspace",
")",
"{",
"return",
"SYSTEM_KEYSPACE_NAMES",
".",
"contains",
"(",
"keyspace",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"}"
] | Created by aagrawal on 3/6/18. | [
"Created",
"by",
"aagrawal",
"on",
"3",
"/",
"6",
"/",
"18",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
480bdeee3583b869290c667be3f138376b510bc6 | jrasor/ftc_team_5197_2018_19 | TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RedLookWhack.java | [
"MIT"
] | Java | RedLookWhack | /**
* Autonomous opmode for Red Alliance in the 2017-2018 FTC "Relic Recovery" game.
* Look at left Jewel, determine its color, then make the correct robot turn to
* knock off the Blue Jewel.
*
* It runs on a Trainerbot.
*/ | Autonomous opmode for Red Alliance in the 2017-2018 FTC "Relic Recovery" game.
Look at left Jewel, determine its color, then make the correct robot turn to
knock off the Blue Jewel.
It runs on a Trainerbot. | [
"Autonomous",
"opmode",
"for",
"Red",
"Alliance",
"in",
"the",
"2017",
"-",
"2018",
"FTC",
"\"",
"Relic",
"Recovery",
"\"",
"game",
".",
"Look",
"at",
"left",
"Jewel",
"determine",
"its",
"color",
"then",
"make",
"the",
"correct",
"robot",
"turn",
"to",
"knock",
"off",
"the",
"Blue",
"Jewel",
".",
"It",
"runs",
"on",
"a",
"Trainerbot",
"."
] | @Autonomous(name="Red Look and Whack", group="Trainerbot")
@Disabled
public class RedLookWhack extends LinearOpMode {
Trainerbot robot = new Trainerbot();
static final double TURN_SPEED = 0.20; // slow to minimize wheel slippage
static final double KNOCK_ANGLE = 0.25; // radians
static final double DEPLOYED = 0.04; // Extended from front of robot
static final double STOWED = 1.00; // Folded back toward rear
private boolean redIsLeft;
@Override
public void runOpMode() {
// Initialize the drive train.
// The initHardware() method of the hardware class does all the work here.
robot.init(hardwareMap);
robot.leftDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
robot.rightDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
robot.leftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
robot.rightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
// Define class members, initialize the subsystems they refer to.
Servo servo = hardwareMap.get(Servo.class, "paddle");
servo.setPosition(STOWED);
ColorSensor colorSensor;
colorSensor = hardwareMap.get(ColorSensor.class, "colorSensor");
// Turn the LED on.
colorSensor.enableLed(true);
// Wait for the game to start (driver presses PLAY).
waitForStart();
// Get paddle out in front of robot, so its sensor can see the left Jewel.
servo.setPosition(DEPLOYED);
sleep(2000); // Give time to get there.
// Determine left Jewel color.
// Read the RGB data, and report colors to driver station.
telemetry.addData("Red ", colorSensor.red());
telemetry.addData("Green", colorSensor.green());
telemetry.addData("Blue ", colorSensor.blue());
telemetry.update();
// To Do: handle error cases: green dominant, red == blue, no colors seen.
redIsLeft = colorSensor.red() > colorSensor.blue() ? true : false;
if (redIsLeft) { // knock the left Jewel off
turnAngle(TURN_SPEED, -KNOCK_ANGLE);
}
else { // knock the right Jewel off
turnAngle(TURN_SPEED, KNOCK_ANGLE);
}
}
// Turn on vertical axis between the drive wheels.
public void turnAngle (double speed, double angle) {
double leftArc = (-robot.DRIVE_WHEEL_SEPARATION/2.0) * angle;
double rightArc = (robot.DRIVE_WHEEL_SEPARATION/2.0) * angle;
int newLeftTarget;
int newRightTarget;
if (opModeIsActive()) {
robot.leftDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
robot.rightDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
// Determine new target positions, and pass those to motor controller.
newLeftTarget = (int) (leftArc * robot.COUNTS_PER_INCH);
newRightTarget = (int) (rightArc * robot.COUNTS_PER_INCH);
robot.leftDrive.setTargetPosition(newLeftTarget);
robot.rightDrive.setTargetPosition(newRightTarget);
// There are other motor run modes.
robot.leftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
robot.rightDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
// Note: Reverse movement is obtained by setting a negative target, not speed.
robot.leftDrive.setPower(speed);
robot.rightDrive.setPower(speed);
// Stop as soon as one motor has reached its target position.
while (opModeIsActive() &&
(robot.leftDrive.isBusy() && robot.rightDrive.isBusy())) {
}
// Set motors in reasonable condition for next moveRotations.
robot.leftDrive.setPower(0);
robot.rightDrive.setPower(0);
robot.leftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
robot.rightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
// Give time for Driver person to see the colors, and evaluate the decision
// making.
sleep (5000);
}
}
} | [
"@",
"Autonomous",
"(",
"name",
"=",
"\"",
"Red Look and Whack",
"\"",
",",
"group",
"=",
"\"",
"Trainerbot",
"\"",
")",
"@",
"Disabled",
"public",
"class",
"RedLookWhack",
"extends",
"LinearOpMode",
"{",
"Trainerbot",
"robot",
"=",
"new",
"Trainerbot",
"(",
")",
";",
"static",
"final",
"double",
"TURN_SPEED",
"=",
"0.20",
";",
"static",
"final",
"double",
"KNOCK_ANGLE",
"=",
"0.25",
";",
"static",
"final",
"double",
"DEPLOYED",
"=",
"0.04",
";",
"static",
"final",
"double",
"STOWED",
"=",
"1.00",
";",
"private",
"boolean",
"redIsLeft",
";",
"@",
"Override",
"public",
"void",
"runOpMode",
"(",
")",
"{",
"robot",
".",
"init",
"(",
"hardwareMap",
")",
";",
"robot",
".",
"leftDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"STOP_AND_RESET_ENCODER",
")",
";",
"robot",
".",
"rightDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"STOP_AND_RESET_ENCODER",
")",
";",
"robot",
".",
"leftDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"RUN_USING_ENCODER",
")",
";",
"robot",
".",
"rightDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"RUN_USING_ENCODER",
")",
";",
"Servo",
"servo",
"=",
"hardwareMap",
".",
"get",
"(",
"Servo",
".",
"class",
",",
"\"",
"paddle",
"\"",
")",
";",
"servo",
".",
"setPosition",
"(",
"STOWED",
")",
";",
"ColorSensor",
"colorSensor",
";",
"colorSensor",
"=",
"hardwareMap",
".",
"get",
"(",
"ColorSensor",
".",
"class",
",",
"\"",
"colorSensor",
"\"",
")",
";",
"colorSensor",
".",
"enableLed",
"(",
"true",
")",
";",
"waitForStart",
"(",
")",
";",
"servo",
".",
"setPosition",
"(",
"DEPLOYED",
")",
";",
"sleep",
"(",
"2000",
")",
";",
"telemetry",
".",
"addData",
"(",
"\"",
"Red ",
"\"",
",",
"colorSensor",
".",
"red",
"(",
")",
")",
";",
"telemetry",
".",
"addData",
"(",
"\"",
"Green",
"\"",
",",
"colorSensor",
".",
"green",
"(",
")",
")",
";",
"telemetry",
".",
"addData",
"(",
"\"",
"Blue ",
"\"",
",",
"colorSensor",
".",
"blue",
"(",
")",
")",
";",
"telemetry",
".",
"update",
"(",
")",
";",
"redIsLeft",
"=",
"colorSensor",
".",
"red",
"(",
")",
">",
"colorSensor",
".",
"blue",
"(",
")",
"?",
"true",
":",
"false",
";",
"if",
"(",
"redIsLeft",
")",
"{",
"turnAngle",
"(",
"TURN_SPEED",
",",
"-",
"KNOCK_ANGLE",
")",
";",
"}",
"else",
"{",
"turnAngle",
"(",
"TURN_SPEED",
",",
"KNOCK_ANGLE",
")",
";",
"}",
"}",
"public",
"void",
"turnAngle",
"(",
"double",
"speed",
",",
"double",
"angle",
")",
"{",
"double",
"leftArc",
"=",
"(",
"-",
"robot",
".",
"DRIVE_WHEEL_SEPARATION",
"/",
"2.0",
")",
"*",
"angle",
";",
"double",
"rightArc",
"=",
"(",
"robot",
".",
"DRIVE_WHEEL_SEPARATION",
"/",
"2.0",
")",
"*",
"angle",
";",
"int",
"newLeftTarget",
";",
"int",
"newRightTarget",
";",
"if",
"(",
"opModeIsActive",
"(",
")",
")",
"{",
"robot",
".",
"leftDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"STOP_AND_RESET_ENCODER",
")",
";",
"robot",
".",
"rightDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"STOP_AND_RESET_ENCODER",
")",
";",
"newLeftTarget",
"=",
"(",
"int",
")",
"(",
"leftArc",
"*",
"robot",
".",
"COUNTS_PER_INCH",
")",
";",
"newRightTarget",
"=",
"(",
"int",
")",
"(",
"rightArc",
"*",
"robot",
".",
"COUNTS_PER_INCH",
")",
";",
"robot",
".",
"leftDrive",
".",
"setTargetPosition",
"(",
"newLeftTarget",
")",
";",
"robot",
".",
"rightDrive",
".",
"setTargetPosition",
"(",
"newRightTarget",
")",
";",
"robot",
".",
"leftDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"RUN_TO_POSITION",
")",
";",
"robot",
".",
"rightDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"RUN_TO_POSITION",
")",
";",
"robot",
".",
"leftDrive",
".",
"setPower",
"(",
"speed",
")",
";",
"robot",
".",
"rightDrive",
".",
"setPower",
"(",
"speed",
")",
";",
"while",
"(",
"opModeIsActive",
"(",
")",
"&&",
"(",
"robot",
".",
"leftDrive",
".",
"isBusy",
"(",
")",
"&&",
"robot",
".",
"rightDrive",
".",
"isBusy",
"(",
")",
")",
")",
"{",
"}",
"robot",
".",
"leftDrive",
".",
"setPower",
"(",
"0",
")",
";",
"robot",
".",
"rightDrive",
".",
"setPower",
"(",
"0",
")",
";",
"robot",
".",
"leftDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"RUN_USING_ENCODER",
")",
";",
"robot",
".",
"rightDrive",
".",
"setMode",
"(",
"DcMotor",
".",
"RunMode",
".",
"RUN_USING_ENCODER",
")",
";",
"sleep",
"(",
"5000",
")",
";",
"}",
"}",
"}"
] | Autonomous opmode for Red Alliance in the 2017-2018 FTC "Relic Recovery" game. | [
"Autonomous",
"opmode",
"for",
"Red",
"Alliance",
"in",
"the",
"2017",
"-",
"2018",
"FTC",
"\"",
"Relic",
"Recovery",
"\"",
"game",
"."
] | [
"// slow to minimize wheel slippage",
"// radians",
"// Extended from front of robot",
"// Folded back toward rear",
"// Initialize the drive train.",
"// The initHardware() method of the hardware class does all the work here.",
"// Define class members, initialize the subsystems they refer to.",
"// Turn the LED on.",
"// Wait for the game to start (driver presses PLAY).",
"// Get paddle out in front of robot, so its sensor can see the left Jewel.",
"// Give time to get there.",
"// Determine left Jewel color.",
"// Read the RGB data, and report colors to driver station.",
"// To Do: handle error cases: green dominant, red == blue, no colors seen.",
"// knock the left Jewel off",
"// knock the right Jewel off",
"// Turn on vertical axis between the drive wheels.",
"// Determine new target positions, and pass those to motor controller.",
"// There are other motor run modes.",
"// Note: Reverse movement is obtained by setting a negative target, not speed.",
"// Stop as soon as one motor has reached its target position.",
"// Set motors in reasonable condition for next moveRotations.",
"// Give time for Driver person to see the colors, and evaluate the decision",
"// making."
] | [
{
"param": "LinearOpMode",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "LinearOpMode",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
480c2b27b9977f528d3545526d549780a902f839 | soerendomroes/lingua-franca | org.lflang.diagram/src/org/lflang/diagram/synthesis/SynthesisRegistration.java | [
"BSD-2-Clause"
] | Java | SynthesisRegistration | /**
* Registration of all diagram synthesis related classes in Klighd.
*
* @author{Alexander Schulz-Rosengarten <[email protected]>}
*/ | Registration of all diagram synthesis related classes in Klighd.
@author{Alexander Schulz-Rosengarten } | [
"Registration",
"of",
"all",
"diagram",
"synthesis",
"related",
"classes",
"in",
"Klighd",
".",
"@author",
"{",
"Alexander",
"Schulz",
"-",
"Rosengarten",
"}"
] | public class SynthesisRegistration implements IKlighdStartupHook {
@Override
public void execute() {
KlighdDataManager reg = KlighdDataManager.getInstance();
// Synthesis
reg.registerDiagramSynthesisClass(LinguaFrancaSynthesis.ID, LinguaFrancaSynthesis.class);
// Actions
reg.registerAction(MemorizingExpandCollapseAction.ID, new MemorizingExpandCollapseAction());
reg.registerAction(ExpandAllReactorsAction.ID, new ExpandAllReactorsAction());
reg.registerAction(CollapseAllReactorsAction.ID, new CollapseAllReactorsAction());
reg.registerAction(ShowCycleAction.ID, new ShowCycleAction());
reg.registerAction(FilterCycleAction.ID, new FilterCycleAction());
// Style Mod
reg.registerStyleModifier(ReactionPortAdjustment.ID, new ReactionPortAdjustment());
}
} | [
"public",
"class",
"SynthesisRegistration",
"implements",
"IKlighdStartupHook",
"{",
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"KlighdDataManager",
"reg",
"=",
"KlighdDataManager",
".",
"getInstance",
"(",
")",
";",
"reg",
".",
"registerDiagramSynthesisClass",
"(",
"LinguaFrancaSynthesis",
".",
"ID",
",",
"LinguaFrancaSynthesis",
".",
"class",
")",
";",
"reg",
".",
"registerAction",
"(",
"MemorizingExpandCollapseAction",
".",
"ID",
",",
"new",
"MemorizingExpandCollapseAction",
"(",
")",
")",
";",
"reg",
".",
"registerAction",
"(",
"ExpandAllReactorsAction",
".",
"ID",
",",
"new",
"ExpandAllReactorsAction",
"(",
")",
")",
";",
"reg",
".",
"registerAction",
"(",
"CollapseAllReactorsAction",
".",
"ID",
",",
"new",
"CollapseAllReactorsAction",
"(",
")",
")",
";",
"reg",
".",
"registerAction",
"(",
"ShowCycleAction",
".",
"ID",
",",
"new",
"ShowCycleAction",
"(",
")",
")",
";",
"reg",
".",
"registerAction",
"(",
"FilterCycleAction",
".",
"ID",
",",
"new",
"FilterCycleAction",
"(",
")",
")",
";",
"reg",
".",
"registerStyleModifier",
"(",
"ReactionPortAdjustment",
".",
"ID",
",",
"new",
"ReactionPortAdjustment",
"(",
")",
")",
";",
"}",
"}"
] | Registration of all diagram synthesis related classes in Klighd. | [
"Registration",
"of",
"all",
"diagram",
"synthesis",
"related",
"classes",
"in",
"Klighd",
"."
] | [
"// Synthesis",
"// Actions",
"// Style Mod"
] | [
{
"param": "IKlighdStartupHook",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "IKlighdStartupHook",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
480ccf6ca3aa5157b6f51b09397061a193bd0007 | alsash/calcncook | app/src/main/java/com/alsash/reciper/data/db/table/RecipeTable.java | [
"Apache-2.0"
] | Java | RecipeTable | /**
* A model of the Recipe entity
* that persists in local relational database table by GreenDao framework
* and serialized from JSON by Gson framework
*/ | A model of the Recipe entity
that persists in local relational database table by GreenDao framework
and serialized from JSON by Gson framework | [
"A",
"model",
"of",
"the",
"Recipe",
"entity",
"that",
"persists",
"in",
"local",
"relational",
"database",
"table",
"by",
"GreenDao",
"framework",
"and",
"serialized",
"from",
"JSON",
"by",
"Gson",
"framework"
] | @Entity(
nameInDb = "RECIPE",
generateGettersSetters = false,
active = true
)
public final class RecipeTable implements Table, RecipeFull {
@Id
Long id;
@Unique
String uuid;
@Index
Date changedAt;
@SerializedName("created_at_unix")
Date createdAt;
String name;
String source;
String description;
@NotNull
int servings;
@NotNull
double massFlowRateGps; // gram per second
@NotNull
boolean favorite;
@Index(name = "CATEGORY_TO_RECIPE")
String categoryUuid;
@Index(name = "AUTHOR_TO_RECIPE")
String authorUuid;
@ToMany(joinProperties = {@JoinProperty(name = "categoryUuid", referencedName = "uuid")})
List<CategoryTable> categoryTables;
@ToMany(joinProperties = {@JoinProperty(name = "authorUuid", referencedName = "uuid")})
List<AuthorTable> authorTables;
@ToMany(joinProperties = {@JoinProperty(name = "uuid", referencedName = "recipeUuid")})
List<RecipePhotoTable> recipePhotoTables;
@ToMany(joinProperties = {@JoinProperty(name = "uuid", referencedName = "recipeUuid")})
List<RecipeLabelTable> recipeLabelTables;
@ToMany(joinProperties = {@JoinProperty(name = "uuid", referencedName = "recipeUuid")})
List<RecipeFoodTable> recipeFoodTables;
@ToMany(joinProperties = {@JoinProperty(name = "uuid", referencedName = "recipeUuid")})
List<RecipeMethodTable> recipeMethodTables;
private transient List<Photo> photos = new ArrayList<>();
private transient List<Label> labels = new ArrayList<>();
private transient List<Ingredient> ingredients = new ArrayList<>();
private transient List<Method> methods = new ArrayList<>();
/**
* Used to resolve relations
*/
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/**
* Used for active entity operations.
*/
@Generated(hash = 1210201788)
private transient RecipeTableDao myDao;
@Generated(hash = 1582739737)
public RecipeTable(Long id, String uuid, Date changedAt, Date createdAt, String name, String source,
String description, int servings, double massFlowRateGps, boolean favorite,
String categoryUuid, String authorUuid) {
this.id = id;
this.uuid = uuid;
this.changedAt = changedAt;
this.createdAt = createdAt;
this.name = name;
this.source = source;
this.description = description;
this.servings = servings;
this.massFlowRateGps = massFlowRateGps;
this.favorite = favorite;
this.categoryUuid = categoryUuid;
this.authorUuid = authorUuid;
}
@Generated(hash = 1656289545)
public RecipeTable() {
}
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
@Override
public String getUuid() {
return uuid;
}
@Override
public void setUuid(String uuid) {
this.uuid = uuid;
}
@Override
public Date getChangedAt() {
return changedAt;
}
@Override
public void setChangedAt(Date changedAt) {
this.changedAt = changedAt;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
@Override
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public int getServings() {
return servings;
}
public void setServings(int servings) {
this.servings = servings;
}
@Override
public double getMassFlowRateGps() {
return massFlowRateGps;
}
public void setMassFlowRateGps(double massFlowRateGps) {
this.massFlowRateGps = massFlowRateGps;
}
@Override
public boolean isFavorite() {
return favorite;
}
public boolean getFavorite() {
return isFavorite();
}
public void setFavorite(boolean favorite) {
this.favorite = favorite;
}
public String getCategoryUuid() {
return categoryUuid;
}
public void setCategoryUuid(String categoryUuid) {
this.categoryUuid = categoryUuid;
}
public String getAuthorUuid() {
return authorUuid;
}
public void setAuthorUuid(String authorUuid) {
this.authorUuid = authorUuid;
}
@Override
public Photo getMainPhoto() {
for (RecipePhotoTable recipePhotoTable : getRecipePhotoTables()) {
if (recipePhotoTable.main)
return recipePhotoTable.getPhotoTables().size() > 0 ?
recipePhotoTable.getPhotoTables().get(0) :
null;
}
return null;
}
@Override
public Author getAuthor() {
return getAuthorTables().size() > 0 ? getAuthorTables().get(0) : null;
}
@Override
public Category getCategory() {
return getCategoryTables().size() > 0 ? getCategoryTables().get(0) : null;
}
@Override
public List<Photo> getPhotos() {
photos.clear();
for (RecipePhotoTable recipePhotoTable : getRecipePhotoTables()) {
photos.addAll(recipePhotoTable.getPhotoTables());
}
return photos;
}
@Override
public List<Label> getLabels() {
labels.clear();
for (RecipeLabelTable recipeLabelTable : getRecipeLabelTables()) {
labels.addAll(recipeLabelTable.getLabelTables());
}
return labels;
}
@Override
public List<Ingredient> getIngredients() {
ingredients.clear();
ingredients.addAll(getRecipeFoodTables());
return ingredients;
}
@Override
public List<Method> getMethods() {
methods.clear();
methods.addAll(getRecipeMethodTables());
return methods;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1211508832)
public List<CategoryTable> getCategoryTables() {
if (categoryTables == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
CategoryTableDao targetDao = daoSession.getCategoryTableDao();
List<CategoryTable> categoryTablesNew = targetDao
._queryRecipeTable_CategoryTables(categoryUuid);
synchronized (this) {
if (categoryTables == null) {
categoryTables = categoryTablesNew;
}
}
}
return categoryTables;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1017928287)
public synchronized void resetCategoryTables() {
categoryTables = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1157942686)
public List<AuthorTable> getAuthorTables() {
if (authorTables == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
AuthorTableDao targetDao = daoSession.getAuthorTableDao();
List<AuthorTable> authorTablesNew = targetDao
._queryRecipeTable_AuthorTables(authorUuid);
synchronized (this) {
if (authorTables == null) {
authorTables = authorTablesNew;
}
}
}
return authorTables;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 376306627)
public synchronized void resetAuthorTables() {
authorTables = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 601605547)
public List<RecipePhotoTable> getRecipePhotoTables() {
if (recipePhotoTables == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
RecipePhotoTableDao targetDao = daoSession.getRecipePhotoTableDao();
List<RecipePhotoTable> recipePhotoTablesNew = targetDao
._queryRecipeTable_RecipePhotoTables(uuid);
synchronized (this) {
if (recipePhotoTables == null) {
recipePhotoTables = recipePhotoTablesNew;
}
}
}
return recipePhotoTables;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 71148360)
public synchronized void resetRecipePhotoTables() {
recipePhotoTables = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 1985941725)
public List<RecipeLabelTable> getRecipeLabelTables() {
if (recipeLabelTables == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
RecipeLabelTableDao targetDao = daoSession.getRecipeLabelTableDao();
List<RecipeLabelTable> recipeLabelTablesNew = targetDao
._queryRecipeTable_RecipeLabelTables(uuid);
synchronized (this) {
if (recipeLabelTables == null) {
recipeLabelTables = recipeLabelTablesNew;
}
}
}
return recipeLabelTables;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 621796270)
public synchronized void resetRecipeLabelTables() {
recipeLabelTables = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 425446250)
public List<RecipeFoodTable> getRecipeFoodTables() {
if (recipeFoodTables == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
RecipeFoodTableDao targetDao = daoSession.getRecipeFoodTableDao();
List<RecipeFoodTable> recipeFoodTablesNew = targetDao
._queryRecipeTable_RecipeFoodTables(uuid);
synchronized (this) {
if (recipeFoodTables == null) {
recipeFoodTables = recipeFoodTablesNew;
}
}
}
return recipeFoodTables;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 1460648270)
public synchronized void resetRecipeFoodTables() {
recipeFoodTables = null;
}
/**
* To-many relationship, resolved on first access (and after reset).
* Changes to to-many relations are not persisted, make changes to the target entity.
*/
@Generated(hash = 822006377)
public List<RecipeMethodTable> getRecipeMethodTables() {
if (recipeMethodTables == null) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
RecipeMethodTableDao targetDao = daoSession.getRecipeMethodTableDao();
List<RecipeMethodTable> recipeMethodTablesNew = targetDao
._queryRecipeTable_RecipeMethodTables(uuid);
synchronized (this) {
if (recipeMethodTables == null) {
recipeMethodTables = recipeMethodTablesNew;
}
}
}
return recipeMethodTables;
}
/**
* Resets a to-many relationship, making the next get call to query for a fresh result.
*/
@Generated(hash = 864534768)
public synchronized void resetRecipeMethodTables() {
recipeMethodTables = null;
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/**
* called by internal mechanisms, do not call yourself.
*/
@Generated(hash = 173120018)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getRecipeTableDao() : null;
}
} | [
"@",
"Entity",
"(",
"nameInDb",
"=",
"\"",
"RECIPE",
"\"",
",",
"generateGettersSetters",
"=",
"false",
",",
"active",
"=",
"true",
")",
"public",
"final",
"class",
"RecipeTable",
"implements",
"Table",
",",
"RecipeFull",
"{",
"@",
"Id",
"Long",
"id",
";",
"@",
"Unique",
"String",
"uuid",
";",
"@",
"Index",
"Date",
"changedAt",
";",
"@",
"SerializedName",
"(",
"\"",
"created_at_unix",
"\"",
")",
"Date",
"createdAt",
";",
"String",
"name",
";",
"String",
"source",
";",
"String",
"description",
";",
"@",
"NotNull",
"int",
"servings",
";",
"@",
"NotNull",
"double",
"massFlowRateGps",
";",
"@",
"NotNull",
"boolean",
"favorite",
";",
"@",
"Index",
"(",
"name",
"=",
"\"",
"CATEGORY_TO_RECIPE",
"\"",
")",
"String",
"categoryUuid",
";",
"@",
"Index",
"(",
"name",
"=",
"\"",
"AUTHOR_TO_RECIPE",
"\"",
")",
"String",
"authorUuid",
";",
"@",
"ToMany",
"(",
"joinProperties",
"=",
"{",
"@",
"JoinProperty",
"(",
"name",
"=",
"\"",
"categoryUuid",
"\"",
",",
"referencedName",
"=",
"\"",
"uuid",
"\"",
")",
"}",
")",
"List",
"<",
"CategoryTable",
">",
"categoryTables",
";",
"@",
"ToMany",
"(",
"joinProperties",
"=",
"{",
"@",
"JoinProperty",
"(",
"name",
"=",
"\"",
"authorUuid",
"\"",
",",
"referencedName",
"=",
"\"",
"uuid",
"\"",
")",
"}",
")",
"List",
"<",
"AuthorTable",
">",
"authorTables",
";",
"@",
"ToMany",
"(",
"joinProperties",
"=",
"{",
"@",
"JoinProperty",
"(",
"name",
"=",
"\"",
"uuid",
"\"",
",",
"referencedName",
"=",
"\"",
"recipeUuid",
"\"",
")",
"}",
")",
"List",
"<",
"RecipePhotoTable",
">",
"recipePhotoTables",
";",
"@",
"ToMany",
"(",
"joinProperties",
"=",
"{",
"@",
"JoinProperty",
"(",
"name",
"=",
"\"",
"uuid",
"\"",
",",
"referencedName",
"=",
"\"",
"recipeUuid",
"\"",
")",
"}",
")",
"List",
"<",
"RecipeLabelTable",
">",
"recipeLabelTables",
";",
"@",
"ToMany",
"(",
"joinProperties",
"=",
"{",
"@",
"JoinProperty",
"(",
"name",
"=",
"\"",
"uuid",
"\"",
",",
"referencedName",
"=",
"\"",
"recipeUuid",
"\"",
")",
"}",
")",
"List",
"<",
"RecipeFoodTable",
">",
"recipeFoodTables",
";",
"@",
"ToMany",
"(",
"joinProperties",
"=",
"{",
"@",
"JoinProperty",
"(",
"name",
"=",
"\"",
"uuid",
"\"",
",",
"referencedName",
"=",
"\"",
"recipeUuid",
"\"",
")",
"}",
")",
"List",
"<",
"RecipeMethodTable",
">",
"recipeMethodTables",
";",
"private",
"transient",
"List",
"<",
"Photo",
">",
"photos",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"private",
"transient",
"List",
"<",
"Label",
">",
"labels",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"private",
"transient",
"List",
"<",
"Ingredient",
">",
"ingredients",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"private",
"transient",
"List",
"<",
"Method",
">",
"methods",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"/**\n * Used to resolve relations\n */",
"@",
"Generated",
"(",
"hash",
"=",
"2040040024",
")",
"private",
"transient",
"DaoSession",
"daoSession",
";",
"/**\n * Used for active entity operations.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"1210201788",
")",
"private",
"transient",
"RecipeTableDao",
"myDao",
";",
"@",
"Generated",
"(",
"hash",
"=",
"1582739737",
")",
"public",
"RecipeTable",
"(",
"Long",
"id",
",",
"String",
"uuid",
",",
"Date",
"changedAt",
",",
"Date",
"createdAt",
",",
"String",
"name",
",",
"String",
"source",
",",
"String",
"description",
",",
"int",
"servings",
",",
"double",
"massFlowRateGps",
",",
"boolean",
"favorite",
",",
"String",
"categoryUuid",
",",
"String",
"authorUuid",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"uuid",
"=",
"uuid",
";",
"this",
".",
"changedAt",
"=",
"changedAt",
";",
"this",
".",
"createdAt",
"=",
"createdAt",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"source",
"=",
"source",
";",
"this",
".",
"description",
"=",
"description",
";",
"this",
".",
"servings",
"=",
"servings",
";",
"this",
".",
"massFlowRateGps",
"=",
"massFlowRateGps",
";",
"this",
".",
"favorite",
"=",
"favorite",
";",
"this",
".",
"categoryUuid",
"=",
"categoryUuid",
";",
"this",
".",
"authorUuid",
"=",
"authorUuid",
";",
"}",
"@",
"Generated",
"(",
"hash",
"=",
"1656289545",
")",
"public",
"RecipeTable",
"(",
")",
"{",
"}",
"@",
"Override",
"public",
"Long",
"getId",
"(",
")",
"{",
"return",
"id",
";",
"}",
"@",
"Override",
"public",
"void",
"setId",
"(",
"Long",
"id",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"}",
"@",
"Override",
"public",
"String",
"getUuid",
"(",
")",
"{",
"return",
"uuid",
";",
"}",
"@",
"Override",
"public",
"void",
"setUuid",
"(",
"String",
"uuid",
")",
"{",
"this",
".",
"uuid",
"=",
"uuid",
";",
"}",
"@",
"Override",
"public",
"Date",
"getChangedAt",
"(",
")",
"{",
"return",
"changedAt",
";",
"}",
"@",
"Override",
"public",
"void",
"setChangedAt",
"(",
"Date",
"changedAt",
")",
"{",
"this",
".",
"changedAt",
"=",
"changedAt",
";",
"}",
"@",
"Override",
"public",
"Date",
"getCreatedAt",
"(",
")",
"{",
"return",
"createdAt",
";",
"}",
"public",
"void",
"setCreatedAt",
"(",
"Date",
"createdAt",
")",
"{",
"this",
".",
"createdAt",
"=",
"createdAt",
";",
"}",
"@",
"Override",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"@",
"Override",
"public",
"String",
"getSource",
"(",
")",
"{",
"return",
"source",
";",
"}",
"public",
"void",
"setSource",
"(",
"String",
"source",
")",
"{",
"this",
".",
"source",
"=",
"source",
";",
"}",
"@",
"Override",
"public",
"String",
"getDescription",
"(",
")",
"{",
"return",
"description",
";",
"}",
"public",
"void",
"setDescription",
"(",
"String",
"description",
")",
"{",
"this",
".",
"description",
"=",
"description",
";",
"}",
"@",
"Override",
"public",
"int",
"getServings",
"(",
")",
"{",
"return",
"servings",
";",
"}",
"public",
"void",
"setServings",
"(",
"int",
"servings",
")",
"{",
"this",
".",
"servings",
"=",
"servings",
";",
"}",
"@",
"Override",
"public",
"double",
"getMassFlowRateGps",
"(",
")",
"{",
"return",
"massFlowRateGps",
";",
"}",
"public",
"void",
"setMassFlowRateGps",
"(",
"double",
"massFlowRateGps",
")",
"{",
"this",
".",
"massFlowRateGps",
"=",
"massFlowRateGps",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isFavorite",
"(",
")",
"{",
"return",
"favorite",
";",
"}",
"public",
"boolean",
"getFavorite",
"(",
")",
"{",
"return",
"isFavorite",
"(",
")",
";",
"}",
"public",
"void",
"setFavorite",
"(",
"boolean",
"favorite",
")",
"{",
"this",
".",
"favorite",
"=",
"favorite",
";",
"}",
"public",
"String",
"getCategoryUuid",
"(",
")",
"{",
"return",
"categoryUuid",
";",
"}",
"public",
"void",
"setCategoryUuid",
"(",
"String",
"categoryUuid",
")",
"{",
"this",
".",
"categoryUuid",
"=",
"categoryUuid",
";",
"}",
"public",
"String",
"getAuthorUuid",
"(",
")",
"{",
"return",
"authorUuid",
";",
"}",
"public",
"void",
"setAuthorUuid",
"(",
"String",
"authorUuid",
")",
"{",
"this",
".",
"authorUuid",
"=",
"authorUuid",
";",
"}",
"@",
"Override",
"public",
"Photo",
"getMainPhoto",
"(",
")",
"{",
"for",
"(",
"RecipePhotoTable",
"recipePhotoTable",
":",
"getRecipePhotoTables",
"(",
")",
")",
"{",
"if",
"(",
"recipePhotoTable",
".",
"main",
")",
"return",
"recipePhotoTable",
".",
"getPhotoTables",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
"?",
"recipePhotoTable",
".",
"getPhotoTables",
"(",
")",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"Author",
"getAuthor",
"(",
")",
"{",
"return",
"getAuthorTables",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
"?",
"getAuthorTables",
"(",
")",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}",
"@",
"Override",
"public",
"Category",
"getCategory",
"(",
")",
"{",
"return",
"getCategoryTables",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
"?",
"getCategoryTables",
"(",
")",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"Photo",
">",
"getPhotos",
"(",
")",
"{",
"photos",
".",
"clear",
"(",
")",
";",
"for",
"(",
"RecipePhotoTable",
"recipePhotoTable",
":",
"getRecipePhotoTables",
"(",
")",
")",
"{",
"photos",
".",
"addAll",
"(",
"recipePhotoTable",
".",
"getPhotoTables",
"(",
")",
")",
";",
"}",
"return",
"photos",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"Label",
">",
"getLabels",
"(",
")",
"{",
"labels",
".",
"clear",
"(",
")",
";",
"for",
"(",
"RecipeLabelTable",
"recipeLabelTable",
":",
"getRecipeLabelTables",
"(",
")",
")",
"{",
"labels",
".",
"addAll",
"(",
"recipeLabelTable",
".",
"getLabelTables",
"(",
")",
")",
";",
"}",
"return",
"labels",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"Ingredient",
">",
"getIngredients",
"(",
")",
"{",
"ingredients",
".",
"clear",
"(",
")",
";",
"ingredients",
".",
"addAll",
"(",
"getRecipeFoodTables",
"(",
")",
")",
";",
"return",
"ingredients",
";",
"}",
"@",
"Override",
"public",
"List",
"<",
"Method",
">",
"getMethods",
"(",
")",
"{",
"methods",
".",
"clear",
"(",
")",
";",
"methods",
".",
"addAll",
"(",
"getRecipeMethodTables",
"(",
")",
")",
";",
"return",
"methods",
";",
"}",
"/**\n * To-many relationship, resolved on first access (and after reset).\n * Changes to to-many relations are not persisted, make changes to the target entity.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"1211508832",
")",
"public",
"List",
"<",
"CategoryTable",
">",
"getCategoryTables",
"(",
")",
"{",
"if",
"(",
"categoryTables",
"==",
"null",
")",
"{",
"final",
"DaoSession",
"daoSession",
"=",
"this",
".",
"daoSession",
";",
"if",
"(",
"daoSession",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"CategoryTableDao",
"targetDao",
"=",
"daoSession",
".",
"getCategoryTableDao",
"(",
")",
";",
"List",
"<",
"CategoryTable",
">",
"categoryTablesNew",
"=",
"targetDao",
".",
"_queryRecipeTable_CategoryTables",
"(",
"categoryUuid",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"categoryTables",
"==",
"null",
")",
"{",
"categoryTables",
"=",
"categoryTablesNew",
";",
"}",
"}",
"}",
"return",
"categoryTables",
";",
"}",
"/**\n * Resets a to-many relationship, making the next get call to query for a fresh result.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"1017928287",
")",
"public",
"synchronized",
"void",
"resetCategoryTables",
"(",
")",
"{",
"categoryTables",
"=",
"null",
";",
"}",
"/**\n * To-many relationship, resolved on first access (and after reset).\n * Changes to to-many relations are not persisted, make changes to the target entity.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"1157942686",
")",
"public",
"List",
"<",
"AuthorTable",
">",
"getAuthorTables",
"(",
")",
"{",
"if",
"(",
"authorTables",
"==",
"null",
")",
"{",
"final",
"DaoSession",
"daoSession",
"=",
"this",
".",
"daoSession",
";",
"if",
"(",
"daoSession",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"AuthorTableDao",
"targetDao",
"=",
"daoSession",
".",
"getAuthorTableDao",
"(",
")",
";",
"List",
"<",
"AuthorTable",
">",
"authorTablesNew",
"=",
"targetDao",
".",
"_queryRecipeTable_AuthorTables",
"(",
"authorUuid",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"authorTables",
"==",
"null",
")",
"{",
"authorTables",
"=",
"authorTablesNew",
";",
"}",
"}",
"}",
"return",
"authorTables",
";",
"}",
"/**\n * Resets a to-many relationship, making the next get call to query for a fresh result.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"376306627",
")",
"public",
"synchronized",
"void",
"resetAuthorTables",
"(",
")",
"{",
"authorTables",
"=",
"null",
";",
"}",
"/**\n * To-many relationship, resolved on first access (and after reset).\n * Changes to to-many relations are not persisted, make changes to the target entity.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"601605547",
")",
"public",
"List",
"<",
"RecipePhotoTable",
">",
"getRecipePhotoTables",
"(",
")",
"{",
"if",
"(",
"recipePhotoTables",
"==",
"null",
")",
"{",
"final",
"DaoSession",
"daoSession",
"=",
"this",
".",
"daoSession",
";",
"if",
"(",
"daoSession",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"RecipePhotoTableDao",
"targetDao",
"=",
"daoSession",
".",
"getRecipePhotoTableDao",
"(",
")",
";",
"List",
"<",
"RecipePhotoTable",
">",
"recipePhotoTablesNew",
"=",
"targetDao",
".",
"_queryRecipeTable_RecipePhotoTables",
"(",
"uuid",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"recipePhotoTables",
"==",
"null",
")",
"{",
"recipePhotoTables",
"=",
"recipePhotoTablesNew",
";",
"}",
"}",
"}",
"return",
"recipePhotoTables",
";",
"}",
"/**\n * Resets a to-many relationship, making the next get call to query for a fresh result.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"71148360",
")",
"public",
"synchronized",
"void",
"resetRecipePhotoTables",
"(",
")",
"{",
"recipePhotoTables",
"=",
"null",
";",
"}",
"/**\n * To-many relationship, resolved on first access (and after reset).\n * Changes to to-many relations are not persisted, make changes to the target entity.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"1985941725",
")",
"public",
"List",
"<",
"RecipeLabelTable",
">",
"getRecipeLabelTables",
"(",
")",
"{",
"if",
"(",
"recipeLabelTables",
"==",
"null",
")",
"{",
"final",
"DaoSession",
"daoSession",
"=",
"this",
".",
"daoSession",
";",
"if",
"(",
"daoSession",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"RecipeLabelTableDao",
"targetDao",
"=",
"daoSession",
".",
"getRecipeLabelTableDao",
"(",
")",
";",
"List",
"<",
"RecipeLabelTable",
">",
"recipeLabelTablesNew",
"=",
"targetDao",
".",
"_queryRecipeTable_RecipeLabelTables",
"(",
"uuid",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"recipeLabelTables",
"==",
"null",
")",
"{",
"recipeLabelTables",
"=",
"recipeLabelTablesNew",
";",
"}",
"}",
"}",
"return",
"recipeLabelTables",
";",
"}",
"/**\n * Resets a to-many relationship, making the next get call to query for a fresh result.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"621796270",
")",
"public",
"synchronized",
"void",
"resetRecipeLabelTables",
"(",
")",
"{",
"recipeLabelTables",
"=",
"null",
";",
"}",
"/**\n * To-many relationship, resolved on first access (and after reset).\n * Changes to to-many relations are not persisted, make changes to the target entity.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"425446250",
")",
"public",
"List",
"<",
"RecipeFoodTable",
">",
"getRecipeFoodTables",
"(",
")",
"{",
"if",
"(",
"recipeFoodTables",
"==",
"null",
")",
"{",
"final",
"DaoSession",
"daoSession",
"=",
"this",
".",
"daoSession",
";",
"if",
"(",
"daoSession",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"RecipeFoodTableDao",
"targetDao",
"=",
"daoSession",
".",
"getRecipeFoodTableDao",
"(",
")",
";",
"List",
"<",
"RecipeFoodTable",
">",
"recipeFoodTablesNew",
"=",
"targetDao",
".",
"_queryRecipeTable_RecipeFoodTables",
"(",
"uuid",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"recipeFoodTables",
"==",
"null",
")",
"{",
"recipeFoodTables",
"=",
"recipeFoodTablesNew",
";",
"}",
"}",
"}",
"return",
"recipeFoodTables",
";",
"}",
"/**\n * Resets a to-many relationship, making the next get call to query for a fresh result.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"1460648270",
")",
"public",
"synchronized",
"void",
"resetRecipeFoodTables",
"(",
")",
"{",
"recipeFoodTables",
"=",
"null",
";",
"}",
"/**\n * To-many relationship, resolved on first access (and after reset).\n * Changes to to-many relations are not persisted, make changes to the target entity.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"822006377",
")",
"public",
"List",
"<",
"RecipeMethodTable",
">",
"getRecipeMethodTables",
"(",
")",
"{",
"if",
"(",
"recipeMethodTables",
"==",
"null",
")",
"{",
"final",
"DaoSession",
"daoSession",
"=",
"this",
".",
"daoSession",
";",
"if",
"(",
"daoSession",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"RecipeMethodTableDao",
"targetDao",
"=",
"daoSession",
".",
"getRecipeMethodTableDao",
"(",
")",
";",
"List",
"<",
"RecipeMethodTable",
">",
"recipeMethodTablesNew",
"=",
"targetDao",
".",
"_queryRecipeTable_RecipeMethodTables",
"(",
"uuid",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"recipeMethodTables",
"==",
"null",
")",
"{",
"recipeMethodTables",
"=",
"recipeMethodTablesNew",
";",
"}",
"}",
"}",
"return",
"recipeMethodTables",
";",
"}",
"/**\n * Resets a to-many relationship, making the next get call to query for a fresh result.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"864534768",
")",
"public",
"synchronized",
"void",
"resetRecipeMethodTables",
"(",
")",
"{",
"recipeMethodTables",
"=",
"null",
";",
"}",
"/**\n * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.\n * Entity must attached to an entity context.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"128553479",
")",
"public",
"void",
"delete",
"(",
")",
"{",
"if",
"(",
"myDao",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"myDao",
".",
"delete",
"(",
"this",
")",
";",
"}",
"/**\n * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.\n * Entity must attached to an entity context.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"1942392019",
")",
"public",
"void",
"refresh",
"(",
")",
"{",
"if",
"(",
"myDao",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"myDao",
".",
"refresh",
"(",
"this",
")",
";",
"}",
"/**\n * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.\n * Entity must attached to an entity context.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"713229351",
")",
"public",
"void",
"update",
"(",
")",
"{",
"if",
"(",
"myDao",
"==",
"null",
")",
"{",
"throw",
"new",
"DaoException",
"(",
"\"",
"Entity is detached from DAO context",
"\"",
")",
";",
"}",
"myDao",
".",
"update",
"(",
"this",
")",
";",
"}",
"/**\n * called by internal mechanisms, do not call yourself.\n */",
"@",
"Generated",
"(",
"hash",
"=",
"173120018",
")",
"public",
"void",
"__setDaoSession",
"(",
"DaoSession",
"daoSession",
")",
"{",
"this",
".",
"daoSession",
"=",
"daoSession",
";",
"myDao",
"=",
"daoSession",
"!=",
"null",
"?",
"daoSession",
".",
"getRecipeTableDao",
"(",
")",
":",
"null",
";",
"}",
"}"
] | A model of the Recipe entity
that persists in local relational database table by GreenDao framework
and serialized from JSON by Gson framework | [
"A",
"model",
"of",
"the",
"Recipe",
"entity",
"that",
"persists",
"in",
"local",
"relational",
"database",
"table",
"by",
"GreenDao",
"framework",
"and",
"serialized",
"from",
"JSON",
"by",
"Gson",
"framework"
] | [
"// gram per second"
] | [
{
"param": "Table, RecipeFull",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Table, RecipeFull",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
480e06d524b9ea3003dae345bfdfc6a5c60c4842 | mitre-icarus/ICArUS-Challenge-Problem-Software-and-Data | src/main/java/org/mitre/icarus/cps/examples/phase_2/KmlExample.java | [
"Apache-2.0"
] | Java | KmlExample | /**
* Provides examples for converting feature XML files to KML files.
*
* @author LWONG
*/ | Provides examples for converting feature XML files to KML files.
@author LWONG | [
"Provides",
"examples",
"for",
"converting",
"feature",
"XML",
"files",
"to",
"KML",
"files",
".",
"@author",
"LWONG"
] | public class KmlExample {
/**
* Converts the specified Area Of Interest XML file to a KML file in the same directory.
*
* @param xmlFilepath full or relative path to the XML
*/
public static void createAreaOfInterestKml(String xmlFilepath) {
try {
// open an output file
FileOutputStream kmlFile = new FileOutputStream(xmlFilepath.replace(".xml", ".kml"));
// load the XML into the feature object
JAXBContext context = JAXBContext.newInstance(AreaOfInterest.class);
Unmarshaller um = context.createUnmarshaller();
AreaOfInterest areaOfInterest =
(AreaOfInterest) um.unmarshal(new FileReader(xmlFilepath));
// convert to KML
final Kml kml = areaOfInterest.getKMLRepresentation();
// write to the output file
kml.marshal(kmlFile);
} catch (JAXBException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
/**
* Converts the specified Blue Locations XML file to a KML file in the same directory.
*
* @param xmlFilepath full or relative path to the XML
*/
public static void createBlueLocationsKml(String xmlFilepath) {
try {
// open an output file
FileOutputStream kmlFile = new FileOutputStream(xmlFilepath.replace(".xml", ".kml"));
// load the XML into the feature object
JAXBContext context = JAXBContext.newInstance(FeatureContainer.class);
Unmarshaller um = context.createUnmarshaller();
@SuppressWarnings("unchecked")
FeatureContainer<BlueLocation> blueLocations =
(FeatureContainer<BlueLocation>)um.unmarshal(new FileReader(xmlFilepath));
// convert to KML
final Kml kml = blueLocations.getKMLRepresentation();
// write to the output file
kml.marshal(kmlFile);
} catch (JAXBException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
/**
* Example main creates KML files for Mission 1 Area of Interest and Blue Locations.
*
* @param args
*/
public static void main(String[] args) {
String areaOfInterestXml = "data/Phase_2_CPD/exams/Sample-Exam-2/Mission1_Area_Of_Interest.xml";
createAreaOfInterestKml(areaOfInterestXml);
String blueLocationsXml = "data/Phase_2_CPD/exams/Sample-Exam-2/Mission1_Blue_Locations.xml";
createBlueLocationsKml(blueLocationsXml);
}
} | [
"public",
"class",
"KmlExample",
"{",
"/**\n\t * Converts the specified Area Of Interest XML file to a KML file in the same directory.\n\t * \n\t * @param xmlFilepath full or relative path to the XML\n\t */",
"public",
"static",
"void",
"createAreaOfInterestKml",
"(",
"String",
"xmlFilepath",
")",
"{",
"try",
"{",
"FileOutputStream",
"kmlFile",
"=",
"new",
"FileOutputStream",
"(",
"xmlFilepath",
".",
"replace",
"(",
"\"",
".xml",
"\"",
",",
"\"",
".kml",
"\"",
")",
")",
";",
"JAXBContext",
"context",
"=",
"JAXBContext",
".",
"newInstance",
"(",
"AreaOfInterest",
".",
"class",
")",
";",
"Unmarshaller",
"um",
"=",
"context",
".",
"createUnmarshaller",
"(",
")",
";",
"AreaOfInterest",
"areaOfInterest",
"=",
"(",
"AreaOfInterest",
")",
"um",
".",
"unmarshal",
"(",
"new",
"FileReader",
"(",
"xmlFilepath",
")",
")",
";",
"final",
"Kml",
"kml",
"=",
"areaOfInterest",
".",
"getKMLRepresentation",
"(",
")",
";",
"kml",
".",
"marshal",
"(",
"kmlFile",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"/**\n\t * Converts the specified Blue Locations XML file to a KML file in the same directory.\n\t * \n\t * @param xmlFilepath full or relative path to the XML\n\t */",
"public",
"static",
"void",
"createBlueLocationsKml",
"(",
"String",
"xmlFilepath",
")",
"{",
"try",
"{",
"FileOutputStream",
"kmlFile",
"=",
"new",
"FileOutputStream",
"(",
"xmlFilepath",
".",
"replace",
"(",
"\"",
".xml",
"\"",
",",
"\"",
".kml",
"\"",
")",
")",
";",
"JAXBContext",
"context",
"=",
"JAXBContext",
".",
"newInstance",
"(",
"FeatureContainer",
".",
"class",
")",
";",
"Unmarshaller",
"um",
"=",
"context",
".",
"createUnmarshaller",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"FeatureContainer",
"<",
"BlueLocation",
">",
"blueLocations",
"=",
"(",
"FeatureContainer",
"<",
"BlueLocation",
">",
")",
"um",
".",
"unmarshal",
"(",
"new",
"FileReader",
"(",
"xmlFilepath",
")",
")",
";",
"final",
"Kml",
"kml",
"=",
"blueLocations",
".",
"getKMLRepresentation",
"(",
")",
";",
"kml",
".",
"marshal",
"(",
"kmlFile",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"/**\n\t * Example main creates KML files for Mission 1 Area of Interest and Blue Locations.\n\t * \n\t * @param args\n\t */",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"String",
"areaOfInterestXml",
"=",
"\"",
"data/Phase_2_CPD/exams/Sample-Exam-2/Mission1_Area_Of_Interest.xml",
"\"",
";",
"createAreaOfInterestKml",
"(",
"areaOfInterestXml",
")",
";",
"String",
"blueLocationsXml",
"=",
"\"",
"data/Phase_2_CPD/exams/Sample-Exam-2/Mission1_Blue_Locations.xml",
"\"",
";",
"createBlueLocationsKml",
"(",
"blueLocationsXml",
")",
";",
"}",
"}"
] | Provides examples for converting feature XML files to KML files. | [
"Provides",
"examples",
"for",
"converting",
"feature",
"XML",
"files",
"to",
"KML",
"files",
"."
] | [
"// open an output file",
"// load the XML into the feature object",
"// convert to KML",
"// write to the output file",
"// open an output file",
"// load the XML into the feature object",
"// convert to KML",
"// write to the output file"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
480fab6caed35de51698a0711b4ddd725c228df1 | Zutubi/pulse | com.zutubi.pulse.master/src/java/com/zutubi/pulse/master/upgrade/tasks/RemoveTriggerDataMapRefactorUpgradeTask.java | [
"Apache-2.0"
] | Java | RemoveTriggerDataMapRefactorUpgradeTask | /**
* A task to remove the data map for triggers. In most cases the information
* is already duplicated in the config, except for simple triggers used by the
* Pulse backend. In this latter case the data is moved into proper columns.
*/ | A task to remove the data map for triggers. In most cases the information
is already duplicated in the config, except for simple triggers used by the
Pulse backend. In this latter case the data is moved into proper columns. | [
"A",
"task",
"to",
"remove",
"the",
"data",
"map",
"for",
"triggers",
".",
"In",
"most",
"cases",
"the",
"information",
"is",
"already",
"duplicated",
"in",
"the",
"config",
"except",
"for",
"simple",
"triggers",
"used",
"by",
"the",
"Pulse",
"backend",
".",
"In",
"this",
"latter",
"case",
"the",
"data",
"is",
"moved",
"into",
"proper",
"columns",
"."
] | public class RemoveTriggerDataMapRefactorUpgradeTask extends AbstractSchemaRefactorUpgradeTask
{
private static final String TABLE_TRIGGER = "LOCAL_TRIGGER";
private static final String COLUMN_DATA = "DATA";
private static final String PARAM_INTERVAL = "interval";
private static final String PARAM_REPEAT = "repeat";
private static final String PARAM_START = "start";
protected void doRefactor(Connection con, SchemaRefactor refactor) throws Exception
{
refactor.patch("com/zutubi/pulse/master/upgrade/tasks/schema/Schema-2.1.5-patch-02.hbm.xml");
moveSimpleTriggerData(con);
refactor.dropColumn(TABLE_TRIGGER, COLUMN_DATA);
}
private void moveSimpleTriggerData(Connection con) throws Exception
{
PreparedStatement selectStatement = null;
PreparedStatement updateStatement = null;
ResultSet rs = null;
try
{
selectStatement = con.prepareStatement("select ID, DATA from LOCAL_TRIGGER where TRIGGER_TYPE = 'SIMPLE'");
updateStatement = con.prepareStatement("update LOCAL_TRIGGER set TRIGGER_INTERVAL = ?, REPEAT_COUNT = ?, START_TIME = ? where ID = ?");
rs = selectStatement.executeQuery();
while (rs.next())
{
setParameters(rs, updateStatement);
updateStatement.executeUpdate();
}
}
finally
{
JDBCUtils.close(rs);
JDBCUtils.close(selectStatement);
JDBCUtils.close(updateStatement);
}
}
private void setParameters(ResultSet rs, PreparedStatement updateStatement) throws SQLException, IOException, ClassNotFoundException
{
ObjectInputStream ois = null;
try
{
ois = new ObjectInputStream(new ByteArrayInputStream(rs.getBytes(COLUMN_DATA)));
Map<Serializable, Serializable> dataMap = (Map<Serializable, Serializable>)ois.readObject();
long interval = (Long) dataMap.get(PARAM_INTERVAL);
int repeat = (Integer) dataMap.get(PARAM_REPEAT);
Date start = (Date) dataMap.get(PARAM_START);
updateStatement.setLong(1, interval);
updateStatement.setInt(2, repeat);
updateStatement.setDate(3, new java.sql.Date(start.getTime()));
updateStatement.setLong(4, rs.getLong("ID"));
}
finally
{
IOUtils.close(ois);
}
}
} | [
"public",
"class",
"RemoveTriggerDataMapRefactorUpgradeTask",
"extends",
"AbstractSchemaRefactorUpgradeTask",
"{",
"private",
"static",
"final",
"String",
"TABLE_TRIGGER",
"=",
"\"",
"LOCAL_TRIGGER",
"\"",
";",
"private",
"static",
"final",
"String",
"COLUMN_DATA",
"=",
"\"",
"DATA",
"\"",
";",
"private",
"static",
"final",
"String",
"PARAM_INTERVAL",
"=",
"\"",
"interval",
"\"",
";",
"private",
"static",
"final",
"String",
"PARAM_REPEAT",
"=",
"\"",
"repeat",
"\"",
";",
"private",
"static",
"final",
"String",
"PARAM_START",
"=",
"\"",
"start",
"\"",
";",
"protected",
"void",
"doRefactor",
"(",
"Connection",
"con",
",",
"SchemaRefactor",
"refactor",
")",
"throws",
"Exception",
"{",
"refactor",
".",
"patch",
"(",
"\"",
"com/zutubi/pulse/master/upgrade/tasks/schema/Schema-2.1.5-patch-02.hbm.xml",
"\"",
")",
";",
"moveSimpleTriggerData",
"(",
"con",
")",
";",
"refactor",
".",
"dropColumn",
"(",
"TABLE_TRIGGER",
",",
"COLUMN_DATA",
")",
";",
"}",
"private",
"void",
"moveSimpleTriggerData",
"(",
"Connection",
"con",
")",
"throws",
"Exception",
"{",
"PreparedStatement",
"selectStatement",
"=",
"null",
";",
"PreparedStatement",
"updateStatement",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"selectStatement",
"=",
"con",
".",
"prepareStatement",
"(",
"\"",
"select ID, DATA from LOCAL_TRIGGER where TRIGGER_TYPE = 'SIMPLE'",
"\"",
")",
";",
"updateStatement",
"=",
"con",
".",
"prepareStatement",
"(",
"\"",
"update LOCAL_TRIGGER set TRIGGER_INTERVAL = ?, REPEAT_COUNT = ?, START_TIME = ? where ID = ?",
"\"",
")",
";",
"rs",
"=",
"selectStatement",
".",
"executeQuery",
"(",
")",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"setParameters",
"(",
"rs",
",",
"updateStatement",
")",
";",
"updateStatement",
".",
"executeUpdate",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"JDBCUtils",
".",
"close",
"(",
"rs",
")",
";",
"JDBCUtils",
".",
"close",
"(",
"selectStatement",
")",
";",
"JDBCUtils",
".",
"close",
"(",
"updateStatement",
")",
";",
"}",
"}",
"private",
"void",
"setParameters",
"(",
"ResultSet",
"rs",
",",
"PreparedStatement",
"updateStatement",
")",
"throws",
"SQLException",
",",
"IOException",
",",
"ClassNotFoundException",
"{",
"ObjectInputStream",
"ois",
"=",
"null",
";",
"try",
"{",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"new",
"ByteArrayInputStream",
"(",
"rs",
".",
"getBytes",
"(",
"COLUMN_DATA",
")",
")",
")",
";",
"Map",
"<",
"Serializable",
",",
"Serializable",
">",
"dataMap",
"=",
"(",
"Map",
"<",
"Serializable",
",",
"Serializable",
">",
")",
"ois",
".",
"readObject",
"(",
")",
";",
"long",
"interval",
"=",
"(",
"Long",
")",
"dataMap",
".",
"get",
"(",
"PARAM_INTERVAL",
")",
";",
"int",
"repeat",
"=",
"(",
"Integer",
")",
"dataMap",
".",
"get",
"(",
"PARAM_REPEAT",
")",
";",
"Date",
"start",
"=",
"(",
"Date",
")",
"dataMap",
".",
"get",
"(",
"PARAM_START",
")",
";",
"updateStatement",
".",
"setLong",
"(",
"1",
",",
"interval",
")",
";",
"updateStatement",
".",
"setInt",
"(",
"2",
",",
"repeat",
")",
";",
"updateStatement",
".",
"setDate",
"(",
"3",
",",
"new",
"java",
".",
"sql",
".",
"Date",
"(",
"start",
".",
"getTime",
"(",
")",
")",
")",
";",
"updateStatement",
".",
"setLong",
"(",
"4",
",",
"rs",
".",
"getLong",
"(",
"\"",
"ID",
"\"",
")",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"close",
"(",
"ois",
")",
";",
"}",
"}",
"}"
] | A task to remove the data map for triggers. | [
"A",
"task",
"to",
"remove",
"the",
"data",
"map",
"for",
"triggers",
"."
] | [] | [
{
"param": "AbstractSchemaRefactorUpgradeTask",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractSchemaRefactorUpgradeTask",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
481b42569e2fead6ec96010862c1057e5f8e3b8e | mstepan/data-structures-in-java-1353 | src/eu/javaspecialists/courses/datastructures/ch4_sets/_4_4_CopyOnWriteArraySet.java | [
"Apache-2.0"
] | Java | _4_4_CopyOnWriteArraySet | /**
* For very small sets
*/ | For very small sets | [
"For",
"very",
"small",
"sets"
] | public class _4_4_CopyOnWriteArraySet {
public static void main(String... args) {
MyObservable model = new MyObservable();
model.addObserver(new MyObserver1());
model.addObserver(new MyObserver1());
model.notifyObservers("change-123");
}
static class MyObserver1 implements MyObserver {
@Override
public void update(MyObservable obsModel, Object arg) {
System.out.println("Observer2: " + arg);
}
}
@FunctionalInterface
interface MyObserver {
void update(MyObservable obsModel, Object arg);
}
static class MyObservable {
private final Set<MyObserver> obs = new CopyOnWriteArraySet<>();
public void addObserver(MyObserver o) {
if (o == null) {
throw new NullPointerException();
}
obs.add(o);
}
public void notifyObservers(Object arg) {
for (MyObserver singleObserver : obs) {
singleObserver.update(this, arg);
}
}
public void deleteObservers() {
obs.clear();
}
}
} | [
"public",
"class",
"_4_4_CopyOnWriteArraySet",
"{",
"public",
"static",
"void",
"main",
"(",
"String",
"...",
"args",
")",
"{",
"MyObservable",
"model",
"=",
"new",
"MyObservable",
"(",
")",
";",
"model",
".",
"addObserver",
"(",
"new",
"MyObserver1",
"(",
")",
")",
";",
"model",
".",
"addObserver",
"(",
"new",
"MyObserver1",
"(",
")",
")",
";",
"model",
".",
"notifyObservers",
"(",
"\"",
"change-123",
"\"",
")",
";",
"}",
"static",
"class",
"MyObserver1",
"implements",
"MyObserver",
"{",
"@",
"Override",
"public",
"void",
"update",
"(",
"MyObservable",
"obsModel",
",",
"Object",
"arg",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Observer2: ",
"\"",
"+",
"arg",
")",
";",
"}",
"}",
"@",
"FunctionalInterface",
"interface",
"MyObserver",
"{",
"void",
"update",
"(",
"MyObservable",
"obsModel",
",",
"Object",
"arg",
")",
";",
"}",
"static",
"class",
"MyObservable",
"{",
"private",
"final",
"Set",
"<",
"MyObserver",
">",
"obs",
"=",
"new",
"CopyOnWriteArraySet",
"<",
">",
"(",
")",
";",
"public",
"void",
"addObserver",
"(",
"MyObserver",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"obs",
".",
"add",
"(",
"o",
")",
";",
"}",
"public",
"void",
"notifyObservers",
"(",
"Object",
"arg",
")",
"{",
"for",
"(",
"MyObserver",
"singleObserver",
":",
"obs",
")",
"{",
"singleObserver",
".",
"update",
"(",
"this",
",",
"arg",
")",
";",
"}",
"}",
"public",
"void",
"deleteObservers",
"(",
")",
"{",
"obs",
".",
"clear",
"(",
")",
";",
"}",
"}",
"}"
] | For very small sets | [
"For",
"very",
"small",
"sets"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
481f1432de419cc1cb1aad49bee3f78a4e0589db | zhenbinwei/MyDemo | app/src/main/java/com/example/weizhenbin/mydemo/bean/GanhuoListBean.java | [
"Apache-2.0"
] | Java | GanhuoListBean | /**
* Created by weizhenbin on 2017/6/14.
*/ | Created by weizhenbin on 2017/6/14. | [
"Created",
"by",
"weizhenbin",
"on",
"2017",
"/",
"6",
"/",
"14",
"."
] | public class GanhuoListBean {
public boolean error;
public List<ResultsBean> results;
public static GanhuoListBean paseJsonData(JSONObject object) {
if (object == null) {
return null;
}
GanhuoListBean ganhuoListBean = new GanhuoListBean();
ganhuoListBean.error = object.optBoolean("error");
ganhuoListBean.results = new ArrayList<>();
JSONArray jsonArray = object.optJSONArray("results");
if (jsonArray != null) {
for (int i = 0; i < jsonArray.length(); i++) {
ganhuoListBean.results.add(ResultsBean.paseJsonData(jsonArray.optJSONObject(i)));
}
}
return ganhuoListBean;
}
public static class ResultsBean implements ImageCheckControl.ImageInfo {
/**
* _id : 58e5bd9c421aa90d6f211e3f
* createdAt : 2017-04-06T12:01:32.576Z
* desc : 4-6
* publishedAt : 2017-04-06T12:06:10.17Z
* source : chrome
* type : 福利
* url : http://7xi8d6.com1.z0.glb.clouddn.com/2017-04-06-17493825_1061197430652762_1457834104966873088_n.jpg
* used : true
* who : 代码家
*/
public String _id;
public String createdAt;
public String desc;
public String publishedAt;
public String source;
public String type;
public String url;
public boolean used;
public String who;
public List<String> images;
public static ResultsBean paseJsonData(JSONObject object) {
if (object == null) {
return null;
}
ResultsBean resultsBean = new ResultsBean();
resultsBean._id = object.optString("_id");
resultsBean.createdAt = object.optString("createdAt");
resultsBean.desc = object.optString("desc");
resultsBean.publishedAt = object.optString("publishedAt");
resultsBean.source = object.optString("source");
resultsBean.type = object.optString("type");
resultsBean.url = object.optString("url");
resultsBean.who = object.optString("who");
resultsBean.used = object.optBoolean("used");
JSONArray jsonArray = object.optJSONArray("images");
if (jsonArray != null) {
resultsBean.images = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
resultsBean.images.add(jsonArray.optString(i));
}
}
return resultsBean;
}
@Override
public String getUrl() {
return url;
}
@Override
public boolean isImage() {
if(type.equals("福利")){
return true;
}
return false;
}
}
} | [
"public",
"class",
"GanhuoListBean",
"{",
"public",
"boolean",
"error",
";",
"public",
"List",
"<",
"ResultsBean",
">",
"results",
";",
"public",
"static",
"GanhuoListBean",
"paseJsonData",
"(",
"JSONObject",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"GanhuoListBean",
"ganhuoListBean",
"=",
"new",
"GanhuoListBean",
"(",
")",
";",
"ganhuoListBean",
".",
"error",
"=",
"object",
".",
"optBoolean",
"(",
"\"",
"error",
"\"",
")",
";",
"ganhuoListBean",
".",
"results",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"JSONArray",
"jsonArray",
"=",
"object",
".",
"optJSONArray",
"(",
"\"",
"results",
"\"",
")",
";",
"if",
"(",
"jsonArray",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"jsonArray",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"ganhuoListBean",
".",
"results",
".",
"add",
"(",
"ResultsBean",
".",
"paseJsonData",
"(",
"jsonArray",
".",
"optJSONObject",
"(",
"i",
")",
")",
")",
";",
"}",
"}",
"return",
"ganhuoListBean",
";",
"}",
"public",
"static",
"class",
"ResultsBean",
"implements",
"ImageCheckControl",
".",
"ImageInfo",
"{",
"/**\n * _id : 58e5bd9c421aa90d6f211e3f\n * createdAt : 2017-04-06T12:01:32.576Z\n * desc : 4-6\n * publishedAt : 2017-04-06T12:06:10.17Z\n * source : chrome\n * type : 福利\n * url : http://7xi8d6.com1.z0.glb.clouddn.com/2017-04-06-17493825_1061197430652762_1457834104966873088_n.jpg\n * used : true\n * who : 代码家\n */",
"public",
"String",
"_id",
";",
"public",
"String",
"createdAt",
";",
"public",
"String",
"desc",
";",
"public",
"String",
"publishedAt",
";",
"public",
"String",
"source",
";",
"public",
"String",
"type",
";",
"public",
"String",
"url",
";",
"public",
"boolean",
"used",
";",
"public",
"String",
"who",
";",
"public",
"List",
"<",
"String",
">",
"images",
";",
"public",
"static",
"ResultsBean",
"paseJsonData",
"(",
"JSONObject",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"ResultsBean",
"resultsBean",
"=",
"new",
"ResultsBean",
"(",
")",
";",
"resultsBean",
".",
"_id",
"=",
"object",
".",
"optString",
"(",
"\"",
"_id",
"\"",
")",
";",
"resultsBean",
".",
"createdAt",
"=",
"object",
".",
"optString",
"(",
"\"",
"createdAt",
"\"",
")",
";",
"resultsBean",
".",
"desc",
"=",
"object",
".",
"optString",
"(",
"\"",
"desc",
"\"",
")",
";",
"resultsBean",
".",
"publishedAt",
"=",
"object",
".",
"optString",
"(",
"\"",
"publishedAt",
"\"",
")",
";",
"resultsBean",
".",
"source",
"=",
"object",
".",
"optString",
"(",
"\"",
"source",
"\"",
")",
";",
"resultsBean",
".",
"type",
"=",
"object",
".",
"optString",
"(",
"\"",
"type",
"\"",
")",
";",
"resultsBean",
".",
"url",
"=",
"object",
".",
"optString",
"(",
"\"",
"url",
"\"",
")",
";",
"resultsBean",
".",
"who",
"=",
"object",
".",
"optString",
"(",
"\"",
"who",
"\"",
")",
";",
"resultsBean",
".",
"used",
"=",
"object",
".",
"optBoolean",
"(",
"\"",
"used",
"\"",
")",
";",
"JSONArray",
"jsonArray",
"=",
"object",
".",
"optJSONArray",
"(",
"\"",
"images",
"\"",
")",
";",
"if",
"(",
"jsonArray",
"!=",
"null",
")",
"{",
"resultsBean",
".",
"images",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"jsonArray",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"resultsBean",
".",
"images",
".",
"add",
"(",
"jsonArray",
".",
"optString",
"(",
"i",
")",
")",
";",
"}",
"}",
"return",
"resultsBean",
";",
"}",
"@",
"Override",
"public",
"String",
"getUrl",
"(",
")",
"{",
"return",
"url",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isImage",
"(",
")",
"{",
"if",
"(",
"type",
".",
"equals",
"(",
"\"",
"福利\")){",
"",
"",
"",
"",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"}",
"}"
] | Created by weizhenbin on 2017/6/14. | [
"Created",
"by",
"weizhenbin",
"on",
"2017",
"/",
"6",
"/",
"14",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
482027f83d762777da799866d6e3ad3c969bebbf | Yinten/KSyncTesting | app/src/main/java/com/kinvey/bookshelf/Book.java | [
"Apache-2.0"
] | Java | Book | /**
* Created by Prots on 3/15/16.
*/ | Created by Prots on 3/15/16. | [
"Created",
"by",
"Prots",
"on",
"3",
"/",
"15",
"/",
"16",
"."
] | public class Book extends GenericJson {
@Key(Constants.NAME)
private String name;
@Key(Constants.IMAGE_ID)
private String imageId;
public CAddress getAddress() {
return address;
}
public void setAddress(CAddress address) {
this.address = address;
}
@Key("address")
private CAddress address;
public Book(){
address = new CAddress();
};
public Book(String name){
this.name = name;
address = new CAddress();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getImageId() {
return imageId;
}
public void setImageId(String imageId) {
this.imageId = imageId;
}
} | [
"public",
"class",
"Book",
"extends",
"GenericJson",
"{",
"@",
"Key",
"(",
"Constants",
".",
"NAME",
")",
"private",
"String",
"name",
";",
"@",
"Key",
"(",
"Constants",
".",
"IMAGE_ID",
")",
"private",
"String",
"imageId",
";",
"public",
"CAddress",
"getAddress",
"(",
")",
"{",
"return",
"address",
";",
"}",
"public",
"void",
"setAddress",
"(",
"CAddress",
"address",
")",
"{",
"this",
".",
"address",
"=",
"address",
";",
"}",
"@",
"Key",
"(",
"\"",
"address",
"\"",
")",
"private",
"CAddress",
"address",
";",
"public",
"Book",
"(",
")",
"{",
"address",
"=",
"new",
"CAddress",
"(",
")",
";",
"}",
";",
"public",
"Book",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"address",
"=",
"new",
"CAddress",
"(",
")",
";",
"}",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"public",
"String",
"getImageId",
"(",
")",
"{",
"return",
"imageId",
";",
"}",
"public",
"void",
"setImageId",
"(",
"String",
"imageId",
")",
"{",
"this",
".",
"imageId",
"=",
"imageId",
";",
"}",
"}"
] | Created by Prots on 3/15/16. | [
"Created",
"by",
"Prots",
"on",
"3",
"/",
"15",
"/",
"16",
"."
] | [] | [
{
"param": "GenericJson",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "GenericJson",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4822b000b96e4ba6a29e643acfa4fdadc570d340 | sfdc-acs/xacml-3.0 | xacml/src/main/java/oasis/names/tc/xacml/_3_0/core/schema/wd_17/ResultType.java | [
"MIT"
] | Java | ResultType | /**
* <p>Java class for ResultType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="ResultType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Decision"/>
* <element ref="{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Status" minOccurs="0"/>
* <element ref="{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Obligations" minOccurs="0"/>
* <element ref="{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AssociatedAdvice" minOccurs="0"/>
* <element ref="{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Attributes" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}PolicyIdentifierList" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/ | Java class for ResultType complex type.
The following schema fragment specifies the expected content contained within this class.
| [
"Java",
"class",
"for",
"ResultType",
"complex",
"type",
".",
"The",
"following",
"schema",
"fragment",
"specifies",
"the",
"expected",
"content",
"contained",
"within",
"this",
"class",
"."
] | @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResultType", propOrder = {
"decision",
"status",
"obligations",
"associatedAdvice",
"attributes",
"policyIdentifierList"
})
public class ResultType {
@XmlElement(name = "Decision", required = true)
protected DecisionType decision;
@XmlElement(name = "Status")
protected StatusType status;
@XmlElement(name = "Obligations")
protected ObligationsType obligations;
@XmlElement(name = "AssociatedAdvice")
protected AssociatedAdviceType associatedAdvice;
@XmlElement(name = "Attributes")
protected List<AttributesType> attributes;
@XmlElement(name = "PolicyIdentifierList")
protected PolicyIdentifierListType policyIdentifierList;
/**
* Gets the value of the decision property.
*
* @return
* possible object is
* {@link DecisionType }
*
*/
public DecisionType getDecision() {
return decision;
}
/**
* Sets the value of the decision property.
*
* @param value
* allowed object is
* {@link DecisionType }
*
*/
public void setDecision(DecisionType value) {
this.decision = value;
}
/**
* Gets the value of the status property.
*
* @return
* possible object is
* {@link StatusType }
*
*/
public StatusType getStatus() {
return status;
}
/**
* Sets the value of the status property.
*
* @param value
* allowed object is
* {@link StatusType }
*
*/
public void setStatus(StatusType value) {
this.status = value;
}
/**
* Gets the value of the obligations property.
*
* @return
* possible object is
* {@link ObligationsType }
*
*/
public ObligationsType getObligations() {
return obligations;
}
/**
* Sets the value of the obligations property.
*
* @param value
* allowed object is
* {@link ObligationsType }
*
*/
public void setObligations(ObligationsType value) {
this.obligations = value;
}
/**
* Gets the value of the associatedAdvice property.
*
* @return
* possible object is
* {@link AssociatedAdviceType }
*
*/
public AssociatedAdviceType getAssociatedAdvice() {
return associatedAdvice;
}
/**
* Sets the value of the associatedAdvice property.
*
* @param value
* allowed object is
* {@link AssociatedAdviceType }
*
*/
public void setAssociatedAdvice(AssociatedAdviceType value) {
this.associatedAdvice = value;
}
/**
* Gets the value of the attributes property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the attributes property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getAttributes().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link AttributesType }
*
*
*/
public List<AttributesType> getAttributes() {
if (attributes == null) {
attributes = new ArrayList<AttributesType>();
}
return this.attributes;
}
/**
* Gets the value of the policyIdentifierList property.
*
* @return
* possible object is
* {@link PolicyIdentifierListType }
*
*/
public PolicyIdentifierListType getPolicyIdentifierList() {
return policyIdentifierList;
}
/**
* Sets the value of the policyIdentifierList property.
*
* @param value
* allowed object is
* {@link PolicyIdentifierListType }
*
*/
public void setPolicyIdentifierList(PolicyIdentifierListType value) {
this.policyIdentifierList = value;
}
} | [
"@",
"XmlAccessorType",
"(",
"XmlAccessType",
".",
"FIELD",
")",
"@",
"XmlType",
"(",
"name",
"=",
"\"",
"ResultType",
"\"",
",",
"propOrder",
"=",
"{",
"\"",
"decision",
"\"",
",",
"\"",
"status",
"\"",
",",
"\"",
"obligations",
"\"",
",",
"\"",
"associatedAdvice",
"\"",
",",
"\"",
"attributes",
"\"",
",",
"\"",
"policyIdentifierList",
"\"",
"}",
")",
"public",
"class",
"ResultType",
"{",
"@",
"XmlElement",
"(",
"name",
"=",
"\"",
"Decision",
"\"",
",",
"required",
"=",
"true",
")",
"protected",
"DecisionType",
"decision",
";",
"@",
"XmlElement",
"(",
"name",
"=",
"\"",
"Status",
"\"",
")",
"protected",
"StatusType",
"status",
";",
"@",
"XmlElement",
"(",
"name",
"=",
"\"",
"Obligations",
"\"",
")",
"protected",
"ObligationsType",
"obligations",
";",
"@",
"XmlElement",
"(",
"name",
"=",
"\"",
"AssociatedAdvice",
"\"",
")",
"protected",
"AssociatedAdviceType",
"associatedAdvice",
";",
"@",
"XmlElement",
"(",
"name",
"=",
"\"",
"Attributes",
"\"",
")",
"protected",
"List",
"<",
"AttributesType",
">",
"attributes",
";",
"@",
"XmlElement",
"(",
"name",
"=",
"\"",
"PolicyIdentifierList",
"\"",
")",
"protected",
"PolicyIdentifierListType",
"policyIdentifierList",
";",
"/**\n * Gets the value of the decision property.\n * \n * @return\n * possible object is\n * {@link DecisionType }\n * \n */",
"public",
"DecisionType",
"getDecision",
"(",
")",
"{",
"return",
"decision",
";",
"}",
"/**\n * Sets the value of the decision property.\n * \n * @param value\n * allowed object is\n * {@link DecisionType }\n * \n */",
"public",
"void",
"setDecision",
"(",
"DecisionType",
"value",
")",
"{",
"this",
".",
"decision",
"=",
"value",
";",
"}",
"/**\n * Gets the value of the status property.\n * \n * @return\n * possible object is\n * {@link StatusType }\n * \n */",
"public",
"StatusType",
"getStatus",
"(",
")",
"{",
"return",
"status",
";",
"}",
"/**\n * Sets the value of the status property.\n * \n * @param value\n * allowed object is\n * {@link StatusType }\n * \n */",
"public",
"void",
"setStatus",
"(",
"StatusType",
"value",
")",
"{",
"this",
".",
"status",
"=",
"value",
";",
"}",
"/**\n * Gets the value of the obligations property.\n * \n * @return\n * possible object is\n * {@link ObligationsType }\n * \n */",
"public",
"ObligationsType",
"getObligations",
"(",
")",
"{",
"return",
"obligations",
";",
"}",
"/**\n * Sets the value of the obligations property.\n * \n * @param value\n * allowed object is\n * {@link ObligationsType }\n * \n */",
"public",
"void",
"setObligations",
"(",
"ObligationsType",
"value",
")",
"{",
"this",
".",
"obligations",
"=",
"value",
";",
"}",
"/**\n * Gets the value of the associatedAdvice property.\n * \n * @return\n * possible object is\n * {@link AssociatedAdviceType }\n * \n */",
"public",
"AssociatedAdviceType",
"getAssociatedAdvice",
"(",
")",
"{",
"return",
"associatedAdvice",
";",
"}",
"/**\n * Sets the value of the associatedAdvice property.\n * \n * @param value\n * allowed object is\n * {@link AssociatedAdviceType }\n * \n */",
"public",
"void",
"setAssociatedAdvice",
"(",
"AssociatedAdviceType",
"value",
")",
"{",
"this",
".",
"associatedAdvice",
"=",
"value",
";",
"}",
"/**\n * Gets the value of the attributes property.\n * \n * <p>\n * This accessor method returns a reference to the live list,\n * not a snapshot. Therefore any modification you make to the\n * returned list will be present inside the JAXB object.\n * This is why there is not a <CODE>set</CODE> method for the attributes property.\n * \n * <p>\n * For example, to add a new item, do as follows:\n * <pre>\n * getAttributes().add(newItem);\n * </pre>\n * \n * \n * <p>\n * Objects of the following type(s) are allowed in the list\n * {@link AttributesType }\n * \n * \n */",
"public",
"List",
"<",
"AttributesType",
">",
"getAttributes",
"(",
")",
"{",
"if",
"(",
"attributes",
"==",
"null",
")",
"{",
"attributes",
"=",
"new",
"ArrayList",
"<",
"AttributesType",
">",
"(",
")",
";",
"}",
"return",
"this",
".",
"attributes",
";",
"}",
"/**\n * Gets the value of the policyIdentifierList property.\n * \n * @return\n * possible object is\n * {@link PolicyIdentifierListType }\n * \n */",
"public",
"PolicyIdentifierListType",
"getPolicyIdentifierList",
"(",
")",
"{",
"return",
"policyIdentifierList",
";",
"}",
"/**\n * Sets the value of the policyIdentifierList property.\n * \n * @param value\n * allowed object is\n * {@link PolicyIdentifierListType }\n * \n */",
"public",
"void",
"setPolicyIdentifierList",
"(",
"PolicyIdentifierListType",
"value",
")",
"{",
"this",
".",
"policyIdentifierList",
"=",
"value",
";",
"}",
"}"
] | <p>Java class for ResultType complex type. | [
"<p",
">",
"Java",
"class",
"for",
"ResultType",
"complex",
"type",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
48293a517d94ebbf578e52c9441e8b9ab5f383d2 | cyterdan/UcPortfolioBacktest | src/main/java/cyterdan/backtest/experimental/Momentum.java | [
"MIT"
] | Java | Momentum | /**
*
* Backtest a momentum + moving average strategy on funds
* @author cytermann
*/ | Backtest a momentum + moving average strategy on funds
@author cytermann | [
"Backtest",
"a",
"momentum",
"+",
"moving",
"average",
"strategy",
"on",
"funds",
"@author",
"cytermann"
] | public class Momentum {
private static DataProvider dataProvider;
private static final int MOVING_AVERAGE_WINDOW_SIZE = 160;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws SQLException, Exception {
dataProvider = new H2DataProvider();
Set<String> allIsins = dataProvider.getIsins();
List<String> inclusions = FUND_CONSTANTS.MES_PLACEMENTS_LIBERTE;
//garder que certains fonds
//retirer les scpis et les fonds euro
allIsins = allIsins.stream().filter(isin -> inclusions.contains(isin))
.filter(isin -> !isin.contains("SCPI") && !isin.contains("QU")).collect(Collectors.toSet());
HistoricalData data = dataProvider.getDataForIsins(allIsins);
data.excludeNonDailyFunds();
// doMomentum(data, MomentumStrategy.BEST_PERFORMANCE, ChronoUnit.WEEKS, 2, 3, true);
Set<String> currentBest = getCurrentBest(data, MomentumStrategy.BEST_PERFORMANCE, ChronoUnit.WEEKS, 2,3);
System.out.println("current allocation :"+currentBest);
}
private static Set<String> getCurrentBest(HistoricalData data, MomentumStrategy strategy, ChronoUnit unit, long qty, long maxNbFunds){
LocalDate friday = LocalDate.now().with(TemporalAdjusters.previousOrSame(DayOfWeek.FRIDAY));
HistoricalData subData = data.subData(friday.minus(qty,unit), friday);
//calculer les x meilleurs fonds sur la periode
List<Map.Entry<String, DailySerie>> bests = subData.series().stream()
.filter((o) -> !o.getKey().equals(HistoricalData.CASH))
.sorted(strategy.getComparator(data, qty, unit).reversed()).collect(Collectors.toList());
Set<String> isins = bests.stream().map(b->b.getKey()).limit(maxNbFunds).collect(Collectors.toSet());
return isins;
}
private static void doMomentum(HistoricalData data, MomentumStrategy strategy, ChronoUnit unit, long qty, long maxNbFunds, boolean verbose) throws SQLException, Exception {
DateBasedAllocation allocation = new DateBasedAllocation();
//tous les mardi, on devrait avoir la maj des données du vendredi précédent.
//on commence le mardi suivant la première phase d'observation (de durée paramètrable)
LocalDate firstKey = data.series().stream().min((o1, o2) -> {
return o1.getValue().firstDate().compareTo(o2.getValue().firstDate());
}).get().getValue().firstDate().plus(qty, unit).plusWeeks(1).with(TemporalAdjusters.nextOrSame(DayOfWeek.TUESDAY));
LocalDate lastKey = data.series().stream().max((o1, o2) -> {
return o1.getValue().latestDate().compareTo(o2.getValue().latestDate());
}).get().getValue().latestDate();
/*
tous les mardis prendre les "meilleurs" fonds sur la période de vendredi de 2 semaines précédentes jusqu'au vendredi précédent
*/
for (LocalDate tuesday = firstKey; tuesday.isBefore(lastKey); tuesday = tuesday.plus(qty, unit)) {
LocalDate debutDePeriode = tuesday.minus(qty, unit).with(TemporalAdjusters.previous(DayOfWeek.FRIDAY));
LocalDate finDePeriode = debutDePeriode.plus(qty, unit).plusDays(1);
HistoricalData subData = data.subData(debutDePeriode, finDePeriode);
//calculer les x meilleurs fonds sur la periode
List<Map.Entry<String, DailySerie>> bests = subData.series().stream()
.filter((o) -> !o.getKey().equals(HistoricalData.CASH))
.sorted(strategy.getComparator(data, qty, unit).reversed()).collect(Collectors.toList());
bests = bests.stream().limit(maxNbFunds).collect(Collectors.toList());
FixedAllocation tuesdayAllocation = new FixedAllocation(AllocationRebalanceMode.REBALANCE_NEVER);
//retirer ceux dont la performance ne dépasse pas le moving average
final LocalDate definitelyATuesday = tuesday;
bests = bests.stream()
.filter((o) -> data.getFundData(o.getKey()).movingAverage(definitelyATuesday, MOVING_AVERAGE_WINDOW_SIZE) < data.getForAt(o.getKey(), definitelyATuesday))
.collect(Collectors.toList());
for (Map.Entry<String, DailySerie> best : bests) {
String bestIsin = best.getKey();
tuesdayAllocation.put(bestIsin, 1.0 / maxNbFunds);
}
tuesdayAllocation.completeWith(HistoricalData.CASH);
if (!tuesdayAllocation.isValid()) {
throw new Exception("allocation is not valid");
}
//arbitrer vers ce(s) fonds le mardi
allocation.set(tuesday, tuesdayAllocation);
}
if (verbose) {
allocation.print();
}
LocalDate portfolioStart = allocation.firstOrder().plusDays(1);
LocalDate portfolioEnd = allocation.lastOrder().plusDays(1);
Portfolio portfolio = new Portfolio(allocation);
DailySerie performance = portfolio.calculateAllocationPerformance(portfolioStart, portfolioEnd, data);
double annualReturn = performance.annualReturns();
double yearlyVolatility = performance.yearlyVolatility();
double sharp = BigDecimal.valueOf((annualReturn - 2.0) / yearlyVolatility).setScale(2, RoundingMode.FLOOR).doubleValue();
Iterator<LocalDate> iterator = allocation.dates().iterator();
iterator.next();
LocalDate start = iterator.next();
double worst = 100.0;
LocalDate worstDate = start;
LocalDate previous = start;
while(iterator.hasNext()){
LocalDate date = iterator.next();
if(iterator.hasNext()){
double perf = performance.extractReturn(previous, date);
if(worst>perf){
worst = perf;
worstDate = date;
}
//System.out.println(date+"\t"+perf );
previous = date;
}
}
System.out.println("worst drawdown="+worst+" @"+worstDate+" with "+allocation.getIsinsForDate(worstDate.minusDays(3)));
String result = ("momentum strategy " + strategy + " every " + qty + " " + unit + " with " + maxNbFunds + " funds : sharp " + sharp + " perf " + annualReturn + " volatility :" + yearlyVolatility);
System.out.println(result);
}
} | [
"public",
"class",
"Momentum",
"{",
"private",
"static",
"DataProvider",
"dataProvider",
";",
"private",
"static",
"final",
"int",
"MOVING_AVERAGE_WINDOW_SIZE",
"=",
"160",
";",
"/**\n * @param args the command line arguments\n */",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"SQLException",
",",
"Exception",
"{",
"dataProvider",
"=",
"new",
"H2DataProvider",
"(",
")",
";",
"Set",
"<",
"String",
">",
"allIsins",
"=",
"dataProvider",
".",
"getIsins",
"(",
")",
";",
"List",
"<",
"String",
">",
"inclusions",
"=",
"FUND_CONSTANTS",
".",
"MES_PLACEMENTS_LIBERTE",
";",
"allIsins",
"=",
"allIsins",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"isin",
"->",
"inclusions",
".",
"contains",
"(",
"isin",
")",
")",
".",
"filter",
"(",
"isin",
"->",
"!",
"isin",
".",
"contains",
"(",
"\"",
"SCPI",
"\"",
")",
"&&",
"!",
"isin",
".",
"contains",
"(",
"\"",
"QU",
"\"",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"HistoricalData",
"data",
"=",
"dataProvider",
".",
"getDataForIsins",
"(",
"allIsins",
")",
";",
"data",
".",
"excludeNonDailyFunds",
"(",
")",
";",
"Set",
"<",
"String",
">",
"currentBest",
"=",
"getCurrentBest",
"(",
"data",
",",
"MomentumStrategy",
".",
"BEST_PERFORMANCE",
",",
"ChronoUnit",
".",
"WEEKS",
",",
"2",
",",
"3",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"current allocation :",
"\"",
"+",
"currentBest",
")",
";",
"}",
"private",
"static",
"Set",
"<",
"String",
">",
"getCurrentBest",
"(",
"HistoricalData",
"data",
",",
"MomentumStrategy",
"strategy",
",",
"ChronoUnit",
"unit",
",",
"long",
"qty",
",",
"long",
"maxNbFunds",
")",
"{",
"LocalDate",
"friday",
"=",
"LocalDate",
".",
"now",
"(",
")",
".",
"with",
"(",
"TemporalAdjusters",
".",
"previousOrSame",
"(",
"DayOfWeek",
".",
"FRIDAY",
")",
")",
";",
"HistoricalData",
"subData",
"=",
"data",
".",
"subData",
"(",
"friday",
".",
"minus",
"(",
"qty",
",",
"unit",
")",
",",
"friday",
")",
";",
"List",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"DailySerie",
">",
">",
"bests",
"=",
"subData",
".",
"series",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"(",
"o",
")",
"->",
"!",
"o",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"HistoricalData",
".",
"CASH",
")",
")",
".",
"sorted",
"(",
"strategy",
".",
"getComparator",
"(",
"data",
",",
"qty",
",",
"unit",
")",
".",
"reversed",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"isins",
"=",
"bests",
".",
"stream",
"(",
")",
".",
"map",
"(",
"b",
"->",
"b",
".",
"getKey",
"(",
")",
")",
".",
"limit",
"(",
"maxNbFunds",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"return",
"isins",
";",
"}",
"private",
"static",
"void",
"doMomentum",
"(",
"HistoricalData",
"data",
",",
"MomentumStrategy",
"strategy",
",",
"ChronoUnit",
"unit",
",",
"long",
"qty",
",",
"long",
"maxNbFunds",
",",
"boolean",
"verbose",
")",
"throws",
"SQLException",
",",
"Exception",
"{",
"DateBasedAllocation",
"allocation",
"=",
"new",
"DateBasedAllocation",
"(",
")",
";",
"LocalDate",
"firstKey",
"=",
"data",
".",
"series",
"(",
")",
".",
"stream",
"(",
")",
".",
"min",
"(",
"(",
"o1",
",",
"o2",
")",
"->",
"{",
"return",
"o1",
".",
"getValue",
"(",
")",
".",
"firstDate",
"(",
")",
".",
"compareTo",
"(",
"o2",
".",
"getValue",
"(",
")",
".",
"firstDate",
"(",
")",
")",
";",
"}",
")",
".",
"get",
"(",
")",
".",
"getValue",
"(",
")",
".",
"firstDate",
"(",
")",
".",
"plus",
"(",
"qty",
",",
"unit",
")",
".",
"plusWeeks",
"(",
"1",
")",
".",
"with",
"(",
"TemporalAdjusters",
".",
"nextOrSame",
"(",
"DayOfWeek",
".",
"TUESDAY",
")",
")",
";",
"LocalDate",
"lastKey",
"=",
"data",
".",
"series",
"(",
")",
".",
"stream",
"(",
")",
".",
"max",
"(",
"(",
"o1",
",",
"o2",
")",
"->",
"{",
"return",
"o1",
".",
"getValue",
"(",
")",
".",
"latestDate",
"(",
")",
".",
"compareTo",
"(",
"o2",
".",
"getValue",
"(",
")",
".",
"latestDate",
"(",
")",
")",
";",
"}",
")",
".",
"get",
"(",
")",
".",
"getValue",
"(",
")",
".",
"latestDate",
"(",
")",
";",
"/*\n tous les mardis prendre les \"meilleurs\" fonds sur la période de vendredi de 2 semaines précédentes jusqu'au vendredi précédent\n */",
"for",
"(",
"LocalDate",
"tuesday",
"=",
"firstKey",
";",
"tuesday",
".",
"isBefore",
"(",
"lastKey",
")",
";",
"tuesday",
"=",
"tuesday",
".",
"plus",
"(",
"qty",
",",
"unit",
")",
")",
"{",
"LocalDate",
"debutDePeriode",
"=",
"tuesday",
".",
"minus",
"(",
"qty",
",",
"unit",
")",
".",
"with",
"(",
"TemporalAdjusters",
".",
"previous",
"(",
"DayOfWeek",
".",
"FRIDAY",
")",
")",
";",
"LocalDate",
"finDePeriode",
"=",
"debutDePeriode",
".",
"plus",
"(",
"qty",
",",
"unit",
")",
".",
"plusDays",
"(",
"1",
")",
";",
"HistoricalData",
"subData",
"=",
"data",
".",
"subData",
"(",
"debutDePeriode",
",",
"finDePeriode",
")",
";",
"List",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"DailySerie",
">",
">",
"bests",
"=",
"subData",
".",
"series",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"(",
"o",
")",
"->",
"!",
"o",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"HistoricalData",
".",
"CASH",
")",
")",
".",
"sorted",
"(",
"strategy",
".",
"getComparator",
"(",
"data",
",",
"qty",
",",
"unit",
")",
".",
"reversed",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"bests",
"=",
"bests",
".",
"stream",
"(",
")",
".",
"limit",
"(",
"maxNbFunds",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"FixedAllocation",
"tuesdayAllocation",
"=",
"new",
"FixedAllocation",
"(",
"AllocationRebalanceMode",
".",
"REBALANCE_NEVER",
")",
";",
"final",
"LocalDate",
"definitelyATuesday",
"=",
"tuesday",
";",
"bests",
"=",
"bests",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"(",
"o",
")",
"->",
"data",
".",
"getFundData",
"(",
"o",
".",
"getKey",
"(",
")",
")",
".",
"movingAverage",
"(",
"definitelyATuesday",
",",
"MOVING_AVERAGE_WINDOW_SIZE",
")",
"<",
"data",
".",
"getForAt",
"(",
"o",
".",
"getKey",
"(",
")",
",",
"definitelyATuesday",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"DailySerie",
">",
"best",
":",
"bests",
")",
"{",
"String",
"bestIsin",
"=",
"best",
".",
"getKey",
"(",
")",
";",
"tuesdayAllocation",
".",
"put",
"(",
"bestIsin",
",",
"1.0",
"/",
"maxNbFunds",
")",
";",
"}",
"tuesdayAllocation",
".",
"completeWith",
"(",
"HistoricalData",
".",
"CASH",
")",
";",
"if",
"(",
"!",
"tuesdayAllocation",
".",
"isValid",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"",
"allocation is not valid",
"\"",
")",
";",
"}",
"allocation",
".",
"set",
"(",
"tuesday",
",",
"tuesdayAllocation",
")",
";",
"}",
"if",
"(",
"verbose",
")",
"{",
"allocation",
".",
"print",
"(",
")",
";",
"}",
"LocalDate",
"portfolioStart",
"=",
"allocation",
".",
"firstOrder",
"(",
")",
".",
"plusDays",
"(",
"1",
")",
";",
"LocalDate",
"portfolioEnd",
"=",
"allocation",
".",
"lastOrder",
"(",
")",
".",
"plusDays",
"(",
"1",
")",
";",
"Portfolio",
"portfolio",
"=",
"new",
"Portfolio",
"(",
"allocation",
")",
";",
"DailySerie",
"performance",
"=",
"portfolio",
".",
"calculateAllocationPerformance",
"(",
"portfolioStart",
",",
"portfolioEnd",
",",
"data",
")",
";",
"double",
"annualReturn",
"=",
"performance",
".",
"annualReturns",
"(",
")",
";",
"double",
"yearlyVolatility",
"=",
"performance",
".",
"yearlyVolatility",
"(",
")",
";",
"double",
"sharp",
"=",
"BigDecimal",
".",
"valueOf",
"(",
"(",
"annualReturn",
"-",
"2.0",
")",
"/",
"yearlyVolatility",
")",
".",
"setScale",
"(",
"2",
",",
"RoundingMode",
".",
"FLOOR",
")",
".",
"doubleValue",
"(",
")",
";",
"Iterator",
"<",
"LocalDate",
">",
"iterator",
"=",
"allocation",
".",
"dates",
"(",
")",
".",
"iterator",
"(",
")",
";",
"iterator",
".",
"next",
"(",
")",
";",
"LocalDate",
"start",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"double",
"worst",
"=",
"100.0",
";",
"LocalDate",
"worstDate",
"=",
"start",
";",
"LocalDate",
"previous",
"=",
"start",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"LocalDate",
"date",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"double",
"perf",
"=",
"performance",
".",
"extractReturn",
"(",
"previous",
",",
"date",
")",
";",
"if",
"(",
"worst",
">",
"perf",
")",
"{",
"worst",
"=",
"perf",
";",
"worstDate",
"=",
"date",
";",
"}",
"previous",
"=",
"date",
";",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"worst drawdown=",
"\"",
"+",
"worst",
"+",
"\"",
" @",
"\"",
"+",
"worstDate",
"+",
"\"",
" with ",
"\"",
"+",
"allocation",
".",
"getIsinsForDate",
"(",
"worstDate",
".",
"minusDays",
"(",
"3",
")",
")",
")",
";",
"String",
"result",
"=",
"(",
"\"",
"momentum strategy ",
"\"",
"+",
"strategy",
"+",
"\"",
" every ",
"\"",
"+",
"qty",
"+",
"\"",
" ",
"\"",
"+",
"unit",
"+",
"\"",
" with ",
"\"",
"+",
"maxNbFunds",
"+",
"\"",
" funds : sharp ",
"\"",
"+",
"sharp",
"+",
"\"",
" perf ",
"\"",
"+",
"annualReturn",
"+",
"\"",
" volatility :",
"\"",
"+",
"yearlyVolatility",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"result",
")",
";",
"}",
"}"
] | Backtest a momentum + moving average strategy on funds
@author cytermann | [
"Backtest",
"a",
"momentum",
"+",
"moving",
"average",
"strategy",
"on",
"funds",
"@author",
"cytermann"
] | [
"//garder que certains fonds",
"//retirer les scpis et les fonds euro ",
"// doMomentum(data, MomentumStrategy.BEST_PERFORMANCE, ChronoUnit.WEEKS, 2, 3, true);",
"//calculer les x meilleurs fonds sur la periode",
"//tous les mardi, on devrait avoir la maj des données du vendredi précédent.",
"//on commence le mardi suivant la première phase d'observation (de durée paramètrable)",
"//calculer les x meilleurs fonds sur la periode",
"//retirer ceux dont la performance ne dépasse pas le moving average",
"//arbitrer vers ce(s) fonds le mardi",
"//System.out.println(date+\"\\t\"+perf );"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
482db44ecb4ec3b7e53e310bd910300668e1efde | Farhin24/ponysql | src/test/java/com/pony/tests/ResultSetTest.java | [
"Apache-2.0"
] | Java | ResultSetTest | /**
* A test of the ResultSet.
*
* @author Tobias Downer
*/ | A test of the ResultSet.
@author Tobias Downer | [
"A",
"test",
"of",
"the",
"ResultSet",
".",
"@author",
"Tobias",
"Downer"
] | public class ResultSetTest {
private static void printSyntax() {
System.out.println(
"Syntax: ResultSetTest -url [jdbc_url] -u [username] -p [password]");
System.out.println();
}
private static void displayResult(ResultSet result_set) throws SQLException {
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
com.pony.util.ResultOutputUtil.formatAsText(result_set, out);
result_set.close();
out.flush();
}
public static void main(String[] args) {
CommandLine command_line = new CommandLine(args);
// Register the Pony JDBC Driver
try {
Class.forName("com.pony.JDBCDriver").newInstance();
} catch (Exception e) {
System.out.println(
"Unable to register the JDBC Driver.\n" +
"Make sure the classpath is correct.\n");
return;
}
// Get the command line arguments
final String url = command_line.switchArgument("-url");
final String username = command_line.switchArgument("-u");
final String password = command_line.switchArgument("-p");
if (url == null) {
printSyntax();
System.out.println("Please provide a JDBC url.");
System.exit(-1);
} else if (username == null || password == null) {
printSyntax();
System.out.println("Please provide a username and password.");
System.exit(-1);
}
// Make a connection with the database. This will create the database
// and log into the newly created database.
Connection connection;
try {
connection = DriverManager.getConnection(url, username, password);
} catch (SQLException e) {
System.out.println(
"Unable to create the database.\n" +
"The reason: " + e.getMessage());
return;
}
// ---------- Tests start point ----------
try {
// Display information about the database,
DatabaseMetaData db_meta = connection.getMetaData();
String name = db_meta.getDatabaseProductName();
String version = db_meta.getDatabaseProductVersion();
System.out.println("Database Product Name: " + name);
System.out.println("Database Product Version: " + version);
// Create a Statement object to execute the queries on,
Statement statement = connection.createStatement();
ResultSet result;
// First we create some test table,
statement.executeQuery(
" DROP TABLE IF EXISTS RSTest");
// First we create some test table,
statement.executeQuery(
" CREATE TABLE IF NOT EXISTS RSTest ( " +
" cola VARCHAR(60), " +
" colb VARCHAR(60), " +
" colc INTEGER, " +
" cold NUMERIC, " +
" cole BOOLEAN " +
" ) ");
PreparedStatement ts1 = connection.prepareStatement(
"INSERT INTO RSTest ( cola, colb, colc, cold, cole ) " +
"VALUES ( ?, ?, ?, ?, ? )");
ResultSet r;
ts1.setString(1, "Bah1");
ts1.setString(2, "Bah2");
ts1.setInt(3, 5);
ts1.setDouble(4, 90.55);
ts1.setBoolean(5, true);
ts1.executeUpdate();
ts1.setString(1, "Bah1");
ts1.setString(2, "Bah2");
ts1.setInt(3, 6);
ts1.setDouble(4, 90.55);
ts1.setBoolean(5, true);
ts1.executeUpdate();
ts1.setString(1, "Bah1");
ts1.setString(2, "Bah2");
ts1.setInt(3, 7);
ts1.setDouble(4, 90.55);
ts1.setBoolean(5, true);
ts1.executeUpdate();
ts1.setString(1, "Bah1");
ts1.setString(2, "Bah2");
ts1.setInt(3, 8);
ts1.setDouble(4, 90.55);
ts1.setBoolean(5, true);
ts1.executeUpdate();
PreparedStatement ts2 = connection.prepareStatement(
"DELETE FROM RSTest WHERE colc = ? ");
ts2.setInt(1, 6);
r = ts2.executeQuery();
r.next();
System.out.println(r.getInt(1));
ts2.setInt(1, 7);
r = ts2.executeQuery();
r.next();
System.out.println(r.getInt(1));
ts2.setInt(1, 10);
r = ts2.executeQuery();
r.next();
System.out.println(r.getInt(1));
System.out.println("\n--- All Tests Complete ---");
connection.commit();
displayResult(statement.executeQuery("show status"));
displayResult(statement.executeQuery("show connections"));
// Close the statement and the connection.
statement.close();
connection.close();
} catch (SQLException e) {
System.out.println(
"An error occured\n" +
"The SQLException message is: " + e.getMessage());
e.printStackTrace();
return;
}
// // Close the the connection.
// try {
// connection.close();
// }
// catch (SQLException e2) {
// e2.printStackTrace(System.err);
// }
}
} | [
"public",
"class",
"ResultSetTest",
"{",
"private",
"static",
"void",
"printSyntax",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Syntax: ResultSetTest -url [jdbc_url] -u [username] -p [password]",
"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}",
"private",
"static",
"void",
"displayResult",
"(",
"ResultSet",
"result_set",
")",
"throws",
"SQLException",
"{",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"System",
".",
"out",
")",
")",
";",
"com",
".",
"pony",
".",
"util",
".",
"ResultOutputUtil",
".",
"formatAsText",
"(",
"result_set",
",",
"out",
")",
";",
"result_set",
".",
"close",
"(",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"}",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"CommandLine",
"command_line",
"=",
"new",
"CommandLine",
"(",
"args",
")",
";",
"try",
"{",
"Class",
".",
"forName",
"(",
"\"",
"com.pony.JDBCDriver",
"\"",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Unable to register the JDBC Driver.",
"\\n",
"\"",
"+",
"\"",
"Make sure the classpath is correct.",
"\\n",
"\"",
")",
";",
"return",
";",
"}",
"final",
"String",
"url",
"=",
"command_line",
".",
"switchArgument",
"(",
"\"",
"-url",
"\"",
")",
";",
"final",
"String",
"username",
"=",
"command_line",
".",
"switchArgument",
"(",
"\"",
"-u",
"\"",
")",
";",
"final",
"String",
"password",
"=",
"command_line",
".",
"switchArgument",
"(",
"\"",
"-p",
"\"",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"printSyntax",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Please provide a JDBC url.",
"\"",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"username",
"==",
"null",
"||",
"password",
"==",
"null",
")",
"{",
"printSyntax",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Please provide a username and password.",
"\"",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"Connection",
"connection",
";",
"try",
"{",
"connection",
"=",
"DriverManager",
".",
"getConnection",
"(",
"url",
",",
"username",
",",
"password",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Unable to create the database.",
"\\n",
"\"",
"+",
"\"",
"The reason: ",
"\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
";",
"}",
"try",
"{",
"DatabaseMetaData",
"db_meta",
"=",
"connection",
".",
"getMetaData",
"(",
")",
";",
"String",
"name",
"=",
"db_meta",
".",
"getDatabaseProductName",
"(",
")",
";",
"String",
"version",
"=",
"db_meta",
".",
"getDatabaseProductVersion",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Database Product Name: ",
"\"",
"+",
"name",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Database Product Version: ",
"\"",
"+",
"version",
")",
";",
"Statement",
"statement",
"=",
"connection",
".",
"createStatement",
"(",
")",
";",
"ResultSet",
"result",
";",
"statement",
".",
"executeQuery",
"(",
"\"",
" DROP TABLE IF EXISTS RSTest",
"\"",
")",
";",
"statement",
".",
"executeQuery",
"(",
"\"",
" CREATE TABLE IF NOT EXISTS RSTest ( ",
"\"",
"+",
"\"",
" cola VARCHAR(60), ",
"\"",
"+",
"\"",
" colb VARCHAR(60), ",
"\"",
"+",
"\"",
" colc INTEGER, ",
"\"",
"+",
"\"",
" cold NUMERIC, ",
"\"",
"+",
"\"",
" cole BOOLEAN ",
"\"",
"+",
"\"",
" ) ",
"\"",
")",
";",
"PreparedStatement",
"ts1",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"",
"INSERT INTO RSTest ( cola, colb, colc, cold, cole ) ",
"\"",
"+",
"\"",
"VALUES ( ?, ?, ?, ?, ? )",
"\"",
")",
";",
"ResultSet",
"r",
";",
"ts1",
".",
"setString",
"(",
"1",
",",
"\"",
"Bah1",
"\"",
")",
";",
"ts1",
".",
"setString",
"(",
"2",
",",
"\"",
"Bah2",
"\"",
")",
";",
"ts1",
".",
"setInt",
"(",
"3",
",",
"5",
")",
";",
"ts1",
".",
"setDouble",
"(",
"4",
",",
"90.55",
")",
";",
"ts1",
".",
"setBoolean",
"(",
"5",
",",
"true",
")",
";",
"ts1",
".",
"executeUpdate",
"(",
")",
";",
"ts1",
".",
"setString",
"(",
"1",
",",
"\"",
"Bah1",
"\"",
")",
";",
"ts1",
".",
"setString",
"(",
"2",
",",
"\"",
"Bah2",
"\"",
")",
";",
"ts1",
".",
"setInt",
"(",
"3",
",",
"6",
")",
";",
"ts1",
".",
"setDouble",
"(",
"4",
",",
"90.55",
")",
";",
"ts1",
".",
"setBoolean",
"(",
"5",
",",
"true",
")",
";",
"ts1",
".",
"executeUpdate",
"(",
")",
";",
"ts1",
".",
"setString",
"(",
"1",
",",
"\"",
"Bah1",
"\"",
")",
";",
"ts1",
".",
"setString",
"(",
"2",
",",
"\"",
"Bah2",
"\"",
")",
";",
"ts1",
".",
"setInt",
"(",
"3",
",",
"7",
")",
";",
"ts1",
".",
"setDouble",
"(",
"4",
",",
"90.55",
")",
";",
"ts1",
".",
"setBoolean",
"(",
"5",
",",
"true",
")",
";",
"ts1",
".",
"executeUpdate",
"(",
")",
";",
"ts1",
".",
"setString",
"(",
"1",
",",
"\"",
"Bah1",
"\"",
")",
";",
"ts1",
".",
"setString",
"(",
"2",
",",
"\"",
"Bah2",
"\"",
")",
";",
"ts1",
".",
"setInt",
"(",
"3",
",",
"8",
")",
";",
"ts1",
".",
"setDouble",
"(",
"4",
",",
"90.55",
")",
";",
"ts1",
".",
"setBoolean",
"(",
"5",
",",
"true",
")",
";",
"ts1",
".",
"executeUpdate",
"(",
")",
";",
"PreparedStatement",
"ts2",
"=",
"connection",
".",
"prepareStatement",
"(",
"\"",
"DELETE FROM RSTest WHERE colc = ? ",
"\"",
")",
";",
"ts2",
".",
"setInt",
"(",
"1",
",",
"6",
")",
";",
"r",
"=",
"ts2",
".",
"executeQuery",
"(",
")",
";",
"r",
".",
"next",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"r",
".",
"getInt",
"(",
"1",
")",
")",
";",
"ts2",
".",
"setInt",
"(",
"1",
",",
"7",
")",
";",
"r",
"=",
"ts2",
".",
"executeQuery",
"(",
")",
";",
"r",
".",
"next",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"r",
".",
"getInt",
"(",
"1",
")",
")",
";",
"ts2",
".",
"setInt",
"(",
"1",
",",
"10",
")",
";",
"r",
"=",
"ts2",
".",
"executeQuery",
"(",
")",
";",
"r",
".",
"next",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"r",
".",
"getInt",
"(",
"1",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"\\n",
"--- All Tests Complete ---",
"\"",
")",
";",
"connection",
".",
"commit",
"(",
")",
";",
"displayResult",
"(",
"statement",
".",
"executeQuery",
"(",
"\"",
"show status",
"\"",
")",
")",
";",
"displayResult",
"(",
"statement",
".",
"executeQuery",
"(",
"\"",
"show connections",
"\"",
")",
")",
";",
"statement",
".",
"close",
"(",
")",
";",
"connection",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"An error occured",
"\\n",
"\"",
"+",
"\"",
"The SQLException message is: ",
"\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
";",
"}",
"}",
"}"
] | A test of the ResultSet. | [
"A",
"test",
"of",
"the",
"ResultSet",
"."
] | [
"// Register the Pony JDBC Driver",
"// Get the command line arguments",
"// Make a connection with the database. This will create the database",
"// and log into the newly created database.",
"// ---------- Tests start point ----------",
"// Display information about the database,",
"// Create a Statement object to execute the queries on,",
"// First we create some test table,",
"// First we create some test table,",
"// Close the statement and the connection.",
"// // Close the the connection.",
"// try {",
"// connection.close();",
"// }",
"// catch (SQLException e2) {",
"// e2.printStackTrace(System.err);",
"// }"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4835c6fd0eee3659fc4e12bf2f1ea44b32b84e5a | yaoyang4346/MyWeather | app/src/main/java/com/app/chenyang/sweather/BaseActivity.java | [
"Apache-2.0"
] | Java | BaseActivity | /**
* Created by chenyang on 2017/3/31.
*/ | Created by chenyang on 2017/3/31. | [
"Created",
"by",
"chenyang",
"on",
"2017",
"/",
"3",
"/",
"31",
"."
] | public abstract class BaseActivity<V , T extends BasePresenter<V>> extends AppCompatActivity {
protected T mPresenter;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPresenter = createPresenter();
mPresenter.attachView((V) this);
}
@Override
public void onDestroy() {
super.onDestroy();
mPresenter.detachView();
}
public abstract T createPresenter();
} | [
"public",
"abstract",
"class",
"BaseActivity",
"<",
"V",
",",
"T",
"extends",
"BasePresenter",
"<",
"V",
">",
">",
"extends",
"AppCompatActivity",
"{",
"protected",
"T",
"mPresenter",
";",
"@",
"Override",
"public",
"void",
"onCreate",
"(",
"@",
"Nullable",
"Bundle",
"savedInstanceState",
")",
"{",
"super",
".",
"onCreate",
"(",
"savedInstanceState",
")",
";",
"mPresenter",
"=",
"createPresenter",
"(",
")",
";",
"mPresenter",
".",
"attachView",
"(",
"(",
"V",
")",
"this",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onDestroy",
"(",
")",
"{",
"super",
".",
"onDestroy",
"(",
")",
";",
"mPresenter",
".",
"detachView",
"(",
")",
";",
"}",
"public",
"abstract",
"T",
"createPresenter",
"(",
")",
";",
"}"
] | Created by chenyang on 2017/3/31. | [
"Created",
"by",
"chenyang",
"on",
"2017",
"/",
"3",
"/",
"31",
"."
] | [] | [
{
"param": "AppCompatActivity",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AppCompatActivity",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
483e794e04b39bf2d93bfa1adb7e855663dc5bfc | xiaqingyun/commons-vfs | commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/test/SftpMultiThreadWriteTests.java | [
"Apache-2.0"
] | Java | SftpMultiThreadWriteTests | /**
* MultiThread tests for writing with SFTP provider.
*/ | MultiThread tests for writing with SFTP provider. | [
"MultiThread",
"tests",
"for",
"writing",
"with",
"SFTP",
"provider",
"."
] | public class SftpMultiThreadWriteTests extends AbstractProviderTestCase {
/**
* Sets up a scratch folder for the test to use.
*/
protected FileObject createScratchFolder() throws Exception {
final FileObject scratchFolder = getWriteFolder();
// Make sure the test folder is empty
scratchFolder.delete(Selectors.EXCLUDE_SELF);
scratchFolder.createFolder();
return scratchFolder;
}
/**
* Returns the capabilities required by the tests of this test case.
*/
@Override
protected Capability[] getRequiredCaps() {
return new Capability[] {Capability.CREATE, Capability.DELETE, Capability.GET_TYPE, Capability.LIST_CHILDREN,
Capability.READ_CONTENT, Capability.WRITE_CONTENT};
}
/**
* Tests file copy from local file system in parallel mode. This was a problem with SFTP channels.
*/
@Test
public void testParallelCopyFromLocalFileSystem() throws Exception {
final File localFile = new File("src/test/resources/test-data/test.zip");
final FileObject localFileObject = VFS.getManager().toFileObject(localFile);
final FileObject scratchFolder = createScratchFolder();
final List<Callable<Boolean>> tasks = new ArrayList<>();
for (int i = 0; i < 100; i++) {
final String fileName = "file" + i + "copy.txt";
tasks.add(() -> {
try {
final FileObject fileCopy = scratchFolder.resolveFile(fileName);
assertFalse(fileCopy.exists());
fileCopy.copyFrom(localFileObject, Selectors.SELECT_SELF);
} catch (final Throwable e) {
return false;
}
return true;
});
}
final ExecutorService service = Executors.newFixedThreadPool(10);
try {
final List<Future<Boolean>> futures = service.invokeAll(tasks);
assertTrue(futures.stream().allMatch(fut -> {
try {
return fut.get(5, TimeUnit.SECONDS);
} catch (final Exception e) {
return false;
}
}));
} finally {
service.shutdown();
}
}
} | [
"public",
"class",
"SftpMultiThreadWriteTests",
"extends",
"AbstractProviderTestCase",
"{",
"/**\n * Sets up a scratch folder for the test to use.\n */",
"protected",
"FileObject",
"createScratchFolder",
"(",
")",
"throws",
"Exception",
"{",
"final",
"FileObject",
"scratchFolder",
"=",
"getWriteFolder",
"(",
")",
";",
"scratchFolder",
".",
"delete",
"(",
"Selectors",
".",
"EXCLUDE_SELF",
")",
";",
"scratchFolder",
".",
"createFolder",
"(",
")",
";",
"return",
"scratchFolder",
";",
"}",
"/**\n * Returns the capabilities required by the tests of this test case.\n */",
"@",
"Override",
"protected",
"Capability",
"[",
"]",
"getRequiredCaps",
"(",
")",
"{",
"return",
"new",
"Capability",
"[",
"]",
"{",
"Capability",
".",
"CREATE",
",",
"Capability",
".",
"DELETE",
",",
"Capability",
".",
"GET_TYPE",
",",
"Capability",
".",
"LIST_CHILDREN",
",",
"Capability",
".",
"READ_CONTENT",
",",
"Capability",
".",
"WRITE_CONTENT",
"}",
";",
"}",
"/**\n * Tests file copy from local file system in parallel mode. This was a problem with SFTP channels.\n */",
"@",
"Test",
"public",
"void",
"testParallelCopyFromLocalFileSystem",
"(",
")",
"throws",
"Exception",
"{",
"final",
"File",
"localFile",
"=",
"new",
"File",
"(",
"\"",
"src/test/resources/test-data/test.zip",
"\"",
")",
";",
"final",
"FileObject",
"localFileObject",
"=",
"VFS",
".",
"getManager",
"(",
")",
".",
"toFileObject",
"(",
"localFile",
")",
";",
"final",
"FileObject",
"scratchFolder",
"=",
"createScratchFolder",
"(",
")",
";",
"final",
"List",
"<",
"Callable",
"<",
"Boolean",
">",
">",
"tasks",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"100",
";",
"i",
"++",
")",
"{",
"final",
"String",
"fileName",
"=",
"\"",
"file",
"\"",
"+",
"i",
"+",
"\"",
"copy.txt",
"\"",
";",
"tasks",
".",
"add",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"final",
"FileObject",
"fileCopy",
"=",
"scratchFolder",
".",
"resolveFile",
"(",
"fileName",
")",
";",
"assertFalse",
"(",
"fileCopy",
".",
"exists",
"(",
")",
")",
";",
"fileCopy",
".",
"copyFrom",
"(",
"localFileObject",
",",
"Selectors",
".",
"SELECT_SELF",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
")",
";",
"}",
"final",
"ExecutorService",
"service",
"=",
"Executors",
".",
"newFixedThreadPool",
"(",
"10",
")",
";",
"try",
"{",
"final",
"List",
"<",
"Future",
"<",
"Boolean",
">",
">",
"futures",
"=",
"service",
".",
"invokeAll",
"(",
"tasks",
")",
";",
"assertTrue",
"(",
"futures",
".",
"stream",
"(",
")",
".",
"allMatch",
"(",
"fut",
"->",
"{",
"try",
"{",
"return",
"fut",
".",
"get",
"(",
"5",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
")",
")",
";",
"}",
"finally",
"{",
"service",
".",
"shutdown",
"(",
")",
";",
"}",
"}",
"}"
] | MultiThread tests for writing with SFTP provider. | [
"MultiThread",
"tests",
"for",
"writing",
"with",
"SFTP",
"provider",
"."
] | [
"// Make sure the test folder is empty"
] | [
{
"param": "AbstractProviderTestCase",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractProviderTestCase",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
48475e964bbe5d1bda5e3f6987830f839fca3fb7 | amrut-prabhu/club-connect | src/test/java/seedu/club/testutil/MemberBuilder.java | [
"MIT"
] | Java | MemberBuilder | /**
* A utility class to help with building member objects.
*/ | A utility class to help with building member objects. | [
"A",
"utility",
"class",
"to",
"help",
"with",
"building",
"member",
"objects",
"."
] | public class MemberBuilder {
public static final String DEFAULT_NAME = "Alicia";
public static final String DEFAULT_PHONE = "85355255";
public static final String DEFAULT_MATRIC_NUMBER = "A1357904H";
public static final String DEFAULT_EMAIL = "[email protected]";
public static final String DEFAULT_GROUP = "exco";
public static final String DEFAULT_TAGS = "head";
public static final String DEFAULT_USERNAME = "A1357904H";
public static final String DEFAULT_PASSWORD = "password";
private Name name;
private Phone phone;
private Email email;
private MatricNumber matricNumber;
private Group group;
private Set<Tag> tags;
private Username username;
private Password password;
public MemberBuilder() {
name = new Name(DEFAULT_NAME);
phone = new Phone(DEFAULT_PHONE);
email = new Email(DEFAULT_EMAIL);
matricNumber = new MatricNumber(DEFAULT_MATRIC_NUMBER);
group = new Group(DEFAULT_GROUP);
tags = SampleDataUtil.getTagSet(DEFAULT_TAGS);
username = new Username(DEFAULT_USERNAME);
password = new Password(DEFAULT_PASSWORD);
}
/**
* Initializes the MemberBuilder with the data of {@code memberToCopy}.
*/
public MemberBuilder(Member memberToCopy) {
name = memberToCopy.getName();
phone = memberToCopy.getPhone();
email = memberToCopy.getEmail();
matricNumber = memberToCopy.getMatricNumber();
group = memberToCopy.getGroup();
tags = new HashSet<>(memberToCopy.getTags());
username = new Username(matricNumber.value);
password = new Password("password");
}
/**
* Sets the {@code Name} of the {@code member} that we are building.
*/
public MemberBuilder withName(String name) {
this.name = new Name(name);
return this;
}
/**
* Parses the {@code tags} into a {@code Set<Tag>} and set it to the {@code member} that we are building.
*/
public MemberBuilder withTags(String ... tags) {
this.tags = SampleDataUtil.getTagSet(tags);
return this;
}
/**
* Sets the {@code MatricNumber} of the {@code member} that we are building.
*/
public MemberBuilder withMatricNumber(String matricNumber) {
this.matricNumber = new MatricNumber(matricNumber);
return this;
}
/**
* Sets the {@code Phone} of the {@code member} that we are building.
*/
public MemberBuilder withPhone(String phone) {
this.phone = new Phone(phone);
return this;
}
/**
* Sets the {@code Email} of the {@code member} that we are building.
*/
public MemberBuilder withEmail(String email) {
this.email = new Email(email);
return this;
}
/**
* Sets the {@code Username} of the {@code member} that we are building
*/
public MemberBuilder withUsername(String username) {
this.username = new Username(username);
return this;
}
/**
* Sets the {@code Group} of the {@code member} that we are building.
*/
public MemberBuilder withGroup(String group) {
this.group = new Group(group);
return this;
}
/**
* Sets the {@code Group} of the {@code member} that we are building to the default group - "member".
*/
public MemberBuilder withGroup() {
this.group = new Group(Group.DEFAULT_GROUP);
return this;
}
/**
* Sets the {@Password} of the {@code member} that we are building
* @return
*/
public MemberBuilder withPassword(String password) {
this.password = new Password(password);
return this;
}
public Member build() {
return new Member(name, phone, email, matricNumber, group, tags);
}
} | [
"public",
"class",
"MemberBuilder",
"{",
"public",
"static",
"final",
"String",
"DEFAULT_NAME",
"=",
"\"",
"Alicia",
"\"",
";",
"public",
"static",
"final",
"String",
"DEFAULT_PHONE",
"=",
"\"",
"85355255",
"\"",
";",
"public",
"static",
"final",
"String",
"DEFAULT_MATRIC_NUMBER",
"=",
"\"",
"A1357904H",
"\"",
";",
"public",
"static",
"final",
"String",
"DEFAULT_EMAIL",
"=",
"\"",
"[email protected]",
"\"",
";",
"public",
"static",
"final",
"String",
"DEFAULT_GROUP",
"=",
"\"",
"exco",
"\"",
";",
"public",
"static",
"final",
"String",
"DEFAULT_TAGS",
"=",
"\"",
"head",
"\"",
";",
"public",
"static",
"final",
"String",
"DEFAULT_USERNAME",
"=",
"\"",
"A1357904H",
"\"",
";",
"public",
"static",
"final",
"String",
"DEFAULT_PASSWORD",
"=",
"\"",
"password",
"\"",
";",
"private",
"Name",
"name",
";",
"private",
"Phone",
"phone",
";",
"private",
"Email",
"email",
";",
"private",
"MatricNumber",
"matricNumber",
";",
"private",
"Group",
"group",
";",
"private",
"Set",
"<",
"Tag",
">",
"tags",
";",
"private",
"Username",
"username",
";",
"private",
"Password",
"password",
";",
"public",
"MemberBuilder",
"(",
")",
"{",
"name",
"=",
"new",
"Name",
"(",
"DEFAULT_NAME",
")",
";",
"phone",
"=",
"new",
"Phone",
"(",
"DEFAULT_PHONE",
")",
";",
"email",
"=",
"new",
"Email",
"(",
"DEFAULT_EMAIL",
")",
";",
"matricNumber",
"=",
"new",
"MatricNumber",
"(",
"DEFAULT_MATRIC_NUMBER",
")",
";",
"group",
"=",
"new",
"Group",
"(",
"DEFAULT_GROUP",
")",
";",
"tags",
"=",
"SampleDataUtil",
".",
"getTagSet",
"(",
"DEFAULT_TAGS",
")",
";",
"username",
"=",
"new",
"Username",
"(",
"DEFAULT_USERNAME",
")",
";",
"password",
"=",
"new",
"Password",
"(",
"DEFAULT_PASSWORD",
")",
";",
"}",
"/**\n * Initializes the MemberBuilder with the data of {@code memberToCopy}.\n */",
"public",
"MemberBuilder",
"(",
"Member",
"memberToCopy",
")",
"{",
"name",
"=",
"memberToCopy",
".",
"getName",
"(",
")",
";",
"phone",
"=",
"memberToCopy",
".",
"getPhone",
"(",
")",
";",
"email",
"=",
"memberToCopy",
".",
"getEmail",
"(",
")",
";",
"matricNumber",
"=",
"memberToCopy",
".",
"getMatricNumber",
"(",
")",
";",
"group",
"=",
"memberToCopy",
".",
"getGroup",
"(",
")",
";",
"tags",
"=",
"new",
"HashSet",
"<",
">",
"(",
"memberToCopy",
".",
"getTags",
"(",
")",
")",
";",
"username",
"=",
"new",
"Username",
"(",
"matricNumber",
".",
"value",
")",
";",
"password",
"=",
"new",
"Password",
"(",
"\"",
"password",
"\"",
")",
";",
"}",
"/**\n * Sets the {@code Name} of the {@code member} that we are building.\n */",
"public",
"MemberBuilder",
"withName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"new",
"Name",
"(",
"name",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Parses the {@code tags} into a {@code Set<Tag>} and set it to the {@code member} that we are building.\n */",
"public",
"MemberBuilder",
"withTags",
"(",
"String",
"...",
"tags",
")",
"{",
"this",
".",
"tags",
"=",
"SampleDataUtil",
".",
"getTagSet",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Sets the {@code MatricNumber} of the {@code member} that we are building.\n */",
"public",
"MemberBuilder",
"withMatricNumber",
"(",
"String",
"matricNumber",
")",
"{",
"this",
".",
"matricNumber",
"=",
"new",
"MatricNumber",
"(",
"matricNumber",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Sets the {@code Phone} of the {@code member} that we are building.\n */",
"public",
"MemberBuilder",
"withPhone",
"(",
"String",
"phone",
")",
"{",
"this",
".",
"phone",
"=",
"new",
"Phone",
"(",
"phone",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Sets the {@code Email} of the {@code member} that we are building.\n */",
"public",
"MemberBuilder",
"withEmail",
"(",
"String",
"email",
")",
"{",
"this",
".",
"email",
"=",
"new",
"Email",
"(",
"email",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Sets the {@code Username} of the {@code member} that we are building\n */",
"public",
"MemberBuilder",
"withUsername",
"(",
"String",
"username",
")",
"{",
"this",
".",
"username",
"=",
"new",
"Username",
"(",
"username",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Sets the {@code Group} of the {@code member} that we are building.\n */",
"public",
"MemberBuilder",
"withGroup",
"(",
"String",
"group",
")",
"{",
"this",
".",
"group",
"=",
"new",
"Group",
"(",
"group",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Sets the {@code Group} of the {@code member} that we are building to the default group - \"member\".\n */",
"public",
"MemberBuilder",
"withGroup",
"(",
")",
"{",
"this",
".",
"group",
"=",
"new",
"Group",
"(",
"Group",
".",
"DEFAULT_GROUP",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Sets the {@Password} of the {@code member} that we are building\n * @return\n */",
"public",
"MemberBuilder",
"withPassword",
"(",
"String",
"password",
")",
"{",
"this",
".",
"password",
"=",
"new",
"Password",
"(",
"password",
")",
";",
"return",
"this",
";",
"}",
"public",
"Member",
"build",
"(",
")",
"{",
"return",
"new",
"Member",
"(",
"name",
",",
"phone",
",",
"email",
",",
"matricNumber",
",",
"group",
",",
"tags",
")",
";",
"}",
"}"
] | A utility class to help with building member objects. | [
"A",
"utility",
"class",
"to",
"help",
"with",
"building",
"member",
"objects",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
484a1fab57e5abb78801d830eba38c164333799a | erikandre/hprof-tools | hprof-viewer/src/main/java/com/badoo/hprof/viewer/provider/ClassProvider.java | [
"MIT"
] | Java | ClassProvider | /**
* Provider of class information.
*
* Created by Erik Andre on 12/12/15.
*/ | Provider of class information.
Created by Erik Andre on 12/12/15. | [
"Provider",
"of",
"class",
"information",
".",
"Created",
"by",
"Erik",
"Andre",
"on",
"12",
"/",
"12",
"/",
"15",
"."
] | public class ClassProvider extends BaseProvider {
private final MemoryDump data;
private final Map<ClassDefinition, String> classNames = new HashMap<ClassDefinition, String>();
public ClassProvider(@Nonnull MemoryDump data) {
this.data = data;
for (ClassDefinition cls : data.classes.values()) {
classNames.put(cls, data.strings.get(cls.getNameStringId()).getValue());
}
setStatus(ProviderStatus.LOADED);
}
public String getClassName(@Nonnull ClassDefinition cls) {
return classNames.get(cls);
}
public int getInstanceSizeForClass(@Nonnull ClassDefinition cls) {
int size = 0;
//noinspection ConstantConditions
while (cls != null) {
size += cls.getInstanceSize();
cls = data.classes.get(cls.getSuperClassObjectId());
}
return size;
}
public List<ClassDefinition> getClassesMatchingQuery(@Nonnull String query) {
List<ClassDefinition> result = new ArrayList<ClassDefinition>();
for (ClassDefinition cls : data.classes.values()) {
String className = data.strings.get(cls.getNameStringId()).getValue();
if (className.contains(query)) {
result.add(cls);
}
}
return result;
}
} | [
"public",
"class",
"ClassProvider",
"extends",
"BaseProvider",
"{",
"private",
"final",
"MemoryDump",
"data",
";",
"private",
"final",
"Map",
"<",
"ClassDefinition",
",",
"String",
">",
"classNames",
"=",
"new",
"HashMap",
"<",
"ClassDefinition",
",",
"String",
">",
"(",
")",
";",
"public",
"ClassProvider",
"(",
"@",
"Nonnull",
"MemoryDump",
"data",
")",
"{",
"this",
".",
"data",
"=",
"data",
";",
"for",
"(",
"ClassDefinition",
"cls",
":",
"data",
".",
"classes",
".",
"values",
"(",
")",
")",
"{",
"classNames",
".",
"put",
"(",
"cls",
",",
"data",
".",
"strings",
".",
"get",
"(",
"cls",
".",
"getNameStringId",
"(",
")",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"setStatus",
"(",
"ProviderStatus",
".",
"LOADED",
")",
";",
"}",
"public",
"String",
"getClassName",
"(",
"@",
"Nonnull",
"ClassDefinition",
"cls",
")",
"{",
"return",
"classNames",
".",
"get",
"(",
"cls",
")",
";",
"}",
"public",
"int",
"getInstanceSizeForClass",
"(",
"@",
"Nonnull",
"ClassDefinition",
"cls",
")",
"{",
"int",
"size",
"=",
"0",
";",
"while",
"(",
"cls",
"!=",
"null",
")",
"{",
"size",
"+=",
"cls",
".",
"getInstanceSize",
"(",
")",
";",
"cls",
"=",
"data",
".",
"classes",
".",
"get",
"(",
"cls",
".",
"getSuperClassObjectId",
"(",
")",
")",
";",
"}",
"return",
"size",
";",
"}",
"public",
"List",
"<",
"ClassDefinition",
">",
"getClassesMatchingQuery",
"(",
"@",
"Nonnull",
"String",
"query",
")",
"{",
"List",
"<",
"ClassDefinition",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"ClassDefinition",
">",
"(",
")",
";",
"for",
"(",
"ClassDefinition",
"cls",
":",
"data",
".",
"classes",
".",
"values",
"(",
")",
")",
"{",
"String",
"className",
"=",
"data",
".",
"strings",
".",
"get",
"(",
"cls",
".",
"getNameStringId",
"(",
")",
")",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"className",
".",
"contains",
"(",
"query",
")",
")",
"{",
"result",
".",
"add",
"(",
"cls",
")",
";",
"}",
"}",
"return",
"result",
";",
"}",
"}"
] | Provider of class information. | [
"Provider",
"of",
"class",
"information",
"."
] | [
"//noinspection ConstantConditions"
] | [
{
"param": "BaseProvider",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "BaseProvider",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
484bff4a84e1c9751fc210f4c12d1492ea5ac87d | Alfresco/records-management | rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/RMConstraintGet.java | [
"OLDAP-2.5"
] | Java | RMConstraintGet | /**
* Implementation for Java backed webscript to return
* the values for an RM constraint.
*/ | Implementation for Java backed webscript to return
the values for an RM constraint. | [
"Implementation",
"for",
"Java",
"backed",
"webscript",
"to",
"return",
"the",
"values",
"for",
"an",
"RM",
"constraint",
"."
] | public class RMConstraintGet extends DeclarativeWebScript
{
/*
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
String extensionPath = req.getExtensionPath();
String constraintName = extensionPath.replace('_', ':');
List<String> values = caveatConfigService.getRMAllowedValues(constraintName);
// create model object with the lists model
Map<String, Object> model = new HashMap<>(1);
model.put("allowedValuesForCurrentUser", values);
model.put("constraintName", extensionPath);
return model;
}
public void setCaveatConfigService(RMCaveatConfigService caveatConfigService)
{
this.caveatConfigService = caveatConfigService;
}
public RMCaveatConfigService getCaveatConfigService()
{
return caveatConfigService;
}
private RMCaveatConfigService caveatConfigService;
} | [
"public",
"class",
"RMConstraintGet",
"extends",
"DeclarativeWebScript",
"{",
"/*\n * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)\n */",
"@",
"Override",
"protected",
"Map",
"<",
"String",
",",
"Object",
">",
"executeImpl",
"(",
"WebScriptRequest",
"req",
",",
"Status",
"status",
",",
"Cache",
"cache",
")",
"{",
"String",
"extensionPath",
"=",
"req",
".",
"getExtensionPath",
"(",
")",
";",
"String",
"constraintName",
"=",
"extensionPath",
".",
"replace",
"(",
"'_'",
",",
"':'",
")",
";",
"List",
"<",
"String",
">",
"values",
"=",
"caveatConfigService",
".",
"getRMAllowedValues",
"(",
"constraintName",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"model",
"=",
"new",
"HashMap",
"<",
">",
"(",
"1",
")",
";",
"model",
".",
"put",
"(",
"\"",
"allowedValuesForCurrentUser",
"\"",
",",
"values",
")",
";",
"model",
".",
"put",
"(",
"\"",
"constraintName",
"\"",
",",
"extensionPath",
")",
";",
"return",
"model",
";",
"}",
"public",
"void",
"setCaveatConfigService",
"(",
"RMCaveatConfigService",
"caveatConfigService",
")",
"{",
"this",
".",
"caveatConfigService",
"=",
"caveatConfigService",
";",
"}",
"public",
"RMCaveatConfigService",
"getCaveatConfigService",
"(",
")",
"{",
"return",
"caveatConfigService",
";",
"}",
"private",
"RMCaveatConfigService",
"caveatConfigService",
";",
"}"
] | Implementation for Java backed webscript to return
the values for an RM constraint. | [
"Implementation",
"for",
"Java",
"backed",
"webscript",
"to",
"return",
"the",
"values",
"for",
"an",
"RM",
"constraint",
"."
] | [
"// create model object with the lists model"
] | [
{
"param": "DeclarativeWebScript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DeclarativeWebScript",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
484c1e3f68817d2ff7d8e32550e0787cc4b2bb94 | rsteppac/ipf | platform-camel/core/src/main/java/org/openehealth/ipf/platform/camel/core/reifier/ProcessorAdapterReifier.java | [
"Apache-2.0"
] | Java | ProcessorAdapterReifier | /**
* @author Christian Ohr
*/ | @author Christian Ohr | [
"@author",
"Christian",
"Ohr"
] | public abstract class ProcessorAdapterReifier<T extends ProcessorAdapterDefinition> extends DelegateReifier<T> {
public ProcessorAdapterReifier(Route route, T definition) {
super(route, definition);
}
@Override
protected Processor doCreateDelegate() {
var adapter = doCreateProcessor();
if (definition.getInputExpression() != null) {
adapter.input(definition.getInputExpression());
}
if (definition.getParamsExpression() != null) {
adapter.params(definition.getParamsExpression());
}
return adapter;
}
protected abstract ProcessorAdapter doCreateProcessor();
} | [
"public",
"abstract",
"class",
"ProcessorAdapterReifier",
"<",
"T",
"extends",
"ProcessorAdapterDefinition",
">",
"extends",
"DelegateReifier",
"<",
"T",
">",
"{",
"public",
"ProcessorAdapterReifier",
"(",
"Route",
"route",
",",
"T",
"definition",
")",
"{",
"super",
"(",
"route",
",",
"definition",
")",
";",
"}",
"@",
"Override",
"protected",
"Processor",
"doCreateDelegate",
"(",
")",
"{",
"var",
"adapter",
"=",
"doCreateProcessor",
"(",
")",
";",
"if",
"(",
"definition",
".",
"getInputExpression",
"(",
")",
"!=",
"null",
")",
"{",
"adapter",
".",
"input",
"(",
"definition",
".",
"getInputExpression",
"(",
")",
")",
";",
"}",
"if",
"(",
"definition",
".",
"getParamsExpression",
"(",
")",
"!=",
"null",
")",
"{",
"adapter",
".",
"params",
"(",
"definition",
".",
"getParamsExpression",
"(",
")",
")",
";",
"}",
"return",
"adapter",
";",
"}",
"protected",
"abstract",
"ProcessorAdapter",
"doCreateProcessor",
"(",
")",
";",
"}"
] | @author Christian Ohr | [
"@author",
"Christian",
"Ohr"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
485401131e8aec8e682c10f571806b4a10e54b20 | bgoeschi/OCD-Workbench | src/main/java/i5/las2peer/services/ocd/algorithms/OcdAlgorithmExecutor.java | [
"Apache-2.0"
] | Java | OcdAlgorithmExecutor | /**
* Manages the execution of an OcdAlgorithm.
* @author Sebastian
*
*/ | Manages the execution of an OcdAlgorithm.
@author Sebastian | [
"Manages",
"the",
"execution",
"of",
"an",
"OcdAlgorithm",
".",
"@author",
"Sebastian"
] | public class OcdAlgorithmExecutor {
/**
* Calculates a cover by executing an ocd algorithm on a graph.
* The algorithm is run on each weakly connected component seperately.
* Small components are automatically considered to be one community.
* @param graph The graph.
* @param algorithm The algorithm.
* @param componentNodeCountFilter Weakly connected components of a size
* lower than the filter will automatically be considered a single community.
* @return A cover of the graph calculated by the algorithm.
* @throws OcdAlgorithmException In case of an algorithm failure.
* @throws InterruptedException In case of an algorithm interrupt.
*/
public Cover execute(CustomGraph graph, OcdAlgorithm algorithm, int componentNodeCountFilter) throws OcdAlgorithmException, InterruptedException {
CustomGraph graphCopy = new CustomGraph(graph);
GraphProcessor processor = new GraphProcessor();
processor.makeCompatible(graphCopy, algorithm.compatibleGraphTypes());
if(algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.WORD_CLUSTERING_REF_ALGORITHM.toString())||algorithm.getAlgorithmType().toString().equalsIgnoreCase(CoverCreationType.COST_FUNC_OPT_CLUSTERING_ALGORITHM.toString())){
ExecutionTime executionTime = new ExecutionTime();
Cover cover = algorithm.detectOverlappingCommunities(graph);
cover.setCreationMethod(new CoverCreationLog(algorithm.getAlgorithmType(), algorithm.getParameters(), algorithm.compatibleGraphTypes()));
cover.getCreationMethod().setStatus(ExecutionStatus.COMPLETED);
executionTime.setCoverExecutionTime(cover);
return cover;
}else{
List<Pair<CustomGraph, Map<Node, Node>>> components;
List<Pair<Cover, Map<Node, Node>>> componentCovers;
components = processor.divideIntoConnectedComponents(graphCopy);
ExecutionTime executionTime = new ExecutionTime();
componentCovers = calculateComponentCovers(components, algorithm, componentNodeCountFilter, executionTime);
Cover coverCopy = processor.mergeComponentCovers(graphCopy, componentCovers);
Cover cover = new Cover(graph, coverCopy.getMemberships());
cover.setCreationMethod(coverCopy.getCreationMethod());
cover.getCreationMethod().setStatus(ExecutionStatus.COMPLETED);
executionTime.setCoverExecutionTime(cover);
return cover;
}
}
/*
* Calculates the cover of each connected component.
* @param components The connected components each with a node mapping from the component nodes to the original graph nodes.
* @param algorithm The algorithm to calculate the covers with.
* @param componentNodeCountFilter Components of a size lower than the filter will automatically be considered a single community.
* @param executionTime The execution time metric corresponding the algorithm execution.
* @return The covers of the connected components each with a node mapping from the component nodes to the original graph nodes.
* @throws OcdAlgorithmException In case of an algorithm failure.
* @throws InterruptedException In case of an algorithm interrupt.
*/
private List<Pair<Cover, Map<Node, Node>>> calculateComponentCovers(List<Pair<CustomGraph, Map<Node, Node>>> components,
OcdAlgorithm algorithm, int componentNodeCountFilter, ExecutionTime executionTime) throws OcdAlgorithmException, InterruptedException {
List<Pair<Cover, Map<Node, Node>>> componentCovers = new ArrayList<Pair<Cover, Map<Node, Node>>>();
CustomGraph component;
Cover componentCover;
for(Pair<CustomGraph, Map<Node, Node>> pair : components) {
component = pair.getFirst();
if(component.nodeCount() < componentNodeCountFilter) {
componentCover = computeSingleCommunityCover(component, algorithm);
}
else {
executionTime.start();
componentCover = algorithm.detectOverlappingCommunities(component);
componentCover.setCreationMethod(new CoverCreationLog(algorithm.getAlgorithmType(), algorithm.getParameters(), algorithm.compatibleGraphTypes()));
componentCover.getCreationMethod().setStatus(ExecutionStatus.COMPLETED);
executionTime.stop();
}
componentCovers.add(new Pair<Cover, Map<Node, Node>>(componentCover, pair.getSecond()));
}
return componentCovers;
}
/*
* Calculates a cover consisting of a single community.
* @param graph The graph to create the cover for.
* @param algorithm The algorithm used for setting the log entry.
* @return The cover.
*/
private Cover computeSingleCommunityCover(CustomGraph graph, OcdAlgorithm algorithm) {
Matrix memberships = new CCSMatrix(graph.nodeCount(), 1);
memberships.assign(1);
Cover cover = new Cover (graph, memberships);
cover.setCreationMethod(new CoverCreationLog(algorithm.getAlgorithmType(), algorithm.getParameters(), algorithm.compatibleGraphTypes()));
cover.getCreationMethod().setStatus(ExecutionStatus.COMPLETED);
return cover;
}
} | [
"public",
"class",
"OcdAlgorithmExecutor",
"{",
"/**\n\t * Calculates a cover by executing an ocd algorithm on a graph.\n\t * The algorithm is run on each weakly connected component seperately.\n\t * Small components are automatically considered to be one community.\n\t * @param graph The graph.\n\t * @param algorithm The algorithm.\n\t * @param componentNodeCountFilter Weakly connected components of a size\n\t * lower than the filter will automatically be considered a single community.\n\t * @return A cover of the graph calculated by the algorithm.\n\t * @throws OcdAlgorithmException In case of an algorithm failure.\n\t * @throws InterruptedException In case of an algorithm interrupt.\n\t */",
"public",
"Cover",
"execute",
"(",
"CustomGraph",
"graph",
",",
"OcdAlgorithm",
"algorithm",
",",
"int",
"componentNodeCountFilter",
")",
"throws",
"OcdAlgorithmException",
",",
"InterruptedException",
"{",
"CustomGraph",
"graphCopy",
"=",
"new",
"CustomGraph",
"(",
"graph",
")",
";",
"GraphProcessor",
"processor",
"=",
"new",
"GraphProcessor",
"(",
")",
";",
"processor",
".",
"makeCompatible",
"(",
"graphCopy",
",",
"algorithm",
".",
"compatibleGraphTypes",
"(",
")",
")",
";",
"if",
"(",
"algorithm",
".",
"getAlgorithmType",
"(",
")",
".",
"toString",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"CoverCreationType",
".",
"WORD_CLUSTERING_REF_ALGORITHM",
".",
"toString",
"(",
")",
")",
"||",
"algorithm",
".",
"getAlgorithmType",
"(",
")",
".",
"toString",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"CoverCreationType",
".",
"COST_FUNC_OPT_CLUSTERING_ALGORITHM",
".",
"toString",
"(",
")",
")",
")",
"{",
"ExecutionTime",
"executionTime",
"=",
"new",
"ExecutionTime",
"(",
")",
";",
"Cover",
"cover",
"=",
"algorithm",
".",
"detectOverlappingCommunities",
"(",
"graph",
")",
";",
"cover",
".",
"setCreationMethod",
"(",
"new",
"CoverCreationLog",
"(",
"algorithm",
".",
"getAlgorithmType",
"(",
")",
",",
"algorithm",
".",
"getParameters",
"(",
")",
",",
"algorithm",
".",
"compatibleGraphTypes",
"(",
")",
")",
")",
";",
"cover",
".",
"getCreationMethod",
"(",
")",
".",
"setStatus",
"(",
"ExecutionStatus",
".",
"COMPLETED",
")",
";",
"executionTime",
".",
"setCoverExecutionTime",
"(",
"cover",
")",
";",
"return",
"cover",
";",
"}",
"else",
"{",
"List",
"<",
"Pair",
"<",
"CustomGraph",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
">",
"components",
";",
"List",
"<",
"Pair",
"<",
"Cover",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
">",
"componentCovers",
";",
"components",
"=",
"processor",
".",
"divideIntoConnectedComponents",
"(",
"graphCopy",
")",
";",
"ExecutionTime",
"executionTime",
"=",
"new",
"ExecutionTime",
"(",
")",
";",
"componentCovers",
"=",
"calculateComponentCovers",
"(",
"components",
",",
"algorithm",
",",
"componentNodeCountFilter",
",",
"executionTime",
")",
";",
"Cover",
"coverCopy",
"=",
"processor",
".",
"mergeComponentCovers",
"(",
"graphCopy",
",",
"componentCovers",
")",
";",
"Cover",
"cover",
"=",
"new",
"Cover",
"(",
"graph",
",",
"coverCopy",
".",
"getMemberships",
"(",
")",
")",
";",
"cover",
".",
"setCreationMethod",
"(",
"coverCopy",
".",
"getCreationMethod",
"(",
")",
")",
";",
"cover",
".",
"getCreationMethod",
"(",
")",
".",
"setStatus",
"(",
"ExecutionStatus",
".",
"COMPLETED",
")",
";",
"executionTime",
".",
"setCoverExecutionTime",
"(",
"cover",
")",
";",
"return",
"cover",
";",
"}",
"}",
"/*\n\t * Calculates the cover of each connected component.\n\t * @param components The connected components each with a node mapping from the component nodes to the original graph nodes.\n\t * @param algorithm The algorithm to calculate the covers with.\n\t * @param componentNodeCountFilter Components of a size lower than the filter will automatically be considered a single community.\n\t * @param executionTime The execution time metric corresponding the algorithm execution.\n\t * @return The covers of the connected components each with a node mapping from the component nodes to the original graph nodes.\n\t * @throws OcdAlgorithmException In case of an algorithm failure.\n\t * @throws InterruptedException In case of an algorithm interrupt.\n\t */",
"private",
"List",
"<",
"Pair",
"<",
"Cover",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
">",
"calculateComponentCovers",
"(",
"List",
"<",
"Pair",
"<",
"CustomGraph",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
">",
"components",
",",
"OcdAlgorithm",
"algorithm",
",",
"int",
"componentNodeCountFilter",
",",
"ExecutionTime",
"executionTime",
")",
"throws",
"OcdAlgorithmException",
",",
"InterruptedException",
"{",
"List",
"<",
"Pair",
"<",
"Cover",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
">",
"componentCovers",
"=",
"new",
"ArrayList",
"<",
"Pair",
"<",
"Cover",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
">",
"(",
")",
";",
"CustomGraph",
"component",
";",
"Cover",
"componentCover",
";",
"for",
"(",
"Pair",
"<",
"CustomGraph",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
"pair",
":",
"components",
")",
"{",
"component",
"=",
"pair",
".",
"getFirst",
"(",
")",
";",
"if",
"(",
"component",
".",
"nodeCount",
"(",
")",
"<",
"componentNodeCountFilter",
")",
"{",
"componentCover",
"=",
"computeSingleCommunityCover",
"(",
"component",
",",
"algorithm",
")",
";",
"}",
"else",
"{",
"executionTime",
".",
"start",
"(",
")",
";",
"componentCover",
"=",
"algorithm",
".",
"detectOverlappingCommunities",
"(",
"component",
")",
";",
"componentCover",
".",
"setCreationMethod",
"(",
"new",
"CoverCreationLog",
"(",
"algorithm",
".",
"getAlgorithmType",
"(",
")",
",",
"algorithm",
".",
"getParameters",
"(",
")",
",",
"algorithm",
".",
"compatibleGraphTypes",
"(",
")",
")",
")",
";",
"componentCover",
".",
"getCreationMethod",
"(",
")",
".",
"setStatus",
"(",
"ExecutionStatus",
".",
"COMPLETED",
")",
";",
"executionTime",
".",
"stop",
"(",
")",
";",
"}",
"componentCovers",
".",
"add",
"(",
"new",
"Pair",
"<",
"Cover",
",",
"Map",
"<",
"Node",
",",
"Node",
">",
">",
"(",
"componentCover",
",",
"pair",
".",
"getSecond",
"(",
")",
")",
")",
";",
"}",
"return",
"componentCovers",
";",
"}",
"/*\n\t * Calculates a cover consisting of a single community.\n\t * @param graph The graph to create the cover for.\n\t * @param algorithm The algorithm used for setting the log entry.\n\t * @return The cover.\n\t */",
"private",
"Cover",
"computeSingleCommunityCover",
"(",
"CustomGraph",
"graph",
",",
"OcdAlgorithm",
"algorithm",
")",
"{",
"Matrix",
"memberships",
"=",
"new",
"CCSMatrix",
"(",
"graph",
".",
"nodeCount",
"(",
")",
",",
"1",
")",
";",
"memberships",
".",
"assign",
"(",
"1",
")",
";",
"Cover",
"cover",
"=",
"new",
"Cover",
"(",
"graph",
",",
"memberships",
")",
";",
"cover",
".",
"setCreationMethod",
"(",
"new",
"CoverCreationLog",
"(",
"algorithm",
".",
"getAlgorithmType",
"(",
")",
",",
"algorithm",
".",
"getParameters",
"(",
")",
",",
"algorithm",
".",
"compatibleGraphTypes",
"(",
")",
")",
")",
";",
"cover",
".",
"getCreationMethod",
"(",
")",
".",
"setStatus",
"(",
"ExecutionStatus",
".",
"COMPLETED",
")",
";",
"return",
"cover",
";",
"}",
"}"
] | Manages the execution of an OcdAlgorithm. | [
"Manages",
"the",
"execution",
"of",
"an",
"OcdAlgorithm",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
485404c204dc2bc136038f215b9350a583f98016 | ColmanOB/SessionBuddy | SessionBuddy/src/sessionbuddy/ActivityStream.java | [
"MIT"
] | Java | ActivityStream | /**
* Query thesession.org API for an activity stream and parse the response into a usable structure
*
* @author Colman O'B
* @since 2018-12-19
*
*/ | Query thesession.org API for an activity stream and parse the response into a usable structure
| [
"Query",
"thesession",
".",
"org",
"API",
"for",
"an",
"activity",
"stream",
"and",
"parse",
"the",
"response",
"into",
"a",
"usable",
"structure"
] | public class ActivityStream {
/**
* Retrieve an activity stream without specifying a category.
* This does not specify a number of results per page, or a particular page number of the result set.
*
* @return An ArrayList of ActivityStreamResult objects
* @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page
* @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated
* @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it
* @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException
* @since 2018-12-18
*/
public static ArrayList<ActivityStreamResult> readActivityStream()
throws IllegalArgumentException, IllegalStateException, IOException, URISyntaxException {
try {
// Make the API call, parse the response into a wrapper, and return the wrapper
String response = HttpRequestor.submitRequest(composeURLAllCategories());
ActivityStreamWrapper parsedResponse = JsonParser.parseResponse(response, ActivityStreamWrapper.class);
return populateActivityStreamResult(parsedResponse);
}
catch (IllegalArgumentException | IOException | IllegalStateException | URISyntaxException ex) {
throw ex;
}
}
/**
* Retrieve an activity stream without specifying a category.
* Used when you want to specify a number of results per page in the API response.
*
* @param resultsPerPage The number of results to be returned per page in the API response
* @return An ArrayList of ActivityStreamResult objects
* @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page
* @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated
* @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it
* @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException
* @since 2018-12-18
*/
public static ArrayList<ActivityStreamResult> readActivityStream(int resultsPerPage)
throws IllegalArgumentException, IllegalStateException, IOException, URISyntaxException {
try {
// Make the API call, parse the response into a wrapper, and return the wrapper
PageCountValidator.validate(resultsPerPage);
String response = HttpRequestor.submitRequest(composeURLAllCategories(resultsPerPage));
ActivityStreamWrapper parsedResponse = JsonParser.parseResponse(response, ActivityStreamWrapper.class);
return populateActivityStreamResult(parsedResponse);
}
catch (IllegalArgumentException | IOException | IllegalStateException | URISyntaxException ex) {
throw ex;
}
}
/**
* Retrieve an activity stream without specifying a category.
* Used when you want to specify a number of results per page and a specific page number within that response.
*
* @param resultsPerPage The number of results to be returned per page in the API response
* @param pageNumber A specific page within the response from the API
* @return An ArrayList of ActivityStreamResult objects
* @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page
* @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated
* @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it
* @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException
* @since 2018-12-18
*/
public static ArrayList<ActivityStreamResult> readActivityStream(int resultsPerPage, int pageNumber)
throws IllegalArgumentException, IllegalStateException, IOException, URISyntaxException {
try {
// Make the API call, parse the response into a wrapper, and return the wrapper
PageCountValidator.validate(resultsPerPage);
String response = HttpRequestor.submitRequest(composeURLAllCategories(resultsPerPage, pageNumber));
ActivityStreamWrapper parsedResponse = JsonParser.parseResponse(response, ActivityStreamWrapper.class);
return populateActivityStreamResult(parsedResponse);
}
catch (IllegalArgumentException | IOException | IllegalStateException | URISyntaxException ex) {
throw ex;
}
}
/**
* Retrieve an activity stream for a particular category. Currently the available categories are;
* Tunes, Recordings, Sessions, Events, Discussions
*
* Used when you do not want to specify a number of results per page or any specific page
* within the response.
*
* @param dataCategory the category of data in question, e.g. tunes, discussions, sessions etc.
* @return an ArrayList of ActivityStreamResult objects
* @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page
* @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated
* @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it
* @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException
* @since 2018-12-20
*/
public static ArrayList<ActivityStreamResult> readActivityStream(DataCategory dataCategory)
throws IllegalArgumentException, IllegalStateException, IOException, URISyntaxException {
// Handle cases where a data category is provided that does not have an activity stream
if (dataCategory == DataCategory.members) {
throw new IllegalArgumentException("Invalid category - No activity stream is available");
}
try {
// Make the API call, parse the response into a wrapper, and return the wrapper
String response = HttpRequestor.submitRequest(composeURLSingleCategory(dataCategory));
ActivityStreamWrapper parsedResponse = JsonParser.parseResponse(response, ActivityStreamWrapper.class);
return populateActivityStreamResult(parsedResponse);
}
catch (IllegalArgumentException | IOException | IllegalStateException | URISyntaxException ex) {
throw ex;
}
}
/**
* Retrieve an activity stream for a particular category. Currently the available categories are;
* Tunes, Recordings, Sessions, Events, Discussions
*
* This is used when you want to specify the number of results per page but not a specific page
* within the response.
*
* @param dataCategory the category of data in question, e.g. tunes, discussions, sessions etc.
* @param resultsPerPage the number of results to be returned per page in the API response
* @return an ArrayList of ActivityStreamResult objects
* @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page
* @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated
* @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it
* @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException
* @since 2018-12-20
*/
public static ArrayList<ActivityStreamResult> readActivityStream(DataCategory dataCategory, int resultsPerPage)
throws IllegalArgumentException, IllegalStateException, IOException, URISyntaxException {
// Handle cases where a data category is provided that does not have an activity stream
if (dataCategory == DataCategory.members) {
throw new IllegalArgumentException("Invalid category - No activity stream is available");
}
try {
// Make the API call, parse the response into a wrapper, and return the wrapper
PageCountValidator.validate(resultsPerPage);
String response = HttpRequestor.submitRequest(composeURLSingleCategory(dataCategory, resultsPerPage));
ActivityStreamWrapper parsedResponse = JsonParser.parseResponse(response, ActivityStreamWrapper.class);
return populateActivityStreamResult(parsedResponse);
}
catch (IllegalArgumentException | IOException | IllegalStateException | URISyntaxException ex) {
throw ex;
}
}
/**
* Retrieves an activity stream for a particular data category. Currently the available categories are;
* Tunes, Recordings, Sessions, Events, Discussions
*
* This is used when you want to specify both number of results per page and a specific page
* within the response.
*
* @param dataCategory the category of data in question, e.g. tunes, discussions, sessions etc.
* @param resultsPerPage the number of results to be returned per page in the API response
* @param pageNumber specifies an individual page within the API response
* @return an ArrayList of ActivityStreamResult objects
* @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page
* @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated
* @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it
* @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException
* @since 2018-12-20
*/
public static ArrayList<ActivityStreamResult> readActivityStream(DataCategory dataCategory, int resultsPerPage, int pageNumber)
throws IllegalArgumentException, IllegalStateException, IOException, URISyntaxException {
// Handle cases where a data category is provided that does not have an activity stream
if (dataCategory == DataCategory.members) {
throw new IllegalArgumentException("Invalid category - No activity stream is available");
}
try {
// Make the API call, parse the response into a wrapper, and return the wrapper
PageCountValidator.validate(resultsPerPage);
String response = HttpRequestor.submitRequest(composeURLSingleCategory(dataCategory, resultsPerPage, pageNumber));
ActivityStreamWrapper parsedResponse = JsonParser.parseResponse(response, ActivityStreamWrapper.class);
return populateActivityStreamResult(parsedResponse);
}
catch (IllegalArgumentException | IOException | IllegalStateException | URISyntaxException ex) {
throw ex;
}
}
public static ArrayList<ActivityStreamResult> readActivityStreamItem(DataCategory dataCategory, int itemID)
throws IllegalArgumentException, IllegalStateException, IOException, URISyntaxException {
try {
// Make the API call, parse the response into a wrapper, and return the wrapper
String response = HttpRequestor.submitRequest(composeURLSingleItem(dataCategory, itemID));
ActivityStreamWrapper parsedResponse = JsonParser.parseResponse(response, ActivityStreamWrapper.class);
return populateActivityStreamResult(parsedResponse);
}
catch (IllegalArgumentException | IOException | IllegalStateException | URISyntaxException ex) {
throw ex;
}
}
/**
* Helper method to gather and parse the response to a request for an Activity Stream
*
* @param parsedResponse an ActivityStreamWrapper object that has already been created an populated
* @return an ArrayList of ActivityStreamResult objects
*/
private static ArrayList<ActivityStreamResult> populateActivityStreamResult(ActivityStreamWrapper parsedResponse) {
ArrayList<ActivityStreamResult> activityStream = new ArrayList<ActivityStreamResult>();
// Loop as many times as the count of items in the result set
for (int i = 0; i < (parsedResponse.items.length); i++) {
// Extract the required elements from each individual search result in the JSON response
ActivityStreamDetails details = new ActivityStreamDetails(parsedResponse.items[i].published,
StringCleaner.cleanString(parsedResponse.items[i].title), parsedResponse.items[i].verb);
ActivityStreamObject actor = new ActivityStreamObject(parsedResponse.items[i].actor.url,
parsedResponse.items[i].actor.objectType, parsedResponse.items[i].actor.id,
parsedResponse.items[i].actor.displayName);
ActivityStreamObject object = new ActivityStreamObject(parsedResponse.items[i].object.url,
parsedResponse.items[i].object.objectType, parsedResponse.items[i].object.id,
parsedResponse.items[i].object.displayName);
ActivityStreamObject target = new ActivityStreamObject(parsedResponse.items[i].target.url,
parsedResponse.items[i].target.objectType, parsedResponse.items[i].target.id,
parsedResponse.items[i].target.displayName);
ActivityStreamResult currentResult = new ActivityStreamResult(details, actor, object, target);
// Add the current ActivityStreamResult object to the ArrayList to be returned to the caller
activityStream.add(currentResult);
}
return activityStream;
}
/**
* A helper method used to put the URL together to query the API at thesession.org
*
* @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.
* @return A URL specifying a particular resource from thesession.org API
* @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException
* @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException
*/
private static URL composeURLSingleCategory(DataCategory dataCategory)
throws MalformedURLException, URISyntaxException {
URL requestURL;
URLComposer builder = new URLComposer();
requestURL = builder.new Builder()
.requestType(RequestType.ACTIVITY_STREAM)
.path(dataCategory + "/" + "activity")
.build();
return requestURL;
}
/**
* A helper method used to put the URL together to query the API at thesession.org
*
* @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.
* @return A URL specifying a particular resource from thesession.org API
* @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException
* @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException
*/
private static URL composeURLSingleCategory(DataCategory dataCategory, int resultsPerPage)
throws MalformedURLException, URISyntaxException {
URL requestURL;
URLComposer builder = new URLComposer();
requestURL = builder.new Builder()
.requestType(RequestType.ACTIVITY_STREAM)
.path(dataCategory + "/" + "activity")
.itemsPerPage(resultsPerPage)
.build();
return requestURL;
}
/**
* A helper method used to put the URL together to query the API at thesession.org
*
* @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.
* @return A URL specifying a particular resource from thesession.org API
* @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException
* @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException
*/
private static URL composeURLSingleCategory(DataCategory dataCategory, int resultsPerPage, int pageNumber)
throws MalformedURLException, URISyntaxException {
URL requestURL;
// If a particular page within the response from the API is specified:
if (pageNumber > 0) {
URLComposer builder = new URLComposer();
requestURL = builder.new Builder()
.requestType(RequestType.ACTIVITY_STREAM)
.path(dataCategory + "/" + "activity")
.itemsPerPage(resultsPerPage)
.pageNumber(pageNumber)
.build();
}
// If anything other than a positive integer was specified as the page number
else {
throw new IllegalArgumentException("Page number must be an integer value greater than zero");
}
return requestURL;
}
/**
* A helper method used to put the URL together to query the API at thesession.org for an activity
* stream, specifically one with no data category, i.e. for retrieving details of all recent
* activity across thesession.org.
*
* This is used when you do not want to specify either the number of results to be returned per
* page, nor a specific page number within the response.
*
* @return A URL specifying a particular resource from thesession.org API
* @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException
* @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException
*/
private static URL composeURLAllCategories() throws MalformedURLException, URISyntaxException {
URL requestURL;
URLComposer builder = new URLComposer();
requestURL = builder.new Builder()
.requestType(RequestType.ACTIVITY_STREAM)
.path("/" + "activity")
.build();
return requestURL;
}
/**
* A helper method used to put the URL together to query the API at thesession.org for an activity
* stream, specifically one with no data category, i.e. for retrieving details of all recent
* activity across thesession.org.
*
* This is used when you want to specify the number of results to be returned per page, but do not
* want to specify a particular page number.
*
* @return A URL specifying a particular resource from thesession.org API
* @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException
* @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException
*/
private static URL composeURLAllCategories(int resultsPerPage)
throws MalformedURLException, URISyntaxException {
URL requestURL;
if (resultsPerPage >= 0) {
URLComposer builder = new URLComposer();
requestURL = builder.new Builder()
.requestType(RequestType.ACTIVITY_STREAM)
.path("/" + "activity")
.itemsPerPage(resultsPerPage)
.build();
}
// If page number is not a positive integer
else {
throw new IllegalArgumentException("Results per page number must be an integer value greater than zero");
}
return requestURL;
}
/**
* A helper method used to put the URL together to query the API at thesession.org for an activity
* stream, specifically one with no data category, i.e. for retrieving details of all recent
* activity across thesession.org
*
* @param resultsPerPage The number of results to be returned per page in the response
* @param pageNumber An individual page number within the response
* @return A URL specifying the activity stream across all categories on thesession.org
* @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException
* @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException
*/
private static URL composeURLAllCategories(int resultsPerPage, int pageNumber)
throws MalformedURLException, URISyntaxException {
URL requestURL;
// If a particular page within the response from the API is specified:
if (pageNumber > 0) {
URLComposer builder = new URLComposer();
requestURL = builder.new Builder()
.requestType(RequestType.ACTIVITY_STREAM)
.path("/" + "activity")
.itemsPerPage(resultsPerPage)
.pageNumber(pageNumber)
.build();
}
// If the page number is anything other than a positive integer
else {
throw new IllegalArgumentException("Page number must be an integer value greater than zero");
}
return requestURL;
}
/**
* A helper method used to put the URL together to query the API at thesession.org for an activity
* stream for a specific item, e.g. for retrieving details of all recent activity relating to a
* particular tune or session etc.
*
* @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.
* @param itemID The numeric ID in thesession.org database of the item being queried
* @return A URL specifying the activity stream for a particular item on thesession.org
* @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException
* @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException
*/
private static URL composeURLSingleItem(DataCategory dataCategory, int itemID)
throws MalformedURLException, URISyntaxException {
URL requestURL;
URLComposer builder = new URLComposer();
requestURL = builder.new Builder()
.requestType(RequestType.SINGLE_ITEM)
.path(dataCategory + "/" + itemID + "/activity")
.build();
return requestURL;
}
} | [
"public",
"class",
"ActivityStream",
"{",
"/**\r\n * Retrieve an activity stream without specifying a category.\r\n * This does not specify a number of results per page, or a particular page number of the result set.\r\n * \r\n * @return An ArrayList of ActivityStreamResult objects\r\n * @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page\r\n * @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated\r\n * @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it\r\n * @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException\r\n * @since 2018-12-18\r\n */",
"public",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"readActivityStream",
"(",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalStateException",
",",
"IOException",
",",
"URISyntaxException",
"{",
"try",
"{",
"String",
"response",
"=",
"HttpRequestor",
".",
"submitRequest",
"(",
"composeURLAllCategories",
"(",
")",
")",
";",
"ActivityStreamWrapper",
"parsedResponse",
"=",
"JsonParser",
".",
"parseResponse",
"(",
"response",
",",
"ActivityStreamWrapper",
".",
"class",
")",
";",
"return",
"populateActivityStreamResult",
"(",
"parsedResponse",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IOException",
"|",
"IllegalStateException",
"|",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"/**\r\n * Retrieve an activity stream without specifying a category.\r\n * Used when you want to specify a number of results per page in the API response.\r\n * \r\n * @param resultsPerPage The number of results to be returned per page in the API response\r\n * @return An ArrayList of ActivityStreamResult objects\r\n * @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page\r\n * @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated\r\n * @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it\r\n * @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException\r\n * @since 2018-12-18\r\n */",
"public",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"readActivityStream",
"(",
"int",
"resultsPerPage",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalStateException",
",",
"IOException",
",",
"URISyntaxException",
"{",
"try",
"{",
"PageCountValidator",
".",
"validate",
"(",
"resultsPerPage",
")",
";",
"String",
"response",
"=",
"HttpRequestor",
".",
"submitRequest",
"(",
"composeURLAllCategories",
"(",
"resultsPerPage",
")",
")",
";",
"ActivityStreamWrapper",
"parsedResponse",
"=",
"JsonParser",
".",
"parseResponse",
"(",
"response",
",",
"ActivityStreamWrapper",
".",
"class",
")",
";",
"return",
"populateActivityStreamResult",
"(",
"parsedResponse",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IOException",
"|",
"IllegalStateException",
"|",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"/**\r\n * Retrieve an activity stream without specifying a category.\r\n * Used when you want to specify a number of results per page and a specific page number within that response.\r\n * \r\n * @param resultsPerPage The number of results to be returned per page in the API response\r\n * @param pageNumber A specific page within the response from the API\r\n * @return An ArrayList of ActivityStreamResult objects\r\n * @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page\r\n * @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated\r\n * @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it\r\n * @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException\r\n * @since 2018-12-18\r\n */",
"public",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"readActivityStream",
"(",
"int",
"resultsPerPage",
",",
"int",
"pageNumber",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalStateException",
",",
"IOException",
",",
"URISyntaxException",
"{",
"try",
"{",
"PageCountValidator",
".",
"validate",
"(",
"resultsPerPage",
")",
";",
"String",
"response",
"=",
"HttpRequestor",
".",
"submitRequest",
"(",
"composeURLAllCategories",
"(",
"resultsPerPage",
",",
"pageNumber",
")",
")",
";",
"ActivityStreamWrapper",
"parsedResponse",
"=",
"JsonParser",
".",
"parseResponse",
"(",
"response",
",",
"ActivityStreamWrapper",
".",
"class",
")",
";",
"return",
"populateActivityStreamResult",
"(",
"parsedResponse",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IOException",
"|",
"IllegalStateException",
"|",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"/**\r\n * Retrieve an activity stream for a particular category. Currently the available categories are; \r\n * Tunes, Recordings, Sessions, Events, Discussions\r\n * \r\n * Used when you do not want to specify a number of results per page or any specific page\r\n * within the response.\r\n * \r\n * @param dataCategory the category of data in question, e.g. tunes, discussions, sessions etc.\r\n * @return an ArrayList of ActivityStreamResult objects\r\n * @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page\r\n * @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated\r\n * @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it\r\n * @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException\r\n * @since 2018-12-20\r\n */",
"public",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"readActivityStream",
"(",
"DataCategory",
"dataCategory",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalStateException",
",",
"IOException",
",",
"URISyntaxException",
"{",
"if",
"(",
"dataCategory",
"==",
"DataCategory",
".",
"members",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Invalid category - No activity stream is available",
"\"",
")",
";",
"}",
"try",
"{",
"String",
"response",
"=",
"HttpRequestor",
".",
"submitRequest",
"(",
"composeURLSingleCategory",
"(",
"dataCategory",
")",
")",
";",
"ActivityStreamWrapper",
"parsedResponse",
"=",
"JsonParser",
".",
"parseResponse",
"(",
"response",
",",
"ActivityStreamWrapper",
".",
"class",
")",
";",
"return",
"populateActivityStreamResult",
"(",
"parsedResponse",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IOException",
"|",
"IllegalStateException",
"|",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"/**\r\n * Retrieve an activity stream for a particular category. Currently the available categories are; \r\n * Tunes, Recordings, Sessions, Events, Discussions\r\n * \r\n * This is used when you want to specify the number of results per page but not a specific page\r\n * within the response.\r\n * \r\n * @param dataCategory the category of data in question, e.g. tunes, discussions, sessions etc.\r\n * @param resultsPerPage the number of results to be returned per page in the API response\r\n * @return an ArrayList of ActivityStreamResult objects\r\n * @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page\r\n * @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated\r\n * @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it\r\n * @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException\r\n * @since 2018-12-20\r\n */",
"public",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"readActivityStream",
"(",
"DataCategory",
"dataCategory",
",",
"int",
"resultsPerPage",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalStateException",
",",
"IOException",
",",
"URISyntaxException",
"{",
"if",
"(",
"dataCategory",
"==",
"DataCategory",
".",
"members",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Invalid category - No activity stream is available",
"\"",
")",
";",
"}",
"try",
"{",
"PageCountValidator",
".",
"validate",
"(",
"resultsPerPage",
")",
";",
"String",
"response",
"=",
"HttpRequestor",
".",
"submitRequest",
"(",
"composeURLSingleCategory",
"(",
"dataCategory",
",",
"resultsPerPage",
")",
")",
";",
"ActivityStreamWrapper",
"parsedResponse",
"=",
"JsonParser",
".",
"parseResponse",
"(",
"response",
",",
"ActivityStreamWrapper",
".",
"class",
")",
";",
"return",
"populateActivityStreamResult",
"(",
"parsedResponse",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IOException",
"|",
"IllegalStateException",
"|",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"/**\r\n * Retrieves an activity stream for a particular data category. Currently the available categories are; \r\n * Tunes, Recordings, Sessions, Events, Discussions\r\n * \r\n * This is used when you want to specify both number of results per page and a specific page\r\n * within the response.\r\n * \r\n * @param dataCategory the category of data in question, e.g. tunes, discussions, sessions etc.\r\n * @param resultsPerPage the number of results to be returned per page in the API response\r\n * @param pageNumber specifies an individual page within the API response\r\n * @return an ArrayList of ActivityStreamResult objects\r\n * @throws IllegalArgumentException if an attempt was made to specify more than 50 results per page\r\n * @throws IllegalStateException if an attempt was made to check the number of pages in a JSON response before the pageCount field has been populated\r\n * @throws IOException if a problem was encountered setting up the HTTP connection or reading data from it\r\n * @throws URISyntaxException if the underlying UrlBuilder class throws a URISyntaxException\r\n * @since 2018-12-20\r\n */",
"public",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"readActivityStream",
"(",
"DataCategory",
"dataCategory",
",",
"int",
"resultsPerPage",
",",
"int",
"pageNumber",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalStateException",
",",
"IOException",
",",
"URISyntaxException",
"{",
"if",
"(",
"dataCategory",
"==",
"DataCategory",
".",
"members",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Invalid category - No activity stream is available",
"\"",
")",
";",
"}",
"try",
"{",
"PageCountValidator",
".",
"validate",
"(",
"resultsPerPage",
")",
";",
"String",
"response",
"=",
"HttpRequestor",
".",
"submitRequest",
"(",
"composeURLSingleCategory",
"(",
"dataCategory",
",",
"resultsPerPage",
",",
"pageNumber",
")",
")",
";",
"ActivityStreamWrapper",
"parsedResponse",
"=",
"JsonParser",
".",
"parseResponse",
"(",
"response",
",",
"ActivityStreamWrapper",
".",
"class",
")",
";",
"return",
"populateActivityStreamResult",
"(",
"parsedResponse",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IOException",
"|",
"IllegalStateException",
"|",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"public",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"readActivityStreamItem",
"(",
"DataCategory",
"dataCategory",
",",
"int",
"itemID",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalStateException",
",",
"IOException",
",",
"URISyntaxException",
"{",
"try",
"{",
"String",
"response",
"=",
"HttpRequestor",
".",
"submitRequest",
"(",
"composeURLSingleItem",
"(",
"dataCategory",
",",
"itemID",
")",
")",
";",
"ActivityStreamWrapper",
"parsedResponse",
"=",
"JsonParser",
".",
"parseResponse",
"(",
"response",
",",
"ActivityStreamWrapper",
".",
"class",
")",
";",
"return",
"populateActivityStreamResult",
"(",
"parsedResponse",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"|",
"IOException",
"|",
"IllegalStateException",
"|",
"URISyntaxException",
"ex",
")",
"{",
"throw",
"ex",
";",
"}",
"}",
"/**\r\n * Helper method to gather and parse the response to a request for an Activity Stream\r\n * \r\n * @param parsedResponse an ActivityStreamWrapper object that has already been created an populated\r\n * @return an ArrayList of ActivityStreamResult objects\r\n */",
"private",
"static",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"populateActivityStreamResult",
"(",
"ActivityStreamWrapper",
"parsedResponse",
")",
"{",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"activityStream",
"=",
"new",
"ArrayList",
"<",
"ActivityStreamResult",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"parsedResponse",
".",
"items",
".",
"length",
")",
";",
"i",
"++",
")",
"{",
"ActivityStreamDetails",
"details",
"=",
"new",
"ActivityStreamDetails",
"(",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"published",
",",
"StringCleaner",
".",
"cleanString",
"(",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"title",
")",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"verb",
")",
";",
"ActivityStreamObject",
"actor",
"=",
"new",
"ActivityStreamObject",
"(",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"actor",
".",
"url",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"actor",
".",
"objectType",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"actor",
".",
"id",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"actor",
".",
"displayName",
")",
";",
"ActivityStreamObject",
"object",
"=",
"new",
"ActivityStreamObject",
"(",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"object",
".",
"url",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"object",
".",
"objectType",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"object",
".",
"id",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"object",
".",
"displayName",
")",
";",
"ActivityStreamObject",
"target",
"=",
"new",
"ActivityStreamObject",
"(",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"target",
".",
"url",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"target",
".",
"objectType",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"target",
".",
"id",
",",
"parsedResponse",
".",
"items",
"[",
"i",
"]",
".",
"target",
".",
"displayName",
")",
";",
"ActivityStreamResult",
"currentResult",
"=",
"new",
"ActivityStreamResult",
"(",
"details",
",",
"actor",
",",
"object",
",",
"target",
")",
";",
"activityStream",
".",
"add",
"(",
"currentResult",
")",
";",
"}",
"return",
"activityStream",
";",
"}",
"/**\r\n * A helper method used to put the URL together to query the API at thesession.org\r\n * \r\n * @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.\r\n * @return A URL specifying a particular resource from thesession.org API\r\n * @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException\r\n * @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException\r\n */",
"private",
"static",
"URL",
"composeURLSingleCategory",
"(",
"DataCategory",
"dataCategory",
")",
"throws",
"MalformedURLException",
",",
"URISyntaxException",
"{",
"URL",
"requestURL",
";",
"URLComposer",
"builder",
"=",
"new",
"URLComposer",
"(",
")",
";",
"requestURL",
"=",
"builder",
".",
"new",
"Builder",
"(",
")",
".",
"requestType",
"(",
"RequestType",
".",
"ACTIVITY_STREAM",
")",
".",
"path",
"(",
"dataCategory",
"+",
"\"",
"/",
"\"",
"+",
"\"",
"activity",
"\"",
")",
".",
"build",
"(",
")",
";",
"return",
"requestURL",
";",
"}",
"/**\r\n * A helper method used to put the URL together to query the API at thesession.org\r\n * \r\n * @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.\r\n * @return A URL specifying a particular resource from thesession.org API\r\n * @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException\r\n * @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException\r\n */",
"private",
"static",
"URL",
"composeURLSingleCategory",
"(",
"DataCategory",
"dataCategory",
",",
"int",
"resultsPerPage",
")",
"throws",
"MalformedURLException",
",",
"URISyntaxException",
"{",
"URL",
"requestURL",
";",
"URLComposer",
"builder",
"=",
"new",
"URLComposer",
"(",
")",
";",
"requestURL",
"=",
"builder",
".",
"new",
"Builder",
"(",
")",
".",
"requestType",
"(",
"RequestType",
".",
"ACTIVITY_STREAM",
")",
".",
"path",
"(",
"dataCategory",
"+",
"\"",
"/",
"\"",
"+",
"\"",
"activity",
"\"",
")",
".",
"itemsPerPage",
"(",
"resultsPerPage",
")",
".",
"build",
"(",
")",
";",
"return",
"requestURL",
";",
"}",
"/**\r\n * A helper method used to put the URL together to query the API at thesession.org\r\n * \r\n * @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.\r\n * @return A URL specifying a particular resource from thesession.org API\r\n * @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException\r\n * @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException\r\n */",
"private",
"static",
"URL",
"composeURLSingleCategory",
"(",
"DataCategory",
"dataCategory",
",",
"int",
"resultsPerPage",
",",
"int",
"pageNumber",
")",
"throws",
"MalformedURLException",
",",
"URISyntaxException",
"{",
"URL",
"requestURL",
";",
"if",
"(",
"pageNumber",
">",
"0",
")",
"{",
"URLComposer",
"builder",
"=",
"new",
"URLComposer",
"(",
")",
";",
"requestURL",
"=",
"builder",
".",
"new",
"Builder",
"(",
")",
".",
"requestType",
"(",
"RequestType",
".",
"ACTIVITY_STREAM",
")",
".",
"path",
"(",
"dataCategory",
"+",
"\"",
"/",
"\"",
"+",
"\"",
"activity",
"\"",
")",
".",
"itemsPerPage",
"(",
"resultsPerPage",
")",
".",
"pageNumber",
"(",
"pageNumber",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Page number must be an integer value greater than zero",
"\"",
")",
";",
"}",
"return",
"requestURL",
";",
"}",
"/**\r\n * A helper method used to put the URL together to query the API at thesession.org for an activity\r\n * stream, specifically one with no data category, i.e. for retrieving details of all recent\r\n * activity across thesession.org.\r\n * \r\n * This is used when you do not want to specify either the number of results to be returned per\r\n * page, nor a specific page number within the response.\r\n * \r\n * @return A URL specifying a particular resource from thesession.org API\r\n * @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException\r\n * @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException\r\n */",
"private",
"static",
"URL",
"composeURLAllCategories",
"(",
")",
"throws",
"MalformedURLException",
",",
"URISyntaxException",
"{",
"URL",
"requestURL",
";",
"URLComposer",
"builder",
"=",
"new",
"URLComposer",
"(",
")",
";",
"requestURL",
"=",
"builder",
".",
"new",
"Builder",
"(",
")",
".",
"requestType",
"(",
"RequestType",
".",
"ACTIVITY_STREAM",
")",
".",
"path",
"(",
"\"",
"/",
"\"",
"+",
"\"",
"activity",
"\"",
")",
".",
"build",
"(",
")",
";",
"return",
"requestURL",
";",
"}",
"/**\r\n * A helper method used to put the URL together to query the API at thesession.org for an activity\r\n * stream, specifically one with no data category, i.e. for retrieving details of all recent\r\n * activity across thesession.org.\r\n * \r\n * This is used when you want to specify the number of results to be returned per page, but do not\r\n * want to specify a particular page number.\r\n * \r\n * @return A URL specifying a particular resource from thesession.org API\r\n * @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException\r\n * @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException\r\n */",
"private",
"static",
"URL",
"composeURLAllCategories",
"(",
"int",
"resultsPerPage",
")",
"throws",
"MalformedURLException",
",",
"URISyntaxException",
"{",
"URL",
"requestURL",
";",
"if",
"(",
"resultsPerPage",
">=",
"0",
")",
"{",
"URLComposer",
"builder",
"=",
"new",
"URLComposer",
"(",
")",
";",
"requestURL",
"=",
"builder",
".",
"new",
"Builder",
"(",
")",
".",
"requestType",
"(",
"RequestType",
".",
"ACTIVITY_STREAM",
")",
".",
"path",
"(",
"\"",
"/",
"\"",
"+",
"\"",
"activity",
"\"",
")",
".",
"itemsPerPage",
"(",
"resultsPerPage",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Results per page number must be an integer value greater than zero",
"\"",
")",
";",
"}",
"return",
"requestURL",
";",
"}",
"/**\r\n * A helper method used to put the URL together to query the API at thesession.org for an activity\r\n * stream, specifically one with no data category, i.e. for retrieving details of all recent\r\n * activity across thesession.org\r\n * \r\n * @param resultsPerPage The number of results to be returned per page in the response\r\n * @param pageNumber An individual page number within the response\r\n * @return A URL specifying the activity stream across all categories on thesession.org\r\n * @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException\r\n * @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException\r\n */",
"private",
"static",
"URL",
"composeURLAllCategories",
"(",
"int",
"resultsPerPage",
",",
"int",
"pageNumber",
")",
"throws",
"MalformedURLException",
",",
"URISyntaxException",
"{",
"URL",
"requestURL",
";",
"if",
"(",
"pageNumber",
">",
"0",
")",
"{",
"URLComposer",
"builder",
"=",
"new",
"URLComposer",
"(",
")",
";",
"requestURL",
"=",
"builder",
".",
"new",
"Builder",
"(",
")",
".",
"requestType",
"(",
"RequestType",
".",
"ACTIVITY_STREAM",
")",
".",
"path",
"(",
"\"",
"/",
"\"",
"+",
"\"",
"activity",
"\"",
")",
".",
"itemsPerPage",
"(",
"resultsPerPage",
")",
".",
"pageNumber",
"(",
"pageNumber",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Page number must be an integer value greater than zero",
"\"",
")",
";",
"}",
"return",
"requestURL",
";",
"}",
"/**\r\n * A helper method used to put the URL together to query the API at thesession.org for an activity\r\n * stream for a specific item, e.g. for retrieving details of all recent activity relating to a\r\n * particular tune or session etc.\r\n * \r\n * @param dataCategory The category of data to be queried, e.g. tunes, discussions, events etc.\r\n * @param itemID The numeric ID in thesession.org database of the item being queried\r\n * @return A URL specifying the activity stream for a particular item on thesession.org\r\n * @throws MalformedURLException if the UrlBuilder.buildURL static method throws a MalformedURLException\r\n * @throws URISyntaxException if the UrlBuilder.buildURL static method throws a URISyntaxException\r\n */",
"private",
"static",
"URL",
"composeURLSingleItem",
"(",
"DataCategory",
"dataCategory",
",",
"int",
"itemID",
")",
"throws",
"MalformedURLException",
",",
"URISyntaxException",
"{",
"URL",
"requestURL",
";",
"URLComposer",
"builder",
"=",
"new",
"URLComposer",
"(",
")",
";",
"requestURL",
"=",
"builder",
".",
"new",
"Builder",
"(",
")",
".",
"requestType",
"(",
"RequestType",
".",
"SINGLE_ITEM",
")",
".",
"path",
"(",
"dataCategory",
"+",
"\"",
"/",
"\"",
"+",
"itemID",
"+",
"\"",
"/activity",
"\"",
")",
".",
"build",
"(",
")",
";",
"return",
"requestURL",
";",
"}",
"}"
] | Query thesession.org API for an activity stream and parse the response into a usable structure | [
"Query",
"thesession",
".",
"org",
"API",
"for",
"an",
"activity",
"stream",
"and",
"parse",
"the",
"response",
"into",
"a",
"usable",
"structure"
] | [
"// Make the API call, parse the response into a wrapper, and return the wrapper\r",
"// Make the API call, parse the response into a wrapper, and return the wrapper\r",
"// Make the API call, parse the response into a wrapper, and return the wrapper\r",
"// Handle cases where a data category is provided that does not have an activity stream\r",
"// Make the API call, parse the response into a wrapper, and return the wrapper\r",
"// Handle cases where a data category is provided that does not have an activity stream\r",
"// Make the API call, parse the response into a wrapper, and return the wrapper\r",
"// Handle cases where a data category is provided that does not have an activity stream\r",
"// Make the API call, parse the response into a wrapper, and return the wrapper\r",
"// Make the API call, parse the response into a wrapper, and return the wrapper\r",
"// Loop as many times as the count of items in the result set\r",
"// Extract the required elements from each individual search result in the JSON response\r",
"// Add the current ActivityStreamResult object to the ArrayList to be returned to the caller\r",
"// If a particular page within the response from the API is specified:\r",
"// If anything other than a positive integer was specified as the page number\r",
"// If page number is not a positive integer\r",
"// If a particular page within the response from the API is specified:\r",
"// If the page number is anything other than a positive integer\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
48567b346253543c5f7e7f3c68975fdf6bacf3a6 | gwfxp/Tutorial_Projects | java/common-util/src/main/java/com/youdaigc/util/bean/MyClassHelper.java | [
"MIT"
] | Java | MyClassHelper | /**
* Created by GaoWeiFeng on 2017-06-05.
* Common class reflection operation methods
*/ | Created by GaoWeiFeng on 2017-06-05.
Common class reflection operation methods | [
"Created",
"by",
"GaoWeiFeng",
"on",
"2017",
"-",
"06",
"-",
"05",
".",
"Common",
"class",
"reflection",
"operation",
"methods"
] | public class MyClassHelper implements Serializable{
private static final Logger logger = LoggerFactory.getLogger(MyClassHelper.class);
final public static String ClassPathStr = "classpath:";
private static final long serialVersionUID = -8691284644610550233L;
/**
* 获取Class Path 的根目录
* @return
*/
static public String getClassPathRootPath(){
try {
return MyClassHelper.class.getResource("/").toURI().getPath();
} catch (URISyntaxException e) {
logger.error(e.getMessage(), e);
}
return null;
}
/**
* 获取指定路径的真实全路径
* 如果是classpath:xxxx 则会转为当前Classpath + xxxx路径
* @param originalPath
* @return
*/
static public String getAbsolutePath(String originalPath){
if(originalPath == null) {
return null;
}
StringBuilder fullPath = new StringBuilder();
if(originalPath.toLowerCase().startsWith(ClassPathStr)) {
// If Path Start with classpath:, then use relative path
fullPath.append(getClassPathRootPath());
if (!fullPath.toString().endsWith("/") && !fullPath.toString().endsWith("\\")) {
fullPath.append(File.separatorChar);
}
originalPath = originalPath.substring(ClassPathStr.length());
}
fullPath.append(originalPath);
return fullPath.toString();
}
/**
* 获取指定路径的真实全路径 (如果是classpath:xxxx 则会转为当前Classpath + xxxx路径)
*
* @param fileSuffix 文件的后缀
* @param pathName 路径的片段名称
* @return
*/
static public String getAbsolutePathEx(String fileSuffix, String... pathName){
StringBuilder fullPath = new StringBuilder();
if(pathName != null && pathName.length > 0){
boolean needAppendPathSeparator = false;
for(String path : pathName){
// 如果Path中包含ClassPath字符
if(path.toLowerCase().startsWith(ClassPathStr)) {
fullPath.append(getClassPathRootPath());
// 截取ClassPath后面的路径
path = path.substring(ClassPathStr.length());
}
// 如果已存在的路径不是分隔符结尾
if(fullPath.length() >1 && !fullPath.toString().trim().endsWith("/") && !fullPath.toString().trim().endsWith("\\")){
needAppendPathSeparator = true;
}else{
needAppendPathSeparator = false;
}
// 如果后面的字符串不是分隔符开始,且之前的字符串没有分隔符结尾,就需要自动补足分隔符
if(needAppendPathSeparator && !path.toString().trim().startsWith("/") && !path.toString().trim().startsWith("\\")){
fullPath.append(File.separatorChar);
}
fullPath.append(path);
}
}
// 添加文件后缀:
// Note: 不排除空字符串,是考虑可能出现的特殊格式要求
if(fileSuffix != null){
fullPath.append(fileSuffix);
}
return fullPath.toString();
}
/**
* 获取指定的Class中实现的所有接口
* @param sourceClass
* @return
*/
static public List<Class> getClassAllInterfaces(Class<?> sourceClass){
if(sourceClass == null) {
return null;
}
List<Class> resultList = new ArrayList<>();
List<Class> bufList;
Class<?> targetClass = sourceClass.getSuperclass();
if(targetClass != null){
// 递归获取父类的 接口
bufList = getClassAllInterfaces(targetClass);
if(bufList != null){
resultList.addAll(bufList);
}
}
// 获取当前Class实现的接口
Class[] currentClassInterfaces = sourceClass.getInterfaces();
if(currentClassInterfaces != null){
resultList.addAll(Arrays.asList(currentClassInterfaces));
}
return resultList;
}
/**
* 检查指定的Class中是否实现了 指定的接口
* @param sourceClass
* @param targetInterface
* @return
*/
static public boolean isClassImplInterfaces(Class<?> sourceClass, Class<?> targetInterface){
if(sourceClass == null || targetInterface == null) {
return false;
}
Class<?> parentClass = sourceClass.getSuperclass();
if(targetInterface.isInterface()){
// 检查当前Class的Interface实现
for(Class inf : sourceClass.getInterfaces()){
if(inf.equals(targetInterface)) {
return true;
}
}
}else {
if(sourceClass.equals(targetInterface)) {
return true;
}
}
// 递归检查父类的实现
if(parentClass != null && !parentClass.equals(Object.class)){
return isClassImplInterfaces(parentClass, targetInterface);
}
return false;
// 1. 检查当前的Class是否实现
// if(sourceClass.isAssignableFrom(targetInterface)) return true;
// else {
// Class<?> targetClass = sourceClass.getSuperclass();
// // 递归查询父类是否实现了 接口
// return isClassImplInterfaces(targetClass, targetInterface);
// }
}
/**
* 根据名字创建对应的Class
* @param classFullName
* @return
*/
static public Class getClassFromName(String classFullName){
if(StringUtils.isNoneBlank(classFullName)){
try {
return Class.forName(classFullName);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
return null;
}
/**
* 根据指定的Class名称创建对应Class的实例对象
* @param classFullName : 需要实例化的对象Class全名
* @param constructorAgrs 需要实例化的对象构造式的必须参数
* @return
*/
static public <T> T getClassInstance(String classFullName, Object... constructorAgrs){
Class targetClass = getClassFromName(classFullName);
if(targetClass == null) {
return null;
}
try {
if(constructorAgrs != null && constructorAgrs.length>0 && constructorAgrs[0]!=null){
Class[] argClassType = new Class[constructorAgrs.length];
for(int i=0; i<constructorAgrs.length; i++){
argClassType[i] = constructorAgrs[i].getClass();
}
return (T) targetClass.getDeclaredConstructor(argClassType).newInstance(constructorAgrs);
}else{
return (T) targetClass.newInstance();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return null;
}
/**
* 根据指定的Class名称创建对应Class的实例对象 (可以带需要初始化的参数类名)
* @param classFullName : 需要实例化的对象Class全名
* @param constructorAgrs 需要实例化的对象构造式的必须参数类的全名
* @return
*/
static public <T> T getClassInstanceWithClassNameArgs(String classFullName, String... constructorAgrs){
if(classFullName == null) {
return null;
}
Object[] param = null;
if(constructorAgrs != null && constructorAgrs.length>0 && constructorAgrs[0]!=null) {
param = new Object[constructorAgrs.length];
for (int i = 0; i < constructorAgrs.length; i++) {
param[i] = MyClassHelper.getClassInstance(constructorAgrs[i]);
}
}
return getClassInstance(classFullName, param);
}
/**
* 获取指定的类方法
*
* @param sourceClass
* @param methodName
* @param caseSenstive
* @param parameterTypes
* @return
*/
static public Method getClassMethod(final Class sourceClass, final String methodName, final boolean caseSenstive, final Class<?>... parameterTypes){
if(sourceClass == null || methodName == null) {
return null;
}
boolean matchFound = false;
for(Method method : sourceClass.getMethods()){
if(caseSenstive){
matchFound = methodName.equals(method.getName());
}else{
matchFound = methodName.equalsIgnoreCase(method.getName());
}
if(matchFound){
if(parameterTypes != null) {
if(parameterTypes.length == method.getParameterCount()){
Parameter[] parameters = method.getParameters();
for(int i=0; i<parameters.length; i++){
if(!parameters[0].getType().equals(parameterTypes[i])){
matchFound = false;
break;
}
}
}
}
if(matchFound) {
return method;
}
}
}
return null;
}
} | [
"public",
"class",
"MyClassHelper",
"implements",
"Serializable",
"{",
"private",
"static",
"final",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"MyClassHelper",
".",
"class",
")",
";",
"final",
"public",
"static",
"String",
"ClassPathStr",
"=",
"\"",
"classpath:",
"\"",
";",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"-",
"8691284644610550233L",
";",
"/**\n * 获取Class Path 的根目录\n * @return\n */",
"static",
"public",
"String",
"getClassPathRootPath",
"(",
")",
"{",
"try",
"{",
"return",
"MyClassHelper",
".",
"class",
".",
"getResource",
"(",
"\"",
"/",
"\"",
")",
".",
"toURI",
"(",
")",
".",
"getPath",
"(",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"/**\n * 获取指定路径的真实全路径\n * 如果是classpath:xxxx 则会转为当前Classpath + xxxx路径\n * @param originalPath\n * @return\n */",
"static",
"public",
"String",
"getAbsolutePath",
"(",
"String",
"originalPath",
")",
"{",
"if",
"(",
"originalPath",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuilder",
"fullPath",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"originalPath",
".",
"toLowerCase",
"(",
")",
".",
"startsWith",
"(",
"ClassPathStr",
")",
")",
"{",
"fullPath",
".",
"append",
"(",
"getClassPathRootPath",
"(",
")",
")",
";",
"if",
"(",
"!",
"fullPath",
".",
"toString",
"(",
")",
".",
"endsWith",
"(",
"\"",
"/",
"\"",
")",
"&&",
"!",
"fullPath",
".",
"toString",
"(",
")",
".",
"endsWith",
"(",
"\"",
"\\\\",
"\"",
")",
")",
"{",
"fullPath",
".",
"append",
"(",
"File",
".",
"separatorChar",
")",
";",
"}",
"originalPath",
"=",
"originalPath",
".",
"substring",
"(",
"ClassPathStr",
".",
"length",
"(",
")",
")",
";",
"}",
"fullPath",
".",
"append",
"(",
"originalPath",
")",
";",
"return",
"fullPath",
".",
"toString",
"(",
")",
";",
"}",
"/**\n * 获取指定路径的真实全路径 (如果是classpath:xxxx 则会转为当前Classpath + xxxx路径)\n *\n * @param fileSuffix 文件的后缀\n * @param pathName 路径的片段名称\n * @return\n */",
"static",
"public",
"String",
"getAbsolutePathEx",
"(",
"String",
"fileSuffix",
",",
"String",
"...",
"pathName",
")",
"{",
"StringBuilder",
"fullPath",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"pathName",
"!=",
"null",
"&&",
"pathName",
".",
"length",
">",
"0",
")",
"{",
"boolean",
"needAppendPathSeparator",
"=",
"false",
";",
"for",
"(",
"String",
"path",
":",
"pathName",
")",
"{",
"if",
"(",
"path",
".",
"toLowerCase",
"(",
")",
".",
"startsWith",
"(",
"ClassPathStr",
")",
")",
"{",
"fullPath",
".",
"append",
"(",
"getClassPathRootPath",
"(",
")",
")",
";",
"path",
"=",
"path",
".",
"substring",
"(",
"ClassPathStr",
".",
"length",
"(",
")",
")",
";",
"}",
"if",
"(",
"fullPath",
".",
"length",
"(",
")",
">",
"1",
"&&",
"!",
"fullPath",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
".",
"endsWith",
"(",
"\"",
"/",
"\"",
")",
"&&",
"!",
"fullPath",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
".",
"endsWith",
"(",
"\"",
"\\\\",
"\"",
")",
")",
"{",
"needAppendPathSeparator",
"=",
"true",
";",
"}",
"else",
"{",
"needAppendPathSeparator",
"=",
"false",
";",
"}",
"if",
"(",
"needAppendPathSeparator",
"&&",
"!",
"path",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
".",
"startsWith",
"(",
"\"",
"/",
"\"",
")",
"&&",
"!",
"path",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
".",
"startsWith",
"(",
"\"",
"\\\\",
"\"",
")",
")",
"{",
"fullPath",
".",
"append",
"(",
"File",
".",
"separatorChar",
")",
";",
"}",
"fullPath",
".",
"append",
"(",
"path",
")",
";",
"}",
"}",
"if",
"(",
"fileSuffix",
"!=",
"null",
")",
"{",
"fullPath",
".",
"append",
"(",
"fileSuffix",
")",
";",
"}",
"return",
"fullPath",
".",
"toString",
"(",
")",
";",
"}",
"/**\n * 获取指定的Class中实现的所有接口\n * @param sourceClass\n * @return\n */",
"static",
"public",
"List",
"<",
"Class",
">",
"getClassAllInterfaces",
"(",
"Class",
"<",
"?",
">",
"sourceClass",
")",
"{",
"if",
"(",
"sourceClass",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"Class",
">",
"resultList",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"List",
"<",
"Class",
">",
"bufList",
";",
"Class",
"<",
"?",
">",
"targetClass",
"=",
"sourceClass",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"targetClass",
"!=",
"null",
")",
"{",
"bufList",
"=",
"getClassAllInterfaces",
"(",
"targetClass",
")",
";",
"if",
"(",
"bufList",
"!=",
"null",
")",
"{",
"resultList",
".",
"addAll",
"(",
"bufList",
")",
";",
"}",
"}",
"Class",
"[",
"]",
"currentClassInterfaces",
"=",
"sourceClass",
".",
"getInterfaces",
"(",
")",
";",
"if",
"(",
"currentClassInterfaces",
"!=",
"null",
")",
"{",
"resultList",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"currentClassInterfaces",
")",
")",
";",
"}",
"return",
"resultList",
";",
"}",
"/**\n * 检查指定的Class中是否实现了 指定的接口\n * @param sourceClass\n * @param targetInterface\n * @return\n */",
"static",
"public",
"boolean",
"isClassImplInterfaces",
"(",
"Class",
"<",
"?",
">",
"sourceClass",
",",
"Class",
"<",
"?",
">",
"targetInterface",
")",
"{",
"if",
"(",
"sourceClass",
"==",
"null",
"||",
"targetInterface",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"Class",
"<",
"?",
">",
"parentClass",
"=",
"sourceClass",
".",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"targetInterface",
".",
"isInterface",
"(",
")",
")",
"{",
"for",
"(",
"Class",
"inf",
":",
"sourceClass",
".",
"getInterfaces",
"(",
")",
")",
"{",
"if",
"(",
"inf",
".",
"equals",
"(",
"targetInterface",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"sourceClass",
".",
"equals",
"(",
"targetInterface",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"parentClass",
"!=",
"null",
"&&",
"!",
"parentClass",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
"{",
"return",
"isClassImplInterfaces",
"(",
"parentClass",
",",
"targetInterface",
")",
";",
"}",
"return",
"false",
";",
"}",
"/**\n * 根据名字创建对应的Class\n * @param classFullName\n * @return\n */",
"static",
"public",
"Class",
"getClassFromName",
"(",
"String",
"classFullName",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNoneBlank",
"(",
"classFullName",
")",
")",
"{",
"try",
"{",
"return",
"Class",
".",
"forName",
"(",
"classFullName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"/**\n * 根据指定的Class名称创建对应Class的实例对象\n * @param classFullName : 需要实例化的对象Class全名\n * @param constructorAgrs 需要实例化的对象构造式的必须参数\n * @return\n */",
"static",
"public",
"<",
"T",
">",
"T",
"getClassInstance",
"(",
"String",
"classFullName",
",",
"Object",
"...",
"constructorAgrs",
")",
"{",
"Class",
"targetClass",
"=",
"getClassFromName",
"(",
"classFullName",
")",
";",
"if",
"(",
"targetClass",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"if",
"(",
"constructorAgrs",
"!=",
"null",
"&&",
"constructorAgrs",
".",
"length",
">",
"0",
"&&",
"constructorAgrs",
"[",
"0",
"]",
"!=",
"null",
")",
"{",
"Class",
"[",
"]",
"argClassType",
"=",
"new",
"Class",
"[",
"constructorAgrs",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"constructorAgrs",
".",
"length",
";",
"i",
"++",
")",
"{",
"argClassType",
"[",
"i",
"]",
"=",
"constructorAgrs",
"[",
"i",
"]",
".",
"getClass",
"(",
")",
";",
"}",
"return",
"(",
"T",
")",
"targetClass",
".",
"getDeclaredConstructor",
"(",
"argClassType",
")",
".",
"newInstance",
"(",
"constructorAgrs",
")",
";",
"}",
"else",
"{",
"return",
"(",
"T",
")",
"targetClass",
".",
"newInstance",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"/**\n * 根据指定的Class名称创建对应Class的实例对象 (可以带需要初始化的参数类名)\n * @param classFullName : 需要实例化的对象Class全名\n * @param constructorAgrs 需要实例化的对象构造式的必须参数类的全名\n * @return\n */",
"static",
"public",
"<",
"T",
">",
"T",
"getClassInstanceWithClassNameArgs",
"(",
"String",
"classFullName",
",",
"String",
"...",
"constructorAgrs",
")",
"{",
"if",
"(",
"classFullName",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Object",
"[",
"]",
"param",
"=",
"null",
";",
"if",
"(",
"constructorAgrs",
"!=",
"null",
"&&",
"constructorAgrs",
".",
"length",
">",
"0",
"&&",
"constructorAgrs",
"[",
"0",
"]",
"!=",
"null",
")",
"{",
"param",
"=",
"new",
"Object",
"[",
"constructorAgrs",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"constructorAgrs",
".",
"length",
";",
"i",
"++",
")",
"{",
"param",
"[",
"i",
"]",
"=",
"MyClassHelper",
".",
"getClassInstance",
"(",
"constructorAgrs",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"getClassInstance",
"(",
"classFullName",
",",
"param",
")",
";",
"}",
"/**\n * 获取指定的类方法\n *\n * @param sourceClass\n * @param methodName\n * @param caseSenstive\n * @param parameterTypes\n * @return\n */",
"static",
"public",
"Method",
"getClassMethod",
"(",
"final",
"Class",
"sourceClass",
",",
"final",
"String",
"methodName",
",",
"final",
"boolean",
"caseSenstive",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"parameterTypes",
")",
"{",
"if",
"(",
"sourceClass",
"==",
"null",
"||",
"methodName",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"boolean",
"matchFound",
"=",
"false",
";",
"for",
"(",
"Method",
"method",
":",
"sourceClass",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"caseSenstive",
")",
"{",
"matchFound",
"=",
"methodName",
".",
"equals",
"(",
"method",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"matchFound",
"=",
"methodName",
".",
"equalsIgnoreCase",
"(",
"method",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"matchFound",
")",
"{",
"if",
"(",
"parameterTypes",
"!=",
"null",
")",
"{",
"if",
"(",
"parameterTypes",
".",
"length",
"==",
"method",
".",
"getParameterCount",
"(",
")",
")",
"{",
"Parameter",
"[",
"]",
"parameters",
"=",
"method",
".",
"getParameters",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parameters",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"parameters",
"[",
"0",
"]",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"parameterTypes",
"[",
"i",
"]",
")",
")",
"{",
"matchFound",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"matchFound",
")",
"{",
"return",
"method",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}",
"}"
] | Created by GaoWeiFeng on 2017-06-05. | [
"Created",
"by",
"GaoWeiFeng",
"on",
"2017",
"-",
"06",
"-",
"05",
"."
] | [
"// If Path Start with classpath:, then use relative path",
"// 如果Path中包含ClassPath字符",
"// 截取ClassPath后面的路径",
"// 如果已存在的路径不是分隔符结尾",
"// 如果后面的字符串不是分隔符开始,且之前的字符串没有分隔符结尾,就需要自动补足分隔符",
"// 添加文件后缀:",
"// Note: 不排除空字符串,是考虑可能出现的特殊格式要求",
"// 递归获取父类的 接口",
"// 获取当前Class实现的接口",
"// 检查当前Class的Interface实现",
"// 递归检查父类的实现",
"// 1. 检查当前的Class是否实现",
"// if(sourceClass.isAssignableFrom(targetInterface)) return true;",
"// else {",
"// Class<?> targetClass = sourceClass.getSuperclass();",
"// // 递归查询父类是否实现了 接口",
"// return isClassImplInterfaces(targetClass, targetInterface);",
"// }"
] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
485a02706a7e61ffb2925c30d0ed85dcfcb5e5bd | andyChenHuaYing/spring-boot-demo | sbd-tomcat-jsp/src/main/java/org/oscar/demo/tomcat/jsp/WelcomeController.java | [
"Apache-2.0"
] | Java | WelcomeController | /**
* Description:
* <p>
* Author: oscar
* Create Date: 14/11/16
* Version: 1.0-SNAPSHOT
*/ |
Author: oscar
Create Date: 14/11/16
Version: 1.0-SNAPSHOT | [
"Author",
":",
"oscar",
"Create",
"Date",
":",
"14",
"/",
"11",
"/",
"16",
"Version",
":",
"1",
".",
"0",
"-",
"SNAPSHOT"
] | @Controller
public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello Jsp";
@GetMapping("/")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);
return "welcome";
}
@RequestMapping("/fail")
public String fail() {
throw new MyException("Oh dear!");
}
/**
* None RuntimeException
*/
@RequestMapping("/fail2")
public String fail2() {
throw new IllegalStateException();
}
} | [
"@",
"Controller",
"public",
"class",
"WelcomeController",
"{",
"@",
"Value",
"(",
"\"",
"${application.message:Hello World}",
"\"",
")",
"private",
"String",
"message",
"=",
"\"",
"Hello Jsp",
"\"",
";",
"@",
"GetMapping",
"(",
"\"",
"/",
"\"",
")",
"public",
"String",
"welcome",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"model",
")",
"{",
"model",
".",
"put",
"(",
"\"",
"time",
"\"",
",",
"new",
"Date",
"(",
")",
")",
";",
"model",
".",
"put",
"(",
"\"",
"message",
"\"",
",",
"this",
".",
"message",
")",
";",
"return",
"\"",
"welcome",
"\"",
";",
"}",
"@",
"RequestMapping",
"(",
"\"",
"/fail",
"\"",
")",
"public",
"String",
"fail",
"(",
")",
"{",
"throw",
"new",
"MyException",
"(",
"\"",
"Oh dear!",
"\"",
")",
";",
"}",
"/**\n * None RuntimeException\n */",
"@",
"RequestMapping",
"(",
"\"",
"/fail2",
"\"",
")",
"public",
"String",
"fail2",
"(",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"}",
"}"
] | Description:
<p>
Author: oscar
Create Date: 14/11/16
Version: 1.0-SNAPSHOT | [
"Description",
":",
"<p",
">",
"Author",
":",
"oscar",
"Create",
"Date",
":",
"14",
"/",
"11",
"/",
"16",
"Version",
":",
"1",
".",
"0",
"-",
"SNAPSHOT"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
485c49f9ee43a5b0b7866ee8218cdf24d136f73b | knowhowlab/org.knowhowlab.comm.testing | org.knowhowlab.comm.testing.it/org.knowhowlab.comm.testing.it.osgi.pax.exam/src/test/java/org/knowhowlab/comm/testing/it/osgi/tests/AbstractTest.java | [
"Apache-2.0"
] | Java | AbstractTest | /**
* Abstract test with all initializations
*
* @author dmytro.pishchukhin
*/ | Abstract test with all initializations
@author dmytro.pishchukhin | [
"Abstract",
"test",
"with",
"all",
"initializations",
"@author",
"dmytro",
".",
"pishchukhin"
] | @RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public abstract class AbstractTest {
/**
* Injected BundleContext
*/
@Inject
protected BundleContext bc;
@Before
public void init() {
OSGiAssert.setDefaultBundleContext(bc);
}
/**
* Runner config
*
* @return config
*/
protected static Option[] baseConfiguration(Option... extraOptions) {
Option[] options = options(
junitBundles(),
// list of bundles that should be installed
mavenBundle("org.osgi", "org.osgi.compendium", "4.2.0"),
mavenBundle().groupId("org.knowhowlab.osgi").artifactId("org.knowhowlab.osgi.testing.all").version("1.3.0"),
systemProperty("project.version").value(System.getProperty("project.version")),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
);
if (extraOptions != null) {
options = combine(options, extraOptions);
}
return options;
}
} | [
"@",
"RunWith",
"(",
"PaxExam",
".",
"class",
")",
"@",
"ExamReactorStrategy",
"(",
"PerMethod",
".",
"class",
")",
"public",
"abstract",
"class",
"AbstractTest",
"{",
"/**\n * Injected BundleContext\n */",
"@",
"Inject",
"protected",
"BundleContext",
"bc",
";",
"@",
"Before",
"public",
"void",
"init",
"(",
")",
"{",
"OSGiAssert",
".",
"setDefaultBundleContext",
"(",
"bc",
")",
";",
"}",
"/**\n * Runner config\n *\n * @return config\n */",
"protected",
"static",
"Option",
"[",
"]",
"baseConfiguration",
"(",
"Option",
"...",
"extraOptions",
")",
"{",
"Option",
"[",
"]",
"options",
"=",
"options",
"(",
"junitBundles",
"(",
")",
",",
"mavenBundle",
"(",
"\"",
"org.osgi",
"\"",
",",
"\"",
"org.osgi.compendium",
"\"",
",",
"\"",
"4.2.0",
"\"",
")",
",",
"mavenBundle",
"(",
")",
".",
"groupId",
"(",
"\"",
"org.knowhowlab.osgi",
"\"",
")",
".",
"artifactId",
"(",
"\"",
"org.knowhowlab.osgi.testing.all",
"\"",
")",
".",
"version",
"(",
"\"",
"1.3.0",
"\"",
")",
",",
"systemProperty",
"(",
"\"",
"project.version",
"\"",
")",
".",
"value",
"(",
"System",
".",
"getProperty",
"(",
"\"",
"project.version",
"\"",
")",
")",
",",
"systemProperty",
"(",
"\"",
"org.ops4j.pax.logging.DefaultServiceLog.level",
"\"",
")",
".",
"value",
"(",
"\"",
"WARN",
"\"",
")",
")",
";",
"if",
"(",
"extraOptions",
"!=",
"null",
")",
"{",
"options",
"=",
"combine",
"(",
"options",
",",
"extraOptions",
")",
";",
"}",
"return",
"options",
";",
"}",
"}"
] | Abstract test with all initializations
@author dmytro.pishchukhin | [
"Abstract",
"test",
"with",
"all",
"initializations",
"@author",
"dmytro",
".",
"pishchukhin"
] | [
"// list of bundles that should be installed"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4866c541338a04136f0491ecb0d9a6251fcbade5 | timfel/netbeans | ide/editor.settings.storage/test/unit/src/org/netbeans/modules/editor/settings/storage/preferences/PreferencesTest.java | [
"Apache-2.0"
] | Java | PreferencesTest | /**
*
* @author Vita Stejskal
*/ | @author Vita Stejskal | [
"@author",
"Vita",
"Stejskal"
] | public class PreferencesTest extends NbTestCase {
public PreferencesTest(String name) {
super(name);
}
protected @Override void setUp() throws Exception {
super.setUp();
clearWorkDir();
EditorTestLookup.setLookup(
new URL[] {
getClass().getClassLoader().getResource(
"org/netbeans/modules/editor/settings/storage/preferences/test-layer-PreferencesStorageTest.xml"),
getClass().getClassLoader().getResource(
"org/netbeans/modules/editor/settings/storage/layer.xml"),
getClass().getClassLoader().getResource(
"org/netbeans/core/resources/mf-layer.xml"), // for MIMEResolverImpl to work
},
getWorkDir(),
new Object[] {},
getClass().getClassLoader()
);
// This is here to initialize Nb URL factory (org.netbeans.core.startup),
// which is needed by Nb EntityCatalog (org.netbeans.core).
// Also see the test dependencies in project.xml
Main.initializeURLFactory();
}
public static TestSuite suite() {
NbTestSuite suite = new NbTestSuite();
suite.addTest(new PreferencesTest("testSimple"));
suite.addTest(new PreferencesTest("testWriting"));
suite.addTest(new PreferencesTest("testEvents1"));
suite.addTest(new PreferencesTest("testEvents2"));
suite.addTest(new PreferencesTest("testEvents142723"));
return suite;
}
public void testSimple() {
Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
assertEquals("Wrong value for 'simple-value-setting-A'", "value-A", prefs.get("simple-value-setting-A", null));
assertEquals("Wrong value for 'localized-setting'", "Hey! This is the value from Bundle.properties!!!", prefs.get("localized-setting", null));
prefs = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
// inherited from MimePath.EMPTY
assertEquals("Wrong value for 'simple-value-setting-A'", "value-A", prefs.get("simple-value-setting-A", null));
assertEquals("Wrong value for 'localized-setting'", "Hey! This is the value from Bundle.properties!!!", prefs.get("localized-setting", null));
// from text/x-testA
assertEquals("Wrong value for 'testA-1-setting-1'", "value-of-testA-1-setting-1", prefs.get("testA-1-setting-1", null));
assertEquals("Wrong value for 'testA-1-setting-2'", "The-Default-Value", prefs.get("testA-1-setting-2", "The-Default-Value"));
assertEquals("Wrong value for 'testA-1-setting-3'", "value-of-testA-1-setting-3-from-testA-2", prefs.get("testA-1-setting-3", null));
assertEquals("Wrong value for 'testA-2-setting-1'", "value-of-testA-2-setting-1", prefs.get("testA-2-setting-1", null));
}
public void testWriting() throws Exception {
{
Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
assertEquals("Wrong value for 'simple-value-setting-A'", "value-A", prefs.get("simple-value-setting-A", null));
prefs.put("simple-value-setting-A", "New-Written-Value");
assertEquals("Wrong value for 'simple-value-setting-A'", "New-Written-Value", prefs.get("simple-value-setting-A", null));
prefs.sync();
}
{
// read the settings right from the file
StorageImpl<String, TypedValue> storage = new StorageImpl<String, TypedValue>(new PreferencesStorage(), null);
Map<String, TypedValue> map = storage.load(MimePath.EMPTY, null, false);
assertEquals("Wrong value for 'simple-value-setting-A'", "New-Written-Value", map.get("simple-value-setting-A").getValue());
}
}
public void testEvents1() throws Exception {
Preferences prefsA = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
L listenerA = new L();
prefsA.addPreferenceChangeListener(listenerA);
Preferences prefsB = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
L listenerB = new L();
prefsB.addPreferenceChangeListener(listenerB);
assertNotNull("'simple-value-setting-A' should not be null", prefsA.get("simple-value-setting-A", null));
assertNotNull("'simple-value-setting-A' should not be null", prefsB.get("simple-value-setting-A", null));
assertEquals("Wrong value for 'testA-1-setting-1'", "value-of-testA-1-setting-1", prefsB.get("testA-1-setting-1", null));
assertEquals("There should be no A events", 0, listenerA.count);
assertEquals("There should be no B events", 0, listenerB.count);
prefsA.put("simple-value-setting-A", "new-value");
assertEquals("Wrong value for 'simple-value-setting-A'", "new-value", prefsA.get("simple-value-setting-A", null));
assertEquals("The value for 'simple-value-setting-A' was not propagated", "new-value", prefsB.get("simple-value-setting-A", null));
Thread.sleep(500);
assertEquals("Wrong number of A events", 1, listenerA.count);
assertEquals("Wrong setting name in the A event", "simple-value-setting-A", listenerA.lastEvent.getKey());
assertEquals("Wrong setting value in the A event", "new-value", listenerA.lastEvent.getNewValue());
assertSame("Wrong Preferences instance in the A event", prefsA, listenerA.lastEvent.getNode());
assertEquals("Wrong number of B events", 1, listenerB.count);
assertEquals("Wrong setting name in the B event", "simple-value-setting-A", listenerB.lastEvent.getKey());
assertEquals("Wrong setting value in the B event", "new-value", listenerB.lastEvent.getNewValue());
assertSame("Wrong Preferences instance in the B event", prefsB, listenerB.lastEvent.getNode());
}
public void testEvents2() throws Exception {
Preferences prefsA = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
L listenerA = new L();
prefsA.addPreferenceChangeListener(listenerA);
Preferences prefsB = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
L listenerB = new L();
prefsB.addPreferenceChangeListener(listenerB);
String origValue = prefsA.get("simple-value-setting-A", null);
assertNotNull("'simple-value-setting-A' should not be null", origValue);
assertNotNull("'simple-value-setting-A' should not be null", prefsB.get("simple-value-setting-A", null));
assertEquals("Wrong value for 'testA-1-setting-1'", "value-of-testA-1-setting-1", prefsB.get("testA-1-setting-1", null));
assertEquals("There should be no A events", 0, listenerA.count);
assertEquals("There should be no B events", 0, listenerB.count);
prefsB.put("simple-value-setting-A", "another-value-for-testA");
assertEquals("Wrong value for 'simple-value-setting-A'", origValue, prefsA.get("simple-value-setting-A", null));
assertEquals("Wrong value for 'simple-value-setting-A' in 'text/x-testA'", "another-value-for-testA", prefsB.get("simple-value-setting-A", null));
Thread.sleep(500);
assertEquals("Wrong number of A events", 0, listenerA.count);
assertEquals("Wrong number of B events", 1, listenerB.count);
assertEquals("Wrong setting name in the B event", "simple-value-setting-A", listenerB.lastEvent.getKey());
assertEquals("Wrong setting value in the B event", "another-value-for-testA", listenerB.lastEvent.getNewValue());
assertSame("Wrong Preferences instance in the B event", prefsB, listenerB.lastEvent.getNode());
listenerA.count = 0; listenerA.lastEvent = null;
listenerB.count = 0; listenerB.lastEvent = null;
// now change the value in MimeType.EMPTY
prefsA.put("simple-value-setting-A", "another-value-for-MimeType.EMPTY");
assertEquals("Wrong value for 'simple-value-setting-A'", "another-value-for-MimeType.EMPTY", prefsA.get("simple-value-setting-A", null));
assertEquals("Wrong value for 'simple-value-setting-A' in 'text/x-testA'", "another-value-for-testA", prefsB.get("simple-value-setting-A", null));
Thread.sleep(500);
assertEquals("Wrong number of A events", 1, listenerA.count);
assertEquals("Wrong setting name in the A event", "simple-value-setting-A", listenerA.lastEvent.getKey());
assertEquals("Wrong setting value in the A event", "another-value-for-MimeType.EMPTY", listenerA.lastEvent.getNewValue());
assertSame("Wrong Preferences instance in the A event", prefsA, listenerA.lastEvent.getNode());
assertEquals("Wrong number of B events", 0, listenerB.count);
}
@RandomlyFails
public void testEvents142723() throws Exception {
Preferences prefsA = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
Preferences prefsB = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
String key1 = "all-lang-key-" + getName();
prefsA.put(key1, "xyz");
assertEquals("'" + key1 + "' has wrong value", "xyz", prefsA.get(key1, null));
// attach listeners
L listenerA = new L();
prefsA.addPreferenceChangeListener(listenerA);
L listenerB = new L();
prefsB.addPreferenceChangeListener(listenerB);
// putting the same value again should not fire an event
prefsA.put(key1, "xyz");
assertEquals("'" + key1 + "' has wrong value", "xyz", prefsA.get(key1, null));
assertEquals("There should be no events from prefsA", 0, listenerA.count);
assertEquals("'" + key1 + "' should inherit the value", "xyz", prefsB.get(key1, null));
assertEquals("There should be no events from prefsB", 0, listenerB.count);
// putting the same value again should not fire an event
prefsB.put(key1, "xyz");
assertEquals("'" + key1 + "' has wrong value in prefsB", "xyz", prefsB.get(key1, null));
assertEquals("There should still be no events from prefsB", 0, listenerB.count);
}
private static final class L implements PreferenceChangeListener {
public int count = 0;
public PreferenceChangeEvent lastEvent = null;
public void preferenceChange(PreferenceChangeEvent evt) {
count++;
lastEvent = evt;
}
} // End of L class
} | [
"public",
"class",
"PreferencesTest",
"extends",
"NbTestCase",
"{",
"public",
"PreferencesTest",
"(",
"String",
"name",
")",
"{",
"super",
"(",
"name",
")",
";",
"}",
"protected",
"@",
"Override",
"void",
"setUp",
"(",
")",
"throws",
"Exception",
"{",
"super",
".",
"setUp",
"(",
")",
";",
"clearWorkDir",
"(",
")",
";",
"EditorTestLookup",
".",
"setLookup",
"(",
"new",
"URL",
"[",
"]",
"{",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"",
"org/netbeans/modules/editor/settings/storage/preferences/test-layer-PreferencesStorageTest.xml",
"\"",
")",
",",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"",
"org/netbeans/modules/editor/settings/storage/layer.xml",
"\"",
")",
",",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"\"",
"org/netbeans/core/resources/mf-layer.xml",
"\"",
")",
",",
"}",
",",
"getWorkDir",
"(",
")",
",",
"new",
"Object",
"[",
"]",
"{",
"}",
",",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
")",
";",
"Main",
".",
"initializeURLFactory",
"(",
")",
";",
"}",
"public",
"static",
"TestSuite",
"suite",
"(",
")",
"{",
"NbTestSuite",
"suite",
"=",
"new",
"NbTestSuite",
"(",
")",
";",
"suite",
".",
"addTest",
"(",
"new",
"PreferencesTest",
"(",
"\"",
"testSimple",
"\"",
")",
")",
";",
"suite",
".",
"addTest",
"(",
"new",
"PreferencesTest",
"(",
"\"",
"testWriting",
"\"",
")",
")",
";",
"suite",
".",
"addTest",
"(",
"new",
"PreferencesTest",
"(",
"\"",
"testEvents1",
"\"",
")",
")",
";",
"suite",
".",
"addTest",
"(",
"new",
"PreferencesTest",
"(",
"\"",
"testEvents2",
"\"",
")",
")",
";",
"suite",
".",
"addTest",
"(",
"new",
"PreferencesTest",
"(",
"\"",
"testEvents142723",
"\"",
")",
")",
";",
"return",
"suite",
";",
"}",
"public",
"void",
"testSimple",
"(",
")",
"{",
"Preferences",
"prefs",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"EMPTY",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"\"",
"value-A",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'localized-setting'",
"\"",
",",
"\"",
"Hey! This is the value from Bundle.properties!!!",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"localized-setting",
"\"",
",",
"null",
")",
")",
";",
"prefs",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"parse",
"(",
"\"",
"text/x-testA",
"\"",
")",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"\"",
"value-A",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'localized-setting'",
"\"",
",",
"\"",
"Hey! This is the value from Bundle.properties!!!",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"localized-setting",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'testA-1-setting-1'",
"\"",
",",
"\"",
"value-of-testA-1-setting-1",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"testA-1-setting-1",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'testA-1-setting-2'",
"\"",
",",
"\"",
"The-Default-Value",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"testA-1-setting-2",
"\"",
",",
"\"",
"The-Default-Value",
"\"",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'testA-1-setting-3'",
"\"",
",",
"\"",
"value-of-testA-1-setting-3-from-testA-2",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"testA-1-setting-3",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'testA-2-setting-1'",
"\"",
",",
"\"",
"value-of-testA-2-setting-1",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"testA-2-setting-1",
"\"",
",",
"null",
")",
")",
";",
"}",
"public",
"void",
"testWriting",
"(",
")",
"throws",
"Exception",
"{",
"{",
"Preferences",
"prefs",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"EMPTY",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"\"",
"value-A",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"prefs",
".",
"put",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"\"",
"New-Written-Value",
"\"",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"\"",
"New-Written-Value",
"\"",
",",
"prefs",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"prefs",
".",
"sync",
"(",
")",
";",
"}",
"{",
"StorageImpl",
"<",
"String",
",",
"TypedValue",
">",
"storage",
"=",
"new",
"StorageImpl",
"<",
"String",
",",
"TypedValue",
">",
"(",
"new",
"PreferencesStorage",
"(",
")",
",",
"null",
")",
";",
"Map",
"<",
"String",
",",
"TypedValue",
">",
"map",
"=",
"storage",
".",
"load",
"(",
"MimePath",
".",
"EMPTY",
",",
"null",
",",
"false",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"\"",
"New-Written-Value",
"\"",
",",
"map",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"public",
"void",
"testEvents1",
"(",
")",
"throws",
"Exception",
"{",
"Preferences",
"prefsA",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"EMPTY",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"L",
"listenerA",
"=",
"new",
"L",
"(",
")",
";",
"prefsA",
".",
"addPreferenceChangeListener",
"(",
"listenerA",
")",
";",
"Preferences",
"prefsB",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"parse",
"(",
"\"",
"text/x-testA",
"\"",
")",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"L",
"listenerB",
"=",
"new",
"L",
"(",
")",
";",
"prefsB",
".",
"addPreferenceChangeListener",
"(",
"listenerB",
")",
";",
"assertNotNull",
"(",
"\"",
"'simple-value-setting-A' should not be null",
"\"",
",",
"prefsA",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertNotNull",
"(",
"\"",
"'simple-value-setting-A' should not be null",
"\"",
",",
"prefsB",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'testA-1-setting-1'",
"\"",
",",
"\"",
"value-of-testA-1-setting-1",
"\"",
",",
"prefsB",
".",
"get",
"(",
"\"",
"testA-1-setting-1",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"There should be no A events",
"\"",
",",
"0",
",",
"listenerA",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"There should be no B events",
"\"",
",",
"0",
",",
"listenerB",
".",
"count",
")",
";",
"prefsA",
".",
"put",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"\"",
"new-value",
"\"",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"\"",
"new-value",
"\"",
",",
"prefsA",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"The value for 'simple-value-setting-A' was not propagated",
"\"",
",",
"\"",
"new-value",
"\"",
",",
"prefsB",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong number of A events",
"\"",
",",
"1",
",",
"listenerA",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting name in the A event",
"\"",
",",
"\"",
"simple-value-setting-A",
"\"",
",",
"listenerA",
".",
"lastEvent",
".",
"getKey",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting value in the A event",
"\"",
",",
"\"",
"new-value",
"\"",
",",
"listenerA",
".",
"lastEvent",
".",
"getNewValue",
"(",
")",
")",
";",
"assertSame",
"(",
"\"",
"Wrong Preferences instance in the A event",
"\"",
",",
"prefsA",
",",
"listenerA",
".",
"lastEvent",
".",
"getNode",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong number of B events",
"\"",
",",
"1",
",",
"listenerB",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting name in the B event",
"\"",
",",
"\"",
"simple-value-setting-A",
"\"",
",",
"listenerB",
".",
"lastEvent",
".",
"getKey",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting value in the B event",
"\"",
",",
"\"",
"new-value",
"\"",
",",
"listenerB",
".",
"lastEvent",
".",
"getNewValue",
"(",
")",
")",
";",
"assertSame",
"(",
"\"",
"Wrong Preferences instance in the B event",
"\"",
",",
"prefsB",
",",
"listenerB",
".",
"lastEvent",
".",
"getNode",
"(",
")",
")",
";",
"}",
"public",
"void",
"testEvents2",
"(",
")",
"throws",
"Exception",
"{",
"Preferences",
"prefsA",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"EMPTY",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"L",
"listenerA",
"=",
"new",
"L",
"(",
")",
";",
"prefsA",
".",
"addPreferenceChangeListener",
"(",
"listenerA",
")",
";",
"Preferences",
"prefsB",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"parse",
"(",
"\"",
"text/x-testA",
"\"",
")",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"L",
"listenerB",
"=",
"new",
"L",
"(",
")",
";",
"prefsB",
".",
"addPreferenceChangeListener",
"(",
"listenerB",
")",
";",
"String",
"origValue",
"=",
"prefsA",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
";",
"assertNotNull",
"(",
"\"",
"'simple-value-setting-A' should not be null",
"\"",
",",
"origValue",
")",
";",
"assertNotNull",
"(",
"\"",
"'simple-value-setting-A' should not be null",
"\"",
",",
"prefsB",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'testA-1-setting-1'",
"\"",
",",
"\"",
"value-of-testA-1-setting-1",
"\"",
",",
"prefsB",
".",
"get",
"(",
"\"",
"testA-1-setting-1",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"There should be no A events",
"\"",
",",
"0",
",",
"listenerA",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"There should be no B events",
"\"",
",",
"0",
",",
"listenerB",
".",
"count",
")",
";",
"prefsB",
".",
"put",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"\"",
"another-value-for-testA",
"\"",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"origValue",
",",
"prefsA",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A' in 'text/x-testA'",
"\"",
",",
"\"",
"another-value-for-testA",
"\"",
",",
"prefsB",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong number of A events",
"\"",
",",
"0",
",",
"listenerA",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong number of B events",
"\"",
",",
"1",
",",
"listenerB",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting name in the B event",
"\"",
",",
"\"",
"simple-value-setting-A",
"\"",
",",
"listenerB",
".",
"lastEvent",
".",
"getKey",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting value in the B event",
"\"",
",",
"\"",
"another-value-for-testA",
"\"",
",",
"listenerB",
".",
"lastEvent",
".",
"getNewValue",
"(",
")",
")",
";",
"assertSame",
"(",
"\"",
"Wrong Preferences instance in the B event",
"\"",
",",
"prefsB",
",",
"listenerB",
".",
"lastEvent",
".",
"getNode",
"(",
")",
")",
";",
"listenerA",
".",
"count",
"=",
"0",
";",
"listenerA",
".",
"lastEvent",
"=",
"null",
";",
"listenerB",
".",
"count",
"=",
"0",
";",
"listenerB",
".",
"lastEvent",
"=",
"null",
";",
"prefsA",
".",
"put",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"\"",
"another-value-for-MimeType.EMPTY",
"\"",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A'",
"\"",
",",
"\"",
"another-value-for-MimeType.EMPTY",
"\"",
",",
"prefsA",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong value for 'simple-value-setting-A' in 'text/x-testA'",
"\"",
",",
"\"",
"another-value-for-testA",
"\"",
",",
"prefsB",
".",
"get",
"(",
"\"",
"simple-value-setting-A",
"\"",
",",
"null",
")",
")",
";",
"Thread",
".",
"sleep",
"(",
"500",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong number of A events",
"\"",
",",
"1",
",",
"listenerA",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting name in the A event",
"\"",
",",
"\"",
"simple-value-setting-A",
"\"",
",",
"listenerA",
".",
"lastEvent",
".",
"getKey",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong setting value in the A event",
"\"",
",",
"\"",
"another-value-for-MimeType.EMPTY",
"\"",
",",
"listenerA",
".",
"lastEvent",
".",
"getNewValue",
"(",
")",
")",
";",
"assertSame",
"(",
"\"",
"Wrong Preferences instance in the A event",
"\"",
",",
"prefsA",
",",
"listenerA",
".",
"lastEvent",
".",
"getNode",
"(",
")",
")",
";",
"assertEquals",
"(",
"\"",
"Wrong number of B events",
"\"",
",",
"0",
",",
"listenerB",
".",
"count",
")",
";",
"}",
"@",
"RandomlyFails",
"public",
"void",
"testEvents142723",
"(",
")",
"throws",
"Exception",
"{",
"Preferences",
"prefsA",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"EMPTY",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"Preferences",
"prefsB",
"=",
"MimeLookup",
".",
"getLookup",
"(",
"MimePath",
".",
"parse",
"(",
"\"",
"text/x-testA",
"\"",
")",
")",
".",
"lookup",
"(",
"Preferences",
".",
"class",
")",
";",
"String",
"key1",
"=",
"\"",
"all-lang-key-",
"\"",
"+",
"getName",
"(",
")",
";",
"prefsA",
".",
"put",
"(",
"key1",
",",
"\"",
"xyz",
"\"",
")",
";",
"assertEquals",
"(",
"\"",
"'",
"\"",
"+",
"key1",
"+",
"\"",
"' has wrong value",
"\"",
",",
"\"",
"xyz",
"\"",
",",
"prefsA",
".",
"get",
"(",
"key1",
",",
"null",
")",
")",
";",
"L",
"listenerA",
"=",
"new",
"L",
"(",
")",
";",
"prefsA",
".",
"addPreferenceChangeListener",
"(",
"listenerA",
")",
";",
"L",
"listenerB",
"=",
"new",
"L",
"(",
")",
";",
"prefsB",
".",
"addPreferenceChangeListener",
"(",
"listenerB",
")",
";",
"prefsA",
".",
"put",
"(",
"key1",
",",
"\"",
"xyz",
"\"",
")",
";",
"assertEquals",
"(",
"\"",
"'",
"\"",
"+",
"key1",
"+",
"\"",
"' has wrong value",
"\"",
",",
"\"",
"xyz",
"\"",
",",
"prefsA",
".",
"get",
"(",
"key1",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"There should be no events from prefsA",
"\"",
",",
"0",
",",
"listenerA",
".",
"count",
")",
";",
"assertEquals",
"(",
"\"",
"'",
"\"",
"+",
"key1",
"+",
"\"",
"' should inherit the value",
"\"",
",",
"\"",
"xyz",
"\"",
",",
"prefsB",
".",
"get",
"(",
"key1",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"There should be no events from prefsB",
"\"",
",",
"0",
",",
"listenerB",
".",
"count",
")",
";",
"prefsB",
".",
"put",
"(",
"key1",
",",
"\"",
"xyz",
"\"",
")",
";",
"assertEquals",
"(",
"\"",
"'",
"\"",
"+",
"key1",
"+",
"\"",
"' has wrong value in prefsB",
"\"",
",",
"\"",
"xyz",
"\"",
",",
"prefsB",
".",
"get",
"(",
"key1",
",",
"null",
")",
")",
";",
"assertEquals",
"(",
"\"",
"There should still be no events from prefsB",
"\"",
",",
"0",
",",
"listenerB",
".",
"count",
")",
";",
"}",
"private",
"static",
"final",
"class",
"L",
"implements",
"PreferenceChangeListener",
"{",
"public",
"int",
"count",
"=",
"0",
";",
"public",
"PreferenceChangeEvent",
"lastEvent",
"=",
"null",
";",
"public",
"void",
"preferenceChange",
"(",
"PreferenceChangeEvent",
"evt",
")",
"{",
"count",
"++",
";",
"lastEvent",
"=",
"evt",
";",
"}",
"}",
"}"
] | @author Vita Stejskal | [
"@author",
"Vita",
"Stejskal"
] | [
"// for MIMEResolverImpl to work",
"// This is here to initialize Nb URL factory (org.netbeans.core.startup),",
"// which is needed by Nb EntityCatalog (org.netbeans.core).",
"// Also see the test dependencies in project.xml",
"// inherited from MimePath.EMPTY",
"// from text/x-testA",
"// read the settings right from the file",
"// now change the value in MimeType.EMPTY",
"// attach listeners",
"// putting the same value again should not fire an event",
"// putting the same value again should not fire an event",
"// End of L class"
] | [
{
"param": "NbTestCase",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "NbTestCase",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
48677abbb7732448165461eccba27a741c9ee0f1 | psiroky/guvnor | guvnor-webapp-drools/src/main/java/org/drools/guvnor/client/decisiontable/ActionRetractFactPopup.java | [
"Apache-2.0"
] | Java | ActionRetractFactPopup | /**
* A popup to define the parameters of an Action to retract a Fact
*/ | A popup to define the parameters of an Action to retract a Fact | [
"A",
"popup",
"to",
"define",
"the",
"parameters",
"of",
"an",
"Action",
"to",
"retract",
"a",
"Fact"
] | public class ActionRetractFactPopup extends FormStylePopup {
private ActionRetractFactCol52 editingCol;
private GuidedDecisionTable52 model;
private BRLRuleModel rm;
public ActionRetractFactPopup(final GuidedDecisionTable52 model,
final GenericColumnCommand refreshGrid,
final ActionRetractFactCol52 col,
final boolean isNew,
final boolean isReadOnly) {
this.rm = new BRLRuleModel( model );
this.editingCol = cloneActionRetractColumn( col );
this.model = model;
setTitle( Constants.INSTANCE.ColumnConfigurationRetractAFact() );
setModal( false );
//Show available pattern bindings, if Limited Entry
if ( model.getTableFormat() == TableFormat.LIMITED_ENTRY ) {
final LimitedEntryActionRetractFactCol52 ler = (LimitedEntryActionRetractFactCol52) editingCol;
final ListBox patterns = loadBoundFacts( ler.getValue().getStringValue() );
patterns.setEnabled( !isReadOnly );
if ( !isReadOnly ) {
patterns.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent event) {
int index = patterns.getSelectedIndex();
if ( index > -1 ) {
ler.getValue().setStringValue( patterns.getValue( index ) );
}
}
} );
}
addAttribute( Constants.INSTANCE.FactToRetractColon(),
patterns );
}
//Column header
final TextBox header = new TextBox();
header.setText( col.getHeader() );
header.setEnabled( !isReadOnly );
if ( !isReadOnly ) {
header.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent event) {
editingCol.setHeader( header.getText() );
}
} );
}
addAttribute( Constants.INSTANCE.ColumnHeaderDescription(),
header );
//Hide column tick-box
addAttribute( Constants.INSTANCE.HideThisColumn(),
DTCellValueWidgetFactory.getHideColumnIndicator( editingCol ) );
Button apply = new Button( Constants.INSTANCE.ApplyChanges() );
apply.addClickHandler( new ClickHandler() {
public void onClick(ClickEvent w) {
if ( null == editingCol.getHeader()
|| "".equals( editingCol.getHeader() ) ) {
Window.alert( Constants.INSTANCE.YouMustEnterAColumnHeaderValueDescription() );
return;
}
if ( isNew ) {
if ( !unique( editingCol.getHeader() ) ) {
Window.alert( Constants.INSTANCE.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
} else {
if ( !col.getHeader().equals( editingCol.getHeader() ) ) {
if ( !unique( editingCol.getHeader() ) ) {
Window.alert( Constants.INSTANCE.ThatColumnNameIsAlreadyInUsePleasePickAnother() );
return;
}
}
}
// Pass new\modified column back for handling
refreshGrid.execute( editingCol );
hide();
}
} );
addAttribute( "",
apply );
}
private boolean unique(String header) {
for ( ActionCol52 o : model.getActionCols() ) {
if ( o.getHeader().equals( header ) ) return false;
}
return true;
}
private ActionRetractFactCol52 cloneActionRetractColumn(ActionRetractFactCol52 col) {
ActionRetractFactCol52 clone = null;
if ( col instanceof LimitedEntryCol ) {
clone = new LimitedEntryActionRetractFactCol52();
DTCellValue52 dcv = new DTCellValue52( ((LimitedEntryCol) col).getValue().getStringValue() );
((LimitedEntryCol) clone).setValue( dcv );
} else {
clone = new ActionRetractFactCol52();
}
clone.setHeader( col.getHeader() );
clone.setHideColumn( col.isHideColumn() );
return clone;
}
private ListBox loadBoundFacts(String binding) {
ListBox listBox = new ListBox();
listBox.addItem( Constants.INSTANCE.Choose() );
List<String> factBindings = rm.getLHSBoundFacts();
for ( int index = 0; index < factBindings.size(); index++ ) {
String boundName = factBindings.get( index );
if ( !"".equals( boundName ) ) {
listBox.addItem( boundName );
if ( boundName.equals( binding ) ) {
listBox.setSelectedIndex( index + 1 );
}
}
}
listBox.setEnabled( listBox.getItemCount() > 1 );
if ( listBox.getItemCount() == 1 ) {
listBox.clear();
listBox.addItem( Constants.INSTANCE.NoPatternBindingsAvailable() );
}
return listBox;
}
} | [
"public",
"class",
"ActionRetractFactPopup",
"extends",
"FormStylePopup",
"{",
"private",
"ActionRetractFactCol52",
"editingCol",
";",
"private",
"GuidedDecisionTable52",
"model",
";",
"private",
"BRLRuleModel",
"rm",
";",
"public",
"ActionRetractFactPopup",
"(",
"final",
"GuidedDecisionTable52",
"model",
",",
"final",
"GenericColumnCommand",
"refreshGrid",
",",
"final",
"ActionRetractFactCol52",
"col",
",",
"final",
"boolean",
"isNew",
",",
"final",
"boolean",
"isReadOnly",
")",
"{",
"this",
".",
"rm",
"=",
"new",
"BRLRuleModel",
"(",
"model",
")",
";",
"this",
".",
"editingCol",
"=",
"cloneActionRetractColumn",
"(",
"col",
")",
";",
"this",
".",
"model",
"=",
"model",
";",
"setTitle",
"(",
"Constants",
".",
"INSTANCE",
".",
"ColumnConfigurationRetractAFact",
"(",
")",
")",
";",
"setModal",
"(",
"false",
")",
";",
"if",
"(",
"model",
".",
"getTableFormat",
"(",
")",
"==",
"TableFormat",
".",
"LIMITED_ENTRY",
")",
"{",
"final",
"LimitedEntryActionRetractFactCol52",
"ler",
"=",
"(",
"LimitedEntryActionRetractFactCol52",
")",
"editingCol",
";",
"final",
"ListBox",
"patterns",
"=",
"loadBoundFacts",
"(",
"ler",
".",
"getValue",
"(",
")",
".",
"getStringValue",
"(",
")",
")",
";",
"patterns",
".",
"setEnabled",
"(",
"!",
"isReadOnly",
")",
";",
"if",
"(",
"!",
"isReadOnly",
")",
"{",
"patterns",
".",
"addClickHandler",
"(",
"new",
"ClickHandler",
"(",
")",
"{",
"public",
"void",
"onClick",
"(",
"ClickEvent",
"event",
")",
"{",
"int",
"index",
"=",
"patterns",
".",
"getSelectedIndex",
"(",
")",
";",
"if",
"(",
"index",
">",
"-",
"1",
")",
"{",
"ler",
".",
"getValue",
"(",
")",
".",
"setStringValue",
"(",
"patterns",
".",
"getValue",
"(",
"index",
")",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"addAttribute",
"(",
"Constants",
".",
"INSTANCE",
".",
"FactToRetractColon",
"(",
")",
",",
"patterns",
")",
";",
"}",
"final",
"TextBox",
"header",
"=",
"new",
"TextBox",
"(",
")",
";",
"header",
".",
"setText",
"(",
"col",
".",
"getHeader",
"(",
")",
")",
";",
"header",
".",
"setEnabled",
"(",
"!",
"isReadOnly",
")",
";",
"if",
"(",
"!",
"isReadOnly",
")",
"{",
"header",
".",
"addChangeHandler",
"(",
"new",
"ChangeHandler",
"(",
")",
"{",
"public",
"void",
"onChange",
"(",
"ChangeEvent",
"event",
")",
"{",
"editingCol",
".",
"setHeader",
"(",
"header",
".",
"getText",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"addAttribute",
"(",
"Constants",
".",
"INSTANCE",
".",
"ColumnHeaderDescription",
"(",
")",
",",
"header",
")",
";",
"addAttribute",
"(",
"Constants",
".",
"INSTANCE",
".",
"HideThisColumn",
"(",
")",
",",
"DTCellValueWidgetFactory",
".",
"getHideColumnIndicator",
"(",
"editingCol",
")",
")",
";",
"Button",
"apply",
"=",
"new",
"Button",
"(",
"Constants",
".",
"INSTANCE",
".",
"ApplyChanges",
"(",
")",
")",
";",
"apply",
".",
"addClickHandler",
"(",
"new",
"ClickHandler",
"(",
")",
"{",
"public",
"void",
"onClick",
"(",
"ClickEvent",
"w",
")",
"{",
"if",
"(",
"null",
"==",
"editingCol",
".",
"getHeader",
"(",
")",
"||",
"\"",
"\"",
".",
"equals",
"(",
"editingCol",
".",
"getHeader",
"(",
")",
")",
")",
"{",
"Window",
".",
"alert",
"(",
"Constants",
".",
"INSTANCE",
".",
"YouMustEnterAColumnHeaderValueDescription",
"(",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"isNew",
")",
"{",
"if",
"(",
"!",
"unique",
"(",
"editingCol",
".",
"getHeader",
"(",
")",
")",
")",
"{",
"Window",
".",
"alert",
"(",
"Constants",
".",
"INSTANCE",
".",
"ThatColumnNameIsAlreadyInUsePleasePickAnother",
"(",
")",
")",
";",
"return",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"col",
".",
"getHeader",
"(",
")",
".",
"equals",
"(",
"editingCol",
".",
"getHeader",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"unique",
"(",
"editingCol",
".",
"getHeader",
"(",
")",
")",
")",
"{",
"Window",
".",
"alert",
"(",
"Constants",
".",
"INSTANCE",
".",
"ThatColumnNameIsAlreadyInUsePleasePickAnother",
"(",
")",
")",
";",
"return",
";",
"}",
"}",
"}",
"refreshGrid",
".",
"execute",
"(",
"editingCol",
")",
";",
"hide",
"(",
")",
";",
"}",
"}",
")",
";",
"addAttribute",
"(",
"\"",
"\"",
",",
"apply",
")",
";",
"}",
"private",
"boolean",
"unique",
"(",
"String",
"header",
")",
"{",
"for",
"(",
"ActionCol52",
"o",
":",
"model",
".",
"getActionCols",
"(",
")",
")",
"{",
"if",
"(",
"o",
".",
"getHeader",
"(",
")",
".",
"equals",
"(",
"header",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"private",
"ActionRetractFactCol52",
"cloneActionRetractColumn",
"(",
"ActionRetractFactCol52",
"col",
")",
"{",
"ActionRetractFactCol52",
"clone",
"=",
"null",
";",
"if",
"(",
"col",
"instanceof",
"LimitedEntryCol",
")",
"{",
"clone",
"=",
"new",
"LimitedEntryActionRetractFactCol52",
"(",
")",
";",
"DTCellValue52",
"dcv",
"=",
"new",
"DTCellValue52",
"(",
"(",
"(",
"LimitedEntryCol",
")",
"col",
")",
".",
"getValue",
"(",
")",
".",
"getStringValue",
"(",
")",
")",
";",
"(",
"(",
"LimitedEntryCol",
")",
"clone",
")",
".",
"setValue",
"(",
"dcv",
")",
";",
"}",
"else",
"{",
"clone",
"=",
"new",
"ActionRetractFactCol52",
"(",
")",
";",
"}",
"clone",
".",
"setHeader",
"(",
"col",
".",
"getHeader",
"(",
")",
")",
";",
"clone",
".",
"setHideColumn",
"(",
"col",
".",
"isHideColumn",
"(",
")",
")",
";",
"return",
"clone",
";",
"}",
"private",
"ListBox",
"loadBoundFacts",
"(",
"String",
"binding",
")",
"{",
"ListBox",
"listBox",
"=",
"new",
"ListBox",
"(",
")",
";",
"listBox",
".",
"addItem",
"(",
"Constants",
".",
"INSTANCE",
".",
"Choose",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"factBindings",
"=",
"rm",
".",
"getLHSBoundFacts",
"(",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"factBindings",
".",
"size",
"(",
")",
";",
"index",
"++",
")",
"{",
"String",
"boundName",
"=",
"factBindings",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"!",
"\"",
"\"",
".",
"equals",
"(",
"boundName",
")",
")",
"{",
"listBox",
".",
"addItem",
"(",
"boundName",
")",
";",
"if",
"(",
"boundName",
".",
"equals",
"(",
"binding",
")",
")",
"{",
"listBox",
".",
"setSelectedIndex",
"(",
"index",
"+",
"1",
")",
";",
"}",
"}",
"}",
"listBox",
".",
"setEnabled",
"(",
"listBox",
".",
"getItemCount",
"(",
")",
">",
"1",
")",
";",
"if",
"(",
"listBox",
".",
"getItemCount",
"(",
")",
"==",
"1",
")",
"{",
"listBox",
".",
"clear",
"(",
")",
";",
"listBox",
".",
"addItem",
"(",
"Constants",
".",
"INSTANCE",
".",
"NoPatternBindingsAvailable",
"(",
")",
")",
";",
"}",
"return",
"listBox",
";",
"}",
"}"
] | A popup to define the parameters of an Action to retract a Fact | [
"A",
"popup",
"to",
"define",
"the",
"parameters",
"of",
"an",
"Action",
"to",
"retract",
"a",
"Fact"
] | [
"//Show available pattern bindings, if Limited Entry",
"//Column header",
"//Hide column tick-box",
"// Pass new\\modified column back for handling"
] | [
{
"param": "FormStylePopup",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "FormStylePopup",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
48681a19a59b2edade6131036c9851fdcc66db70 | MTDATA/hive | hcatalog/core/src/main/java/org/apache/hive/hcatalog/security/StorageDelegationAuthorizationProvider.java | [
"Apache-2.0"
] | Java | StorageDelegationAuthorizationProvider | /**
* A HiveAuthorizationProvider which delegates the authorization requests to
* the underlying AuthorizationProviders obtained from the StorageHandler.
*/ | A HiveAuthorizationProvider which delegates the authorization requests to
the underlying AuthorizationProviders obtained from the StorageHandler. | [
"A",
"HiveAuthorizationProvider",
"which",
"delegates",
"the",
"authorization",
"requests",
"to",
"the",
"underlying",
"AuthorizationProviders",
"obtained",
"from",
"the",
"StorageHandler",
"."
] | public class StorageDelegationAuthorizationProvider extends HiveAuthorizationProviderBase {
protected HiveAuthorizationProvider hdfsAuthorizer = new HdfsAuthorizationProvider();
protected static Map<String, String> authProviders = new HashMap<String, String>();
@Override
public void setConf(Configuration conf) {
super.setConf(conf);
hdfsAuthorizer.setConf(conf);
}
@Override
public void init(Configuration conf) throws HiveException {
hive_db = new HiveProxy(Hive.get(new HiveConf(conf, HiveAuthorizationProvider.class)));
}
@Override
public void setAuthenticator(HiveAuthenticationProvider authenticator) {
super.setAuthenticator(authenticator);
hdfsAuthorizer.setAuthenticator(authenticator);
}
static {
registerAuthProvider("org.apache.hadoop.hive.hbase.HBaseStorageHandler",
"org.apache.hive.hcatalog.hbase.HBaseAuthorizationProvider");
registerAuthProvider("org.apache.hive.hcatalog.hbase.HBaseHCatStorageHandler",
"org.apache.hive.hcatalog.hbase.HBaseAuthorizationProvider");
}
//workaround until Hive adds StorageHandler.getAuthorizationProvider(). Remove these parts afterwards
public static void registerAuthProvider(String storageHandlerClass,
String authProviderClass) {
authProviders.put(storageHandlerClass, authProviderClass);
}
/** Returns the StorageHandler of the Table obtained from the HCatStorageHandler */
protected HiveAuthorizationProvider getDelegate(Table table) throws HiveException {
HiveStorageHandler handler = table.getStorageHandler();
if (handler != null) {
if (handler instanceof HiveStorageHandler) {
return ((HiveStorageHandler) handler).getAuthorizationProvider();
} else {
String authProviderClass = authProviders.get(handler.getClass().getCanonicalName());
if (authProviderClass != null) {
try {
ReflectionUtils.newInstance(getConf().getClassByName(authProviderClass), getConf());
} catch (ClassNotFoundException ex) {
throw new HiveException("Cannot instantiate delegation AuthotizationProvider");
}
}
//else we do not have anything to delegate to
throw new HiveException(String.format("Storage Handler for table:%s is not an instance " +
"of HCatStorageHandler", table.getTableName()));
}
} else {
//return an authorizer for HDFS
return hdfsAuthorizer;
}
}
@Override
public void authorize(Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv)
throws HiveException, AuthorizationException {
//global authorizations against warehouse hdfs directory
hdfsAuthorizer.authorize(readRequiredPriv, writeRequiredPriv);
}
@Override
public void authorize(Database db, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv)
throws HiveException, AuthorizationException {
//db's are tied to a hdfs location
hdfsAuthorizer.authorize(db, readRequiredPriv, writeRequiredPriv);
}
@Override
public void authorize(Table table, Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv)
throws HiveException, AuthorizationException {
getDelegate(table).authorize(table, readRequiredPriv, writeRequiredPriv);
}
@Override
public void authorize(Partition part, Privilege[] readRequiredPriv,
Privilege[] writeRequiredPriv) throws HiveException, AuthorizationException {
getDelegate(part.getTable()).authorize(part, readRequiredPriv, writeRequiredPriv);
}
@Override
public void authorize(Table table, Partition part, List<String> columns,
Privilege[] readRequiredPriv, Privilege[] writeRequiredPriv) throws HiveException,
AuthorizationException {
getDelegate(table).authorize(table, part, columns, readRequiredPriv, writeRequiredPriv);
}
} | [
"public",
"class",
"StorageDelegationAuthorizationProvider",
"extends",
"HiveAuthorizationProviderBase",
"{",
"protected",
"HiveAuthorizationProvider",
"hdfsAuthorizer",
"=",
"new",
"HdfsAuthorizationProvider",
"(",
")",
";",
"protected",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"authProviders",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"@",
"Override",
"public",
"void",
"setConf",
"(",
"Configuration",
"conf",
")",
"{",
"super",
".",
"setConf",
"(",
"conf",
")",
";",
"hdfsAuthorizer",
".",
"setConf",
"(",
"conf",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"init",
"(",
"Configuration",
"conf",
")",
"throws",
"HiveException",
"{",
"hive_db",
"=",
"new",
"HiveProxy",
"(",
"Hive",
".",
"get",
"(",
"new",
"HiveConf",
"(",
"conf",
",",
"HiveAuthorizationProvider",
".",
"class",
")",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"setAuthenticator",
"(",
"HiveAuthenticationProvider",
"authenticator",
")",
"{",
"super",
".",
"setAuthenticator",
"(",
"authenticator",
")",
";",
"hdfsAuthorizer",
".",
"setAuthenticator",
"(",
"authenticator",
")",
";",
"}",
"static",
"{",
"registerAuthProvider",
"(",
"\"",
"org.apache.hadoop.hive.hbase.HBaseStorageHandler",
"\"",
",",
"\"",
"org.apache.hive.hcatalog.hbase.HBaseAuthorizationProvider",
"\"",
")",
";",
"registerAuthProvider",
"(",
"\"",
"org.apache.hive.hcatalog.hbase.HBaseHCatStorageHandler",
"\"",
",",
"\"",
"org.apache.hive.hcatalog.hbase.HBaseAuthorizationProvider",
"\"",
")",
";",
"}",
"public",
"static",
"void",
"registerAuthProvider",
"(",
"String",
"storageHandlerClass",
",",
"String",
"authProviderClass",
")",
"{",
"authProviders",
".",
"put",
"(",
"storageHandlerClass",
",",
"authProviderClass",
")",
";",
"}",
"/** Returns the StorageHandler of the Table obtained from the HCatStorageHandler */",
"protected",
"HiveAuthorizationProvider",
"getDelegate",
"(",
"Table",
"table",
")",
"throws",
"HiveException",
"{",
"HiveStorageHandler",
"handler",
"=",
"table",
".",
"getStorageHandler",
"(",
")",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"if",
"(",
"handler",
"instanceof",
"HiveStorageHandler",
")",
"{",
"return",
"(",
"(",
"HiveStorageHandler",
")",
"handler",
")",
".",
"getAuthorizationProvider",
"(",
")",
";",
"}",
"else",
"{",
"String",
"authProviderClass",
"=",
"authProviders",
".",
"get",
"(",
"handler",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
")",
";",
"if",
"(",
"authProviderClass",
"!=",
"null",
")",
"{",
"try",
"{",
"ReflectionUtils",
".",
"newInstance",
"(",
"getConf",
"(",
")",
".",
"getClassByName",
"(",
"authProviderClass",
")",
",",
"getConf",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"ex",
")",
"{",
"throw",
"new",
"HiveException",
"(",
"\"",
"Cannot instantiate delegation AuthotizationProvider",
"\"",
")",
";",
"}",
"}",
"throw",
"new",
"HiveException",
"(",
"String",
".",
"format",
"(",
"\"",
"Storage Handler for table:%s is not an instance ",
"\"",
"+",
"\"",
"of HCatStorageHandler",
"\"",
",",
"table",
".",
"getTableName",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"return",
"hdfsAuthorizer",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"authorize",
"(",
"Privilege",
"[",
"]",
"readRequiredPriv",
",",
"Privilege",
"[",
"]",
"writeRequiredPriv",
")",
"throws",
"HiveException",
",",
"AuthorizationException",
"{",
"hdfsAuthorizer",
".",
"authorize",
"(",
"readRequiredPriv",
",",
"writeRequiredPriv",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"authorize",
"(",
"Database",
"db",
",",
"Privilege",
"[",
"]",
"readRequiredPriv",
",",
"Privilege",
"[",
"]",
"writeRequiredPriv",
")",
"throws",
"HiveException",
",",
"AuthorizationException",
"{",
"hdfsAuthorizer",
".",
"authorize",
"(",
"db",
",",
"readRequiredPriv",
",",
"writeRequiredPriv",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"authorize",
"(",
"Table",
"table",
",",
"Privilege",
"[",
"]",
"readRequiredPriv",
",",
"Privilege",
"[",
"]",
"writeRequiredPriv",
")",
"throws",
"HiveException",
",",
"AuthorizationException",
"{",
"getDelegate",
"(",
"table",
")",
".",
"authorize",
"(",
"table",
",",
"readRequiredPriv",
",",
"writeRequiredPriv",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"authorize",
"(",
"Partition",
"part",
",",
"Privilege",
"[",
"]",
"readRequiredPriv",
",",
"Privilege",
"[",
"]",
"writeRequiredPriv",
")",
"throws",
"HiveException",
",",
"AuthorizationException",
"{",
"getDelegate",
"(",
"part",
".",
"getTable",
"(",
")",
")",
".",
"authorize",
"(",
"part",
",",
"readRequiredPriv",
",",
"writeRequiredPriv",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"authorize",
"(",
"Table",
"table",
",",
"Partition",
"part",
",",
"List",
"<",
"String",
">",
"columns",
",",
"Privilege",
"[",
"]",
"readRequiredPriv",
",",
"Privilege",
"[",
"]",
"writeRequiredPriv",
")",
"throws",
"HiveException",
",",
"AuthorizationException",
"{",
"getDelegate",
"(",
"table",
")",
".",
"authorize",
"(",
"table",
",",
"part",
",",
"columns",
",",
"readRequiredPriv",
",",
"writeRequiredPriv",
")",
";",
"}",
"}"
] | A HiveAuthorizationProvider which delegates the authorization requests to
the underlying AuthorizationProviders obtained from the StorageHandler. | [
"A",
"HiveAuthorizationProvider",
"which",
"delegates",
"the",
"authorization",
"requests",
"to",
"the",
"underlying",
"AuthorizationProviders",
"obtained",
"from",
"the",
"StorageHandler",
"."
] | [
"//workaround until Hive adds StorageHandler.getAuthorizationProvider(). Remove these parts afterwards",
"//else we do not have anything to delegate to",
"//return an authorizer for HDFS",
"//global authorizations against warehouse hdfs directory",
"//db's are tied to a hdfs location"
] | [
{
"param": "HiveAuthorizationProviderBase",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "HiveAuthorizationProviderBase",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
486c5ade496c7947153f8fc8b352c8ea45b3ac3e | jensdietrich/se-teaching | visitor/src/main/java/nz/ac/vuw/jenz/visitor/iteration2/VariableFinder.java | [
"Apache-2.0"
] | Java | VariableFinder | /**
* Example visitor, extracts the variables used in a condition.
* @author jens dietrich
*/ | Example visitor, extracts the variables used in a condition.
@author jens dietrich | [
"Example",
"visitor",
"extracts",
"the",
"variables",
"used",
"in",
"a",
"condition",
".",
"@author",
"jens",
"dietrich"
] | class VariableFinder implements ExpressionVisitor {
private Set<String> variables = new HashSet<String>();
@Override
public void visit(Variable variable) {
this.variables.add(variable.getName());
}
@Override
public void visit(Constant constant) {}
@Override
public void visit(ComplexTerm term) {}
@Override
public void visit(Condition condition) {}
public Set<String> getVariables() {
return variables;
}
} | [
"class",
"VariableFinder",
"implements",
"ExpressionVisitor",
"{",
"private",
"Set",
"<",
"String",
">",
"variables",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"@",
"Override",
"public",
"void",
"visit",
"(",
"Variable",
"variable",
")",
"{",
"this",
".",
"variables",
".",
"add",
"(",
"variable",
".",
"getName",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"visit",
"(",
"Constant",
"constant",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"visit",
"(",
"ComplexTerm",
"term",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"visit",
"(",
"Condition",
"condition",
")",
"{",
"}",
"public",
"Set",
"<",
"String",
">",
"getVariables",
"(",
")",
"{",
"return",
"variables",
";",
"}",
"}"
] | Example visitor, extracts the variables used in a condition. | [
"Example",
"visitor",
"extracts",
"the",
"variables",
"used",
"in",
"a",
"condition",
"."
] | [] | [
{
"param": "ExpressionVisitor",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ExpressionVisitor",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
486f2d051d07de2c5f78c2fd818ca51501b17dcb | danamulligan/CA_Simulation | src/cellmodel/celltype/Cell.java | [
"MIT"
] | Java | Cell | /**
* creates a cell object that has an associated state, a list of neighbors, number of moves, number of turns since shape change, and a row and column number
**/ | creates a cell object that has an associated state, a list of neighbors, number of moves, number of turns since shape change, and a row and column number | [
"creates",
"a",
"cell",
"object",
"that",
"has",
"an",
"associated",
"state",
"a",
"list",
"of",
"neighbors",
"number",
"of",
"moves",
"number",
"of",
"turns",
"since",
"shape",
"change",
"and",
"a",
"row",
"and",
"column",
"number"
] | public class Cell{
private int myState;
private int turnsSinceStateChange;
private List<Cell> myNeighbors;
private int myMoves;
private int rowNumber;
private int colNumber;
/**
* constructor to create a cell takes in the number of columns, rows, and the rules
* @param initState initial state of the cell
*
**/
public Cell(int initState, int row, int col) {
myState = initState;
myNeighbors = new ArrayList<Cell>();
myMoves = 0;
rowNumber = row;
colNumber = col;
}
/**
* changes the state and color of the cell increments or resets turnsSinceStateChange takes in the
* number of columns, rows, and the rules
* @param state state that the cell is changing to
**/
public void changeStateAndView(int state) {
if (state == myState) {
turnsSinceStateChange++;
} else {
turnsSinceStateChange = 0;
myState = state;
}
}
/**
* @return the number of times the board has changed since the state of this cell changed
**/
public int getTurnsSinceStateChanges() {
return turnsSinceStateChange;
}
/**
* sets the number of times the board has changed since the state of this cell changed to a given value
**/
public void setTurnsSinceStateChange(int val){
turnsSinceStateChange =val;
}
/**
* @return the state of the cell
**/
public int getState() {
return myState;
}
/**
* get the row the cell is in
* @return rowNumber
*/
public int getRowNumber(){
return rowNumber;
}
/**
* get the column the cell is in
* @return colNumber
*/
public int getColNumber(){
return colNumber;
}
/**
* Add a neighbor to a cell
* @param neighbor cell to be added as a neighbor
*/
public void addNeighbor(Cell neighbor) {
myNeighbors.add(neighbor);
}
/**
* Add a neighbor to a cell
* @param neighbor cell to be removed as a neighbor
*/
public void removeNeighbor(Cell neighbor){
myNeighbors.remove(neighbor);
}
/**
* @return a list of the neighbors of the cell
**/
public List<Cell> getNeighbors() {
return myNeighbors;
}
/**
* sets the neighbors of a cell to be a given list of cells
* @param neighbors a given list of cells that are neighbors of cell
**/
public void setNeighbors(List<Cell> neighbors){
myNeighbors = new ArrayList<>();
myNeighbors= neighbors;
}
/**
* creates a list of neighbor cells that have a given state
* @param state the state that is wanted in the neighbors
* @return the list of neighbors with the desired state
**/
public List<Cell> getNeighborsWithState(int state) {
List<Cell> stateNeighbors = new ArrayList<Cell>();
for (Cell neighbor : myNeighbors) {
if (neighbor.getState() == state) {
stateNeighbors.add(neighbor);
}
}
return stateNeighbors;
}
/**
* @return the number of neighbors that have the same state as the cell
**/
public int numNeighborsOfSameState() {
int counter = 0;
for (Cell neighbor : myNeighbors) {
if (neighbor.getState() == myState) {
counter++;
}
}
return counter;
}
/**
* creates a counter to keep track of the number of neighbors that have a given state
* @param state the state that is wanted in the neighbors
* @return the number of neighbors with the desired state
**/
public int numNeighborsWithGivenState(int state) {
int counter = 0;
for (Cell neighbor : myNeighbors) {
if (neighbor.getState() == state) {
counter++;
}
}
return counter;
}
/**
* sets the state of the cell to a given state
* @param state state that the cell is being set to
**/
public void setState(int state) {
myState = state;
}
/**
* @return the number of moves that the cell has gone through
**/
public int getMoves() {
return myMoves;
}
/**
* sets the number of moves completed to a given integer
* @param moves the number of moves that the cell has gone through
**/
public void setMoves(int moves) {
myMoves = moves;
}
} | [
"public",
"class",
"Cell",
"{",
"private",
"int",
"myState",
";",
"private",
"int",
"turnsSinceStateChange",
";",
"private",
"List",
"<",
"Cell",
">",
"myNeighbors",
";",
"private",
"int",
"myMoves",
";",
"private",
"int",
"rowNumber",
";",
"private",
"int",
"colNumber",
";",
"/**\n * constructor to create a cell takes in the number of columns, rows, and the rules\n * @param initState initial state of the cell\n *\n **/",
"public",
"Cell",
"(",
"int",
"initState",
",",
"int",
"row",
",",
"int",
"col",
")",
"{",
"myState",
"=",
"initState",
";",
"myNeighbors",
"=",
"new",
"ArrayList",
"<",
"Cell",
">",
"(",
")",
";",
"myMoves",
"=",
"0",
";",
"rowNumber",
"=",
"row",
";",
"colNumber",
"=",
"col",
";",
"}",
"/**\n * changes the state and color of the cell increments or resets turnsSinceStateChange takes in the\n * number of columns, rows, and the rules\n * @param state state that the cell is changing to\n **/",
"public",
"void",
"changeStateAndView",
"(",
"int",
"state",
")",
"{",
"if",
"(",
"state",
"==",
"myState",
")",
"{",
"turnsSinceStateChange",
"++",
";",
"}",
"else",
"{",
"turnsSinceStateChange",
"=",
"0",
";",
"myState",
"=",
"state",
";",
"}",
"}",
"/**\n * @return the number of times the board has changed since the state of this cell changed\n **/",
"public",
"int",
"getTurnsSinceStateChanges",
"(",
")",
"{",
"return",
"turnsSinceStateChange",
";",
"}",
"/**\n * sets the number of times the board has changed since the state of this cell changed to a given value\n **/",
"public",
"void",
"setTurnsSinceStateChange",
"(",
"int",
"val",
")",
"{",
"turnsSinceStateChange",
"=",
"val",
";",
"}",
"/**\n * @return the state of the cell\n **/",
"public",
"int",
"getState",
"(",
")",
"{",
"return",
"myState",
";",
"}",
"/**\n * get the row the cell is in\n * @return rowNumber\n */",
"public",
"int",
"getRowNumber",
"(",
")",
"{",
"return",
"rowNumber",
";",
"}",
"/**\n * get the column the cell is in\n * @return colNumber\n */",
"public",
"int",
"getColNumber",
"(",
")",
"{",
"return",
"colNumber",
";",
"}",
"/**\n * Add a neighbor to a cell\n * @param neighbor cell to be added as a neighbor\n */",
"public",
"void",
"addNeighbor",
"(",
"Cell",
"neighbor",
")",
"{",
"myNeighbors",
".",
"add",
"(",
"neighbor",
")",
";",
"}",
"/**\n * Add a neighbor to a cell\n * @param neighbor cell to be removed as a neighbor\n */",
"public",
"void",
"removeNeighbor",
"(",
"Cell",
"neighbor",
")",
"{",
"myNeighbors",
".",
"remove",
"(",
"neighbor",
")",
";",
"}",
"/**\n * @return a list of the neighbors of the cell\n **/",
"public",
"List",
"<",
"Cell",
">",
"getNeighbors",
"(",
")",
"{",
"return",
"myNeighbors",
";",
"}",
"/**\n * sets the neighbors of a cell to be a given list of cells\n * @param neighbors a given list of cells that are neighbors of cell\n **/",
"public",
"void",
"setNeighbors",
"(",
"List",
"<",
"Cell",
">",
"neighbors",
")",
"{",
"myNeighbors",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"myNeighbors",
"=",
"neighbors",
";",
"}",
"/**\n * creates a list of neighbor cells that have a given state\n * @param state the state that is wanted in the neighbors\n * @return the list of neighbors with the desired state\n **/",
"public",
"List",
"<",
"Cell",
">",
"getNeighborsWithState",
"(",
"int",
"state",
")",
"{",
"List",
"<",
"Cell",
">",
"stateNeighbors",
"=",
"new",
"ArrayList",
"<",
"Cell",
">",
"(",
")",
";",
"for",
"(",
"Cell",
"neighbor",
":",
"myNeighbors",
")",
"{",
"if",
"(",
"neighbor",
".",
"getState",
"(",
")",
"==",
"state",
")",
"{",
"stateNeighbors",
".",
"add",
"(",
"neighbor",
")",
";",
"}",
"}",
"return",
"stateNeighbors",
";",
"}",
"/**\n * @return the number of neighbors that have the same state as the cell\n **/",
"public",
"int",
"numNeighborsOfSameState",
"(",
")",
"{",
"int",
"counter",
"=",
"0",
";",
"for",
"(",
"Cell",
"neighbor",
":",
"myNeighbors",
")",
"{",
"if",
"(",
"neighbor",
".",
"getState",
"(",
")",
"==",
"myState",
")",
"{",
"counter",
"++",
";",
"}",
"}",
"return",
"counter",
";",
"}",
"/**\n * creates a counter to keep track of the number of neighbors that have a given state\n * @param state the state that is wanted in the neighbors\n * @return the number of neighbors with the desired state\n **/",
"public",
"int",
"numNeighborsWithGivenState",
"(",
"int",
"state",
")",
"{",
"int",
"counter",
"=",
"0",
";",
"for",
"(",
"Cell",
"neighbor",
":",
"myNeighbors",
")",
"{",
"if",
"(",
"neighbor",
".",
"getState",
"(",
")",
"==",
"state",
")",
"{",
"counter",
"++",
";",
"}",
"}",
"return",
"counter",
";",
"}",
"/**\n * sets the state of the cell to a given state\n * @param state state that the cell is being set to\n **/",
"public",
"void",
"setState",
"(",
"int",
"state",
")",
"{",
"myState",
"=",
"state",
";",
"}",
"/**\n * @return the number of moves that the cell has gone through\n **/",
"public",
"int",
"getMoves",
"(",
")",
"{",
"return",
"myMoves",
";",
"}",
"/**\n * sets the number of moves completed to a given integer\n * @param moves the number of moves that the cell has gone through\n **/",
"public",
"void",
"setMoves",
"(",
"int",
"moves",
")",
"{",
"myMoves",
"=",
"moves",
";",
"}",
"}"
] | creates a cell object that has an associated state, a list of neighbors, number of moves, number of turns since shape change, and a row and column number | [
"creates",
"a",
"cell",
"object",
"that",
"has",
"an",
"associated",
"state",
"a",
"list",
"of",
"neighbors",
"number",
"of",
"moves",
"number",
"of",
"turns",
"since",
"shape",
"change",
"and",
"a",
"row",
"and",
"column",
"number"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
48739e9d18b1a0bbc164821869c59745807c3cb2 | botikasm/lyj-framework | lyj-ext-html-selenium/src/org/lyj/ext/selenium/controllers/routines/controller/scripts/ScriptProgram.java | [
"MIT"
] | Java | ScriptProgram | /**
* Program wrapper.
* Use this class to invoke methods from the program.
*/ | Program wrapper.
Use this class to invoke methods from the program. | [
"Program",
"wrapper",
".",
"Use",
"this",
"class",
"to",
"invoke",
"methods",
"from",
"the",
"program",
"."
] | public class ScriptProgram {
// ------------------------------------------------------------------------
// c o n s t a n t s
// ------------------------------------------------------------------------
private static final String SCRIPT_PREFIX = "$";
private static final String ON_INIT = "_init";
private static final String ON_EXPIRE = "_expire"; // session expired
private static final String ON_LOOP = "_loop";
// ------------------------------------------------------------------------
// f i e l d s
// ------------------------------------------------------------------------
private final String _root;
private final ModelPackage _program_info;
private final String _uid;
private ScriptProgramLogger _logger;
private Program _program;
private ScriptObjectMirror _script_object;
private Object _init_response;
// ------------------------------------------------------------------------
// c o n s t r u c t o r
// ------------------------------------------------------------------------
public ScriptProgram(final String script_root,
final ModelPackage program_info,
final RoutineLogger logger) {
// clone program info
_program_info = program_info;
_root = script_root;
_uid = program_info.name();
_logger = new ScriptProgramLogger(this, logger);
_program = ScriptController.instance().create(_logger).root(_root);
this.init();
}
@Override
public String toString() {
return _program_info.toString();
}
@Override
protected void finalize() throws Throwable {
super.finalize();
}
// ------------------------------------------------------------------------
// p u b l i c
// ------------------------------------------------------------------------
public String root() {
return _root;
}
public String uid() {
return _uid;
}
public ModelPackage info() {
return _program_info;
}
public ScriptProgramLogger logger() {
return _logger;
}
public Object open() throws Exception {
if (null == _script_object) {
if (this.createScriptObject()) {
// ready for onInit method
final Object init_response = this.onInit();
if (null != init_response) {
_init_response = Converter.toJsonCompatible(init_response);
}
}
}
return _init_response;
}
public void close() {
if (null != _program) {
this.finish();
_program.close();
}
_script_object = null;
_program = null;
_logger = null;
_init_response = null;
}
public String script() {
if (null != _program) {
return _program.script();
}
return "";
}
public boolean hasMember(final String memberName) {
return hasMember(_script_object, memberName);
}
public Object callMember(final String scriptName,
final Object... args) throws Exception {
synchronized (this) {
Object script_response = null;
if (this.hasMember(scriptName)) {
script_response = callMember(_script_object, scriptName, args);
} else {
throw new Exception(FormatUtils.format("Missing method or handler. You invoked '%s', but I didn't find a script member with this name.", scriptName));
}
return script_response;
}
}
public Object eval(final String script) throws Exception {
if (null != _script_object) {
return _script_object.eval(script);
}
return false;
}
public Map<String, Object> getContext() {
if (null != _program) {
return _program.context();
}
return new HashMap<>();
}
public Object getContextValue(final String key) {
if (null != _program) {
return _program.context().get(key);
}
return null;
}
public Object setContextValue(final String key,
final Object value) {
if (null != _program) {
return _program.context().put(key, value);
}
return null;
}
public OSEProgramTool getContextTool(final String name) {
if (null != _program) {
return (OSEProgramTool) _program.context().get(ensureScriptPrefix(name));
}
return null;
}
// ------------------------------------------------------------------------
// p a c k a g e
// ------------------------------------------------------------------------
Object onInit() throws Exception {
if (this.hasMember(ON_INIT)) {
return this.callMember(ON_INIT, this);
}
return null;
}
Object onExpire() throws Exception {
if (this.hasMember(ON_EXPIRE)) {
return this.callMember(ON_EXPIRE, this);
}
return null;
}
Object onLoop() throws Exception {
if (this.hasMember(ON_LOOP)) {
return this.callMember(ON_LOOP, this);
}
return null;
}
// ------------------------------------------------------------------------
// p r i v a t e
// ------------------------------------------------------------------------
private void init() {
// extend program with custom context
_program.context().put(ensureScriptPrefix(Tool_error.NAME), new Tool_error(this));
// _program.context().put(ensureScriptPrefix(Tool_rnd.NAME), new Tool_rnd(this));
// _program.context().put(ensureScriptPrefix(Tool_resource.NAME), new Tool_resource(this));
}
private void finish() {
try {
final Set<String> keys = _program.context().keySet();
for (final String key : keys) {
try {
final Object item = _program.context().get(key);
if (item instanceof OSEProgramTool) {
((OSEProgramTool) item).close();
}
} catch (Throwable ignored) {
}
}
} catch (Throwable ignored) {
}
}
private boolean createScriptObject() {
// launch
try {
final Object script = _program.run();
if (script instanceof ScriptObjectMirror) {
_script_object = (ScriptObjectMirror) script;
return true;
} else {
_logger.error("OSEProgram.createScriptObject", new Exception("Program is malformed. It should return a valid program instance."));
}
} catch (NullScriptException ignored) {
// no script to evaluate
} catch (Throwable t) {
_logger.error("OSEProgram.createScriptObject", t);
}
return false;
}
private void onTick(final Loop.LoopInterruptor interruptor) {
synchronized (this) {
try {
this.onLoop();
} catch (Throwable ignored) {
// ignored
}
}
}
// ------------------------------------------------------------------------
// S T A T I C
// ------------------------------------------------------------------------
public static OSEProgramTool tool(final ScriptProgram program,
final String name) {
return null != program ? program.getContextTool(name) : null;
}
public static void clearCache(final String root) {
Program.clearCache(root);
}
public static String ensureScriptPrefix(final String name) {
if (StringUtils.hasText(name)) {
if (!name.startsWith(SCRIPT_PREFIX)) {
return SCRIPT_PREFIX.concat(name);
}
}
return name;
}
public static boolean hasMember(final ScriptObjectMirror script,
final String scriptName) {
if (null != script && StringUtils.hasText(scriptName)) {
try {
if (scriptName.contains(".")) {
final String[] tokens = StringUtils.split(scriptName, ".");
ScriptObjectMirror tmp = null;
for (int i = 0; i < tokens.length; i++) {
final boolean latest = i == tokens.length - 1;
final String method = tokens[i];
if (latest) {
return null != tmp && tmp.hasMember(method);
} else {
tmp = (ScriptObjectMirror) script.callMember(method);
}
}
} else {
return script.hasMember(scriptName);
}
} catch (Throwable ignored) {
// ignored
}
}
return false;
}
public static Object callMember(final ScriptObjectMirror script,
final String scriptName,
final Object... args) throws Exception {
if (null != script && StringUtils.hasText(scriptName)) {
if (scriptName.contains(".")) {
final String[] tokens = StringUtils.split(scriptName, ".");
ScriptObjectMirror tmp = null;
for (int i = 0; i < tokens.length; i++) {
final boolean latest = i == tokens.length - 1;
final String method = tokens[i];
if (latest) {
return validate(null != tmp ? tmp.callMember(method, args) : null);
} else {
tmp = (ScriptObjectMirror) script.callMember(method);
}
}
} else {
return validate(script.callMember(scriptName, args));
}
}
return null;
}
private static Object validate(final Object value) throws Exception {
if (value instanceof ScriptObjectMirror) {
final Map map_value = Tool_error.toMapError(value);
if (isError(map_value)) {
throw new Exception(StringUtils.toString(map_value.get("message")));
}
} else if (value instanceof Map) {
final Map map_value = (Map) value;
if (isError(map_value)) {
throw new Exception(StringUtils.toString(map_value.get("message")));
}
}
return value;
}
private static boolean isError(final Map map_value) {
return map_value.containsKey("type")
&& map_value.get("type").equals("error")
&& StringUtils.hasText(StringUtils.toString(map_value.get("message")));
}
} | [
"public",
"class",
"ScriptProgram",
"{",
"private",
"static",
"final",
"String",
"SCRIPT_PREFIX",
"=",
"\"",
"$",
"\"",
";",
"private",
"static",
"final",
"String",
"ON_INIT",
"=",
"\"",
"_init",
"\"",
";",
"private",
"static",
"final",
"String",
"ON_EXPIRE",
"=",
"\"",
"_expire",
"\"",
";",
"private",
"static",
"final",
"String",
"ON_LOOP",
"=",
"\"",
"_loop",
"\"",
";",
"private",
"final",
"String",
"_root",
";",
"private",
"final",
"ModelPackage",
"_program_info",
";",
"private",
"final",
"String",
"_uid",
";",
"private",
"ScriptProgramLogger",
"_logger",
";",
"private",
"Program",
"_program",
";",
"private",
"ScriptObjectMirror",
"_script_object",
";",
"private",
"Object",
"_init_response",
";",
"public",
"ScriptProgram",
"(",
"final",
"String",
"script_root",
",",
"final",
"ModelPackage",
"program_info",
",",
"final",
"RoutineLogger",
"logger",
")",
"{",
"_program_info",
"=",
"program_info",
";",
"_root",
"=",
"script_root",
";",
"_uid",
"=",
"program_info",
".",
"name",
"(",
")",
";",
"_logger",
"=",
"new",
"ScriptProgramLogger",
"(",
"this",
",",
"logger",
")",
";",
"_program",
"=",
"ScriptController",
".",
"instance",
"(",
")",
".",
"create",
"(",
"_logger",
")",
".",
"root",
"(",
"_root",
")",
";",
"this",
".",
"init",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"_program_info",
".",
"toString",
"(",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"finalize",
"(",
")",
"throws",
"Throwable",
"{",
"super",
".",
"finalize",
"(",
")",
";",
"}",
"public",
"String",
"root",
"(",
")",
"{",
"return",
"_root",
";",
"}",
"public",
"String",
"uid",
"(",
")",
"{",
"return",
"_uid",
";",
"}",
"public",
"ModelPackage",
"info",
"(",
")",
"{",
"return",
"_program_info",
";",
"}",
"public",
"ScriptProgramLogger",
"logger",
"(",
")",
"{",
"return",
"_logger",
";",
"}",
"public",
"Object",
"open",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"null",
"==",
"_script_object",
")",
"{",
"if",
"(",
"this",
".",
"createScriptObject",
"(",
")",
")",
"{",
"final",
"Object",
"init_response",
"=",
"this",
".",
"onInit",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"init_response",
")",
"{",
"_init_response",
"=",
"Converter",
".",
"toJsonCompatible",
"(",
"init_response",
")",
";",
"}",
"}",
"}",
"return",
"_init_response",
";",
"}",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"_program",
")",
"{",
"this",
".",
"finish",
"(",
")",
";",
"_program",
".",
"close",
"(",
")",
";",
"}",
"_script_object",
"=",
"null",
";",
"_program",
"=",
"null",
";",
"_logger",
"=",
"null",
";",
"_init_response",
"=",
"null",
";",
"}",
"public",
"String",
"script",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"_program",
")",
"{",
"return",
"_program",
".",
"script",
"(",
")",
";",
"}",
"return",
"\"",
"\"",
";",
"}",
"public",
"boolean",
"hasMember",
"(",
"final",
"String",
"memberName",
")",
"{",
"return",
"hasMember",
"(",
"_script_object",
",",
"memberName",
")",
";",
"}",
"public",
"Object",
"callMember",
"(",
"final",
"String",
"scriptName",
",",
"final",
"Object",
"...",
"args",
")",
"throws",
"Exception",
"{",
"synchronized",
"(",
"this",
")",
"{",
"Object",
"script_response",
"=",
"null",
";",
"if",
"(",
"this",
".",
"hasMember",
"(",
"scriptName",
")",
")",
"{",
"script_response",
"=",
"callMember",
"(",
"_script_object",
",",
"scriptName",
",",
"args",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"FormatUtils",
".",
"format",
"(",
"\"",
"Missing method or handler. You invoked '%s', but I didn't find a script member with this name.",
"\"",
",",
"scriptName",
")",
")",
";",
"}",
"return",
"script_response",
";",
"}",
"}",
"public",
"Object",
"eval",
"(",
"final",
"String",
"script",
")",
"throws",
"Exception",
"{",
"if",
"(",
"null",
"!=",
"_script_object",
")",
"{",
"return",
"_script_object",
".",
"eval",
"(",
"script",
")",
";",
"}",
"return",
"false",
";",
"}",
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"getContext",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"_program",
")",
"{",
"return",
"_program",
".",
"context",
"(",
")",
";",
"}",
"return",
"new",
"HashMap",
"<",
">",
"(",
")",
";",
"}",
"public",
"Object",
"getContextValue",
"(",
"final",
"String",
"key",
")",
"{",
"if",
"(",
"null",
"!=",
"_program",
")",
"{",
"return",
"_program",
".",
"context",
"(",
")",
".",
"get",
"(",
"key",
")",
";",
"}",
"return",
"null",
";",
"}",
"public",
"Object",
"setContextValue",
"(",
"final",
"String",
"key",
",",
"final",
"Object",
"value",
")",
"{",
"if",
"(",
"null",
"!=",
"_program",
")",
"{",
"return",
"_program",
".",
"context",
"(",
")",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"return",
"null",
";",
"}",
"public",
"OSEProgramTool",
"getContextTool",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"null",
"!=",
"_program",
")",
"{",
"return",
"(",
"OSEProgramTool",
")",
"_program",
".",
"context",
"(",
")",
".",
"get",
"(",
"ensureScriptPrefix",
"(",
"name",
")",
")",
";",
"}",
"return",
"null",
";",
"}",
"Object",
"onInit",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"this",
".",
"hasMember",
"(",
"ON_INIT",
")",
")",
"{",
"return",
"this",
".",
"callMember",
"(",
"ON_INIT",
",",
"this",
")",
";",
"}",
"return",
"null",
";",
"}",
"Object",
"onExpire",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"this",
".",
"hasMember",
"(",
"ON_EXPIRE",
")",
")",
"{",
"return",
"this",
".",
"callMember",
"(",
"ON_EXPIRE",
",",
"this",
")",
";",
"}",
"return",
"null",
";",
"}",
"Object",
"onLoop",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"this",
".",
"hasMember",
"(",
"ON_LOOP",
")",
")",
"{",
"return",
"this",
".",
"callMember",
"(",
"ON_LOOP",
",",
"this",
")",
";",
"}",
"return",
"null",
";",
"}",
"private",
"void",
"init",
"(",
")",
"{",
"_program",
".",
"context",
"(",
")",
".",
"put",
"(",
"ensureScriptPrefix",
"(",
"Tool_error",
".",
"NAME",
")",
",",
"new",
"Tool_error",
"(",
"this",
")",
")",
";",
"}",
"private",
"void",
"finish",
"(",
")",
"{",
"try",
"{",
"final",
"Set",
"<",
"String",
">",
"keys",
"=",
"_program",
".",
"context",
"(",
")",
".",
"keySet",
"(",
")",
";",
"for",
"(",
"final",
"String",
"key",
":",
"keys",
")",
"{",
"try",
"{",
"final",
"Object",
"item",
"=",
"_program",
".",
"context",
"(",
")",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"item",
"instanceof",
"OSEProgramTool",
")",
"{",
"(",
"(",
"OSEProgramTool",
")",
"item",
")",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"ignored",
")",
"{",
"}",
"}",
"}",
"catch",
"(",
"Throwable",
"ignored",
")",
"{",
"}",
"}",
"private",
"boolean",
"createScriptObject",
"(",
")",
"{",
"try",
"{",
"final",
"Object",
"script",
"=",
"_program",
".",
"run",
"(",
")",
";",
"if",
"(",
"script",
"instanceof",
"ScriptObjectMirror",
")",
"{",
"_script_object",
"=",
"(",
"ScriptObjectMirror",
")",
"script",
";",
"return",
"true",
";",
"}",
"else",
"{",
"_logger",
".",
"error",
"(",
"\"",
"OSEProgram.createScriptObject",
"\"",
",",
"new",
"Exception",
"(",
"\"",
"Program is malformed. It should return a valid program instance.",
"\"",
")",
")",
";",
"}",
"}",
"catch",
"(",
"NullScriptException",
"ignored",
")",
"{",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"_logger",
".",
"error",
"(",
"\"",
"OSEProgram.createScriptObject",
"\"",
",",
"t",
")",
";",
"}",
"return",
"false",
";",
"}",
"private",
"void",
"onTick",
"(",
"final",
"Loop",
".",
"LoopInterruptor",
"interruptor",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"try",
"{",
"this",
".",
"onLoop",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ignored",
")",
"{",
"}",
"}",
"}",
"public",
"static",
"OSEProgramTool",
"tool",
"(",
"final",
"ScriptProgram",
"program",
",",
"final",
"String",
"name",
")",
"{",
"return",
"null",
"!=",
"program",
"?",
"program",
".",
"getContextTool",
"(",
"name",
")",
":",
"null",
";",
"}",
"public",
"static",
"void",
"clearCache",
"(",
"final",
"String",
"root",
")",
"{",
"Program",
".",
"clearCache",
"(",
"root",
")",
";",
"}",
"public",
"static",
"String",
"ensureScriptPrefix",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"StringUtils",
".",
"hasText",
"(",
"name",
")",
")",
"{",
"if",
"(",
"!",
"name",
".",
"startsWith",
"(",
"SCRIPT_PREFIX",
")",
")",
"{",
"return",
"SCRIPT_PREFIX",
".",
"concat",
"(",
"name",
")",
";",
"}",
"}",
"return",
"name",
";",
"}",
"public",
"static",
"boolean",
"hasMember",
"(",
"final",
"ScriptObjectMirror",
"script",
",",
"final",
"String",
"scriptName",
")",
"{",
"if",
"(",
"null",
"!=",
"script",
"&&",
"StringUtils",
".",
"hasText",
"(",
"scriptName",
")",
")",
"{",
"try",
"{",
"if",
"(",
"scriptName",
".",
"contains",
"(",
"\"",
".",
"\"",
")",
")",
"{",
"final",
"String",
"[",
"]",
"tokens",
"=",
"StringUtils",
".",
"split",
"(",
"scriptName",
",",
"\"",
".",
"\"",
")",
";",
"ScriptObjectMirror",
"tmp",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"boolean",
"latest",
"=",
"i",
"==",
"tokens",
".",
"length",
"-",
"1",
";",
"final",
"String",
"method",
"=",
"tokens",
"[",
"i",
"]",
";",
"if",
"(",
"latest",
")",
"{",
"return",
"null",
"!=",
"tmp",
"&&",
"tmp",
".",
"hasMember",
"(",
"method",
")",
";",
"}",
"else",
"{",
"tmp",
"=",
"(",
"ScriptObjectMirror",
")",
"script",
".",
"callMember",
"(",
"method",
")",
";",
"}",
"}",
"}",
"else",
"{",
"return",
"script",
".",
"hasMember",
"(",
"scriptName",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"ignored",
")",
"{",
"}",
"}",
"return",
"false",
";",
"}",
"public",
"static",
"Object",
"callMember",
"(",
"final",
"ScriptObjectMirror",
"script",
",",
"final",
"String",
"scriptName",
",",
"final",
"Object",
"...",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"null",
"!=",
"script",
"&&",
"StringUtils",
".",
"hasText",
"(",
"scriptName",
")",
")",
"{",
"if",
"(",
"scriptName",
".",
"contains",
"(",
"\"",
".",
"\"",
")",
")",
"{",
"final",
"String",
"[",
"]",
"tokens",
"=",
"StringUtils",
".",
"split",
"(",
"scriptName",
",",
"\"",
".",
"\"",
")",
";",
"ScriptObjectMirror",
"tmp",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"boolean",
"latest",
"=",
"i",
"==",
"tokens",
".",
"length",
"-",
"1",
";",
"final",
"String",
"method",
"=",
"tokens",
"[",
"i",
"]",
";",
"if",
"(",
"latest",
")",
"{",
"return",
"validate",
"(",
"null",
"!=",
"tmp",
"?",
"tmp",
".",
"callMember",
"(",
"method",
",",
"args",
")",
":",
"null",
")",
";",
"}",
"else",
"{",
"tmp",
"=",
"(",
"ScriptObjectMirror",
")",
"script",
".",
"callMember",
"(",
"method",
")",
";",
"}",
"}",
"}",
"else",
"{",
"return",
"validate",
"(",
"script",
".",
"callMember",
"(",
"scriptName",
",",
"args",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"private",
"static",
"Object",
"validate",
"(",
"final",
"Object",
"value",
")",
"throws",
"Exception",
"{",
"if",
"(",
"value",
"instanceof",
"ScriptObjectMirror",
")",
"{",
"final",
"Map",
"map_value",
"=",
"Tool_error",
".",
"toMapError",
"(",
"value",
")",
";",
"if",
"(",
"isError",
"(",
"map_value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"StringUtils",
".",
"toString",
"(",
"map_value",
".",
"get",
"(",
"\"",
"message",
"\"",
")",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Map",
")",
"{",
"final",
"Map",
"map_value",
"=",
"(",
"Map",
")",
"value",
";",
"if",
"(",
"isError",
"(",
"map_value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"StringUtils",
".",
"toString",
"(",
"map_value",
".",
"get",
"(",
"\"",
"message",
"\"",
")",
")",
")",
";",
"}",
"}",
"return",
"value",
";",
"}",
"private",
"static",
"boolean",
"isError",
"(",
"final",
"Map",
"map_value",
")",
"{",
"return",
"map_value",
".",
"containsKey",
"(",
"\"",
"type",
"\"",
")",
"&&",
"map_value",
".",
"get",
"(",
"\"",
"type",
"\"",
")",
".",
"equals",
"(",
"\"",
"error",
"\"",
")",
"&&",
"StringUtils",
".",
"hasText",
"(",
"StringUtils",
".",
"toString",
"(",
"map_value",
".",
"get",
"(",
"\"",
"message",
"\"",
")",
")",
")",
";",
"}",
"}"
] | Program wrapper. | [
"Program",
"wrapper",
"."
] | [
"// ------------------------------------------------------------------------",
"// c o n s t a n t s",
"// ------------------------------------------------------------------------",
"// session expired",
"// ------------------------------------------------------------------------",
"// f i e l d s",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// c o n s t r u c t o r",
"// ------------------------------------------------------------------------",
"// clone program info",
"// ------------------------------------------------------------------------",
"// p u b l i c",
"// ------------------------------------------------------------------------",
"// ready for onInit method",
"// ------------------------------------------------------------------------",
"// p a c k a g e",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// p r i v a t e",
"// ------------------------------------------------------------------------",
"// extend program with custom context",
"// _program.context().put(ensureScriptPrefix(Tool_rnd.NAME), new Tool_rnd(this));",
"// _program.context().put(ensureScriptPrefix(Tool_resource.NAME), new Tool_resource(this));",
"// launch",
"// no script to evaluate",
"// ignored",
"// ------------------------------------------------------------------------",
"// S T A T I C",
"// ------------------------------------------------------------------------",
"// ignored"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
487543322645f0a7d7105bd89da0d773b92c12b2 | rollingglory/android-rgbase | app/src/main/java/app/model/Color.java | [
"MIT"
] | Java | Color | /**
* Created by mhasby on 9/28/2017.
* [email protected]
*/ | Created by mhasby on 9/28/2017. | [
"Created",
"by",
"mhasby",
"on",
"9",
"/",
"28",
"/",
"2017",
"."
] | public class Color {
public String name;
public int color;
public String hexacode;
public Color(String name, int color, String hexacode) {
this.name = name;
this.color = color;
this.hexacode = hexacode;
}
@Override
public String toString() {
return "Color{" +
"name='" + name + '\'' +
", color=" + color +
", hexacode='" + hexacode + '\'' +
'}';
}
} | [
"public",
"class",
"Color",
"{",
"public",
"String",
"name",
";",
"public",
"int",
"color",
";",
"public",
"String",
"hexacode",
";",
"public",
"Color",
"(",
"String",
"name",
",",
"int",
"color",
",",
"String",
"hexacode",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"color",
"=",
"color",
";",
"this",
".",
"hexacode",
"=",
"hexacode",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"",
"Color{",
"\"",
"+",
"\"",
"name='",
"\"",
"+",
"name",
"+",
"'\\''",
"+",
"\"",
", color=",
"\"",
"+",
"color",
"+",
"\"",
", hexacode='",
"\"",
"+",
"hexacode",
"+",
"'\\''",
"+",
"'}'",
";",
"}",
"}"
] | Created by mhasby on 9/28/2017. | [
"Created",
"by",
"mhasby",
"on",
"9",
"/",
"28",
"/",
"2017",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4877c60837fd1443429c35254bb92ed8ec8d17b8 | rajatbhatta/java-spanner | google-cloud-spanner/src/test/java/com/google/cloud/spanner/FailOnOverkillTraceComponentImpl.java | [
"Apache-2.0"
] | Java | FailOnOverkillTraceComponentImpl | /**
* Simple {@link TraceComponent} implementation that will throw an exception if a {@link Span} is
* ended more than once.
*/ | Simple TraceComponent implementation that will throw an exception if a Span is
ended more than once. | [
"Simple",
"TraceComponent",
"implementation",
"that",
"will",
"throw",
"an",
"exception",
"if",
"a",
"Span",
"is",
"ended",
"more",
"than",
"once",
"."
] | public class FailOnOverkillTraceComponentImpl extends TraceComponent {
private static final Random RANDOM = new Random();
private final Tracer tracer = new TestTracer();
private final PropagationComponent propagationComponent = new TestPropagationComponent();
private final Clock clock = ZeroTimeClock.getInstance();
private final ExportComponent exportComponent = new TestExportComponent();
private final TraceConfig traceConfig = new TestTraceConfig();
private static final Map<String, Boolean> spans = new LinkedHashMap<>();
public static class TestSpan extends Span {
@GuardedBy("this")
private volatile boolean ended = false;
private String spanName;
private TestSpan(String spanName, SpanContext context, EnumSet<Options> options) {
super(context, options);
this.spanName = spanName;
spans.put(this.spanName, false);
}
@Override
public void addAnnotation(String description, Map<String, AttributeValue> attributes) {}
@Override
public void addAnnotation(Annotation annotation) {}
@Override
public void addLink(Link link) {}
@Override
public void end(EndSpanOptions options) {
synchronized (this) {
if (ended) {
throw new IllegalStateException(this.spanName + " already ended");
}
spans.put(this.spanName, true);
ended = true;
}
}
}
public static class TestSpanBuilder extends SpanBuilder {
private String spanName;
TestSpanBuilder(String spanName) {
this.spanName = spanName;
}
@Override
public SpanBuilder setSampler(Sampler sampler) {
return this;
}
@Override
public SpanBuilder setParentLinks(List<Span> parentLinks) {
return this;
}
@Override
public SpanBuilder setRecordEvents(boolean recordEvents) {
return this;
}
@Override
public Span startSpan() {
return new TestSpan(
this.spanName,
SpanContext.create(
TraceId.generateRandomId(RANDOM),
SpanId.generateRandomId(RANDOM),
TraceOptions.builder().setIsSampled(true).build(),
Tracestate.builder().build()),
EnumSet.of(Options.RECORD_EVENTS));
}
}
public static class TestTracer extends Tracer {
@Override
public SpanBuilder spanBuilderWithExplicitParent(String spanName, Span parent) {
return new TestSpanBuilder(spanName);
}
@Override
public SpanBuilder spanBuilderWithRemoteParent(
String spanName, SpanContext remoteParentSpanContext) {
return new TestSpanBuilder(spanName);
}
}
public static class TestPropagationComponent extends PropagationComponent {
@Override
public BinaryFormat getBinaryFormat() {
return null;
}
@Override
public TextFormat getB3Format() {
return null;
}
@Override
public TextFormat getTraceContextFormat() {
return null;
}
}
public static class TestSpanExporter extends SpanExporter {
@Override
public void registerHandler(String name, Handler handler) {}
@Override
public void unregisterHandler(String name) {}
}
public static class TestExportComponent extends ExportComponent {
private final SpanExporter spanExporter = new TestSpanExporter();
@Override
public SpanExporter getSpanExporter() {
return spanExporter;
}
@Override
public RunningSpanStore getRunningSpanStore() {
return null;
}
@Override
public SampledSpanStore getSampledSpanStore() {
return null;
}
}
public static class TestTraceConfig extends TraceConfig {
private volatile TraceParams activeTraceParams = TraceParams.DEFAULT;
@Override
public TraceParams getActiveTraceParams() {
return activeTraceParams;
}
@Override
public void updateActiveTraceParams(TraceParams traceParams) {
this.activeTraceParams = traceParams;
}
}
@Override
public Tracer getTracer() {
return tracer;
}
Map<String, Boolean> getSpans() {
return spans;
}
void clearSpans() {
spans.clear();
}
@Override
public PropagationComponent getPropagationComponent() {
return propagationComponent;
}
@Override
public Clock getClock() {
return clock;
}
@Override
public ExportComponent getExportComponent() {
return exportComponent;
}
@Override
public TraceConfig getTraceConfig() {
return traceConfig;
}
} | [
"public",
"class",
"FailOnOverkillTraceComponentImpl",
"extends",
"TraceComponent",
"{",
"private",
"static",
"final",
"Random",
"RANDOM",
"=",
"new",
"Random",
"(",
")",
";",
"private",
"final",
"Tracer",
"tracer",
"=",
"new",
"TestTracer",
"(",
")",
";",
"private",
"final",
"PropagationComponent",
"propagationComponent",
"=",
"new",
"TestPropagationComponent",
"(",
")",
";",
"private",
"final",
"Clock",
"clock",
"=",
"ZeroTimeClock",
".",
"getInstance",
"(",
")",
";",
"private",
"final",
"ExportComponent",
"exportComponent",
"=",
"new",
"TestExportComponent",
"(",
")",
";",
"private",
"final",
"TraceConfig",
"traceConfig",
"=",
"new",
"TestTraceConfig",
"(",
")",
";",
"private",
"static",
"final",
"Map",
"<",
"String",
",",
"Boolean",
">",
"spans",
"=",
"new",
"LinkedHashMap",
"<",
">",
"(",
")",
";",
"public",
"static",
"class",
"TestSpan",
"extends",
"Span",
"{",
"@",
"GuardedBy",
"(",
"\"",
"this",
"\"",
")",
"private",
"volatile",
"boolean",
"ended",
"=",
"false",
";",
"private",
"String",
"spanName",
";",
"private",
"TestSpan",
"(",
"String",
"spanName",
",",
"SpanContext",
"context",
",",
"EnumSet",
"<",
"Options",
">",
"options",
")",
"{",
"super",
"(",
"context",
",",
"options",
")",
";",
"this",
".",
"spanName",
"=",
"spanName",
";",
"spans",
".",
"put",
"(",
"this",
".",
"spanName",
",",
"false",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"addAnnotation",
"(",
"String",
"description",
",",
"Map",
"<",
"String",
",",
"AttributeValue",
">",
"attributes",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"addAnnotation",
"(",
"Annotation",
"annotation",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"addLink",
"(",
"Link",
"link",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"end",
"(",
"EndSpanOptions",
"options",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"ended",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"this",
".",
"spanName",
"+",
"\"",
" already ended",
"\"",
")",
";",
"}",
"spans",
".",
"put",
"(",
"this",
".",
"spanName",
",",
"true",
")",
";",
"ended",
"=",
"true",
";",
"}",
"}",
"}",
"public",
"static",
"class",
"TestSpanBuilder",
"extends",
"SpanBuilder",
"{",
"private",
"String",
"spanName",
";",
"TestSpanBuilder",
"(",
"String",
"spanName",
")",
"{",
"this",
".",
"spanName",
"=",
"spanName",
";",
"}",
"@",
"Override",
"public",
"SpanBuilder",
"setSampler",
"(",
"Sampler",
"sampler",
")",
"{",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"SpanBuilder",
"setParentLinks",
"(",
"List",
"<",
"Span",
">",
"parentLinks",
")",
"{",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"SpanBuilder",
"setRecordEvents",
"(",
"boolean",
"recordEvents",
")",
"{",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"Span",
"startSpan",
"(",
")",
"{",
"return",
"new",
"TestSpan",
"(",
"this",
".",
"spanName",
",",
"SpanContext",
".",
"create",
"(",
"TraceId",
".",
"generateRandomId",
"(",
"RANDOM",
")",
",",
"SpanId",
".",
"generateRandomId",
"(",
"RANDOM",
")",
",",
"TraceOptions",
".",
"builder",
"(",
")",
".",
"setIsSampled",
"(",
"true",
")",
".",
"build",
"(",
")",
",",
"Tracestate",
".",
"builder",
"(",
")",
".",
"build",
"(",
")",
")",
",",
"EnumSet",
".",
"of",
"(",
"Options",
".",
"RECORD_EVENTS",
")",
")",
";",
"}",
"}",
"public",
"static",
"class",
"TestTracer",
"extends",
"Tracer",
"{",
"@",
"Override",
"public",
"SpanBuilder",
"spanBuilderWithExplicitParent",
"(",
"String",
"spanName",
",",
"Span",
"parent",
")",
"{",
"return",
"new",
"TestSpanBuilder",
"(",
"spanName",
")",
";",
"}",
"@",
"Override",
"public",
"SpanBuilder",
"spanBuilderWithRemoteParent",
"(",
"String",
"spanName",
",",
"SpanContext",
"remoteParentSpanContext",
")",
"{",
"return",
"new",
"TestSpanBuilder",
"(",
"spanName",
")",
";",
"}",
"}",
"public",
"static",
"class",
"TestPropagationComponent",
"extends",
"PropagationComponent",
"{",
"@",
"Override",
"public",
"BinaryFormat",
"getBinaryFormat",
"(",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"TextFormat",
"getB3Format",
"(",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"TextFormat",
"getTraceContextFormat",
"(",
")",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"class",
"TestSpanExporter",
"extends",
"SpanExporter",
"{",
"@",
"Override",
"public",
"void",
"registerHandler",
"(",
"String",
"name",
",",
"Handler",
"handler",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"unregisterHandler",
"(",
"String",
"name",
")",
"{",
"}",
"}",
"public",
"static",
"class",
"TestExportComponent",
"extends",
"ExportComponent",
"{",
"private",
"final",
"SpanExporter",
"spanExporter",
"=",
"new",
"TestSpanExporter",
"(",
")",
";",
"@",
"Override",
"public",
"SpanExporter",
"getSpanExporter",
"(",
")",
"{",
"return",
"spanExporter",
";",
"}",
"@",
"Override",
"public",
"RunningSpanStore",
"getRunningSpanStore",
"(",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"SampledSpanStore",
"getSampledSpanStore",
"(",
")",
"{",
"return",
"null",
";",
"}",
"}",
"public",
"static",
"class",
"TestTraceConfig",
"extends",
"TraceConfig",
"{",
"private",
"volatile",
"TraceParams",
"activeTraceParams",
"=",
"TraceParams",
".",
"DEFAULT",
";",
"@",
"Override",
"public",
"TraceParams",
"getActiveTraceParams",
"(",
")",
"{",
"return",
"activeTraceParams",
";",
"}",
"@",
"Override",
"public",
"void",
"updateActiveTraceParams",
"(",
"TraceParams",
"traceParams",
")",
"{",
"this",
".",
"activeTraceParams",
"=",
"traceParams",
";",
"}",
"}",
"@",
"Override",
"public",
"Tracer",
"getTracer",
"(",
")",
"{",
"return",
"tracer",
";",
"}",
"Map",
"<",
"String",
",",
"Boolean",
">",
"getSpans",
"(",
")",
"{",
"return",
"spans",
";",
"}",
"void",
"clearSpans",
"(",
")",
"{",
"spans",
".",
"clear",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"PropagationComponent",
"getPropagationComponent",
"(",
")",
"{",
"return",
"propagationComponent",
";",
"}",
"@",
"Override",
"public",
"Clock",
"getClock",
"(",
")",
"{",
"return",
"clock",
";",
"}",
"@",
"Override",
"public",
"ExportComponent",
"getExportComponent",
"(",
")",
"{",
"return",
"exportComponent",
";",
"}",
"@",
"Override",
"public",
"TraceConfig",
"getTraceConfig",
"(",
")",
"{",
"return",
"traceConfig",
";",
"}",
"}"
] | Simple {@link TraceComponent} implementation that will throw an exception if a {@link Span} is
ended more than once. | [
"Simple",
"{",
"@link",
"TraceComponent",
"}",
"implementation",
"that",
"will",
"throw",
"an",
"exception",
"if",
"a",
"{",
"@link",
"Span",
"}",
"is",
"ended",
"more",
"than",
"once",
"."
] | [] | [
{
"param": "TraceComponent",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "TraceComponent",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
48797e70d2efdc15ef5a65d37144fa5f56498569 | carloscohen2202/xlt-nocoding | src/main/java/com/xceptance/xlt/nocoding/parser/ParserFactory.java | [
"Apache-2.0"
] | Java | ParserFactory | /**
* The class for getting the accepted extensions and the associated {@link Parser} for the extension
*
* @author ckeiner
*/ | The class for getting the accepted extensions and the associated Parser for the extension
@author ckeiner | [
"The",
"class",
"for",
"getting",
"the",
"accepted",
"extensions",
"and",
"the",
"associated",
"Parser",
"for",
"the",
"extension",
"@author",
"ckeiner"
] | public class ParserFactory
{
/**
* The singleton instance of <code>ParserFactory</code>
*/
private static ParserFactory factoryInstance;
/**
* The map, that maps the extension to a concrete parser
*/
private final Map<String, Parser> extensionsMap;
/**
* Creates a new instance of <code>ParserFactory</code> and fills {@link #extensionsMap} with the known Parsers and
* its extensions
*/
private ParserFactory()
{
extensionsMap = new HashMap<>();
final CsvParser csvParser = new CsvParser();
final YamlParser yamlParser = new YamlParser();
for (final String extension : csvParser.getExtensions())
{
extensionsMap.put(extension, csvParser);
}
for (final String extension : yamlParser.getExtensions())
{
extensionsMap.put(extension, yamlParser);
}
}
/**
* Either creates an instance of <code>ParserFactory</code> if {@link #factoryInstance} is <code>null</code> or
* returns <code>factoryInstance</code>.
*
* @return the singleton instance of <code>ParserFactory</code>
*/
public static synchronized ParserFactory getInstance()
{
if (factoryInstance == null)
{
factoryInstance = new ParserFactory();
}
return factoryInstance;
}
/**
* Returns a list of all known file extensions for the parser, therefore it returns the {@link Map#keySet()} of
* {@link #extensionsMap}.
*
* @return A list with the content of {@link Map#keySet()} of {@link #extensionsMap}.
*/
public List<String> getExtensions()
{
return new ArrayList<>(extensionsMap.keySet());
}
/**
* Checks the parser for its file extensions and then creates the parser is the extension fits
*
* @param file
* @return The Parser associated with the extension of <code>file</code>
*/
public Parser getParser(final String file)
{
// Extract the extension of the file, that is the last position of the . +1, so we cut out the dot
final String extension = file.substring(file.lastIndexOf('.') + 1);
// Get the Parser instance from the extensionsMap
final Parser parser = extensionsMap.get(extension);
// If the parser is null, the extensions could not be found
if (parser == null)
{
throw new IllegalArgumentException("Could not find appropriate parser for the extension " + extension + " with the path "
+ file);
}
XltLogger.runTimeLogger.debug("Using " + parser.getClass().getSimpleName() + " for " + file);
return parser;
}
} | [
"public",
"class",
"ParserFactory",
"{",
"/**\n * The singleton instance of <code>ParserFactory</code>\n */",
"private",
"static",
"ParserFactory",
"factoryInstance",
";",
"/**\n * The map, that maps the extension to a concrete parser\n */",
"private",
"final",
"Map",
"<",
"String",
",",
"Parser",
">",
"extensionsMap",
";",
"/**\n * Creates a new instance of <code>ParserFactory</code> and fills {@link #extensionsMap} with the known Parsers and\n * its extensions\n */",
"private",
"ParserFactory",
"(",
")",
"{",
"extensionsMap",
"=",
"new",
"HashMap",
"<",
">",
"(",
")",
";",
"final",
"CsvParser",
"csvParser",
"=",
"new",
"CsvParser",
"(",
")",
";",
"final",
"YamlParser",
"yamlParser",
"=",
"new",
"YamlParser",
"(",
")",
";",
"for",
"(",
"final",
"String",
"extension",
":",
"csvParser",
".",
"getExtensions",
"(",
")",
")",
"{",
"extensionsMap",
".",
"put",
"(",
"extension",
",",
"csvParser",
")",
";",
"}",
"for",
"(",
"final",
"String",
"extension",
":",
"yamlParser",
".",
"getExtensions",
"(",
")",
")",
"{",
"extensionsMap",
".",
"put",
"(",
"extension",
",",
"yamlParser",
")",
";",
"}",
"}",
"/**\n * Either creates an instance of <code>ParserFactory</code> if {@link #factoryInstance} is <code>null</code> or\n * returns <code>factoryInstance</code>.\n *\n * @return the singleton instance of <code>ParserFactory</code>\n */",
"public",
"static",
"synchronized",
"ParserFactory",
"getInstance",
"(",
")",
"{",
"if",
"(",
"factoryInstance",
"==",
"null",
")",
"{",
"factoryInstance",
"=",
"new",
"ParserFactory",
"(",
")",
";",
"}",
"return",
"factoryInstance",
";",
"}",
"/**\n * Returns a list of all known file extensions for the parser, therefore it returns the {@link Map#keySet()} of\n * {@link #extensionsMap}.\n *\n * @return A list with the content of {@link Map#keySet()} of {@link #extensionsMap}.\n */",
"public",
"List",
"<",
"String",
">",
"getExtensions",
"(",
")",
"{",
"return",
"new",
"ArrayList",
"<",
">",
"(",
"extensionsMap",
".",
"keySet",
"(",
")",
")",
";",
"}",
"/**\n * Checks the parser for its file extensions and then creates the parser is the extension fits\n *\n * @param file\n * @return The Parser associated with the extension of <code>file</code>\n */",
"public",
"Parser",
"getParser",
"(",
"final",
"String",
"file",
")",
"{",
"final",
"String",
"extension",
"=",
"file",
".",
"substring",
"(",
"file",
".",
"lastIndexOf",
"(",
"'.'",
")",
"+",
"1",
")",
";",
"final",
"Parser",
"parser",
"=",
"extensionsMap",
".",
"get",
"(",
"extension",
")",
";",
"if",
"(",
"parser",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Could not find appropriate parser for the extension ",
"\"",
"+",
"extension",
"+",
"\"",
" with the path ",
"\"",
"+",
"file",
")",
";",
"}",
"XltLogger",
".",
"runTimeLogger",
".",
"debug",
"(",
"\"",
"Using ",
"\"",
"+",
"parser",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\"",
" for ",
"\"",
"+",
"file",
")",
";",
"return",
"parser",
";",
"}",
"}"
] | The class for getting the accepted extensions and the associated {@link Parser} for the extension
@author ckeiner | [
"The",
"class",
"for",
"getting",
"the",
"accepted",
"extensions",
"and",
"the",
"associated",
"{",
"@link",
"Parser",
"}",
"for",
"the",
"extension",
"@author",
"ckeiner"
] | [
"// Extract the extension of the file, that is the last position of the . +1, so we cut out the dot",
"// Get the Parser instance from the extensionsMap",
"// If the parser is null, the extensions could not be found"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
487a3774313e2831d56605ec3d872e92f5a24810 | riazanov/alabai | src/main/java/logic/is/power/alabai/BackwardSubsumptionIndex.java | [
"ECL-2.0",
"Apache-2.0"
] | Java | BackwardSubsumptionIndex | /** Index for backward subsumption and backward subsumption resolution. */ | Index for backward subsumption and backward subsumption resolution. | [
"Index",
"for",
"backward",
"subsumption",
"and",
"backward",
"subsumption",
"resolution",
"."
] | final class BackwardSubsumptionIndex {
public BackwardSubsumptionIndex() {
_locks = 0;
}
/** Feature functions that will be used to compute feature
* vector on indexed clauses and queries;
* <b>pre:</b> the index is empty.
*/
public
final
void
setFeatureFunctionVector(ClauseFeatureVector vector) {
_featureFunctionVector = vector;
_featureVector =
new FeatureVector.ArrayBased(vector.size());
_index = new FeatureVectorIndex<LinkedList<Clause>>(vector.size());
}
/** Indicates if the index is in use by some retrieval objects. */
public final boolean isLocked() { return _locks > 0; }
/** <b>pre:</b> <code>!isLocked()</code> */
public final void insert(Clause cl) {
//System.out.println("BS INSERT " + cl);
assert !isLocked();
if (cl.literals().isEmpty()) return;
_featureFunctionVector.
evaluate(cl.literals(),
_featureVector,
0);
Ref<LinkedList<Clause>> indexedObject =
_index.insert(_featureVector);
if (indexedObject.content == null)
indexedObject.content = new LinkedList<Clause>();
indexedObject.content.addLast(cl);
} // insert(Clause cl)
/** <b>pre:</b> <code>!isLocked()</code>
* @return false if the clause is not in the index
*/
public final boolean erase(Clause cl) {
//System.out.println("BS ERASE " + cl);
assert !isLocked();
_featureFunctionVector.
evaluate(cl.literals(),
_featureVector,
0);
Ref<LinkedList<Clause>> indexedObject =
_index.find(_featureVector);
if (indexedObject == null) return false;
assert indexedObject.content != null;
assert !indexedObject.content.isEmpty();
if (!indexedObject.content.remove(cl))
return false;
if (indexedObject.content.isEmpty())
_index.remove(_featureVector,
new Ref<LinkedList<Clause>>());
return true;
} // erase(Clause cl)
/** Iteration over all (undiscarded) indexed clauses subsumed
* by a given query clause.
*/
public class Retrieval implements java.util.Iterator<Clause> {
/** <b>pre:</b>
* {@link logic_warehouse_je#BackwardSubsumptionIndex#setFeatureFunctionVector()}
* must have been called.
*/
public Retrieval() {
_leaves = _index.new Subsumed();
_queryFeatureVector =
new FeatureVector.ArrayBased(_featureFunctionVector.size());
_oneToOneSubsumption = new BackwardSubsumption();
_witnessSubstitution = new Substitution3();
}
/** Clears the state; in particular, releases all pointers to external
* objects and clears the witness substitution; in particular,
* unlocks the host index if it was locked by retrieval.
*/
public final void clear() {
_leaves.clear();
if (_query != null) --_locks;
_query = null;
_clauseIter = null;
_nextClause = null;
_oneToOneSubsumption.clear();
assert _witnessSubstitution.empty();
}
/** Initiates a new retrieval round; automatically locks
* the host index unless the object has been already
* performing retrieval.
*/
public final void reset(Clause query) {
//System.out.println("BS QUERY " + query);
if (_query != null) --_locks;
_query = query;
++_locks;
_featureFunctionVector.
evaluate(_query.literals(),
_queryFeatureVector,
0);
_leaves.reset(_queryFeatureVector);
if (_leaves.hasNext())
{
_clauseIter = _leaves.next().iterator();
assert _clauseIter.hasNext();
_oneToOneSubsumption.setSubsumer(_query.literals());
findNextSubsumedClause();
}
else
{
_nextClause = null;
};
} // reset(NewClause query)
public final boolean hasNext() {
//if (_nextClause != null)
//System.out.println("EXISTS B SUBSUMED " + _nextClause);
return _nextClause != null;
}
/** Next subsumed clause; cannot be the same object as
* the current query, although it can be syntactically
* identical.
*/
public
final
Clause next() throws java.util.NoSuchElementException {
if (!hasNext())
throw new java.util.NoSuchElementException();
Clause result = _nextClause;
findNextSubsumedClause();
//System.out.println("B SUBSUMED " + result);
return result;
} // next()
/** Cannot be used. */
public final void remove() throws Error {
throw
new Error("Forbidden method call: alabai_je.BackwardSubsumptionIndex.Retrieval.remove()");
}
private void findNextSubsumedClause() {
while (_clauseIter.hasNext())
{
_nextClause = _clauseIter.next();
if (_nextClause != _query &&
!_nextClause.isDiscarded() &&
_oneToOneSubsumption.subsume(_nextClause.literals(),
_witnessSubstitution))
{
_witnessSubstitution.uninstantiateAll();
return;
};
if (!_clauseIter.hasNext())
if (_leaves.hasNext())
{
_clauseIter = _leaves.next().iterator();
assert _clauseIter.hasNext();
};
}; // while (__clauseIter.hasNext())
_nextClause = null;
} // findNextSubsumedClause()
// Data:
private
final
FeatureVectorIndex<LinkedList<Clause>>.Subsumed
_leaves;
private Clause _query;
private final FeatureVector.ArrayBased _queryFeatureVector;
private Iterator<Clause> _clauseIter;
private Clause _nextClause;
private final BackwardSubsumption _oneToOneSubsumption;
private final Substitution3 _witnessSubstitution;
} // class Retrieval
// Data:
private int _locks;
private ClauseFeatureVector _featureFunctionVector;
private FeatureVectorIndex<LinkedList<Clause>> _index;
private FeatureVector.ArrayBased _featureVector;
} | [
"final",
"class",
"BackwardSubsumptionIndex",
"{",
"public",
"BackwardSubsumptionIndex",
"(",
")",
"{",
"_locks",
"=",
"0",
";",
"}",
"/** Feature functions that will be used to compute feature\n * vector on indexed clauses and queries;\n * <b>pre:</b> the index is empty.\n */",
"public",
"final",
"void",
"setFeatureFunctionVector",
"(",
"ClauseFeatureVector",
"vector",
")",
"{",
"_featureFunctionVector",
"=",
"vector",
";",
"_featureVector",
"=",
"new",
"FeatureVector",
".",
"ArrayBased",
"(",
"vector",
".",
"size",
"(",
")",
")",
";",
"_index",
"=",
"new",
"FeatureVectorIndex",
"<",
"LinkedList",
"<",
"Clause",
">",
">",
"(",
"vector",
".",
"size",
"(",
")",
")",
";",
"}",
"/** Indicates if the index is in use by some retrieval objects. */",
"public",
"final",
"boolean",
"isLocked",
"(",
")",
"{",
"return",
"_locks",
">",
"0",
";",
"}",
"/** <b>pre:</b> <code>!isLocked()</code> */",
"public",
"final",
"void",
"insert",
"(",
"Clause",
"cl",
")",
"{",
"assert",
"!",
"isLocked",
"(",
")",
";",
"if",
"(",
"cl",
".",
"literals",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"_featureFunctionVector",
".",
"evaluate",
"(",
"cl",
".",
"literals",
"(",
")",
",",
"_featureVector",
",",
"0",
")",
";",
"Ref",
"<",
"LinkedList",
"<",
"Clause",
">",
">",
"indexedObject",
"=",
"_index",
".",
"insert",
"(",
"_featureVector",
")",
";",
"if",
"(",
"indexedObject",
".",
"content",
"==",
"null",
")",
"indexedObject",
".",
"content",
"=",
"new",
"LinkedList",
"<",
"Clause",
">",
"(",
")",
";",
"indexedObject",
".",
"content",
".",
"addLast",
"(",
"cl",
")",
";",
"}",
"/** <b>pre:</b> <code>!isLocked()</code>\n * @return false if the clause is not in the index \n */",
"public",
"final",
"boolean",
"erase",
"(",
"Clause",
"cl",
")",
"{",
"assert",
"!",
"isLocked",
"(",
")",
";",
"_featureFunctionVector",
".",
"evaluate",
"(",
"cl",
".",
"literals",
"(",
")",
",",
"_featureVector",
",",
"0",
")",
";",
"Ref",
"<",
"LinkedList",
"<",
"Clause",
">",
">",
"indexedObject",
"=",
"_index",
".",
"find",
"(",
"_featureVector",
")",
";",
"if",
"(",
"indexedObject",
"==",
"null",
")",
"return",
"false",
";",
"assert",
"indexedObject",
".",
"content",
"!=",
"null",
";",
"assert",
"!",
"indexedObject",
".",
"content",
".",
"isEmpty",
"(",
")",
";",
"if",
"(",
"!",
"indexedObject",
".",
"content",
".",
"remove",
"(",
"cl",
")",
")",
"return",
"false",
";",
"if",
"(",
"indexedObject",
".",
"content",
".",
"isEmpty",
"(",
")",
")",
"_index",
".",
"remove",
"(",
"_featureVector",
",",
"new",
"Ref",
"<",
"LinkedList",
"<",
"Clause",
">",
">",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"/** Iteration over all (undiscarded) indexed clauses subsumed \n * by a given query clause.\n */",
"public",
"class",
"Retrieval",
"implements",
"java",
".",
"util",
".",
"Iterator",
"<",
"Clause",
">",
"{",
"/** <b>pre:</b> \n\t * {@link logic_warehouse_je#BackwardSubsumptionIndex#setFeatureFunctionVector()} \n\t * must have been called.\n\t */",
"public",
"Retrieval",
"(",
")",
"{",
"_leaves",
"=",
"_index",
".",
"new",
"Subsumed",
"(",
")",
";",
"_queryFeatureVector",
"=",
"new",
"FeatureVector",
".",
"ArrayBased",
"(",
"_featureFunctionVector",
".",
"size",
"(",
")",
")",
";",
"_oneToOneSubsumption",
"=",
"new",
"BackwardSubsumption",
"(",
")",
";",
"_witnessSubstitution",
"=",
"new",
"Substitution3",
"(",
")",
";",
"}",
"/** Clears the state; in particular, releases all pointers to external \n\t * objects and clears the witness substitution; in particular,\n\t * unlocks the host index if it was locked by retrieval.\n\t */",
"public",
"final",
"void",
"clear",
"(",
")",
"{",
"_leaves",
".",
"clear",
"(",
")",
";",
"if",
"(",
"_query",
"!=",
"null",
")",
"--",
"_locks",
";",
"_query",
"=",
"null",
";",
"_clauseIter",
"=",
"null",
";",
"_nextClause",
"=",
"null",
";",
"_oneToOneSubsumption",
".",
"clear",
"(",
")",
";",
"assert",
"_witnessSubstitution",
".",
"empty",
"(",
")",
";",
"}",
"/** Initiates a new retrieval round; automatically locks \n\t * the host index unless the object has been already\n\t * performing retrieval.\n\t */",
"public",
"final",
"void",
"reset",
"(",
"Clause",
"query",
")",
"{",
"if",
"(",
"_query",
"!=",
"null",
")",
"--",
"_locks",
";",
"_query",
"=",
"query",
";",
"++",
"_locks",
";",
"_featureFunctionVector",
".",
"evaluate",
"(",
"_query",
".",
"literals",
"(",
")",
",",
"_queryFeatureVector",
",",
"0",
")",
";",
"_leaves",
".",
"reset",
"(",
"_queryFeatureVector",
")",
";",
"if",
"(",
"_leaves",
".",
"hasNext",
"(",
")",
")",
"{",
"_clauseIter",
"=",
"_leaves",
".",
"next",
"(",
")",
".",
"iterator",
"(",
")",
";",
"assert",
"_clauseIter",
".",
"hasNext",
"(",
")",
";",
"_oneToOneSubsumption",
".",
"setSubsumer",
"(",
"_query",
".",
"literals",
"(",
")",
")",
";",
"findNextSubsumedClause",
"(",
")",
";",
"}",
"else",
"{",
"_nextClause",
"=",
"null",
";",
"}",
";",
"}",
"public",
"final",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"_nextClause",
"!=",
"null",
";",
"}",
"/** Next subsumed clause; cannot be the same object as \n\t * the current query, although it can be syntactically\n\t * identical.\n\t */",
"public",
"final",
"Clause",
"next",
"(",
")",
"throws",
"java",
".",
"util",
".",
"NoSuchElementException",
"{",
"if",
"(",
"!",
"hasNext",
"(",
")",
")",
"throw",
"new",
"java",
".",
"util",
".",
"NoSuchElementException",
"(",
")",
";",
"Clause",
"result",
"=",
"_nextClause",
";",
"findNextSubsumedClause",
"(",
")",
";",
"return",
"result",
";",
"}",
"/** Cannot be used. */",
"public",
"final",
"void",
"remove",
"(",
")",
"throws",
"Error",
"{",
"throw",
"new",
"Error",
"(",
"\"",
"Forbidden method call: alabai_je.BackwardSubsumptionIndex.Retrieval.remove()",
"\"",
")",
";",
"}",
"private",
"void",
"findNextSubsumedClause",
"(",
")",
"{",
"while",
"(",
"_clauseIter",
".",
"hasNext",
"(",
")",
")",
"{",
"_nextClause",
"=",
"_clauseIter",
".",
"next",
"(",
")",
";",
"if",
"(",
"_nextClause",
"!=",
"_query",
"&&",
"!",
"_nextClause",
".",
"isDiscarded",
"(",
")",
"&&",
"_oneToOneSubsumption",
".",
"subsume",
"(",
"_nextClause",
".",
"literals",
"(",
")",
",",
"_witnessSubstitution",
")",
")",
"{",
"_witnessSubstitution",
".",
"uninstantiateAll",
"(",
")",
";",
"return",
";",
"}",
";",
"if",
"(",
"!",
"_clauseIter",
".",
"hasNext",
"(",
")",
")",
"if",
"(",
"_leaves",
".",
"hasNext",
"(",
")",
")",
"{",
"_clauseIter",
"=",
"_leaves",
".",
"next",
"(",
")",
".",
"iterator",
"(",
")",
";",
"assert",
"_clauseIter",
".",
"hasNext",
"(",
")",
";",
"}",
";",
"}",
";",
"_nextClause",
"=",
"null",
";",
"}",
"private",
"final",
"FeatureVectorIndex",
"<",
"LinkedList",
"<",
"Clause",
">",
">",
".",
"Subsumed",
"_leaves",
";",
"private",
"Clause",
"_query",
";",
"private",
"final",
"FeatureVector",
".",
"ArrayBased",
"_queryFeatureVector",
";",
"private",
"Iterator",
"<",
"Clause",
">",
"_clauseIter",
";",
"private",
"Clause",
"_nextClause",
";",
"private",
"final",
"BackwardSubsumption",
"_oneToOneSubsumption",
";",
"private",
"final",
"Substitution3",
"_witnessSubstitution",
";",
"}",
"private",
"int",
"_locks",
";",
"private",
"ClauseFeatureVector",
"_featureFunctionVector",
";",
"private",
"FeatureVectorIndex",
"<",
"LinkedList",
"<",
"Clause",
">",
">",
"_index",
";",
"private",
"FeatureVector",
".",
"ArrayBased",
"_featureVector",
";",
"}"
] | Index for backward subsumption and backward subsumption resolution. | [
"Index",
"for",
"backward",
"subsumption",
"and",
"backward",
"subsumption",
"resolution",
"."
] | [
"//System.out.println(\"BS INSERT \" + cl);",
"// insert(Clause cl)",
"//System.out.println(\"BS ERASE \" + cl);",
"// erase(Clause cl)",
"//System.out.println(\"BS QUERY \" + query);",
"// reset(NewClause query)",
"//if (_nextClause != null)",
"//System.out.println(\"EXISTS B SUBSUMED \" + _nextClause);",
"//System.out.println(\"B SUBSUMED \" + result);",
"// next()",
"// while (__clauseIter.hasNext())",
"// findNextSubsumedClause()",
"// Data:",
"// class Retrieval",
"// Data:"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
487a3774313e2831d56605ec3d872e92f5a24810 | riazanov/alabai | src/main/java/logic/is/power/alabai/BackwardSubsumptionIndex.java | [
"ECL-2.0",
"Apache-2.0"
] | Java | Retrieval | /** Iteration over all (undiscarded) indexed clauses subsumed
* by a given query clause.
*/ | Iteration over all (undiscarded) indexed clauses subsumed
by a given query clause. | [
"Iteration",
"over",
"all",
"(",
"undiscarded",
")",
"indexed",
"clauses",
"subsumed",
"by",
"a",
"given",
"query",
"clause",
"."
] | public class Retrieval implements java.util.Iterator<Clause> {
/** <b>pre:</b>
* {@link logic_warehouse_je#BackwardSubsumptionIndex#setFeatureFunctionVector()}
* must have been called.
*/
public Retrieval() {
_leaves = _index.new Subsumed();
_queryFeatureVector =
new FeatureVector.ArrayBased(_featureFunctionVector.size());
_oneToOneSubsumption = new BackwardSubsumption();
_witnessSubstitution = new Substitution3();
}
/** Clears the state; in particular, releases all pointers to external
* objects and clears the witness substitution; in particular,
* unlocks the host index if it was locked by retrieval.
*/
public final void clear() {
_leaves.clear();
if (_query != null) --_locks;
_query = null;
_clauseIter = null;
_nextClause = null;
_oneToOneSubsumption.clear();
assert _witnessSubstitution.empty();
}
/** Initiates a new retrieval round; automatically locks
* the host index unless the object has been already
* performing retrieval.
*/
public final void reset(Clause query) {
//System.out.println("BS QUERY " + query);
if (_query != null) --_locks;
_query = query;
++_locks;
_featureFunctionVector.
evaluate(_query.literals(),
_queryFeatureVector,
0);
_leaves.reset(_queryFeatureVector);
if (_leaves.hasNext())
{
_clauseIter = _leaves.next().iterator();
assert _clauseIter.hasNext();
_oneToOneSubsumption.setSubsumer(_query.literals());
findNextSubsumedClause();
}
else
{
_nextClause = null;
};
} // reset(NewClause query)
public final boolean hasNext() {
//if (_nextClause != null)
//System.out.println("EXISTS B SUBSUMED " + _nextClause);
return _nextClause != null;
}
/** Next subsumed clause; cannot be the same object as
* the current query, although it can be syntactically
* identical.
*/
public
final
Clause next() throws java.util.NoSuchElementException {
if (!hasNext())
throw new java.util.NoSuchElementException();
Clause result = _nextClause;
findNextSubsumedClause();
//System.out.println("B SUBSUMED " + result);
return result;
} // next()
/** Cannot be used. */
public final void remove() throws Error {
throw
new Error("Forbidden method call: alabai_je.BackwardSubsumptionIndex.Retrieval.remove()");
}
private void findNextSubsumedClause() {
while (_clauseIter.hasNext())
{
_nextClause = _clauseIter.next();
if (_nextClause != _query &&
!_nextClause.isDiscarded() &&
_oneToOneSubsumption.subsume(_nextClause.literals(),
_witnessSubstitution))
{
_witnessSubstitution.uninstantiateAll();
return;
};
if (!_clauseIter.hasNext())
if (_leaves.hasNext())
{
_clauseIter = _leaves.next().iterator();
assert _clauseIter.hasNext();
};
}; // while (__clauseIter.hasNext())
_nextClause = null;
} // findNextSubsumedClause()
// Data:
private
final
FeatureVectorIndex<LinkedList<Clause>>.Subsumed
_leaves;
private Clause _query;
private final FeatureVector.ArrayBased _queryFeatureVector;
private Iterator<Clause> _clauseIter;
private Clause _nextClause;
private final BackwardSubsumption _oneToOneSubsumption;
private final Substitution3 _witnessSubstitution;
} | [
"public",
"class",
"Retrieval",
"implements",
"java",
".",
"util",
".",
"Iterator",
"<",
"Clause",
">",
"{",
"/** <b>pre:</b> \n\t * {@link logic_warehouse_je#BackwardSubsumptionIndex#setFeatureFunctionVector()} \n\t * must have been called.\n\t */",
"public",
"Retrieval",
"(",
")",
"{",
"_leaves",
"=",
"_index",
".",
"new",
"Subsumed",
"(",
")",
";",
"_queryFeatureVector",
"=",
"new",
"FeatureVector",
".",
"ArrayBased",
"(",
"_featureFunctionVector",
".",
"size",
"(",
")",
")",
";",
"_oneToOneSubsumption",
"=",
"new",
"BackwardSubsumption",
"(",
")",
";",
"_witnessSubstitution",
"=",
"new",
"Substitution3",
"(",
")",
";",
"}",
"/** Clears the state; in particular, releases all pointers to external \n\t * objects and clears the witness substitution; in particular,\n\t * unlocks the host index if it was locked by retrieval.\n\t */",
"public",
"final",
"void",
"clear",
"(",
")",
"{",
"_leaves",
".",
"clear",
"(",
")",
";",
"if",
"(",
"_query",
"!=",
"null",
")",
"--",
"_locks",
";",
"_query",
"=",
"null",
";",
"_clauseIter",
"=",
"null",
";",
"_nextClause",
"=",
"null",
";",
"_oneToOneSubsumption",
".",
"clear",
"(",
")",
";",
"assert",
"_witnessSubstitution",
".",
"empty",
"(",
")",
";",
"}",
"/** Initiates a new retrieval round; automatically locks \n\t * the host index unless the object has been already\n\t * performing retrieval.\n\t */",
"public",
"final",
"void",
"reset",
"(",
"Clause",
"query",
")",
"{",
"if",
"(",
"_query",
"!=",
"null",
")",
"--",
"_locks",
";",
"_query",
"=",
"query",
";",
"++",
"_locks",
";",
"_featureFunctionVector",
".",
"evaluate",
"(",
"_query",
".",
"literals",
"(",
")",
",",
"_queryFeatureVector",
",",
"0",
")",
";",
"_leaves",
".",
"reset",
"(",
"_queryFeatureVector",
")",
";",
"if",
"(",
"_leaves",
".",
"hasNext",
"(",
")",
")",
"{",
"_clauseIter",
"=",
"_leaves",
".",
"next",
"(",
")",
".",
"iterator",
"(",
")",
";",
"assert",
"_clauseIter",
".",
"hasNext",
"(",
")",
";",
"_oneToOneSubsumption",
".",
"setSubsumer",
"(",
"_query",
".",
"literals",
"(",
")",
")",
";",
"findNextSubsumedClause",
"(",
")",
";",
"}",
"else",
"{",
"_nextClause",
"=",
"null",
";",
"}",
";",
"}",
"public",
"final",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"_nextClause",
"!=",
"null",
";",
"}",
"/** Next subsumed clause; cannot be the same object as \n\t * the current query, although it can be syntactically\n\t * identical.\n\t */",
"public",
"final",
"Clause",
"next",
"(",
")",
"throws",
"java",
".",
"util",
".",
"NoSuchElementException",
"{",
"if",
"(",
"!",
"hasNext",
"(",
")",
")",
"throw",
"new",
"java",
".",
"util",
".",
"NoSuchElementException",
"(",
")",
";",
"Clause",
"result",
"=",
"_nextClause",
";",
"findNextSubsumedClause",
"(",
")",
";",
"return",
"result",
";",
"}",
"/** Cannot be used. */",
"public",
"final",
"void",
"remove",
"(",
")",
"throws",
"Error",
"{",
"throw",
"new",
"Error",
"(",
"\"",
"Forbidden method call: alabai_je.BackwardSubsumptionIndex.Retrieval.remove()",
"\"",
")",
";",
"}",
"private",
"void",
"findNextSubsumedClause",
"(",
")",
"{",
"while",
"(",
"_clauseIter",
".",
"hasNext",
"(",
")",
")",
"{",
"_nextClause",
"=",
"_clauseIter",
".",
"next",
"(",
")",
";",
"if",
"(",
"_nextClause",
"!=",
"_query",
"&&",
"!",
"_nextClause",
".",
"isDiscarded",
"(",
")",
"&&",
"_oneToOneSubsumption",
".",
"subsume",
"(",
"_nextClause",
".",
"literals",
"(",
")",
",",
"_witnessSubstitution",
")",
")",
"{",
"_witnessSubstitution",
".",
"uninstantiateAll",
"(",
")",
";",
"return",
";",
"}",
";",
"if",
"(",
"!",
"_clauseIter",
".",
"hasNext",
"(",
")",
")",
"if",
"(",
"_leaves",
".",
"hasNext",
"(",
")",
")",
"{",
"_clauseIter",
"=",
"_leaves",
".",
"next",
"(",
")",
".",
"iterator",
"(",
")",
";",
"assert",
"_clauseIter",
".",
"hasNext",
"(",
")",
";",
"}",
";",
"}",
";",
"_nextClause",
"=",
"null",
";",
"}",
"private",
"final",
"FeatureVectorIndex",
"<",
"LinkedList",
"<",
"Clause",
">",
">",
".",
"Subsumed",
"_leaves",
";",
"private",
"Clause",
"_query",
";",
"private",
"final",
"FeatureVector",
".",
"ArrayBased",
"_queryFeatureVector",
";",
"private",
"Iterator",
"<",
"Clause",
">",
"_clauseIter",
";",
"private",
"Clause",
"_nextClause",
";",
"private",
"final",
"BackwardSubsumption",
"_oneToOneSubsumption",
";",
"private",
"final",
"Substitution3",
"_witnessSubstitution",
";",
"}"
] | Iteration over all (undiscarded) indexed clauses subsumed
by a given query clause. | [
"Iteration",
"over",
"all",
"(",
"undiscarded",
")",
"indexed",
"clauses",
"subsumed",
"by",
"a",
"given",
"query",
"clause",
"."
] | [
"//System.out.println(\"BS QUERY \" + query);",
"// reset(NewClause query)",
"//if (_nextClause != null)",
"//System.out.println(\"EXISTS B SUBSUMED \" + _nextClause);",
"//System.out.println(\"B SUBSUMED \" + result);",
"// next()",
"// while (__clauseIter.hasNext())",
"// findNextSubsumedClause()",
"// Data:"
] | [
{
"param": "java.util.Iterator<Clause>",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "java.util.Iterator<Clause>",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
487c99b20299d8a0c1e8544b62bdf10b948d7779 | andreamlin/google-cloud-java | google-cloud-clients/google-cloud-talent/src/main/java/com/google/cloud/talent/v4beta1/ResumeServiceClient.java | [
"Apache-2.0"
] | Java | ResumeServiceClient | /**
* Service Description: A service that handles resume parsing.
*
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>
* <code>
* try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ByteString resume = ByteString.copyFromUtf8("");
* ParseResumeResponse response = resumeServiceClient.parseResume(parent, resume);
* }
* </code>
* </pre>
*
* <p>Note: close() needs to be called on the resumeServiceClient object to clean up resources such
* as threads. In the example above, try-with-resources is used, which automatically calls close().
*
* <p>The surface of this class includes several types of Java methods for each of the API's
* methods:
*
* <ol>
* <li>A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available as
* parameters, and not every API method will have a flattened method entry point.
* <li>A "request object" method. This type of method only takes one parameter, a request object,
* which must be constructed before the call. Not every API method will have a request object
* method.
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API
* callable object, which can be used to initiate calls to the service.
* </ol>
*
* <p>See the individual methods for example code.
*
* <p>Many parameters require resource names to be formatted in a particular way. To assist with
* these names, this class includes a format method for each type of name, and additionally a parse
* method to extract the individual identifiers contained within names that are returned.
*
* <p>This class can be customized by passing in a custom instance of ResumeServiceSettings to
* create(). For example:
*
* <p>To customize credentials:
*
* <pre>
* <code>
* ResumeServiceSettings resumeServiceSettings =
* ResumeServiceSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* ResumeServiceClient resumeServiceClient =
* ResumeServiceClient.create(resumeServiceSettings);
* </code>
* </pre>
*
* To customize the endpoint:
*
* <pre>
* <code>
* ResumeServiceSettings resumeServiceSettings =
* ResumeServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
* ResumeServiceClient resumeServiceClient =
* ResumeServiceClient.create(resumeServiceSettings);
* </code>
* </pre>
*/ | Service Description: A service that handles resume parsing.
This class provides the ability to make remote calls to the backing service through method
calls that map to API methods. Sample code to get started.
Note: close() needs to be called on the resumeServiceClient object to clean up resources such
as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's
methods.
A "flattened" method. With this type of method, the fields of the request type have been
converted into function parameters. It may be the case that not all fields are available as
parameters, and not every API method will have a flattened method entry point.
A "request object" method. This type of method only takes one parameter, a request object,
which must be constructed before the call. Not every API method will have a request object
method.
A "callable" method. This type of method takes no parameters and returns an immutable API
callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with
these names, this class includes a format method for each type of name, and additionally a parse
method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of ResumeServiceSettings to
create(). For example.
To customize credentials.
To customize the endpoint.
| [
"Service",
"Description",
":",
"A",
"service",
"that",
"handles",
"resume",
"parsing",
".",
"This",
"class",
"provides",
"the",
"ability",
"to",
"make",
"remote",
"calls",
"to",
"the",
"backing",
"service",
"through",
"method",
"calls",
"that",
"map",
"to",
"API",
"methods",
".",
"Sample",
"code",
"to",
"get",
"started",
".",
"Note",
":",
"close",
"()",
"needs",
"to",
"be",
"called",
"on",
"the",
"resumeServiceClient",
"object",
"to",
"clean",
"up",
"resources",
"such",
"as",
"threads",
".",
"In",
"the",
"example",
"above",
"try",
"-",
"with",
"-",
"resources",
"is",
"used",
"which",
"automatically",
"calls",
"close",
"()",
".",
"The",
"surface",
"of",
"this",
"class",
"includes",
"several",
"types",
"of",
"Java",
"methods",
"for",
"each",
"of",
"the",
"API",
"'",
"s",
"methods",
".",
"A",
"\"",
"flattened",
"\"",
"method",
".",
"With",
"this",
"type",
"of",
"method",
"the",
"fields",
"of",
"the",
"request",
"type",
"have",
"been",
"converted",
"into",
"function",
"parameters",
".",
"It",
"may",
"be",
"the",
"case",
"that",
"not",
"all",
"fields",
"are",
"available",
"as",
"parameters",
"and",
"not",
"every",
"API",
"method",
"will",
"have",
"a",
"flattened",
"method",
"entry",
"point",
".",
"A",
"\"",
"request",
"object",
"\"",
"method",
".",
"This",
"type",
"of",
"method",
"only",
"takes",
"one",
"parameter",
"a",
"request",
"object",
"which",
"must",
"be",
"constructed",
"before",
"the",
"call",
".",
"Not",
"every",
"API",
"method",
"will",
"have",
"a",
"request",
"object",
"method",
".",
"A",
"\"",
"callable",
"\"",
"method",
".",
"This",
"type",
"of",
"method",
"takes",
"no",
"parameters",
"and",
"returns",
"an",
"immutable",
"API",
"callable",
"object",
"which",
"can",
"be",
"used",
"to",
"initiate",
"calls",
"to",
"the",
"service",
".",
"See",
"the",
"individual",
"methods",
"for",
"example",
"code",
".",
"Many",
"parameters",
"require",
"resource",
"names",
"to",
"be",
"formatted",
"in",
"a",
"particular",
"way",
".",
"To",
"assist",
"with",
"these",
"names",
"this",
"class",
"includes",
"a",
"format",
"method",
"for",
"each",
"type",
"of",
"name",
"and",
"additionally",
"a",
"parse",
"method",
"to",
"extract",
"the",
"individual",
"identifiers",
"contained",
"within",
"names",
"that",
"are",
"returned",
".",
"This",
"class",
"can",
"be",
"customized",
"by",
"passing",
"in",
"a",
"custom",
"instance",
"of",
"ResumeServiceSettings",
"to",
"create",
"()",
".",
"For",
"example",
".",
"To",
"customize",
"credentials",
".",
"To",
"customize",
"the",
"endpoint",
"."
] | @Generated("by gapic-generator")
@BetaApi
public class ResumeServiceClient implements BackgroundResource {
private final ResumeServiceSettings settings;
private final ResumeServiceStub stub;
/** Constructs an instance of ResumeServiceClient with default settings. */
public static final ResumeServiceClient create() throws IOException {
return create(ResumeServiceSettings.newBuilder().build());
}
/**
* Constructs an instance of ResumeServiceClient, using the given settings. The channels are
* created based on the settings passed in, or defaults for any settings that are not set.
*/
public static final ResumeServiceClient create(ResumeServiceSettings settings)
throws IOException {
return new ResumeServiceClient(settings);
}
/**
* Constructs an instance of ResumeServiceClient, using the given stub for making calls. This is
* for advanced usage - prefer to use ResumeServiceSettings}.
*/
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final ResumeServiceClient create(ResumeServiceStub stub) {
return new ResumeServiceClient(stub);
}
/**
* Constructs an instance of ResumeServiceClient, using the given settings. This is protected so
* that it is easy to make a subclass, but otherwise, the static factory methods should be
* preferred.
*/
protected ResumeServiceClient(ResumeServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((ResumeServiceStubSettings) settings.getStubSettings()).createStub();
}
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
protected ResumeServiceClient(ResumeServiceStub stub) {
this.settings = null;
this.stub = stub;
}
public final ResumeServiceSettings getSettings() {
return settings;
}
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public ResumeServiceStub getStub() {
return stub;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill
* out the following profile fields if present within the resume:
*
* <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris
* * employmentRecords * educationRecords * skills
*
* <p>Note that some attributes in these fields may not be populated if they're not present within
* the resume or unrecognizable by the resume parser.
*
* <p>This API does not save the resume or profile. To create a profile from this resume, clients
* need to call the CreateProfile method again with the profile returned.
*
* <p>The following list of formats are supported:
*
* <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when
* [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)
*
* <p>Sample code:
*
* <pre><code>
* try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ByteString resume = ByteString.copyFromUtf8("");
* ParseResumeResponse response = resumeServiceClient.parseResume(parent, resume);
* }
* </code></pre>
*
* @param parent Required.
* <p>The resource name of the project.
* <p>The format is "projects/{project_id}", for example, "projects/api-test-project".
* @param resume Required.
* <p>The bytes of the resume file in common format, for example, PDF, TXT. UTF-8 encoding is
* required if the resume is text-based, otherwise an error is thrown.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ParseResumeResponse parseResume(ProjectName parent, ByteString resume) {
ParseResumeRequest request =
ParseResumeRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setResume(resume)
.build();
return parseResume(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill
* out the following profile fields if present within the resume:
*
* <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris
* * employmentRecords * educationRecords * skills
*
* <p>Note that some attributes in these fields may not be populated if they're not present within
* the resume or unrecognizable by the resume parser.
*
* <p>This API does not save the resume or profile. To create a profile from this resume, clients
* need to call the CreateProfile method again with the profile returned.
*
* <p>The following list of formats are supported:
*
* <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when
* [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)
*
* <p>Sample code:
*
* <pre><code>
* try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ByteString resume = ByteString.copyFromUtf8("");
* ParseResumeResponse response = resumeServiceClient.parseResume(parent.toString(), resume);
* }
* </code></pre>
*
* @param parent Required.
* <p>The resource name of the project.
* <p>The format is "projects/{project_id}", for example, "projects/api-test-project".
* @param resume Required.
* <p>The bytes of the resume file in common format, for example, PDF, TXT. UTF-8 encoding is
* required if the resume is text-based, otherwise an error is thrown.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ParseResumeResponse parseResume(String parent, ByteString resume) {
ParseResumeRequest request =
ParseResumeRequest.newBuilder().setParent(parent).setResume(resume).build();
return parseResume(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill
* out the following profile fields if present within the resume:
*
* <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris
* * employmentRecords * educationRecords * skills
*
* <p>Note that some attributes in these fields may not be populated if they're not present within
* the resume or unrecognizable by the resume parser.
*
* <p>This API does not save the resume or profile. To create a profile from this resume, clients
* need to call the CreateProfile method again with the profile returned.
*
* <p>The following list of formats are supported:
*
* <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when
* [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)
*
* <p>Sample code:
*
* <pre><code>
* try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ByteString resume = ByteString.copyFromUtf8("");
* ParseResumeRequest request = ParseResumeRequest.newBuilder()
* .setParent(parent.toString())
* .setResume(resume)
* .build();
* ParseResumeResponse response = resumeServiceClient.parseResume(request);
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ParseResumeResponse parseResume(ParseResumeRequest request) {
return parseResumeCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill
* out the following profile fields if present within the resume:
*
* <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris
* * employmentRecords * educationRecords * skills
*
* <p>Note that some attributes in these fields may not be populated if they're not present within
* the resume or unrecognizable by the resume parser.
*
* <p>This API does not save the resume or profile. To create a profile from this resume, clients
* need to call the CreateProfile method again with the profile returned.
*
* <p>The following list of formats are supported:
*
* <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when
* [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)
*
* <p>Sample code:
*
* <pre><code>
* try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* ByteString resume = ByteString.copyFromUtf8("");
* ParseResumeRequest request = ParseResumeRequest.newBuilder()
* .setParent(parent.toString())
* .setResume(resume)
* .build();
* ApiFuture<ParseResumeResponse> future = resumeServiceClient.parseResumeCallable().futureCall(request);
* // Do something
* ParseResumeResponse response = future.get();
* }
* </code></pre>
*/
public final UnaryCallable<ParseResumeRequest, ParseResumeResponse> parseResumeCallable() {
return stub.parseResumeCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
} | [
"@",
"Generated",
"(",
"\"",
"by gapic-generator",
"\"",
")",
"@",
"BetaApi",
"public",
"class",
"ResumeServiceClient",
"implements",
"BackgroundResource",
"{",
"private",
"final",
"ResumeServiceSettings",
"settings",
";",
"private",
"final",
"ResumeServiceStub",
"stub",
";",
"/** Constructs an instance of ResumeServiceClient with default settings. */",
"public",
"static",
"final",
"ResumeServiceClient",
"create",
"(",
")",
"throws",
"IOException",
"{",
"return",
"create",
"(",
"ResumeServiceSettings",
".",
"newBuilder",
"(",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"/**\n * Constructs an instance of ResumeServiceClient, using the given settings. The channels are\n * created based on the settings passed in, or defaults for any settings that are not set.\n */",
"public",
"static",
"final",
"ResumeServiceClient",
"create",
"(",
"ResumeServiceSettings",
"settings",
")",
"throws",
"IOException",
"{",
"return",
"new",
"ResumeServiceClient",
"(",
"settings",
")",
";",
"}",
"/**\n * Constructs an instance of ResumeServiceClient, using the given stub for making calls. This is\n * for advanced usage - prefer to use ResumeServiceSettings}.\n */",
"@",
"BetaApi",
"(",
"\"",
"A restructuring of stub classes is planned, so this may break in the future",
"\"",
")",
"public",
"static",
"final",
"ResumeServiceClient",
"create",
"(",
"ResumeServiceStub",
"stub",
")",
"{",
"return",
"new",
"ResumeServiceClient",
"(",
"stub",
")",
";",
"}",
"/**\n * Constructs an instance of ResumeServiceClient, using the given settings. This is protected so\n * that it is easy to make a subclass, but otherwise, the static factory methods should be\n * preferred.\n */",
"protected",
"ResumeServiceClient",
"(",
"ResumeServiceSettings",
"settings",
")",
"throws",
"IOException",
"{",
"this",
".",
"settings",
"=",
"settings",
";",
"this",
".",
"stub",
"=",
"(",
"(",
"ResumeServiceStubSettings",
")",
"settings",
".",
"getStubSettings",
"(",
")",
")",
".",
"createStub",
"(",
")",
";",
"}",
"@",
"BetaApi",
"(",
"\"",
"A restructuring of stub classes is planned, so this may break in the future",
"\"",
")",
"protected",
"ResumeServiceClient",
"(",
"ResumeServiceStub",
"stub",
")",
"{",
"this",
".",
"settings",
"=",
"null",
";",
"this",
".",
"stub",
"=",
"stub",
";",
"}",
"public",
"final",
"ResumeServiceSettings",
"getSettings",
"(",
")",
"{",
"return",
"settings",
";",
"}",
"@",
"BetaApi",
"(",
"\"",
"A restructuring of stub classes is planned, so this may break in the future",
"\"",
")",
"public",
"ResumeServiceStub",
"getStub",
"(",
")",
"{",
"return",
"stub",
";",
"}",
"/**\n * Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill\n * out the following profile fields if present within the resume:\n *\n * <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris\n * * employmentRecords * educationRecords * skills\n *\n * <p>Note that some attributes in these fields may not be populated if they're not present within\n * the resume or unrecognizable by the resume parser.\n *\n * <p>This API does not save the resume or profile. To create a profile from this resume, clients\n * need to call the CreateProfile method again with the profile returned.\n *\n * <p>The following list of formats are supported:\n *\n * <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when\n * [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)\n *\n * <p>Sample code:\n *\n * <pre><code>\n * try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {\n * ProjectName parent = ProjectName.of(\"[PROJECT]\");\n * ByteString resume = ByteString.copyFromUtf8(\"\");\n * ParseResumeResponse response = resumeServiceClient.parseResume(parent, resume);\n * }\n * </code></pre>\n *\n * @param parent Required.\n * <p>The resource name of the project.\n * <p>The format is \"projects/{project_id}\", for example, \"projects/api-test-project\".\n * @param resume Required.\n * <p>The bytes of the resume file in common format, for example, PDF, TXT. UTF-8 encoding is\n * required if the resume is text-based, otherwise an error is thrown.\n * @throws com.google.api.gax.rpc.ApiException if the remote call fails\n */",
"public",
"final",
"ParseResumeResponse",
"parseResume",
"(",
"ProjectName",
"parent",
",",
"ByteString",
"resume",
")",
"{",
"ParseResumeRequest",
"request",
"=",
"ParseResumeRequest",
".",
"newBuilder",
"(",
")",
".",
"setParent",
"(",
"parent",
"==",
"null",
"?",
"null",
":",
"parent",
".",
"toString",
"(",
")",
")",
".",
"setResume",
"(",
"resume",
")",
".",
"build",
"(",
")",
";",
"return",
"parseResume",
"(",
"request",
")",
";",
"}",
"/**\n * Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill\n * out the following profile fields if present within the resume:\n *\n * <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris\n * * employmentRecords * educationRecords * skills\n *\n * <p>Note that some attributes in these fields may not be populated if they're not present within\n * the resume or unrecognizable by the resume parser.\n *\n * <p>This API does not save the resume or profile. To create a profile from this resume, clients\n * need to call the CreateProfile method again with the profile returned.\n *\n * <p>The following list of formats are supported:\n *\n * <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when\n * [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)\n *\n * <p>Sample code:\n *\n * <pre><code>\n * try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {\n * ProjectName parent = ProjectName.of(\"[PROJECT]\");\n * ByteString resume = ByteString.copyFromUtf8(\"\");\n * ParseResumeResponse response = resumeServiceClient.parseResume(parent.toString(), resume);\n * }\n * </code></pre>\n *\n * @param parent Required.\n * <p>The resource name of the project.\n * <p>The format is \"projects/{project_id}\", for example, \"projects/api-test-project\".\n * @param resume Required.\n * <p>The bytes of the resume file in common format, for example, PDF, TXT. UTF-8 encoding is\n * required if the resume is text-based, otherwise an error is thrown.\n * @throws com.google.api.gax.rpc.ApiException if the remote call fails\n */",
"public",
"final",
"ParseResumeResponse",
"parseResume",
"(",
"String",
"parent",
",",
"ByteString",
"resume",
")",
"{",
"ParseResumeRequest",
"request",
"=",
"ParseResumeRequest",
".",
"newBuilder",
"(",
")",
".",
"setParent",
"(",
"parent",
")",
".",
"setResume",
"(",
"resume",
")",
".",
"build",
"(",
")",
";",
"return",
"parseResume",
"(",
"request",
")",
";",
"}",
"/**\n * Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill\n * out the following profile fields if present within the resume:\n *\n * <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris\n * * employmentRecords * educationRecords * skills\n *\n * <p>Note that some attributes in these fields may not be populated if they're not present within\n * the resume or unrecognizable by the resume parser.\n *\n * <p>This API does not save the resume or profile. To create a profile from this resume, clients\n * need to call the CreateProfile method again with the profile returned.\n *\n * <p>The following list of formats are supported:\n *\n * <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when\n * [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)\n *\n * <p>Sample code:\n *\n * <pre><code>\n * try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {\n * ProjectName parent = ProjectName.of(\"[PROJECT]\");\n * ByteString resume = ByteString.copyFromUtf8(\"\");\n * ParseResumeRequest request = ParseResumeRequest.newBuilder()\n * .setParent(parent.toString())\n * .setResume(resume)\n * .build();\n * ParseResumeResponse response = resumeServiceClient.parseResume(request);\n * }\n * </code></pre>\n *\n * @param request The request object containing all of the parameters for the API call.\n * @throws com.google.api.gax.rpc.ApiException if the remote call fails\n */",
"public",
"final",
"ParseResumeResponse",
"parseResume",
"(",
"ParseResumeRequest",
"request",
")",
"{",
"return",
"parseResumeCallable",
"(",
")",
".",
"call",
"(",
"request",
")",
";",
"}",
"/**\n * Parses a resume into a [Profile][google.cloud.talent.v4beta1.Profile]. The API attempts to fill\n * out the following profile fields if present within the resume:\n *\n * <p>* personNames * addresses * emailAddress * phoneNumbers * personalUris\n * * employmentRecords * educationRecords * skills\n *\n * <p>Note that some attributes in these fields may not be populated if they're not present within\n * the resume or unrecognizable by the resume parser.\n *\n * <p>This API does not save the resume or profile. To create a profile from this resume, clients\n * need to call the CreateProfile method again with the profile returned.\n *\n * <p>The following list of formats are supported:\n *\n * <p>* PDF * TXT * DOC * RTF * DOCX * PNG (only when\n * [ParseResumeRequest.enable_ocr][] is set to `true`, otherwise an error is thrown)\n *\n * <p>Sample code:\n *\n * <pre><code>\n * try (ResumeServiceClient resumeServiceClient = ResumeServiceClient.create()) {\n * ProjectName parent = ProjectName.of(\"[PROJECT]\");\n * ByteString resume = ByteString.copyFromUtf8(\"\");\n * ParseResumeRequest request = ParseResumeRequest.newBuilder()\n * .setParent(parent.toString())\n * .setResume(resume)\n * .build();\n * ApiFuture<ParseResumeResponse> future = resumeServiceClient.parseResumeCallable().futureCall(request);\n * // Do something\n * ParseResumeResponse response = future.get();\n * }\n * </code></pre>\n */",
"public",
"final",
"UnaryCallable",
"<",
"ParseResumeRequest",
",",
"ParseResumeResponse",
">",
"parseResumeCallable",
"(",
")",
"{",
"return",
"stub",
".",
"parseResumeCallable",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"final",
"void",
"close",
"(",
")",
"{",
"stub",
".",
"close",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"shutdown",
"(",
")",
"{",
"stub",
".",
"shutdown",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isShutdown",
"(",
")",
"{",
"return",
"stub",
".",
"isShutdown",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isTerminated",
"(",
")",
"{",
"return",
"stub",
".",
"isTerminated",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"shutdownNow",
"(",
")",
"{",
"stub",
".",
"shutdownNow",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"awaitTermination",
"(",
"long",
"duration",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"return",
"stub",
".",
"awaitTermination",
"(",
"duration",
",",
"unit",
")",
";",
"}",
"}"
] | Service Description: A service that handles resume parsing. | [
"Service",
"Description",
":",
"A",
"service",
"that",
"handles",
"resume",
"parsing",
"."
] | [
"// AUTO-GENERATED DOCUMENTATION AND METHOD",
"// AUTO-GENERATED DOCUMENTATION AND METHOD",
"// AUTO-GENERATED DOCUMENTATION AND METHOD",
"// AUTO-GENERATED DOCUMENTATION AND METHOD"
] | [
{
"param": "BackgroundResource",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "BackgroundResource",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
487c9ff8af4e8bf29fcb6726a84ae1c6426054a7 | matthkoch/uima-uimaj | uimaj-core/src/test/java/org/apache/uima/cas/test/CASInitializer.java | [
"Apache-2.0"
] | Java | CASInitializer | /**
* Use this as your CAS factory.
*/ | Use this as your CAS factory. | [
"Use",
"this",
"as",
"your",
"CAS",
"factory",
"."
] | public class CASInitializer {
public static CAS initCas(AnnotatorInitializer init, Consumer<TypeSystemImpl> reinitTypeSystem) {
// Create an initial CASMgr from the factory.
// long startTime = System.nanoTime();
CASMgr casMgr0 = CASFactory.createCAS();
CASMgr casMgr = null;
try {
// this call does nothing: because 2nd arg is null
CasCreationUtils.setupTypeSystem(casMgr0, (TypeSystemDescription) null);
// Create a writable type system.
TypeSystemMgr tsa = casMgr0.getTypeSystemMgr();
// Next not needed, type system is already uncommitted
// ((TypeSystemImpl) tsa).setCommitted(false);
// do the type system tests
init.initTypeSystem(tsa);
// Commit the type system.
((CASImpl) casMgr0).commitTypeSystem();
// Due to typesystem consolidation, committing might cause the actual type system in the CAS
// to be replaced by an already cached version. In case this happens, we maybe have to reinit
// the types known on the outsidei via the reinitTypeSystem callback
if (null != reinitTypeSystem) {
reinitTypeSystem.accept(((CASImpl) casMgr0).getTypeSystemImpl());
}
// Create another CAS with the potentially consolidated type system (but why?!)
casMgr = CASFactory.createCAS(casMgr0.getTypeSystemMgr());
// Create the Base indexes.
casMgr.initCASIndexes();
// Commit the index repository.
FSIndexRepositoryMgr irm = casMgr.getIndexRepositoryMgr();
init.initIndexes(irm, casMgr.getTypeSystemMgr());
irm.commit();
} catch (ResourceInitializationException e) {
throw new RuntimeException(e);
} catch (CASException e) {
throw new RuntimeException(e);
}
// System.out.format("Debug SerDesTest6 setup time: %d micros%n",
// (System.nanoTime() - startTime)/1000L);
// Create the default text Sofa and return CAS view
return casMgr.getCAS().getCurrentView();
}
} | [
"public",
"class",
"CASInitializer",
"{",
"public",
"static",
"CAS",
"initCas",
"(",
"AnnotatorInitializer",
"init",
",",
"Consumer",
"<",
"TypeSystemImpl",
">",
"reinitTypeSystem",
")",
"{",
"CASMgr",
"casMgr0",
"=",
"CASFactory",
".",
"createCAS",
"(",
")",
";",
"CASMgr",
"casMgr",
"=",
"null",
";",
"try",
"{",
"CasCreationUtils",
".",
"setupTypeSystem",
"(",
"casMgr0",
",",
"(",
"TypeSystemDescription",
")",
"null",
")",
";",
"TypeSystemMgr",
"tsa",
"=",
"casMgr0",
".",
"getTypeSystemMgr",
"(",
")",
";",
"init",
".",
"initTypeSystem",
"(",
"tsa",
")",
";",
"(",
"(",
"CASImpl",
")",
"casMgr0",
")",
".",
"commitTypeSystem",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"reinitTypeSystem",
")",
"{",
"reinitTypeSystem",
".",
"accept",
"(",
"(",
"(",
"CASImpl",
")",
"casMgr0",
")",
".",
"getTypeSystemImpl",
"(",
")",
")",
";",
"}",
"casMgr",
"=",
"CASFactory",
".",
"createCAS",
"(",
"casMgr0",
".",
"getTypeSystemMgr",
"(",
")",
")",
";",
"casMgr",
".",
"initCASIndexes",
"(",
")",
";",
"FSIndexRepositoryMgr",
"irm",
"=",
"casMgr",
".",
"getIndexRepositoryMgr",
"(",
")",
";",
"init",
".",
"initIndexes",
"(",
"irm",
",",
"casMgr",
".",
"getTypeSystemMgr",
"(",
")",
")",
";",
"irm",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"ResourceInitializationException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"CASException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"casMgr",
".",
"getCAS",
"(",
")",
".",
"getCurrentView",
"(",
")",
";",
"}",
"}"
] | Use this as your CAS factory. | [
"Use",
"this",
"as",
"your",
"CAS",
"factory",
"."
] | [
"// Create an initial CASMgr from the factory.",
"// long startTime = System.nanoTime();",
"// this call does nothing: because 2nd arg is null",
"// Create a writable type system.",
"// Next not needed, type system is already uncommitted",
"// ((TypeSystemImpl) tsa).setCommitted(false);",
"// do the type system tests",
"// Commit the type system.",
"// Due to typesystem consolidation, committing might cause the actual type system in the CAS",
"// to be replaced by an already cached version. In case this happens, we maybe have to reinit",
"// the types known on the outsidei via the reinitTypeSystem callback",
"// Create another CAS with the potentially consolidated type system (but why?!)",
"// Create the Base indexes.",
"// Commit the index repository.",
"// System.out.format(\"Debug SerDesTest6 setup time: %d micros%n\",",
"// (System.nanoTime() - startTime)/1000L);",
"// Create the default text Sofa and return CAS view"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4880b0d935ec37cee850eda0b75fceacdc97bb01 | WorldWindEarth/WorldWindJava | src/gov/nasa/worldwindx/examples/kml/KMLDocumentBuilder.java | [
"Apache-2.0",
"MIT"
] | Java | KMLDocumentBuilder | /**
* Utility class to create KML documents.
*
* @author pabercrombie
* @version $Id: KMLDocumentBuilder.java 1171 2013-02-11 21:45:02Z dcollins $
*/ | Utility class to create KML documents.
@author pabercrombie
@version $Id: KMLDocumentBuilder.java 1171 2013-02-11 21:45:02Z dcollins $ | [
"Utility",
"class",
"to",
"create",
"KML",
"documents",
".",
"@author",
"pabercrombie",
"@version",
"$Id",
":",
"KMLDocumentBuilder",
".",
"java",
"1171",
"2013",
"-",
"02",
"-",
"11",
"21",
":",
"45",
":",
"02Z",
"dcollins",
"$"
] | public class KMLDocumentBuilder
{
protected XMLStreamWriter writer;
/**
* Create a KML document using a Writer.
*
* @param writer Writer to receive KML output.
*
* @throws XMLStreamException If an error is encountered while writing KML.
*/
public KMLDocumentBuilder(Writer writer) throws XMLStreamException
{
this.writer = XMLOutputFactory.newInstance().createXMLStreamWriter(writer);
this.startDocument();
}
/**
* Create a KML document using an OutputStream.
*
* @param stream Stream to receive KML output.
*
* @throws XMLStreamException If an error is encountered while writing KML.
*/
public KMLDocumentBuilder(OutputStream stream) throws XMLStreamException
{
this.writer = XMLOutputFactory.newInstance().createXMLStreamWriter(stream);
this.startDocument();
}
/**
* Start the KML document and write namespace declarations.
*
* @throws XMLStreamException If an error is encountered while writing KML.
*/
protected void startDocument() throws XMLStreamException
{
this.writer.writeStartDocument();
this.writer.writeStartElement("kml");
this.writer.writeDefaultNamespace(KMLConstants.KML_NAMESPACE);
this.writer.setPrefix("gx", GXConstants.GX_NAMESPACE);
this.writer.writeNamespace("gx", GXConstants.GX_NAMESPACE);
this.writer.writeStartElement("Document");
}
/**
* End the KML document.
*
* @throws XMLStreamException If an error is encountered while writing KML.
*/
protected void endDocument() throws XMLStreamException
{
this.writer.writeEndElement(); // Document
this.writer.writeEndElement(); // kml
this.writer.writeEndDocument();
this.writer.close();
}
/**
* Close the document builder.
*
* @throws XMLStreamException If an error is encountered while writing KML.
*/
public void close() throws XMLStreamException
{
this.endDocument();
this.writer.close();
}
/**
* Write an {@link Exportable} object to the document. If the object does not support export in KML format, it will
* be ignored.
*
* @param exportable Object to export in KML.
*
* @throws IOException If an error is encountered while writing KML.
*/
public void writeObject(Exportable exportable) throws IOException
{
String supported = exportable.isExportFormatSupported(KMLConstants.KML_MIME_TYPE);
if (Exportable.FORMAT_SUPPORTED.equals(supported) || Exportable.FORMAT_PARTIALLY_SUPPORTED.equals(supported))
{
exportable.export(KMLConstants.KML_MIME_TYPE, this.writer);
}
}
/**
* Write a list of {@link Exportable} objects to the document. If any objects do not support export in KML format,
* they will be ignored.
*
* @param exportables List of objects to export in KML.
*
* @throws IOException If an error is encountered while writing KML.
*/
public void writeObjects(Exportable... exportables) throws IOException
{
for (Exportable exportable : exportables)
{
String supported = exportable.isExportFormatSupported(KMLConstants.KML_MIME_TYPE);
if (Exportable.FORMAT_SUPPORTED.equals(supported)
|| Exportable.FORMAT_PARTIALLY_SUPPORTED.equals(supported))
{
exportable.export(KMLConstants.KML_MIME_TYPE, this.writer);
}
}
}
} | [
"public",
"class",
"KMLDocumentBuilder",
"{",
"protected",
"XMLStreamWriter",
"writer",
";",
"/**\n * Create a KML document using a Writer.\n *\n * @param writer Writer to receive KML output.\n *\n * @throws XMLStreamException If an error is encountered while writing KML.\n */",
"public",
"KMLDocumentBuilder",
"(",
"Writer",
"writer",
")",
"throws",
"XMLStreamException",
"{",
"this",
".",
"writer",
"=",
"XMLOutputFactory",
".",
"newInstance",
"(",
")",
".",
"createXMLStreamWriter",
"(",
"writer",
")",
";",
"this",
".",
"startDocument",
"(",
")",
";",
"}",
"/**\n * Create a KML document using an OutputStream.\n *\n * @param stream Stream to receive KML output.\n *\n * @throws XMLStreamException If an error is encountered while writing KML.\n */",
"public",
"KMLDocumentBuilder",
"(",
"OutputStream",
"stream",
")",
"throws",
"XMLStreamException",
"{",
"this",
".",
"writer",
"=",
"XMLOutputFactory",
".",
"newInstance",
"(",
")",
".",
"createXMLStreamWriter",
"(",
"stream",
")",
";",
"this",
".",
"startDocument",
"(",
")",
";",
"}",
"/**\n * Start the KML document and write namespace declarations.\n *\n * @throws XMLStreamException If an error is encountered while writing KML.\n */",
"protected",
"void",
"startDocument",
"(",
")",
"throws",
"XMLStreamException",
"{",
"this",
".",
"writer",
".",
"writeStartDocument",
"(",
")",
";",
"this",
".",
"writer",
".",
"writeStartElement",
"(",
"\"",
"kml",
"\"",
")",
";",
"this",
".",
"writer",
".",
"writeDefaultNamespace",
"(",
"KMLConstants",
".",
"KML_NAMESPACE",
")",
";",
"this",
".",
"writer",
".",
"setPrefix",
"(",
"\"",
"gx",
"\"",
",",
"GXConstants",
".",
"GX_NAMESPACE",
")",
";",
"this",
".",
"writer",
".",
"writeNamespace",
"(",
"\"",
"gx",
"\"",
",",
"GXConstants",
".",
"GX_NAMESPACE",
")",
";",
"this",
".",
"writer",
".",
"writeStartElement",
"(",
"\"",
"Document",
"\"",
")",
";",
"}",
"/**\n * End the KML document.\n *\n * @throws XMLStreamException If an error is encountered while writing KML.\n */",
"protected",
"void",
"endDocument",
"(",
")",
"throws",
"XMLStreamException",
"{",
"this",
".",
"writer",
".",
"writeEndElement",
"(",
")",
";",
"this",
".",
"writer",
".",
"writeEndElement",
"(",
")",
";",
"this",
".",
"writer",
".",
"writeEndDocument",
"(",
")",
";",
"this",
".",
"writer",
".",
"close",
"(",
")",
";",
"}",
"/**\n * Close the document builder.\n *\n * @throws XMLStreamException If an error is encountered while writing KML.\n */",
"public",
"void",
"close",
"(",
")",
"throws",
"XMLStreamException",
"{",
"this",
".",
"endDocument",
"(",
")",
";",
"this",
".",
"writer",
".",
"close",
"(",
")",
";",
"}",
"/**\n * Write an {@link Exportable} object to the document. If the object does not support export in KML format, it will\n * be ignored.\n *\n * @param exportable Object to export in KML.\n *\n * @throws IOException If an error is encountered while writing KML.\n */",
"public",
"void",
"writeObject",
"(",
"Exportable",
"exportable",
")",
"throws",
"IOException",
"{",
"String",
"supported",
"=",
"exportable",
".",
"isExportFormatSupported",
"(",
"KMLConstants",
".",
"KML_MIME_TYPE",
")",
";",
"if",
"(",
"Exportable",
".",
"FORMAT_SUPPORTED",
".",
"equals",
"(",
"supported",
")",
"||",
"Exportable",
".",
"FORMAT_PARTIALLY_SUPPORTED",
".",
"equals",
"(",
"supported",
")",
")",
"{",
"exportable",
".",
"export",
"(",
"KMLConstants",
".",
"KML_MIME_TYPE",
",",
"this",
".",
"writer",
")",
";",
"}",
"}",
"/**\n * Write a list of {@link Exportable} objects to the document. If any objects do not support export in KML format,\n * they will be ignored.\n *\n * @param exportables List of objects to export in KML.\n *\n * @throws IOException If an error is encountered while writing KML.\n */",
"public",
"void",
"writeObjects",
"(",
"Exportable",
"...",
"exportables",
")",
"throws",
"IOException",
"{",
"for",
"(",
"Exportable",
"exportable",
":",
"exportables",
")",
"{",
"String",
"supported",
"=",
"exportable",
".",
"isExportFormatSupported",
"(",
"KMLConstants",
".",
"KML_MIME_TYPE",
")",
";",
"if",
"(",
"Exportable",
".",
"FORMAT_SUPPORTED",
".",
"equals",
"(",
"supported",
")",
"||",
"Exportable",
".",
"FORMAT_PARTIALLY_SUPPORTED",
".",
"equals",
"(",
"supported",
")",
")",
"{",
"exportable",
".",
"export",
"(",
"KMLConstants",
".",
"KML_MIME_TYPE",
",",
"this",
".",
"writer",
")",
";",
"}",
"}",
"}",
"}"
] | Utility class to create KML documents. | [
"Utility",
"class",
"to",
"create",
"KML",
"documents",
"."
] | [
"// Document",
"// kml"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
48849729708ad138e8fcd13240f9307acff19c9f | sekkycodes/testresultserver | src/main/java/com/github/sekkycodes/testresultserver/configuration/ClockConfig.java | [
"Apache-2.0"
] | Java | ClockConfig | /**
* Supplies Clocks for Dependency Injection
*/ | Supplies Clocks for Dependency Injection | [
"Supplies",
"Clocks",
"for",
"Dependency",
"Injection"
] | @Configuration
public class ClockConfig {
/**
* Creates a new Clock object with the UTC zone
* @return new Clock instance
*/
@Bean
public Clock createClock() {
return Clock.systemUTC();
}
} | [
"@",
"Configuration",
"public",
"class",
"ClockConfig",
"{",
"/**\n * Creates a new Clock object with the UTC zone\n * @return new Clock instance\n */",
"@",
"Bean",
"public",
"Clock",
"createClock",
"(",
")",
"{",
"return",
"Clock",
".",
"systemUTC",
"(",
")",
";",
"}",
"}"
] | Supplies Clocks for Dependency Injection | [
"Supplies",
"Clocks",
"for",
"Dependency",
"Injection"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4886eba0f34bd12e7e300750330cd6347b5fe22b | ekordev/ReceiptScan | rxcameraview/src/main/java/com/otaliastudios/cameraview/RxPictureResult.java | [
"Apache-2.0"
] | Java | RxPictureResult | /**
* A decorator class that adds the functionality to produce a bitmap as an observable.
* This functionality is desired when the result is used in a chain of rx computations
* and we do not want the bitmap to be posted onto the ui thread, but be able to decide
* on which thread we want it.
*/ | A decorator class that adds the functionality to produce a bitmap as an observable.
This functionality is desired when the result is used in a chain of rx computations
and we do not want the bitmap to be posted onto the ui thread, but be able to decide
on which thread we want it. | [
"A",
"decorator",
"class",
"that",
"adds",
"the",
"functionality",
"to",
"produce",
"a",
"bitmap",
"as",
"an",
"observable",
".",
"This",
"functionality",
"is",
"desired",
"when",
"the",
"result",
"is",
"used",
"in",
"a",
"chain",
"of",
"rx",
"computations",
"and",
"we",
"do",
"not",
"want",
"the",
"bitmap",
"to",
"be",
"posted",
"onto",
"the",
"ui",
"thread",
"but",
"be",
"able",
"to",
"decide",
"on",
"which",
"thread",
"we",
"want",
"it",
"."
] | @SuppressWarnings("WeakerAccess")
public class RxPictureResult extends PictureResult {
private final PictureResult pictureResult;
public RxPictureResult(PictureResult pictureResult) {
this.pictureResult = pictureResult;
}
public Observable<Bitmap> toBitmap(int maxWidth, int maxHeight) {
return Observable.fromCallable(() -> {
System.out.println("Bitmap on " + Thread.currentThread().getName());
Bitmap result = CameraUtils.decodeBitmap(pictureResult.getData(), maxWidth, maxHeight);
if (result == null) {
throw new IllegalStateException("Picture cannot be converted to bitmap. Most probable Out Of Memory");
}
return result;
});
}
public Observable<Bitmap> toBitmap() {
return toBitmap(-1, -1);
}
@Override
public boolean isSnapshot() {
return pictureResult.isSnapshot();
}
@Nullable
@Override
public Location getLocation() {
return pictureResult.getLocation();
}
@Override
public int getRotation() {
return pictureResult.getRotation();
}
@NonNull
@Override
public Size getSize() {
return pictureResult.getSize();
}
@NonNull
@Override
public Facing getFacing() {
return pictureResult.getFacing();
}
@NonNull
@Override
public byte[] getData() {
return pictureResult.getData();
}
@Override
public int getFormat() {
return pictureResult.getFormat();
}
@Override
public void toBitmap(int maxWidth, int maxHeight, @NonNull BitmapCallback callback) {
pictureResult.toBitmap(maxWidth, maxHeight, callback);
}
@Override
public void toBitmap(@NonNull BitmapCallback callback) {
pictureResult.toBitmap(callback);
}
@Override
public void toFile(@NonNull File file, @NonNull FileCallback callback) {
pictureResult.toFile(file, callback);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"",
"WeakerAccess",
"\"",
")",
"public",
"class",
"RxPictureResult",
"extends",
"PictureResult",
"{",
"private",
"final",
"PictureResult",
"pictureResult",
";",
"public",
"RxPictureResult",
"(",
"PictureResult",
"pictureResult",
")",
"{",
"this",
".",
"pictureResult",
"=",
"pictureResult",
";",
"}",
"public",
"Observable",
"<",
"Bitmap",
">",
"toBitmap",
"(",
"int",
"maxWidth",
",",
"int",
"maxHeight",
")",
"{",
"return",
"Observable",
".",
"fromCallable",
"(",
"(",
")",
"->",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Bitmap on ",
"\"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"Bitmap",
"result",
"=",
"CameraUtils",
".",
"decodeBitmap",
"(",
"pictureResult",
".",
"getData",
"(",
")",
",",
"maxWidth",
",",
"maxHeight",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"Picture cannot be converted to bitmap. Most probable Out Of Memory",
"\"",
")",
";",
"}",
"return",
"result",
";",
"}",
")",
";",
"}",
"public",
"Observable",
"<",
"Bitmap",
">",
"toBitmap",
"(",
")",
"{",
"return",
"toBitmap",
"(",
"-",
"1",
",",
"-",
"1",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"isSnapshot",
"(",
")",
"{",
"return",
"pictureResult",
".",
"isSnapshot",
"(",
")",
";",
"}",
"@",
"Nullable",
"@",
"Override",
"public",
"Location",
"getLocation",
"(",
")",
"{",
"return",
"pictureResult",
".",
"getLocation",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"getRotation",
"(",
")",
"{",
"return",
"pictureResult",
".",
"getRotation",
"(",
")",
";",
"}",
"@",
"NonNull",
"@",
"Override",
"public",
"Size",
"getSize",
"(",
")",
"{",
"return",
"pictureResult",
".",
"getSize",
"(",
")",
";",
"}",
"@",
"NonNull",
"@",
"Override",
"public",
"Facing",
"getFacing",
"(",
")",
"{",
"return",
"pictureResult",
".",
"getFacing",
"(",
")",
";",
"}",
"@",
"NonNull",
"@",
"Override",
"public",
"byte",
"[",
"]",
"getData",
"(",
")",
"{",
"return",
"pictureResult",
".",
"getData",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"getFormat",
"(",
")",
"{",
"return",
"pictureResult",
".",
"getFormat",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"toBitmap",
"(",
"int",
"maxWidth",
",",
"int",
"maxHeight",
",",
"@",
"NonNull",
"BitmapCallback",
"callback",
")",
"{",
"pictureResult",
".",
"toBitmap",
"(",
"maxWidth",
",",
"maxHeight",
",",
"callback",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"toBitmap",
"(",
"@",
"NonNull",
"BitmapCallback",
"callback",
")",
"{",
"pictureResult",
".",
"toBitmap",
"(",
"callback",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"toFile",
"(",
"@",
"NonNull",
"File",
"file",
",",
"@",
"NonNull",
"FileCallback",
"callback",
")",
"{",
"pictureResult",
".",
"toFile",
"(",
"file",
",",
"callback",
")",
";",
"}",
"}"
] | A decorator class that adds the functionality to produce a bitmap as an observable. | [
"A",
"decorator",
"class",
"that",
"adds",
"the",
"functionality",
"to",
"produce",
"a",
"bitmap",
"as",
"an",
"observable",
"."
] | [] | [
{
"param": "PictureResult",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "PictureResult",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4887059df75359279c4f5d3fde37e3f557122878 | northerneyes/Verlet | lib/src/org/verletandroid/VerletCore/Contraints/DistanceConstraint.java | [
"MIT"
] | Java | DistanceConstraint | /**
* Created with IntelliJ IDEA.
* User: George
* Date: 28.04.13
* Time: 23:50
* To change this template use File | Settings | File Templates.
*/ | Created with IntelliJ IDEA.
User: George
Date: 28.04.13
Time: 23:50
To change this template use File | Settings | File Templates. | [
"Created",
"with",
"IntelliJ",
"IDEA",
".",
"User",
":",
"George",
"Date",
":",
"28",
".",
"04",
".",
"13",
"Time",
":",
"23",
":",
"50",
"To",
"change",
"this",
"template",
"use",
"File",
"|",
"Settings",
"|",
"File",
"Templates",
"."
] | public class DistanceConstraint implements IConstraint{
public void setDistance(float distance) {
this.distance = distance;
}
private float distance;
public Particle getA() {
return a;
}
public Particle getB() {
return b;
}
private Particle a;
private Particle b;
private float stiffness;
private int color = Color.parseColor("#d8dde2");
Vec2 normal = new Vec2();
public DistanceConstraint(Particle a, Particle b, float stiffness) {
this.a = a;
this.b = b;
this.stiffness = stiffness;
this.distance = a.getPos().sub(b.getPos()).length();
}
public DistanceConstraint(Particle a, Particle b, float stiffness, float distance) {
this(a, b, stiffness);
this.distance = distance;
}
@Override
public void relax(float stepCoef) {
normal.mutableSet(this.a.pos);
normal.mutableSub(this.b.pos);
float m = normal.length2();
normal.mutableScale(((this.distance*this.distance - m)/m)*this.stiffness*stepCoef);
this.a.pos.mutableAdd(normal);
this.b.pos.mutableSub(normal);
}
@Override
public void draw(IGraphics graphics) {
graphics.setPenStyle(Paint.Style.STROKE);
graphics.setStrokeWidth(3);
graphics.setColorPen(color);
graphics.drawLine(this.a.getPos().x, this.a.getPos().y,
this.b.getPos().x, this.b.getPos().y);
}
@Override
public Vec2 getPos() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public float getDistance() {
return distance;
}
} | [
"public",
"class",
"DistanceConstraint",
"implements",
"IConstraint",
"{",
"public",
"void",
"setDistance",
"(",
"float",
"distance",
")",
"{",
"this",
".",
"distance",
"=",
"distance",
";",
"}",
"private",
"float",
"distance",
";",
"public",
"Particle",
"getA",
"(",
")",
"{",
"return",
"a",
";",
"}",
"public",
"Particle",
"getB",
"(",
")",
"{",
"return",
"b",
";",
"}",
"private",
"Particle",
"a",
";",
"private",
"Particle",
"b",
";",
"private",
"float",
"stiffness",
";",
"private",
"int",
"color",
"=",
"Color",
".",
"parseColor",
"(",
"\"",
"#d8dde2",
"\"",
")",
";",
"Vec2",
"normal",
"=",
"new",
"Vec2",
"(",
")",
";",
"public",
"DistanceConstraint",
"(",
"Particle",
"a",
",",
"Particle",
"b",
",",
"float",
"stiffness",
")",
"{",
"this",
".",
"a",
"=",
"a",
";",
"this",
".",
"b",
"=",
"b",
";",
"this",
".",
"stiffness",
"=",
"stiffness",
";",
"this",
".",
"distance",
"=",
"a",
".",
"getPos",
"(",
")",
".",
"sub",
"(",
"b",
".",
"getPos",
"(",
")",
")",
".",
"length",
"(",
")",
";",
"}",
"public",
"DistanceConstraint",
"(",
"Particle",
"a",
",",
"Particle",
"b",
",",
"float",
"stiffness",
",",
"float",
"distance",
")",
"{",
"this",
"(",
"a",
",",
"b",
",",
"stiffness",
")",
";",
"this",
".",
"distance",
"=",
"distance",
";",
"}",
"@",
"Override",
"public",
"void",
"relax",
"(",
"float",
"stepCoef",
")",
"{",
"normal",
".",
"mutableSet",
"(",
"this",
".",
"a",
".",
"pos",
")",
";",
"normal",
".",
"mutableSub",
"(",
"this",
".",
"b",
".",
"pos",
")",
";",
"float",
"m",
"=",
"normal",
".",
"length2",
"(",
")",
";",
"normal",
".",
"mutableScale",
"(",
"(",
"(",
"this",
".",
"distance",
"*",
"this",
".",
"distance",
"-",
"m",
")",
"/",
"m",
")",
"*",
"this",
".",
"stiffness",
"*",
"stepCoef",
")",
";",
"this",
".",
"a",
".",
"pos",
".",
"mutableAdd",
"(",
"normal",
")",
";",
"this",
".",
"b",
".",
"pos",
".",
"mutableSub",
"(",
"normal",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"draw",
"(",
"IGraphics",
"graphics",
")",
"{",
"graphics",
".",
"setPenStyle",
"(",
"Paint",
".",
"Style",
".",
"STROKE",
")",
";",
"graphics",
".",
"setStrokeWidth",
"(",
"3",
")",
";",
"graphics",
".",
"setColorPen",
"(",
"color",
")",
";",
"graphics",
".",
"drawLine",
"(",
"this",
".",
"a",
".",
"getPos",
"(",
")",
".",
"x",
",",
"this",
".",
"a",
".",
"getPos",
"(",
")",
".",
"y",
",",
"this",
".",
"b",
".",
"getPos",
"(",
")",
".",
"x",
",",
"this",
".",
"b",
".",
"getPos",
"(",
")",
".",
"y",
")",
";",
"}",
"@",
"Override",
"public",
"Vec2",
"getPos",
"(",
")",
"{",
"return",
"null",
";",
"}",
"public",
"float",
"getDistance",
"(",
")",
"{",
"return",
"distance",
";",
"}",
"}"
] | Created with IntelliJ IDEA. | [
"Created",
"with",
"IntelliJ",
"IDEA",
"."
] | [
"//To change body of implemented methods use File | Settings | File Templates."
] | [
{
"param": "IConstraint",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "IConstraint",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
488809da8a7ef94316f5a52218f9428f133ebe26 | ptrdvrk/appmap-java | src/main/java/com/appland/appmap/util/StringUtil.java | [
"MIT"
] | Java | StringUtil | /**
* Utility methods to format strings.
*/ | Utility methods to format strings. | [
"Utility",
"methods",
"to",
"format",
"strings",
"."
] | public class StringUtil {
/**
* Returns a copy of a string with the first character capitalized.
*/
public static String capitalize(String str) {
return new String(str.substring(0, 1).toUpperCase() + str.substring(1));
}
/**
* Returns a copy of a string with the first character decapitalized.
*/
public static String decapitalize(String str) {
return new String(str.substring(0, 1).toLowerCase() + str.substring(1));
}
/**
* Returns whether or not a string appears to be an acronym.
*/
public static Boolean isAcronym(String str) {
return !decapitalize(str).equals(str.toLowerCase());
}
/**
* Formats an identifier as a sentence.
* Ex: `com.myorg.MyClass` -> `My class`
*/
public static String identifierToSentence(String identifier) {
String[] packages = StringUtils.split(identifier, '.');
String shortPackage = packages[packages.length - 1];
shortPackage = StringUtils.replace(shortPackage, "Test", "");
String[] words = StringUtils.splitByCharacterTypeCamelCase(shortPackage);
String[] formattedWords = new String[words.length];
for (int i = 0; i < formattedWords.length; i++) {
String word = words[i];
if (word.length() == 0) {
continue;
}
if (isAcronym(word)) {
formattedWords[i] = word;
} else {
formattedWords[i] = word.toLowerCase();
}
}
return capitalize(StringUtils.join(formattedWords, ' '));
}
/**
* Returns canonical name of method from class name, static
* parameter, and method name.
*
* @param className the class name to be checked
* @param isStatic {@code true} if the method is static
* @param methodName the method name to be checked
* @return the canonical name of the method
*
*/
public static String canonicalName(String className, boolean isStatic, String methodName){
return className + (isStatic ? "." : "#") + methodName;
}
/**
* Returns canonical name of method referenced in the event.
* @param event the event to reference
* @return the canonical name of the method
*/
public static String canonicalName(Event event) {
return canonicalName(event.definedClass, event.isStatic, event.methodId);
}
/**
* Returns canonical name of method described by behavior.
* @param behavior the behavior described
* @return the canonical name of the method
*/
public static String canonicalName(CtBehavior behavior) {
return canonicalName(behavior.getDeclaringClass().getName(),
Modifier.isStatic(behavior.getModifiers()) ,
behavior.getMethodInfo().getName());
}
} | [
"public",
"class",
"StringUtil",
"{",
"/**\n * Returns a copy of a string with the first character capitalized.\n */",
"public",
"static",
"String",
"capitalize",
"(",
"String",
"str",
")",
"{",
"return",
"new",
"String",
"(",
"str",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"str",
".",
"substring",
"(",
"1",
")",
")",
";",
"}",
"/**\n * Returns a copy of a string with the first character decapitalized.\n */",
"public",
"static",
"String",
"decapitalize",
"(",
"String",
"str",
")",
"{",
"return",
"new",
"String",
"(",
"str",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toLowerCase",
"(",
")",
"+",
"str",
".",
"substring",
"(",
"1",
")",
")",
";",
"}",
"/**\n * Returns whether or not a string appears to be an acronym.\n */",
"public",
"static",
"Boolean",
"isAcronym",
"(",
"String",
"str",
")",
"{",
"return",
"!",
"decapitalize",
"(",
"str",
")",
".",
"equals",
"(",
"str",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"/**\n * Formats an identifier as a sentence.\n * Ex: `com.myorg.MyClass` -> `My class`\n */",
"public",
"static",
"String",
"identifierToSentence",
"(",
"String",
"identifier",
")",
"{",
"String",
"[",
"]",
"packages",
"=",
"StringUtils",
".",
"split",
"(",
"identifier",
",",
"'.'",
")",
";",
"String",
"shortPackage",
"=",
"packages",
"[",
"packages",
".",
"length",
"-",
"1",
"]",
";",
"shortPackage",
"=",
"StringUtils",
".",
"replace",
"(",
"shortPackage",
",",
"\"",
"Test",
"\"",
",",
"\"",
"\"",
")",
";",
"String",
"[",
"]",
"words",
"=",
"StringUtils",
".",
"splitByCharacterTypeCamelCase",
"(",
"shortPackage",
")",
";",
"String",
"[",
"]",
"formattedWords",
"=",
"new",
"String",
"[",
"words",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"formattedWords",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"word",
"=",
"words",
"[",
"i",
"]",
";",
"if",
"(",
"word",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"isAcronym",
"(",
"word",
")",
")",
"{",
"formattedWords",
"[",
"i",
"]",
"=",
"word",
";",
"}",
"else",
"{",
"formattedWords",
"[",
"i",
"]",
"=",
"word",
".",
"toLowerCase",
"(",
")",
";",
"}",
"}",
"return",
"capitalize",
"(",
"StringUtils",
".",
"join",
"(",
"formattedWords",
",",
"' '",
")",
")",
";",
"}",
"/**\n * Returns canonical name of method from class name, static\n * parameter, and method name.\n *\n * @param className the class name to be checked\n * @param isStatic {@code true} if the method is static\n * @param methodName the method name to be checked\n * @return the canonical name of the method\n * \n */",
"public",
"static",
"String",
"canonicalName",
"(",
"String",
"className",
",",
"boolean",
"isStatic",
",",
"String",
"methodName",
")",
"{",
"return",
"className",
"+",
"(",
"isStatic",
"?",
"\"",
".",
"\"",
":",
"\"",
"#",
"\"",
")",
"+",
"methodName",
";",
"}",
"/**\n * Returns canonical name of method referenced in the event.\n * @param event the event to reference\n * @return the canonical name of the method\n */",
"public",
"static",
"String",
"canonicalName",
"(",
"Event",
"event",
")",
"{",
"return",
"canonicalName",
"(",
"event",
".",
"definedClass",
",",
"event",
".",
"isStatic",
",",
"event",
".",
"methodId",
")",
";",
"}",
"/**\n * Returns canonical name of method described by behavior.\n * @param behavior the behavior described\n * @return the canonical name of the method\n */",
"public",
"static",
"String",
"canonicalName",
"(",
"CtBehavior",
"behavior",
")",
"{",
"return",
"canonicalName",
"(",
"behavior",
".",
"getDeclaringClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"Modifier",
".",
"isStatic",
"(",
"behavior",
".",
"getModifiers",
"(",
")",
")",
",",
"behavior",
".",
"getMethodInfo",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Utility methods to format strings. | [
"Utility",
"methods",
"to",
"format",
"strings",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
488b58f5f30451dce6092f9cc6996e39fb33f8f9 | talkable/android-sdk | sdk/src/main/java/com/talkable/sdk/utils/JsonUtils.java | [
"MIT"
] | Java | JsonUtils | // TODO: build a bullet prof json processing [PR-9236] | build a bullet prof json processing [PR-9236] | [
"build",
"a",
"bullet",
"prof",
"json",
"processing",
"[",
"PR",
"-",
"9236",
"]"
] | public class JsonUtils {
private static Gson gson;
private static void initialize() {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Origin.class, new OriginSerializer());
gsonBuilder.registerTypeAdapter(Event.class, new EventSerializer());
gsonBuilder.registerTypeAdapter(Event.class, new EventDeserializer());
gsonBuilder.registerTypeAdapter(AffiliateMember.class, new AffiliateMemberSerializer());
gsonBuilder.registerTypeAdapter(Purchase.class, new PurchaseSerializer());
gsonBuilder.registerTypeAdapter(Purchase.class, new PurchaseDeserializer());
gsonBuilder.registerTypeAdapter(Visitor.class, new VisitorSerializer());
gsonBuilder.registerTypeAdapter(EmailOfferShare.class, new EmailOfferShareSerializer());
gsonBuilder.registerTypeAdapter(ApiRequest.class, new ApiRequestSerializer());
gsonBuilder.setDateFormat(DateUtils.getFormatString());
gson = gsonBuilder.create();
}
private static boolean isInitialized() {
return gson != null;
}
public static Gson getGson() {
if (!isInitialized()) {
initialize();
}
return gson;
}
public static String toJson(Object src) {
return getGson().toJson(src);
}
public static <T> T fromJson(String json, Class<T> classOfT) throws JsonSyntaxException {
return getGson().fromJson(json, classOfT);
}
public static <T> T fromJson(JsonElement json, Class<T> classOfT) throws JsonSyntaxException {
return getGson().fromJson(json, classOfT);
}
public static JsonElement toJsonTree(Object src) {
return getGson().toJsonTree(src);
}
public static JsonElement toJsonTree(Object src, Type typeOfSrc) {
return getGson().toJsonTree(src, typeOfSrc);
}
public static Boolean getJsonBoolean(JsonObject json, String key) {
JsonElement field = json.get(key);
return !isNull(field) && field.getAsBoolean();
}
public static Integer getJsonInt(JsonObject json, String key) {
JsonElement field = json.get(key);
if (isNull(field)) {
return null;
}
return field.getAsInt();
}
public static String getJsonString(JsonObject json, String key) {
JsonElement field = json.get(key);
if (isNull(field)) {
return null;
}
return field.getAsString();
}
public static boolean isNull(JsonElement element) {
return element == null || element.isJsonNull();
}
@Nullable
public static String[] unsplitStringElement(JsonElement json) {
if (isNull(json) || json.getAsString().isEmpty()) {
return null;
}
return json.getAsString().trim().split(",");
}
} | [
"public",
"class",
"JsonUtils",
"{",
"private",
"static",
"Gson",
"gson",
";",
"private",
"static",
"void",
"initialize",
"(",
")",
"{",
"GsonBuilder",
"gsonBuilder",
"=",
"new",
"GsonBuilder",
"(",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"Origin",
".",
"class",
",",
"new",
"OriginSerializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"Event",
".",
"class",
",",
"new",
"EventSerializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"Event",
".",
"class",
",",
"new",
"EventDeserializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"AffiliateMember",
".",
"class",
",",
"new",
"AffiliateMemberSerializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"Purchase",
".",
"class",
",",
"new",
"PurchaseSerializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"Purchase",
".",
"class",
",",
"new",
"PurchaseDeserializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"Visitor",
".",
"class",
",",
"new",
"VisitorSerializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"EmailOfferShare",
".",
"class",
",",
"new",
"EmailOfferShareSerializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"registerTypeAdapter",
"(",
"ApiRequest",
".",
"class",
",",
"new",
"ApiRequestSerializer",
"(",
")",
")",
";",
"gsonBuilder",
".",
"setDateFormat",
"(",
"DateUtils",
".",
"getFormatString",
"(",
")",
")",
";",
"gson",
"=",
"gsonBuilder",
".",
"create",
"(",
")",
";",
"}",
"private",
"static",
"boolean",
"isInitialized",
"(",
")",
"{",
"return",
"gson",
"!=",
"null",
";",
"}",
"public",
"static",
"Gson",
"getGson",
"(",
")",
"{",
"if",
"(",
"!",
"isInitialized",
"(",
")",
")",
"{",
"initialize",
"(",
")",
";",
"}",
"return",
"gson",
";",
"}",
"public",
"static",
"String",
"toJson",
"(",
"Object",
"src",
")",
"{",
"return",
"getGson",
"(",
")",
".",
"toJson",
"(",
"src",
")",
";",
"}",
"public",
"static",
"<",
"T",
">",
"T",
"fromJson",
"(",
"String",
"json",
",",
"Class",
"<",
"T",
">",
"classOfT",
")",
"throws",
"JsonSyntaxException",
"{",
"return",
"getGson",
"(",
")",
".",
"fromJson",
"(",
"json",
",",
"classOfT",
")",
";",
"}",
"public",
"static",
"<",
"T",
">",
"T",
"fromJson",
"(",
"JsonElement",
"json",
",",
"Class",
"<",
"T",
">",
"classOfT",
")",
"throws",
"JsonSyntaxException",
"{",
"return",
"getGson",
"(",
")",
".",
"fromJson",
"(",
"json",
",",
"classOfT",
")",
";",
"}",
"public",
"static",
"JsonElement",
"toJsonTree",
"(",
"Object",
"src",
")",
"{",
"return",
"getGson",
"(",
")",
".",
"toJsonTree",
"(",
"src",
")",
";",
"}",
"public",
"static",
"JsonElement",
"toJsonTree",
"(",
"Object",
"src",
",",
"Type",
"typeOfSrc",
")",
"{",
"return",
"getGson",
"(",
")",
".",
"toJsonTree",
"(",
"src",
",",
"typeOfSrc",
")",
";",
"}",
"public",
"static",
"Boolean",
"getJsonBoolean",
"(",
"JsonObject",
"json",
",",
"String",
"key",
")",
"{",
"JsonElement",
"field",
"=",
"json",
".",
"get",
"(",
"key",
")",
";",
"return",
"!",
"isNull",
"(",
"field",
")",
"&&",
"field",
".",
"getAsBoolean",
"(",
")",
";",
"}",
"public",
"static",
"Integer",
"getJsonInt",
"(",
"JsonObject",
"json",
",",
"String",
"key",
")",
"{",
"JsonElement",
"field",
"=",
"json",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"isNull",
"(",
"field",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"field",
".",
"getAsInt",
"(",
")",
";",
"}",
"public",
"static",
"String",
"getJsonString",
"(",
"JsonObject",
"json",
",",
"String",
"key",
")",
"{",
"JsonElement",
"field",
"=",
"json",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"isNull",
"(",
"field",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"field",
".",
"getAsString",
"(",
")",
";",
"}",
"public",
"static",
"boolean",
"isNull",
"(",
"JsonElement",
"element",
")",
"{",
"return",
"element",
"==",
"null",
"||",
"element",
".",
"isJsonNull",
"(",
")",
";",
"}",
"@",
"Nullable",
"public",
"static",
"String",
"[",
"]",
"unsplitStringElement",
"(",
"JsonElement",
"json",
")",
"{",
"if",
"(",
"isNull",
"(",
"json",
")",
"||",
"json",
".",
"getAsString",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"json",
".",
"getAsString",
"(",
")",
".",
"trim",
"(",
")",
".",
"split",
"(",
"\"",
",",
"\"",
")",
";",
"}",
"}"
] | TODO: build a bullet prof json processing [PR-9236] | [
"TODO",
":",
"build",
"a",
"bullet",
"prof",
"json",
"processing",
"[",
"PR",
"-",
"9236",
"]"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
488cbab11a516b91fa07c37c73c9d84a54c92742 | srcarter3/awips2 | edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/ExtensionArea.java | [
"Apache-2.0"
] | Java | ExtensionArea | /**
* Describes how polygon is allowed to extend into a site's marine areas
* (for land-based warnings) or onto land (for marine-based warnings).
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ------------ --------------------------
* 12/21/2015 DCS 17942 D. Friedman Initial revision
* 03/22/2016 DCS 18719 D. Friedman Add dynamicArea option
* </pre>
*
*/ | Describes how polygon is allowed to extend into a site's marine areas
(for land-based warnings) or onto land (for marine-based warnings).
SOFTWARE HISTORY
Date Ticket# Engineer Description
12/21/2015 DCS 17942 D. | [
"Describes",
"how",
"polygon",
"is",
"allowed",
"to",
"extend",
"into",
"a",
"site",
"'",
"s",
"marine",
"areas",
"(",
"for",
"land",
"-",
"based",
"warnings",
")",
"or",
"onto",
"land",
"(",
"for",
"marine",
"-",
"based",
"warnings",
")",
".",
"SOFTWARE",
"HISTORY",
"Date",
"Ticket#",
"Engineer",
"Description",
"12",
"/",
"21",
"/",
"2015",
"DCS",
"17942",
"D",
"."
] | @XmlAccessorType(XmlAccessType.NONE)
public class ExtensionArea implements Cloneable {
private double distance = Double.NaN;
private double simplificationTolerance = Double.NaN;
private boolean dynamicArea = false;
@XmlAttribute
public double getDistance() {
return distance;
}
public void setDistance(double distance) {
this.distance = distance;
}
@XmlAttribute(name="simplification")
public double getSimplificationTolerance() {
return simplificationTolerance;
}
public void setSimplificationTolerance(double simplificationTolerance) {
this.simplificationTolerance = simplificationTolerance;
}
@XmlAttribute
public boolean isDynamicArea() {
return dynamicArea;
}
public void setDynamicArea(boolean dynamicArea) {
this.dynamicArea = dynamicArea;
}
public ExtensionArea clone() {
try {
return (ExtensionArea) super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
} | [
"@",
"XmlAccessorType",
"(",
"XmlAccessType",
".",
"NONE",
")",
"public",
"class",
"ExtensionArea",
"implements",
"Cloneable",
"{",
"private",
"double",
"distance",
"=",
"Double",
".",
"NaN",
";",
"private",
"double",
"simplificationTolerance",
"=",
"Double",
".",
"NaN",
";",
"private",
"boolean",
"dynamicArea",
"=",
"false",
";",
"@",
"XmlAttribute",
"public",
"double",
"getDistance",
"(",
")",
"{",
"return",
"distance",
";",
"}",
"public",
"void",
"setDistance",
"(",
"double",
"distance",
")",
"{",
"this",
".",
"distance",
"=",
"distance",
";",
"}",
"@",
"XmlAttribute",
"(",
"name",
"=",
"\"",
"simplification",
"\"",
")",
"public",
"double",
"getSimplificationTolerance",
"(",
")",
"{",
"return",
"simplificationTolerance",
";",
"}",
"public",
"void",
"setSimplificationTolerance",
"(",
"double",
"simplificationTolerance",
")",
"{",
"this",
".",
"simplificationTolerance",
"=",
"simplificationTolerance",
";",
"}",
"@",
"XmlAttribute",
"public",
"boolean",
"isDynamicArea",
"(",
")",
"{",
"return",
"dynamicArea",
";",
"}",
"public",
"void",
"setDynamicArea",
"(",
"boolean",
"dynamicArea",
")",
"{",
"this",
".",
"dynamicArea",
"=",
"dynamicArea",
";",
"}",
"public",
"ExtensionArea",
"clone",
"(",
")",
"{",
"try",
"{",
"return",
"(",
"ExtensionArea",
")",
"super",
".",
"clone",
"(",
")",
";",
"}",
"catch",
"(",
"CloneNotSupportedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] | Describes how polygon is allowed to extend into a site's marine areas
(for land-based warnings) or onto land (for marine-based warnings). | [
"Describes",
"how",
"polygon",
"is",
"allowed",
"to",
"extend",
"into",
"a",
"site",
"'",
"s",
"marine",
"areas",
"(",
"for",
"land",
"-",
"based",
"warnings",
")",
"or",
"onto",
"land",
"(",
"for",
"marine",
"-",
"based",
"warnings",
")",
"."
] | [] | [
{
"param": "Cloneable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Cloneable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4890dfcc5b782bbf786cc6d2c865e06116ecc2bf | staycaffeinated/metacode | meta-cli/src/main/java/mmm/coffee/metacode/cli/create/project/AbstractCreateSpringProject.java | [
"Apache-2.0"
] | Java | AbstractCreateSpringProject | /**
* AbstractCreateSpringProject holds command line options that are common
* to spring-webflux and spring-webmvc.
*/ | AbstractCreateSpringProject holds command line options that are common
to spring-webflux and spring-webmvc. | [
"AbstractCreateSpringProject",
"holds",
"command",
"line",
"options",
"that",
"are",
"common",
"to",
"spring",
"-",
"webflux",
"and",
"spring",
"-",
"webmvc",
"."
] | public class AbstractCreateSpringProject extends AbstractCreateRestProject {
//
// The Support option. These are the added capabilities supported by the generated application.
//
// I've been back and forth with what to name this flag. Spring Initialzr has the notion of
// 'dependencies', but all Spring Initializr does is add those dependencies to the gradle/maven build file.
// Micronaut uses the term 'feature', but added libraries aren't exactly 'features' of the
// generated application. The term 'trait' seems in line: for example, a 'postgres trait' indicates
// the traits of a Postgres database are enabled in the application. Along that line, 'support'
// also seems like a good term: the generated application will 'support' postgres or liquibase or CORS
// or heath checks or whatever
// First, we have to provide an Iterable<String> that provides the list of valid candidates
//
// The declaration the additional library options
// For example, ```--add postgres liquibase```
// What about -i --integrations? so, for example, `-i postgres testcontainers`
@CommandLine.Option(names={"-a", "--add"},
arity="0..*",
paramLabel = "LIBRARY",
description = { "Add the support of additional libraries to the project. Currently supported libraries are: ${COMPLETION-CANDIDATES}." }
)
protected SpringIntegrations[] features;
/**
* Creates a project descriptor from the command-line arguments
* @return a POJO that encapsulates the command-line arguments
*/
protected RestProjectDescriptor buildProjectDescriptor(Framework framework) {
// Get the basic information
var descriptor = RestProjectDescriptor
.builder()
.applicationName(applicationName)
.basePackage(packageName)
.basePath(basePath)
.groupId(groupId)
.framework(framework)
.build();
// take note of any features/integrations
if (features != null) {
for (SpringIntegrations f : features) {
descriptor.getIntegrations().add(f.name());
}
}
return descriptor;
}
} | [
"public",
"class",
"AbstractCreateSpringProject",
"extends",
"AbstractCreateRestProject",
"{",
"@",
"CommandLine",
".",
"Option",
"(",
"names",
"=",
"{",
"\"",
"-a",
"\"",
",",
"\"",
"--add",
"\"",
"}",
",",
"arity",
"=",
"\"",
"0..*",
"\"",
",",
"paramLabel",
"=",
"\"",
"LIBRARY",
"\"",
",",
"description",
"=",
"{",
"\"",
"Add the support of additional libraries to the project. Currently supported libraries are: ${COMPLETION-CANDIDATES}.",
"\"",
"}",
")",
"protected",
"SpringIntegrations",
"[",
"]",
"features",
";",
"/**\n * Creates a project descriptor from the command-line arguments\n * @return a POJO that encapsulates the command-line arguments\n */",
"protected",
"RestProjectDescriptor",
"buildProjectDescriptor",
"(",
"Framework",
"framework",
")",
"{",
"var",
"descriptor",
"=",
"RestProjectDescriptor",
".",
"builder",
"(",
")",
".",
"applicationName",
"(",
"applicationName",
")",
".",
"basePackage",
"(",
"packageName",
")",
".",
"basePath",
"(",
"basePath",
")",
".",
"groupId",
"(",
"groupId",
")",
".",
"framework",
"(",
"framework",
")",
".",
"build",
"(",
")",
";",
"if",
"(",
"features",
"!=",
"null",
")",
"{",
"for",
"(",
"SpringIntegrations",
"f",
":",
"features",
")",
"{",
"descriptor",
".",
"getIntegrations",
"(",
")",
".",
"add",
"(",
"f",
".",
"name",
"(",
")",
")",
";",
"}",
"}",
"return",
"descriptor",
";",
"}",
"}"
] | AbstractCreateSpringProject holds command line options that are common
to spring-webflux and spring-webmvc. | [
"AbstractCreateSpringProject",
"holds",
"command",
"line",
"options",
"that",
"are",
"common",
"to",
"spring",
"-",
"webflux",
"and",
"spring",
"-",
"webmvc",
"."
] | [
"//",
"// The Support option. These are the added capabilities supported by the generated application.",
"//",
"// I've been back and forth with what to name this flag. Spring Initialzr has the notion of",
"// 'dependencies', but all Spring Initializr does is add those dependencies to the gradle/maven build file.",
"// Micronaut uses the term 'feature', but added libraries aren't exactly 'features' of the",
"// generated application. The term 'trait' seems in line: for example, a 'postgres trait' indicates",
"// the traits of a Postgres database are enabled in the application. Along that line, 'support'",
"// also seems like a good term: the generated application will 'support' postgres or liquibase or CORS",
"// or heath checks or whatever",
"// First, we have to provide an Iterable<String> that provides the list of valid candidates",
"//",
"// The declaration the additional library options",
"// For example, ```--add postgres liquibase```",
"// What about -i --integrations? so, for example, `-i postgres testcontainers`",
"// Get the basic information",
"// take note of any features/integrations"
] | [
{
"param": "AbstractCreateRestProject",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractCreateRestProject",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc39be83bcd7c79a667a4f22ac1c618d818b8531 | ErhardSiegl/galleon | cli/src/main/java/org/jboss/galleon/cli/cmd/plugin/AbstractPluginsCommand.java | [
"Apache-2.0"
] | Java | AbstractPluginsCommand | /**
* An abstract command that discover plugin options based on the fp or stream
* argument.
*
* @author [email protected]
*/ | An abstract command that discover plugin options based on the fp or stream
argument.
| [
"An",
"abstract",
"command",
"that",
"discover",
"plugin",
"options",
"based",
"on",
"the",
"fp",
"or",
"stream",
"argument",
"."
] | public abstract class AbstractPluginsCommand extends AbstractDynamicCommand implements CommandWithInstallationDirectory {
public AbstractPluginsCommand(PmSession pmSession) {
super(pmSession, true);
}
protected boolean isVerbose() {
return contains(VERBOSE_OPTION_NAME);
}
@Override
protected void runCommand(PmCommandInvocation session, Map<String, String> options) throws CommandExecutionException {
if (isVerbose()) {
session.getPmSession().enableMavenTrace(true);
}
try {
final String id = getId(pmSession);
final FeaturePackLocation loc = id == null ? null : pmSession.
getResolvedLocation(getInstallationDirectory(session.
getConfiguration().getAeshContext()), id);
runCommand(session, options, loc);
} catch (ProvisioningException ex) {
throw new CommandExecutionException(session.getPmSession(), CliErrors.resolveLocationFailed(), ex);
} finally {
session.getPmSession().enableMavenTrace(false);
}
}
protected abstract void runCommand(PmCommandInvocation session, Map<String, String> options,
FeaturePackLocation loc) throws CommandExecutionException;
protected OptionActivator getArgumentActivator() {
return null;
}
@Override
protected void doValidateOptions(PmCommandInvocation invoc) throws CommandExecutionException {
// side effect is to resolve artifact.
String fpl = getId(pmSession);
if (fpl == null) {
throw new CommandExecutionException("Missing feature-pack");
}
}
@Override
protected List<ProcessedOption> getStaticOptions() throws OptionParserException {
List<ProcessedOption> options = new ArrayList<>();
options.add(ProcessedOptionBuilder.builder().name(ARGUMENT_NAME).
hasValue(true).
description(HelpDescriptions.FP_LOCATION).
type(String.class).
required(true).
optionType(OptionType.ARGUMENT).
activator(getArgumentActivator()).
completer(FPLocationCompleter.class).
build());
options.add(ProcessedOptionBuilder.builder().name(VERBOSE_OPTION_NAME).
hasValue(false).
type(Boolean.class).
description(HelpDescriptions.VERBOSE).
optionType(OptionType.BOOLEAN).
build());
options.addAll(getOtherOptions());
return options;
}
protected List<ProcessedOption> getOtherOptions() throws OptionParserException {
return Collections.emptyList();
}
@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
List<DynamicOption> options = new ArrayList<>();
FeaturePackLocation fpl = pmSession.getResolvedLocation(getInstallationDirectory(pmSession.getAeshContext()),
getId(pmSession));
Set<ProvisioningOption> pluginOptions = getPluginOptions(fpl);
for (ProvisioningOption opt : pluginOptions) {
DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
options.add(dynOption);
}
return options;
}
protected abstract Set<ProvisioningOption> getPluginOptions(FeaturePackLocation loc) throws ProvisioningException;
protected ProvisioningManager getManager(PmCommandInvocation session) throws ProvisioningException {
return session.getPmSession().newProvisioningManager(getInstallationDirectory(session.
getConfiguration().getAeshContext()), isVerbose());
}
protected String getId(PmSession session) throws CommandExecutionException {
String streamName = (String) getValue(ARGUMENT_NAME);
if (streamName == null) {
// Check in argument or option, that is the option completion case.
streamName = getArgumentValue();
}
if (streamName != null) {
try {
return session.getResolvedLocation(getInstallationDirectory(session.getAeshContext()),
streamName).toString();
} catch (ProvisioningException ex) {
// Ok, no id set.
}
}
return null;
}
} | [
"public",
"abstract",
"class",
"AbstractPluginsCommand",
"extends",
"AbstractDynamicCommand",
"implements",
"CommandWithInstallationDirectory",
"{",
"public",
"AbstractPluginsCommand",
"(",
"PmSession",
"pmSession",
")",
"{",
"super",
"(",
"pmSession",
",",
"true",
")",
";",
"}",
"protected",
"boolean",
"isVerbose",
"(",
")",
"{",
"return",
"contains",
"(",
"VERBOSE_OPTION_NAME",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"runCommand",
"(",
"PmCommandInvocation",
"session",
",",
"Map",
"<",
"String",
",",
"String",
">",
"options",
")",
"throws",
"CommandExecutionException",
"{",
"if",
"(",
"isVerbose",
"(",
")",
")",
"{",
"session",
".",
"getPmSession",
"(",
")",
".",
"enableMavenTrace",
"(",
"true",
")",
";",
"}",
"try",
"{",
"final",
"String",
"id",
"=",
"getId",
"(",
"pmSession",
")",
";",
"final",
"FeaturePackLocation",
"loc",
"=",
"id",
"==",
"null",
"?",
"null",
":",
"pmSession",
".",
"getResolvedLocation",
"(",
"getInstallationDirectory",
"(",
"session",
".",
"getConfiguration",
"(",
")",
".",
"getAeshContext",
"(",
")",
")",
",",
"id",
")",
";",
"runCommand",
"(",
"session",
",",
"options",
",",
"loc",
")",
";",
"}",
"catch",
"(",
"ProvisioningException",
"ex",
")",
"{",
"throw",
"new",
"CommandExecutionException",
"(",
"session",
".",
"getPmSession",
"(",
")",
",",
"CliErrors",
".",
"resolveLocationFailed",
"(",
")",
",",
"ex",
")",
";",
"}",
"finally",
"{",
"session",
".",
"getPmSession",
"(",
")",
".",
"enableMavenTrace",
"(",
"false",
")",
";",
"}",
"}",
"protected",
"abstract",
"void",
"runCommand",
"(",
"PmCommandInvocation",
"session",
",",
"Map",
"<",
"String",
",",
"String",
">",
"options",
",",
"FeaturePackLocation",
"loc",
")",
"throws",
"CommandExecutionException",
";",
"protected",
"OptionActivator",
"getArgumentActivator",
"(",
")",
"{",
"return",
"null",
";",
"}",
"@",
"Override",
"protected",
"void",
"doValidateOptions",
"(",
"PmCommandInvocation",
"invoc",
")",
"throws",
"CommandExecutionException",
"{",
"String",
"fpl",
"=",
"getId",
"(",
"pmSession",
")",
";",
"if",
"(",
"fpl",
"==",
"null",
")",
"{",
"throw",
"new",
"CommandExecutionException",
"(",
"\"",
"Missing feature-pack",
"\"",
")",
";",
"}",
"}",
"@",
"Override",
"protected",
"List",
"<",
"ProcessedOption",
">",
"getStaticOptions",
"(",
")",
"throws",
"OptionParserException",
"{",
"List",
"<",
"ProcessedOption",
">",
"options",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"options",
".",
"add",
"(",
"ProcessedOptionBuilder",
".",
"builder",
"(",
")",
".",
"name",
"(",
"ARGUMENT_NAME",
")",
".",
"hasValue",
"(",
"true",
")",
".",
"description",
"(",
"HelpDescriptions",
".",
"FP_LOCATION",
")",
".",
"type",
"(",
"String",
".",
"class",
")",
".",
"required",
"(",
"true",
")",
".",
"optionType",
"(",
"OptionType",
".",
"ARGUMENT",
")",
".",
"activator",
"(",
"getArgumentActivator",
"(",
")",
")",
".",
"completer",
"(",
"FPLocationCompleter",
".",
"class",
")",
".",
"build",
"(",
")",
")",
";",
"options",
".",
"add",
"(",
"ProcessedOptionBuilder",
".",
"builder",
"(",
")",
".",
"name",
"(",
"VERBOSE_OPTION_NAME",
")",
".",
"hasValue",
"(",
"false",
")",
".",
"type",
"(",
"Boolean",
".",
"class",
")",
".",
"description",
"(",
"HelpDescriptions",
".",
"VERBOSE",
")",
".",
"optionType",
"(",
"OptionType",
".",
"BOOLEAN",
")",
".",
"build",
"(",
")",
")",
";",
"options",
".",
"addAll",
"(",
"getOtherOptions",
"(",
")",
")",
";",
"return",
"options",
";",
"}",
"protected",
"List",
"<",
"ProcessedOption",
">",
"getOtherOptions",
"(",
")",
"throws",
"OptionParserException",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"@",
"Override",
"protected",
"List",
"<",
"DynamicOption",
">",
"getDynamicOptions",
"(",
"State",
"state",
")",
"throws",
"Exception",
"{",
"List",
"<",
"DynamicOption",
">",
"options",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"FeaturePackLocation",
"fpl",
"=",
"pmSession",
".",
"getResolvedLocation",
"(",
"getInstallationDirectory",
"(",
"pmSession",
".",
"getAeshContext",
"(",
")",
")",
",",
"getId",
"(",
"pmSession",
")",
")",
";",
"Set",
"<",
"ProvisioningOption",
">",
"pluginOptions",
"=",
"getPluginOptions",
"(",
"fpl",
")",
";",
"for",
"(",
"ProvisioningOption",
"opt",
":",
"pluginOptions",
")",
"{",
"DynamicOption",
"dynOption",
"=",
"new",
"DynamicOption",
"(",
"opt",
".",
"getName",
"(",
")",
",",
"opt",
".",
"isRequired",
"(",
")",
")",
";",
"options",
".",
"add",
"(",
"dynOption",
")",
";",
"}",
"return",
"options",
";",
"}",
"protected",
"abstract",
"Set",
"<",
"ProvisioningOption",
">",
"getPluginOptions",
"(",
"FeaturePackLocation",
"loc",
")",
"throws",
"ProvisioningException",
";",
"protected",
"ProvisioningManager",
"getManager",
"(",
"PmCommandInvocation",
"session",
")",
"throws",
"ProvisioningException",
"{",
"return",
"session",
".",
"getPmSession",
"(",
")",
".",
"newProvisioningManager",
"(",
"getInstallationDirectory",
"(",
"session",
".",
"getConfiguration",
"(",
")",
".",
"getAeshContext",
"(",
")",
")",
",",
"isVerbose",
"(",
")",
")",
";",
"}",
"protected",
"String",
"getId",
"(",
"PmSession",
"session",
")",
"throws",
"CommandExecutionException",
"{",
"String",
"streamName",
"=",
"(",
"String",
")",
"getValue",
"(",
"ARGUMENT_NAME",
")",
";",
"if",
"(",
"streamName",
"==",
"null",
")",
"{",
"streamName",
"=",
"getArgumentValue",
"(",
")",
";",
"}",
"if",
"(",
"streamName",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"session",
".",
"getResolvedLocation",
"(",
"getInstallationDirectory",
"(",
"session",
".",
"getAeshContext",
"(",
")",
")",
",",
"streamName",
")",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"ProvisioningException",
"ex",
")",
"{",
"}",
"}",
"return",
"null",
";",
"}",
"}"
] | An abstract command that discover plugin options based on the fp or stream
argument. | [
"An",
"abstract",
"command",
"that",
"discover",
"plugin",
"options",
"based",
"on",
"the",
"fp",
"or",
"stream",
"argument",
"."
] | [
"// side effect is to resolve artifact.",
"// Check in argument or option, that is the option completion case.",
"// Ok, no id set."
] | [
{
"param": "AbstractDynamicCommand",
"type": null
},
{
"param": "CommandWithInstallationDirectory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractDynamicCommand",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "CommandWithInstallationDirectory",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc3cfaf538639c58977d08e903d64257fb7328fa | android-Infoedge/campaign-tracker | utm-grabber/src/main/java/com/infoedge/installreferrer/receiver/ReferralReceiver.java | [
"Apache-2.0"
] | Java | ReferralReceiver | /**
* Created by ashish on 2/8/16.
*/ | Created by ashish on 2/8/16. | [
"Created",
"by",
"ashish",
"on",
"2",
"/",
"8",
"/",
"16",
"."
] | public class ReferralReceiver extends BroadcastReceiver {
private final static String PREFS_FILE_NAME = "ReferralParamsFile";
public final static String[] EXPECTED_PARAMETERS = {"utm_source",
"utm_medium", "utm_term", "utm_content", "utm_campaign"};
@Override
public void onReceive(Context context, Intent intent) {
Map<String, String> referralParams = new HashMap<String, String>();
if (intent == null) {
return;
}
if (!intent.getAction().equals("com.android.vending.INSTALL_REFERRER")) { //$NON-NLS-1$
return;
}
String referrer = intent.getStringExtra("referrer"); //$NON-NLS-1$
if (referrer == null || referrer.length() == 0) {
return;
}
try {
referrer = URLDecoder.decode(referrer, "UTF-8"); //$NON-NLS-1$
} catch (UnsupportedEncodingException e) {
return;
}
try {
String[] params = referrer.split("&"); // $NON-NLS-1$
for (String param : params) {
String[] pair = param.split("="); // $NON-NLS-1$
if (pair.length == 1) {
referralParams.put(pair[0], "AndroidApp");
} else if (pair.length == 2) {
referralParams.put(pair[0], pair[1]);
}
}
} catch (Exception e) {
e.printStackTrace();
}
ReferralReceiver.storeReferralParams(context, referralParams);
}
public static void storeReferralParams(Context context,
Map<String, String> params) {
SharedPreferences storage = context.getSharedPreferences(
ReferralReceiver.PREFS_FILE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = storage.edit();
for (String key : ReferralReceiver.EXPECTED_PARAMETERS) {
String value = params.get(key);
System.out.println("value:::::::::;"+value);
if (value != null) {
editor.putString(key, value);
}
}
editor.commit();
}
public static UtmSourceInfo retrieveReferralParams1(Context context) {
UtmSourceInfo utmSourceInfo = new UtmSourceInfo();
SharedPreferences storage = context.getSharedPreferences(
ReferralReceiver.PREFS_FILE_NAME, Context.MODE_PRIVATE);
utmSourceInfo.setUtmSource(storage.getString(ReferralReceiver.EXPECTED_PARAMETERS[0], null));
utmSourceInfo.setUtmMedium(storage.getString(ReferralReceiver.EXPECTED_PARAMETERS[1], null));
utmSourceInfo.setUtmTerm(storage.getString(ReferralReceiver.EXPECTED_PARAMETERS[2], null));
utmSourceInfo.setUtmContent(storage.getString(ReferralReceiver.EXPECTED_PARAMETERS[3], null));
utmSourceInfo.setUtmCampaign(storage.getString(ReferralReceiver.EXPECTED_PARAMETERS[4], null));
return utmSourceInfo;
}
public static void clearReferralFile(Context context) {
try {
SharedPreferences searcPref = context.getSharedPreferences(
PREFS_FILE_NAME, 0);
SharedPreferences.Editor editor = searcPref.edit();
editor.clear();
editor.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
} | [
"public",
"class",
"ReferralReceiver",
"extends",
"BroadcastReceiver",
"{",
"private",
"final",
"static",
"String",
"PREFS_FILE_NAME",
"=",
"\"",
"ReferralParamsFile",
"\"",
";",
"public",
"final",
"static",
"String",
"[",
"]",
"EXPECTED_PARAMETERS",
"=",
"{",
"\"",
"utm_source",
"\"",
",",
"\"",
"utm_medium",
"\"",
",",
"\"",
"utm_term",
"\"",
",",
"\"",
"utm_content",
"\"",
",",
"\"",
"utm_campaign",
"\"",
"}",
";",
"@",
"Override",
"public",
"void",
"onReceive",
"(",
"Context",
"context",
",",
"Intent",
"intent",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"referralParams",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"intent",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"intent",
".",
"getAction",
"(",
")",
".",
"equals",
"(",
"\"",
"com.android.vending.INSTALL_REFERRER",
"\"",
")",
")",
"{",
"return",
";",
"}",
"String",
"referrer",
"=",
"intent",
".",
"getStringExtra",
"(",
"\"",
"referrer",
"\"",
")",
";",
"if",
"(",
"referrer",
"==",
"null",
"||",
"referrer",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"try",
"{",
"referrer",
"=",
"URLDecoder",
".",
"decode",
"(",
"referrer",
",",
"\"",
"UTF-8",
"\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"return",
";",
"}",
"try",
"{",
"String",
"[",
"]",
"params",
"=",
"referrer",
".",
"split",
"(",
"\"",
"&",
"\"",
")",
";",
"for",
"(",
"String",
"param",
":",
"params",
")",
"{",
"String",
"[",
"]",
"pair",
"=",
"param",
".",
"split",
"(",
"\"",
"=",
"\"",
")",
";",
"if",
"(",
"pair",
".",
"length",
"==",
"1",
")",
"{",
"referralParams",
".",
"put",
"(",
"pair",
"[",
"0",
"]",
",",
"\"",
"AndroidApp",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"pair",
".",
"length",
"==",
"2",
")",
"{",
"referralParams",
".",
"put",
"(",
"pair",
"[",
"0",
"]",
",",
"pair",
"[",
"1",
"]",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"ReferralReceiver",
".",
"storeReferralParams",
"(",
"context",
",",
"referralParams",
")",
";",
"}",
"public",
"static",
"void",
"storeReferralParams",
"(",
"Context",
"context",
",",
"Map",
"<",
"String",
",",
"String",
">",
"params",
")",
"{",
"SharedPreferences",
"storage",
"=",
"context",
".",
"getSharedPreferences",
"(",
"ReferralReceiver",
".",
"PREFS_FILE_NAME",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"SharedPreferences",
".",
"Editor",
"editor",
"=",
"storage",
".",
"edit",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"ReferralReceiver",
".",
"EXPECTED_PARAMETERS",
")",
"{",
"String",
"value",
"=",
"params",
".",
"get",
"(",
"key",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"value:::::::::;",
"\"",
"+",
"value",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"editor",
".",
"putString",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"editor",
".",
"commit",
"(",
")",
";",
"}",
"public",
"static",
"UtmSourceInfo",
"retrieveReferralParams1",
"(",
"Context",
"context",
")",
"{",
"UtmSourceInfo",
"utmSourceInfo",
"=",
"new",
"UtmSourceInfo",
"(",
")",
";",
"SharedPreferences",
"storage",
"=",
"context",
".",
"getSharedPreferences",
"(",
"ReferralReceiver",
".",
"PREFS_FILE_NAME",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"utmSourceInfo",
".",
"setUtmSource",
"(",
"storage",
".",
"getString",
"(",
"ReferralReceiver",
".",
"EXPECTED_PARAMETERS",
"[",
"0",
"]",
",",
"null",
")",
")",
";",
"utmSourceInfo",
".",
"setUtmMedium",
"(",
"storage",
".",
"getString",
"(",
"ReferralReceiver",
".",
"EXPECTED_PARAMETERS",
"[",
"1",
"]",
",",
"null",
")",
")",
";",
"utmSourceInfo",
".",
"setUtmTerm",
"(",
"storage",
".",
"getString",
"(",
"ReferralReceiver",
".",
"EXPECTED_PARAMETERS",
"[",
"2",
"]",
",",
"null",
")",
")",
";",
"utmSourceInfo",
".",
"setUtmContent",
"(",
"storage",
".",
"getString",
"(",
"ReferralReceiver",
".",
"EXPECTED_PARAMETERS",
"[",
"3",
"]",
",",
"null",
")",
")",
";",
"utmSourceInfo",
".",
"setUtmCampaign",
"(",
"storage",
".",
"getString",
"(",
"ReferralReceiver",
".",
"EXPECTED_PARAMETERS",
"[",
"4",
"]",
",",
"null",
")",
")",
";",
"return",
"utmSourceInfo",
";",
"}",
"public",
"static",
"void",
"clearReferralFile",
"(",
"Context",
"context",
")",
"{",
"try",
"{",
"SharedPreferences",
"searcPref",
"=",
"context",
".",
"getSharedPreferences",
"(",
"PREFS_FILE_NAME",
",",
"0",
")",
";",
"SharedPreferences",
".",
"Editor",
"editor",
"=",
"searcPref",
".",
"edit",
"(",
")",
";",
"editor",
".",
"clear",
"(",
")",
";",
"editor",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}"
] | Created by ashish on 2/8/16. | [
"Created",
"by",
"ashish",
"on",
"2",
"/",
"8",
"/",
"16",
"."
] | [
"//$NON-NLS-1$",
"//$NON-NLS-1$",
"//$NON-NLS-1$",
"// $NON-NLS-1$",
"// $NON-NLS-1$"
] | [
{
"param": "BroadcastReceiver",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "BroadcastReceiver",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc3fa6a690fccd2f8e9986fca76f820d5cf2142a | kumarsharma/LegacyData2LinkedData | src/MappingClasses/ML8_HoldingsInfo.java | [
"Apache-2.0"
] | Java | ML8_HoldingsInfo | /**
* 800-840 Series added entry fields
* 841-88X Holdings, alternate graphics, etc. - General information
* @author home
*/ | 800-840 Series added entry fields
841-88X Holdings, alternate graphics, etc. - General information
@author home | [
"800",
"-",
"840",
"Series",
"added",
"entry",
"fields",
"841",
"-",
"88X",
"Holdings",
"alternate",
"graphics",
"etc",
".",
"-",
"General",
"information",
"@author",
"home"
] | public class ML8_HoldingsInfo extends ML00_DataInfo {
public Property getPropertyForDataField(DataField df)
{
int tag = Integer.parseInt(df.getTag());
Property property;
switch(tag)
{
case 800: // Series added entry - personal name
case 810: // Series added entry - corporate name
case 811: // Series added entry - meeting name
case 830: // Series added entry - uniform title
case 841: //-88X Holdings, alternate graphics, etc. - General information
// case 841: // Holdings coded data values
case 842: // T extual physical form designator
case 843: // Reproduction note
case 844: // Name of unit
case 845: // T erms governing use and reproduction note
case 850: // Holding institution
case 852: // Location
case 853: // Captions and pattern -- basic bibli
case 854: // Captions and pattern -- supplementary material
case 855: // Captions and pattern -- indexes
case 856: // Electronic location and access
case 863: // Enumeration and chronology -- basic bibliographic unit
case 864: // Enumeration and chronology -- supplementary material
case 865: // Enumeration and chronology -- indexes
case 866: // T extual holdings -- basic bibliographic unit
case 868: // T extual holdings -- indexes
case 876: // Item information -- basic bibliographic unit
case 877: // Item information -- supplementary material
case 878: // Item information -- indexes
case 880: // Alternate graphic representation
case 886: // Foreign MARC information field
case 887: // Non-MARC information field
default:
property = DC_11.relation;
break;
}
return property;
}
public Property getPropertyForSubFieldUsingDataField(Subfield sf, DataField df)
{
int dTag = Integer.parseInt(df.getTag());
char sTag = sf.getCode();
Property property = null;
switch(dTag)
{
case 830:
{
switch(sTag)
{
case 'a':
property = marcont.hasTitle;//Uniform title (NR)
break;
case 'd':
property = null;//- Date of treaty signing (R)
break;
case 'f':
property = marcont.hasDate;//- Date of a work (NR)
break;
case 'g':
property = null;//- Miscellaneous information (NR)
break;
case 'h':
property = DCTerms.medium;//- Medium (NR)
break;
case 'k':
property = null;//- Form subheading (R)
break;
case 'l':
property = null;//- Language of a work (NR)
break;
case 'm':
property = RDA1.propertyForName("mediumOfPermonanceOfMusicalContentExpression");//- Medium of performance for music (R)
break;
case 'n':
property = null;//- Number of part/section of a work (R)
break;
case 'o':
property = null;//- Arranged statement for music (NR)
break;
case 'p':
property = null;//- Name of part/section of a work (R)
break;
case 'r':
property = null;//- Key for music (NR)
break;
case 's':
property = null;//- Version (NR)
break;
case 't':
property = null;//- Title of a work (NR)
break;
case 'v':
property = null;//- Volume/sequential designation (NR)
break;
case 'w':
property = null;//- Bibliographic record control number (R)
break;
case 'x':
property = null;//- International Standard Serial Number (NR)
break;
case '0':
property = null;//- Authority record control number (R)
break;
case '3':
property = null;//- Materials specified (NR)
break;
case '5':
property = null;//- Institution to which field applies (R)
break;
case '6':
property = null;//- Linkage (NR)
break;
case '8':
property = null;//- Field link and sequence number (R)
break;
}
}
break;
case 856: //series statement
{
switch(sTag)
{
case 'a':
property = null;// - Host name (R)
break;
case 'b':
property = null;//- Access number (R)
break;
case 'c':
property = null;//- Compression information (R)
break;
case 'd':
property = null;//- Path (R)
break;
case 'f':
property = null;//- Electronic name (R)
break;
case 'h':
property = null;//- Processor of request (NR)
break;
case 'i':
property = null;//- Instruction (R)
break;
case 'j':
property = null;//- Bits per second (NR)
break;
case 'k':
property = null;//- Password (NR)
break;
case 'l':
property = null;//- Logon (NR)
break;
case 'm':
property = null;//- Contact for access assistance (R)
break;
case 'n':
property = null;//- Name of location of host (NR)
break;
case 'o':
property = null;//- Operating system (NR)
break;
case 'p':
property = null;//- Port (NR)
break;
case 'q':
property = null;//- Electronic format type (NR)
break;
case 'r':
property = null;//- Settings (NR)
break;
case 's':
property = null;//- File size (R)
break;
case 't':
property = null;//- Terminal emulation (R)
break;
case 'u':
property = marcont.hasURL;//- Uniform Resource Identifier (R)
break;
case 'v':
property = null;//- Hours access method available (R)
break;
case 'w':
property = null;//- Record control number (R)
break;
case 'x':
property = null;//- Nonpublic note (R)
break;
case 'y':
property = null;//- Link text (R)
break;
case 'z':
property = null;//- Public note (R)
break;
case '2':
property = null;//- Access method (NR)
break;
case '3':
property = null;//- Materials specified (NR)
break;
case '6':
property = null;//- Linkage (NR)
break;
case '8':
property = null;//- Field link and sequence number (R)
break;
}
}
break;
case 800: // Series Added Entry - Personal Name (R)
{
switch(sTag)
{
case 'a':
property = null;
break;//Personal name (NR)
case 'b':
property = null;
break;//- Numeration (NR)
case 'c':
property = null;
break;//- Titles and other words associated with a name (R)
case 'd':
property = null;
break;//- Dates associated with a name (NR)
case 'e':
property = null;
break;//- Relator term (R)
case 'f':
property = RDA1.propertyForName("dateOfWork");
break;//- Date of a work (NR)
case 'g':
property = null;
break;//- Miscellaneous information (NR)
case 'h':
property = null;
break;//- Medium (NR)
case 'j':
property = null;
break;//- Attribution qualifier (R)
case 'k':
property = null;
break;//- Form subheading (R)
case 'l':
property = null;
break;//- Language of a work (NR)
case 'm':
property = null;
break;//- Medium of performance for music (R)
case 'n':
property = null;
break;//- Number of part/section of a work (R)
case 'o':
property = null;
break;//- Arranged statement for music (NR)
case 'p':
property = null;
break;//- Name of part/section of a work (R)
case 'q':
property = null;
break;//- Fuller form of name (NR)
case 'r':
property = null;
break;//- Key for music (NR)
case 's':
property = null;
break;//- Version (NR)
case 't':
property = null;
break;//- Title of a work (NR)
case 'u':
property = null;
break;//- Affiliation (NR)
case 'v':
property = null;
break;//- Volume/sequential designation (NR)
case 'w':
property = null;
break;//- Bibliographic record control number (R)
case 'x':
property = null;
break;//- International Standard Serial Number (NR)
case '0':
property = null;
break;//- Authority record control number (R)
case '3':
property = null;
break;//- Materials specified (NR)
case '4':
property = null;
break;//- Relator code (R)
case '5':
property = null;
break;//- Institution to which field applies (R)
case '6':
property = null;//- Linkage (NR)
break;
case '8':
property = null;//- Field link and sequence number (R)
break;
}
}
break;
case 810: // Series Added Entry - Personal Name (R)
{
switch(sTag)
{
case 'a':
property = null;
break;//Corporate name or jurisdiction name as entry element (NR)
case 'b':
property = null;
break;//- Subordinate unit (R)
case 'c':
property = null;
break;//- Location of meeting (NR)
case 'd':
property = null;
break;//- Date of meeting or treaty signing (R)
case 'e':
property = null;
break;//- Relator term (R)
case 'f':
property = RDA1.propertyForName("dateOfWork");
break;//- Date of a work (NR)
case 'g':
property = null;
break;//- Miscellaneous information (NR)
case 'h':
property = null;
break;//- Medium (NR)
case 'j':
property = null;
break;//- Attribution qualifier (R)
case 'k':
property = null;
break;//- Form subheading (R)
case 'l':
property = null;
break;//- Language of a work (NR)
case 'm':
property = null;
break;//- Medium of performance for music (R)
case 'n':
property = null;
break;//- Number of part/section of a work (R)
case 'o':
property = null;
break;//- Arranged statement for music (NR)
case 'p':
property = null;
break;//- Name of part/section of a work (R)
case 'q':
property = null;
break;//- Fuller form of name (NR)
case 'r':
property = null;
break;//- Key for music (NR)
case 's':
property = null;
break;//- Version (NR)
case 't':
property = null;
break;//- Title of a work (NR)
case 'u':
property = null;
break;//- Affiliation (NR)
case 'v':
property = null;
break;//- Volume/sequential designation (NR)
case 'w':
property = null;
break;//- Bibliographic record control number (R)
case 'x':
property = null;
break;//- International Standard Serial Number (NR)
case '0':
property = null;
break;//- Authority record control number (R)
case '3':
property = null;
break;//- Materials specified (NR)
case '4':
property = null;
break;//- Relator code (R)
case '5':
property = null;
break;//- Institution to which field applies (R)
case '6':
property = null;//- Linkage (NR)
break;
case '8':
property = null;//- Field link and sequence number (R)
break;
}
}
break;
case 811: // Series Added Entry-Meeting Name (R)
{
switch(sTag)
{
case 'a':
property = null;
break;//Meeting name or jurisdiction name as entry element (NR)
case 'c':
property = null;
break;//- Location of meeting (NR)
case 'd':
property = null;
break;//- Date of meeting (R)
case 'e':
property = null;
break;//- Subordinate unit (R)
case 'f':
property = RDA1.propertyForName("dateOfWork");
break;//- Date of a work (NR)
case 'g':
property = null;
break;//- Miscellaneous information (NR)
case 'h':
property = null;
break;//- Medium (NR)
case 'j':
property = null;
break;//- Attribution qualifier (R)
case 'k':
property = null;
break;//- Form subheading (R)
case 'l':
property = null;
break;//- Language of a work (NR)
case 'm':
property = null;
break;//- Medium of performance for music (R)
case 'n':
property = null;
break;//- Number of part/section of a work (R)
case 'o':
property = null;
break;//- Arranged statement for music (NR)
case 'p':
property = null;
break;//- Name of part/section of a work (R)
case 'q':
property = null;
break;//- Fuller form of name (NR)
case 'r':
property = null;
break;//- Key for music (NR)
case 's':
property = null;
break;//- Version (NR)
case 't':
property = null;
break;//- Title of a work (NR)
case 'u':
property = null;
break;//- Affiliation (NR)
case 'v':
property = null;
break;//- Volume/sequential designation (NR)
case 'w':
property = null;
break;//- Bibliographic record control number (R)
case 'x':
property = null;
break;//- International Standard Serial Number (NR)
case '0':
property = null;
break;//- Authority record control number (R)
case '3':
property = null;
break;//- Materials specified (NR)
case '4':
property = null;
break;//- Relator code (R)
case '5':
property = null;
break;//- Institution to which field applies (R)
case '6':
property = null;//- Linkage (NR)
break;
case '8':
property = null;//- Field link and sequence number (R)
break;
}
}
break;
case 850://850
{ //Holding Institution (R)
switch(sTag)
{
case 'a':
property = null; // Holding institution (R)
break;
default:
property = null;
break;
}
}
break;
case 852://Location (R)
{
switch(sTag)
{
case 'a':
property = null;
break;
case 'b':
property = null;
break; // Sublocation or collection (R) $c Shelving location (R)
case 'h':
property = null;
break; //Classification part (NR)
case 'i':
property = null;
break; // Item part (R)
case 'j':
property = null;
break; // Shelving control number (NR) $n Country code (NR)
case 'p':
property = null;
break; // Piece Designation (NR)
case 't':
property = null;
break; // Copy number (NR)
default:
property = null;
break;
}
}
break;
case 857://850
{ //Holding Institution (R)
switch(sTag)
{
case 'a':
property = null; // Holding institution (R)
break;
default:
property = null;
break;
}
}
break;
}
return property;
}
} | [
"public",
"class",
"ML8_HoldingsInfo",
"extends",
"ML00_DataInfo",
"{",
"public",
"Property",
"getPropertyForDataField",
"(",
"DataField",
"df",
")",
"{",
"int",
"tag",
"=",
"Integer",
".",
"parseInt",
"(",
"df",
".",
"getTag",
"(",
")",
")",
";",
"Property",
"property",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"800",
":",
"case",
"810",
":",
"case",
"811",
":",
"case",
"830",
":",
"case",
"841",
":",
"case",
"842",
":",
"case",
"843",
":",
"case",
"844",
":",
"case",
"845",
":",
"case",
"850",
":",
"case",
"852",
":",
"case",
"853",
":",
"case",
"854",
":",
"case",
"855",
":",
"case",
"856",
":",
"case",
"863",
":",
"case",
"864",
":",
"case",
"865",
":",
"case",
"866",
":",
"case",
"868",
":",
"case",
"876",
":",
"case",
"877",
":",
"case",
"878",
":",
"case",
"880",
":",
"case",
"886",
":",
"case",
"887",
":",
"default",
":",
"property",
"=",
"DC_11",
".",
"relation",
";",
"break",
";",
"}",
"return",
"property",
";",
"}",
"public",
"Property",
"getPropertyForSubFieldUsingDataField",
"(",
"Subfield",
"sf",
",",
"DataField",
"df",
")",
"{",
"int",
"dTag",
"=",
"Integer",
".",
"parseInt",
"(",
"df",
".",
"getTag",
"(",
")",
")",
";",
"char",
"sTag",
"=",
"sf",
".",
"getCode",
"(",
")",
";",
"Property",
"property",
"=",
"null",
";",
"switch",
"(",
"dTag",
")",
"{",
"case",
"830",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"marcont",
".",
"hasTitle",
";",
"break",
";",
"case",
"'d'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'f'",
":",
"property",
"=",
"marcont",
".",
"hasDate",
";",
"break",
";",
"case",
"'g'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'h'",
":",
"property",
"=",
"DCTerms",
".",
"medium",
";",
"break",
";",
"case",
"'k'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'l'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'m'",
":",
"property",
"=",
"RDA1",
".",
"propertyForName",
"(",
"\"",
"mediumOfPermonanceOfMusicalContentExpression",
"\"",
")",
";",
"break",
";",
"case",
"'n'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'o'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'p'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'r'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'s'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'t'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'v'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'w'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'x'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'0'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'3'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'5'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'6'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'8'",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"856",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'b'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'c'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'d'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'f'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'h'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'i'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'j'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'k'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'l'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'m'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'n'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'o'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'p'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'q'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'r'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'s'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'t'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'u'",
":",
"property",
"=",
"marcont",
".",
"hasURL",
";",
"break",
";",
"case",
"'v'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'w'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'x'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'y'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'z'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'2'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'3'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'6'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'8'",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"800",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'b'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'c'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'d'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'e'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'f'",
":",
"property",
"=",
"RDA1",
".",
"propertyForName",
"(",
"\"",
"dateOfWork",
"\"",
")",
";",
"break",
";",
"case",
"'g'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'h'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'j'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'k'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'l'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'m'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'n'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'o'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'p'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'q'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'r'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'s'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'t'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'u'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'v'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'w'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'x'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'0'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'3'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'4'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'5'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'6'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'8'",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"810",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'b'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'c'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'d'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'e'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'f'",
":",
"property",
"=",
"RDA1",
".",
"propertyForName",
"(",
"\"",
"dateOfWork",
"\"",
")",
";",
"break",
";",
"case",
"'g'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'h'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'j'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'k'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'l'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'m'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'n'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'o'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'p'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'q'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'r'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'s'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'t'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'u'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'v'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'w'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'x'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'0'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'3'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'4'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'5'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'6'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'8'",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"811",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'c'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'d'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'e'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'f'",
":",
"property",
"=",
"RDA1",
".",
"propertyForName",
"(",
"\"",
"dateOfWork",
"\"",
")",
";",
"break",
";",
"case",
"'g'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'h'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'j'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'k'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'l'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'m'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'n'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'o'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'p'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'q'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'r'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'s'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'t'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'u'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'v'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'w'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'x'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'0'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'3'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'4'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'5'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'6'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'8'",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"850",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"null",
";",
"break",
";",
"default",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"852",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'b'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'h'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'i'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'j'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'p'",
":",
"property",
"=",
"null",
";",
"break",
";",
"case",
"'t'",
":",
"property",
"=",
"null",
";",
"break",
";",
"default",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"case",
"857",
":",
"{",
"switch",
"(",
"sTag",
")",
"{",
"case",
"'a'",
":",
"property",
"=",
"null",
";",
"break",
";",
"default",
":",
"property",
"=",
"null",
";",
"break",
";",
"}",
"}",
"break",
";",
"}",
"return",
"property",
";",
"}",
"}"
] | 800-840 Series added entry fields
841-88X Holdings, alternate graphics, etc. | [
"800",
"-",
"840",
"Series",
"added",
"entry",
"fields",
"841",
"-",
"88X",
"Holdings",
"alternate",
"graphics",
"etc",
"."
] | [
"// Series added entry - personal name",
"// Series added entry - corporate name",
"// Series added entry - meeting name",
"// Series added entry - uniform title",
"//-88X Holdings, alternate graphics, etc. - General information",
"// case 841: // Holdings coded data values",
"// T extual physical form designator",
"// Reproduction note",
"// Name of unit",
"// T erms governing use and reproduction note",
"// Holding institution",
"// Location",
"// Captions and pattern -- basic bibli",
"// Captions and pattern -- supplementary material",
"// Captions and pattern -- indexes",
"// Electronic location and access",
"// Enumeration and chronology -- basic bibliographic unit",
"// Enumeration and chronology -- supplementary material",
"// Enumeration and chronology -- indexes",
"// T extual holdings -- basic bibliographic unit",
"// T extual holdings -- indexes",
"// Item information -- basic bibliographic unit",
"// Item information -- supplementary material",
"// Item information -- indexes",
"// Alternate graphic representation",
"// Foreign MARC information field",
"// Non-MARC information field",
"//Uniform title (NR)",
"//- Date of treaty signing (R)",
"//- Date of a work (NR)",
"//- Miscellaneous information (NR)",
"//- Medium (NR)",
"//- Form subheading (R)",
"//- Language of a work (NR)",
"//- Medium of performance for music (R)",
"//- Number of part/section of a work (R)",
"//- Arranged statement for music (NR)",
"//- Name of part/section of a work (R)",
"//- Key for music (NR)",
"//- Version (NR)",
"//- Title of a work (NR) ",
"//- Volume/sequential designation (NR)",
"//- Bibliographic record control number (R)",
"//- International Standard Serial Number (NR)",
"//- Authority record control number (R)",
"//- Materials specified (NR)",
"//- Institution to which field applies (R)",
"//- Linkage (NR)",
"//- Field link and sequence number (R)",
"//series statement",
"// - Host name (R) ",
"//- Access number (R) ",
"//- Compression information (R) ",
"//- Path (R) ",
"//- Electronic name (R) ",
"//- Processor of request (NR) ",
"//- Instruction (R) ",
"//- Bits per second (NR) ",
"//- Password (NR) ",
"//- Logon (NR) ",
"//- Contact for access assistance (R) ",
"//- Name of location of host (NR) ",
"//- Operating system (NR) ",
"//- Port (NR) ",
"//- Electronic format type (NR) ",
"//- Settings (NR) ",
"//- File size (R) ",
"//- Terminal emulation (R) ",
"//- Uniform Resource Identifier (R) ",
"//- Hours access method available (R) ",
"//- Record control number (R) ",
"//- Nonpublic note (R) ",
"//- Link text (R) ",
"//- Public note (R) ",
"//- Access method (NR) ",
"//- Materials specified (NR) ",
"//- Linkage (NR) ",
"//- Field link and sequence number (R) ",
"// Series Added Entry - Personal Name (R)",
"//Personal name (NR)",
"//- Numeration (NR)",
"//- Titles and other words associated with a name (R)",
"//- Dates associated with a name (NR)",
"//- Relator term (R)",
"//- Date of a work (NR)",
"//- Miscellaneous information (NR)",
"//- Medium (NR)",
"//- Attribution qualifier (R)",
"//- Form subheading (R)",
"//- Language of a work (NR)",
"//- Medium of performance for music (R)",
"//- Number of part/section of a work (R)",
"//- Arranged statement for music (NR)",
"//- Name of part/section of a work (R)",
"//- Fuller form of name (NR)",
"//- Key for music (NR)",
"//- Version (NR)",
"//- Title of a work (NR)",
"//- Affiliation (NR)",
"//- Volume/sequential designation (NR)",
"//- Bibliographic record control number (R)",
"//- International Standard Serial Number (NR)",
"//- Authority record control number (R)",
"//- Materials specified (NR)",
"//- Relator code (R)",
"//- Institution to which field applies (R)",
"//- Linkage (NR) ",
"//- Field link and sequence number (R) ",
"// Series Added Entry - Personal Name (R)",
"//Corporate name or jurisdiction name as entry element (NR)",
"//- Subordinate unit (R)",
"//- Location of meeting (NR)",
"//- Date of meeting or treaty signing (R)",
"//- Relator term (R)",
"//- Date of a work (NR)",
"//- Miscellaneous information (NR)",
"//- Medium (NR)",
"//- Attribution qualifier (R)",
"//- Form subheading (R)",
"//- Language of a work (NR)",
"//- Medium of performance for music (R)",
"//- Number of part/section of a work (R)",
"//- Arranged statement for music (NR)",
"//- Name of part/section of a work (R)",
"//- Fuller form of name (NR)",
"//- Key for music (NR)",
"//- Version (NR)",
"//- Title of a work (NR)",
"//- Affiliation (NR)",
"//- Volume/sequential designation (NR)",
"//- Bibliographic record control number (R)",
"//- International Standard Serial Number (NR)",
"//- Authority record control number (R)",
"//- Materials specified (NR)",
"//- Relator code (R)",
"//- Institution to which field applies (R)",
"//- Linkage (NR) ",
"//- Field link and sequence number (R) ",
"// Series Added Entry-Meeting Name (R)",
"//Meeting name or jurisdiction name as entry element (NR)",
"//- Location of meeting (NR)",
"//- Date of meeting (R)",
"//- Subordinate unit (R)",
"//- Date of a work (NR)",
"//- Miscellaneous information (NR)",
"//- Medium (NR)",
"//- Attribution qualifier (R)",
"//- Form subheading (R)",
"//- Language of a work (NR)",
"//- Medium of performance for music (R)",
"//- Number of part/section of a work (R)",
"//- Arranged statement for music (NR)",
"//- Name of part/section of a work (R)",
"//- Fuller form of name (NR)",
"//- Key for music (NR)",
"//- Version (NR)",
"//- Title of a work (NR)",
"//- Affiliation (NR)",
"//- Volume/sequential designation (NR)",
"//- Bibliographic record control number (R)",
"//- International Standard Serial Number (NR)",
"//- Authority record control number (R)",
"//- Materials specified (NR)",
"//- Relator code (R)",
"//- Institution to which field applies (R)",
"//- Linkage (NR) ",
"//- Field link and sequence number (R) ",
"//850",
"//Holding Institution (R)",
"// Holding institution (R)",
"//Location (R)",
"// Sublocation or collection (R) $c Shelving location (R)",
"//Classification part (NR)",
"// Item part (R)",
"// Shelving control number (NR) $n Country code (NR)",
"// Piece Designation (NR)",
"// Copy number (NR)",
"//850",
"//Holding Institution (R)",
"// Holding institution (R)"
] | [
{
"param": "ML00_DataInfo",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ML00_DataInfo",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc41845ec4218a58f20ee69dfc565bcddb910b31 | wdqipai/521266750_qq_com | JavaServer/RecordServer/src/net/silverfoxserver/RCLogicC.java | [
"Apache-2.0"
] | Java | RCLogicC | /**
* Create table
* @author ACER-FX
*/ | Create table
@author ACER-FX | [
"Create",
"table",
"@author",
"ACER",
"-",
"FX"
] | public class RCLogicC {
public static String delMySqlTableSql(String tableName)
{
return "DROP TABLE `" + tableName + "`";
}
public static String[] createMySqlTable(String database,String engine) throws ClassNotFoundException, SQLException
{
//
String[] createOk = {"True", ""};
String sql = "";
try
{
DataSet countRowDs = null;
String createTableSql = "";
String createTableDataSql = "";//默认初始数据
String delTableSql = "";
String[] tableList = {
RCLogic.TableLog,
RCLogic.TableEveryDayLogin,
RCLogic.TableHonor,
RCLogic.TableUsers,
RCLogic.TableLvl,
RCLogic.TableLvlName
};
String tmpStr;
//
for (int i = 0; i < tableList.length; i++)
{
//这里有一个BUG,如果同时安装DISCUZ和PHPWDIN,数据库不删除
//则countTable为1 ,而且后面查不到该表,会出错,因为这张表在另一个数据库里
//用TABLE_SCHEMA解决试下
String countTableSql = "SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_NAME='" +
tableList[i] + "' AND TABLE_SCHEMA ='" +
database + "'";
DataSet countTableDs = MySqlDB.ExecuteQuery(countTableSql);
int countTable = 0;
if (countTableDs.getTables(0).size() > 0)
{
tmpStr = countTableDs.getTables(0).getRows(0).get(0).toString();
countTable = Integer.parseInt(tmpStr
//countTableDs.getTables(0).Rows()[0][0].toString()
);
}
if (0 == countTable)
{
createTableSql = "";
createTableSql = createMySqlTableSql(tableList[i],engine);
MySqlDB.ExecuteNonQuery(createTableSql);
//默认数据
createTableDataSql = "";
createTableDataSql = createMySqlTableDataSql(tableList[i]);
if(!createTableDataSql.equals("")){
MySqlDB.ExecuteNonQuery(createTableDataSql);
}
}
if (countTable > 0 && ((RCLogic.TableLog.equals(tableList[i]) && RCLogic.autoClearTableLog) || (RCLogic.TableEveryDayLogin.equals(tableList[i]) && RCLogic.autoClearTableEveryDayLogin)))
{
delTableSql = "";
delTableSql = delMySqlTableSql(tableList[i]);
MySqlDB.ExecuteNonQuery(delTableSql);
createTableSql = "";
createTableSql = createMySqlTableSql(tableList[i],engine);
MySqlDB.ExecuteNonQuery(createTableSql);
}
//
String countRowSql = "SELECT COUNT(*) FROM " + tableList[i];
System.out.print(SR.GetString(SR.getDB_Log_Reading(), tableList[i]));
countRowDs = MySqlDB.ExecuteQuery(countRowSql);
System.out.println(", " + SR.GetString(SR.getDB_Log_Desc(),
countRowDs.getTables(0).getRows(0).get(0).toString()));
}
}
catch (java.sql.SQLException | RuntimeException exc)
{
createOk[0] = "False";
createOk[1] = exc.getMessage();
Log.WriteStrByException(RCLogic.class.getName(), "createMySqlTable", exc.getMessage(),exc.getStackTrace());
}
return createOk;
}
public static String[] createMsSqlTable()
{
//
String[] createOk = {"True", ""};
DataSet ds;
String sql = "";
try
{
}
catch (RuntimeException exc)
{
createOk[0] = "False";
createOk[1] = exc.getMessage();
Log.WriteStrByException(RCLogic.class.getName(), "createMsSqlTable", exc.getMessage());
}
return createOk;
}
public static String[] createLiteSqlTable()
{
//
String[] createOk = {"True", ""};
DataSet ds;
String sql = "";
try
{
}
catch (RuntimeException exc)
{
createOk[0] = "False";
createOk[1] = exc.getMessage();
Log.WriteStrByException(RCLogicC.class.getName(), "createLiteSqlTable", exc.getMessage());
}
return createOk;
}
public static String createMySqlTableDataSql(String tableName)
{
StringBuilder sb = new StringBuilder();
if(RCLogic.TableLvlName.equals(tableName)){
//默认数据
String sql = "INSERT INTO `" + tableName +
"` (`game`) VALUES ("
+ "'" + "ChChess" + "');";
sb.append(sql);
}
return sb.toString();
}
public static String createMySqlTableSql(String tableName,String engine)
{
StringBuilder sb = new StringBuilder();
//
if (RCLogic.TableLog.equals(tableName))
{
//<Record t='11:39:31,676' a='mysql update' row='1' c='extcredits2' p1='add:1' p2='14717' n='admin' />
/*
InnoDB是为处理巨大数据量时的最大性能设计。它的CPU效率可能是任何其它基于磁盘的关系数据库引擎所不能匹敌的。
InnoDB存储引擎被完全与MySQL服务器整合,InnoDB存储引擎为在主内存中缓存数据和索引而维持它自己的缓冲池。 InnoDB存储它的表&索引在一个表空间中,表空间可以包含数个文件(或原始磁盘分区)。InnoDB 表可以是任何尺寸,即使在文件尺寸被限制为2GB的操作系统上。*/
sb.append("CREATE TABLE ").append(tableName).append(" ( ");
sb.append("logid int(10) unsigned NOT NULL AUTO_INCREMENT, ");
sb.append("game varchar(40) NOT NULL, ");
sb.append("id char(32) NOT NULL, ");//对nick name的MD5值
sb.append("id_sql int(8) unsigned NOT NULL, ");
sb.append("n char(15) NOT NULL, ");
sb.append("room smallint(6) NOT NULL default 0,");
sb.append("t1 int(10) unsigned not null default 0,");
sb.append("t2 int(10) unsigned not null default 0,");
sb.append("t varchar(40) NOT NULL, ");
sb.append("a varchar(40) NOT NULL,");
sb.append("line_n smallint(6) unsigned NOT NULL default 0,");
sb.append("c varchar(40) NOT NULL, ");
sb.append("p1A varchar(40) NOT NULL,");
sb.append("p1B int(10) unsigned not null default 0,");
sb.append("p2 varchar(40) NOT NULL, ");
sb.append("PRIMARY KEY (logid)");
sb.append(")");
//sb.Append( "engine=innodb default charset=utf8 auto_increment=1); ");
sb.append("engine=").append(engine).append(" default charset=utf8 auto_increment=1");
//engine=innodb
//ENGINE=MyISAM
//foreign key(article_Id) references blog_article(article_Id) on delete cascade on update cascade,
//foreign key(user_Name) references blog_user(user_Name) on delete cascade on update cascade
//)engine=innodb default charset=utf8 auto_increment=1);
}else if (RCLogic.TableEveryDayLogin.equals(tableName))
{
sb.append("CREATE TABLE ").append(tableName).append(" ( ");
sb.append("edlid int(10) unsigned NOT NULL AUTO_INCREMENT, ");
//sb.Append( "uid int(8) unsigned NOT NULL default 0, ");
sb.append("game varchar(40) NOT NULL, ");
sb.append("id char(32) NOT NULL, ");//对nick name的MD5值
sb.append("id_sql int(8) unsigned NOT NULL, ");
sb.append("year_date smallint(6) unsigned NOT NULL default 0,");
sb.append("month_date smallint(6) unsigned NOT NULL default 0,");
sb.append("day_date smallint(6) unsigned NOT NULL default 0,");
sb.append("p1 int(8) unsigned NOT NULL default 0,");
sb.append("n char(15) NOT NULL, ");
sb.append("PRIMARY KEY (edlid)");
sb.append(")");
//sb.Append( "engine=innodb default charset=utf8 auto_increment=1); ");
sb.append("engine=").append(engine).append(" default charset=utf8 auto_increment=1");
}
else if(RCLogic.TableLvl.equals(tableName))
{
sb.append("CREATE TABLE ").append(tableName).append(" ( ");
sb.append("lvlid int(10) unsigned NOT NULL AUTO_INCREMENT, ");
sb.append("id char(32) NOT NULL, ");//对nick name的MD5值
sb.append("id_sql int(8) unsigned NOT NULL, ");
sb.append("game varchar(40) NOT NULL, ");
sb.append("exp int(10) unsigned NOT NULL default 0,");
sb.append("lvl smallint(6) unsigned NOT NULL default 0,");
sb.append("n char(15) NOT NULL, ");
sb.append("PRIMARY KEY (lvlid)");
sb.append(")");
//sb.Append( "engine=innodb default charset=utf8 auto_increment=1); ");
sb.append("engine=").append(engine).append(" default charset=utf8 auto_increment=1");
}
else if(RCLogic.TableLvlName.equals(tableName)){
sb.append("CREATE TABLE ").append(tableName).append(" ( ");
sb.append("lvlNameId int(10) unsigned NOT NULL AUTO_INCREMENT, ");
sb.append("game varchar(40) NOT NULL, ");
for(int i=1;i<=9;i++){
sb.append("lvl_").append(String.valueOf(i)).append("_exp int(10) unsigned NOT NULL default ");
sb.append(String.valueOf(i*1000)).append(",");
sb.append("lvl_").append(String.valueOf(i)).append("_n varchar(40) NOT NULL default ");
sb.append("'level").append(String.valueOf(i)).append("',");
}
sb.append("PRIMARY KEY (lvlNameId)");
sb.append(")");
//sb.Append( "engine=innodb default charset=utf8 auto_increment=1); ");
sb.append("engine=").append(engine).append(" default charset=utf8 auto_increment=1");
}
else if (RCLogic.TableHonor.equals(tableName))
{
sb.append("CREATE TABLE ").append(tableName).append(" ( ");
sb.append("honorId int(10) unsigned NOT NULL AUTO_INCREMENT, ");
sb.append("id char(32) NOT NULL, ");//对nick name的MD5值
sb.append("id_sql int(8) unsigned NOT NULL, ");
//翻牌最高连胜次数
sb.append("turn_over_a_card_in_a_row_win smallint(6) unsigned NOT NULL default 0,");
sb.append("turn_over_a_card_win int(8) unsigned NOT NULL default 0,");
sb.append("turn_over_a_card_lost int(8) unsigned NOT NULL default 0,");
sb.append("ddz_win int(8) unsigned NOT NULL default 0,");
//一次性出完手里的牌,二家一张未出,关门总次数
sb.append("ddz_slam_door smallint(6) unsigned NOT NULL default 0,");
//在一场比赛中遇到4个炸弹,并取得胜利,获得炸王称号,炸王总次数
sb.append("ddz_bomb_king smallint(6) unsigned NOT NULL default 0,");
sb.append("ddz_lost int(8) unsigned NOT NULL default 0,");
sb.append("chchess_win int(8) unsigned NOT NULL default 0,");
sb.append("chchess_lost int(8) unsigned NOT NULL default 0,");
sb.append("n char(15) NOT NULL, ");
sb.append("PRIMARY KEY (honorId)");
sb.append(")");
//sb.Append( "engine=innodb default charset=utf8 auto_increment=1; ";
sb.append("engine=").append(engine).append(" default charset=utf8 auto_increment=1");
}else if (RCLogic.TableUsers.equals(tableName))
{
// <u id="c6925d88597588b5542c022ab950dbf3" n="老甜甜" p="[email protected]" s="0" m="[email protected]" cd="2013-11-21 0:21:47" ld="2013-11-21 0:21:47" />
// <u id="c4f96bf0bda95630c19e98a881050582" n="撕破灬晨☼晓的" p="[email protected]" s="0" m="[email protected]" cd="2013-11-24 9:57:13" ld="2013-11-24 10:50:05" />
sb.append("CREATE TABLE ").append(tableName).append(" ( ");
sb.append("id char(32) NOT NULL, ");//对nick name的MD5值
sb.append("id_sql int(8) unsigned NOT NULL, ");
//nickname
sb.append("n char(15) NOT NULL, ");
sb.append("p varchar(12) NOT NULL,");//password
//金币
sb.append("g int(10) NOT NULL default 2000,");//初始会员2000积分
//sex
sb.append("s smallint(6) unsigned NOT NULL default 0,");
//mail
sb.append("m varchar(15) NOT NULL default '',");
//vip
sb.append("vip smallint(6) NOT NULL DEFAULT '0',");
//create date
sb.append("cd varchar(32) NOT NULL default '',");
sb.append("ld varchar(32) NOT NULL default '',"); //last login date
sb.append("PRIMARY KEY (id)");
sb.append(")");
//sb.Append( "engine=innodb default charset=utf8 auto_increment=1; ";
sb.append("engine=").append(engine).append(" default charset=utf8");
}
return sb.toString();
}
} | [
"public",
"class",
"RCLogicC",
"{",
"public",
"static",
"String",
"delMySqlTableSql",
"(",
"String",
"tableName",
")",
"{",
"return",
"\"",
"DROP TABLE `",
"\"",
"+",
"tableName",
"+",
"\"",
"`",
"\"",
";",
"}",
"public",
"static",
"String",
"[",
"]",
"createMySqlTable",
"(",
"String",
"database",
",",
"String",
"engine",
")",
"throws",
"ClassNotFoundException",
",",
"SQLException",
"{",
"String",
"[",
"]",
"createOk",
"=",
"{",
"\"",
"True",
"\"",
",",
"\"",
"\"",
"}",
";",
"String",
"sql",
"=",
"\"",
"\"",
";",
"try",
"{",
"DataSet",
"countRowDs",
"=",
"null",
";",
"String",
"createTableSql",
"=",
"\"",
"\"",
";",
"String",
"createTableDataSql",
"=",
"\"",
"\"",
";",
"String",
"delTableSql",
"=",
"\"",
"\"",
";",
"String",
"[",
"]",
"tableList",
"=",
"{",
"RCLogic",
".",
"TableLog",
",",
"RCLogic",
".",
"TableEveryDayLogin",
",",
"RCLogic",
".",
"TableHonor",
",",
"RCLogic",
".",
"TableUsers",
",",
"RCLogic",
".",
"TableLvl",
",",
"RCLogic",
".",
"TableLvlName",
"}",
";",
"String",
"tmpStr",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tableList",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"countTableSql",
"=",
"\"",
"SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_NAME='",
"\"",
"+",
"tableList",
"[",
"i",
"]",
"+",
"\"",
"' AND TABLE_SCHEMA ='",
"\"",
"+",
"database",
"+",
"\"",
"'",
"\"",
";",
"DataSet",
"countTableDs",
"=",
"MySqlDB",
".",
"ExecuteQuery",
"(",
"countTableSql",
")",
";",
"int",
"countTable",
"=",
"0",
";",
"if",
"(",
"countTableDs",
".",
"getTables",
"(",
"0",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"tmpStr",
"=",
"countTableDs",
".",
"getTables",
"(",
"0",
")",
".",
"getRows",
"(",
"0",
")",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
";",
"countTable",
"=",
"Integer",
".",
"parseInt",
"(",
"tmpStr",
")",
";",
"}",
"if",
"(",
"0",
"==",
"countTable",
")",
"{",
"createTableSql",
"=",
"\"",
"\"",
";",
"createTableSql",
"=",
"createMySqlTableSql",
"(",
"tableList",
"[",
"i",
"]",
",",
"engine",
")",
";",
"MySqlDB",
".",
"ExecuteNonQuery",
"(",
"createTableSql",
")",
";",
"createTableDataSql",
"=",
"\"",
"\"",
";",
"createTableDataSql",
"=",
"createMySqlTableDataSql",
"(",
"tableList",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"createTableDataSql",
".",
"equals",
"(",
"\"",
"\"",
")",
")",
"{",
"MySqlDB",
".",
"ExecuteNonQuery",
"(",
"createTableDataSql",
")",
";",
"}",
"}",
"if",
"(",
"countTable",
">",
"0",
"&&",
"(",
"(",
"RCLogic",
".",
"TableLog",
".",
"equals",
"(",
"tableList",
"[",
"i",
"]",
")",
"&&",
"RCLogic",
".",
"autoClearTableLog",
")",
"||",
"(",
"RCLogic",
".",
"TableEveryDayLogin",
".",
"equals",
"(",
"tableList",
"[",
"i",
"]",
")",
"&&",
"RCLogic",
".",
"autoClearTableEveryDayLogin",
")",
")",
")",
"{",
"delTableSql",
"=",
"\"",
"\"",
";",
"delTableSql",
"=",
"delMySqlTableSql",
"(",
"tableList",
"[",
"i",
"]",
")",
";",
"MySqlDB",
".",
"ExecuteNonQuery",
"(",
"delTableSql",
")",
";",
"createTableSql",
"=",
"\"",
"\"",
";",
"createTableSql",
"=",
"createMySqlTableSql",
"(",
"tableList",
"[",
"i",
"]",
",",
"engine",
")",
";",
"MySqlDB",
".",
"ExecuteNonQuery",
"(",
"createTableSql",
")",
";",
"}",
"String",
"countRowSql",
"=",
"\"",
"SELECT COUNT(*) FROM ",
"\"",
"+",
"tableList",
"[",
"i",
"]",
";",
"System",
".",
"out",
".",
"print",
"(",
"SR",
".",
"GetString",
"(",
"SR",
".",
"getDB_Log_Reading",
"(",
")",
",",
"tableList",
"[",
"i",
"]",
")",
")",
";",
"countRowDs",
"=",
"MySqlDB",
".",
"ExecuteQuery",
"(",
"countRowSql",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
", ",
"\"",
"+",
"SR",
".",
"GetString",
"(",
"SR",
".",
"getDB_Log_Desc",
"(",
")",
",",
"countRowDs",
".",
"getTables",
"(",
"0",
")",
".",
"getRows",
"(",
"0",
")",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"java",
".",
"sql",
".",
"SQLException",
"|",
"RuntimeException",
"exc",
")",
"{",
"createOk",
"[",
"0",
"]",
"=",
"\"",
"False",
"\"",
";",
"createOk",
"[",
"1",
"]",
"=",
"exc",
".",
"getMessage",
"(",
")",
";",
"Log",
".",
"WriteStrByException",
"(",
"RCLogic",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"",
"createMySqlTable",
"\"",
",",
"exc",
".",
"getMessage",
"(",
")",
",",
"exc",
".",
"getStackTrace",
"(",
")",
")",
";",
"}",
"return",
"createOk",
";",
"}",
"public",
"static",
"String",
"[",
"]",
"createMsSqlTable",
"(",
")",
"{",
"String",
"[",
"]",
"createOk",
"=",
"{",
"\"",
"True",
"\"",
",",
"\"",
"\"",
"}",
";",
"DataSet",
"ds",
";",
"String",
"sql",
"=",
"\"",
"\"",
";",
"try",
"{",
"}",
"catch",
"(",
"RuntimeException",
"exc",
")",
"{",
"createOk",
"[",
"0",
"]",
"=",
"\"",
"False",
"\"",
";",
"createOk",
"[",
"1",
"]",
"=",
"exc",
".",
"getMessage",
"(",
")",
";",
"Log",
".",
"WriteStrByException",
"(",
"RCLogic",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"",
"createMsSqlTable",
"\"",
",",
"exc",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"createOk",
";",
"}",
"public",
"static",
"String",
"[",
"]",
"createLiteSqlTable",
"(",
")",
"{",
"String",
"[",
"]",
"createOk",
"=",
"{",
"\"",
"True",
"\"",
",",
"\"",
"\"",
"}",
";",
"DataSet",
"ds",
";",
"String",
"sql",
"=",
"\"",
"\"",
";",
"try",
"{",
"}",
"catch",
"(",
"RuntimeException",
"exc",
")",
"{",
"createOk",
"[",
"0",
"]",
"=",
"\"",
"False",
"\"",
";",
"createOk",
"[",
"1",
"]",
"=",
"exc",
".",
"getMessage",
"(",
")",
";",
"Log",
".",
"WriteStrByException",
"(",
"RCLogicC",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"",
"createLiteSqlTable",
"\"",
",",
"exc",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"createOk",
";",
"}",
"public",
"static",
"String",
"createMySqlTableDataSql",
"(",
"String",
"tableName",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"RCLogic",
".",
"TableLvlName",
".",
"equals",
"(",
"tableName",
")",
")",
"{",
"String",
"sql",
"=",
"\"",
"INSERT INTO `",
"\"",
"+",
"tableName",
"+",
"\"",
"` (`game`) VALUES (",
"\"",
"+",
"\"",
"'",
"\"",
"+",
"\"",
"ChChess",
"\"",
"+",
"\"",
"');",
"\"",
";",
"sb",
".",
"append",
"(",
"sql",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"public",
"static",
"String",
"createMySqlTableSql",
"(",
"String",
"tableName",
",",
"String",
"engine",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"RCLogic",
".",
"TableLog",
".",
"equals",
"(",
"tableName",
")",
")",
"{",
"/*\n InnoDB是为处理巨大数据量时的最大性能设计。它的CPU效率可能是任何其它基于磁盘的关系数据库引擎所不能匹敌的。\nInnoDB存储引擎被完全与MySQL服务器整合,InnoDB存储引擎为在主内存中缓存数据和索引而维持它自己的缓冲池。 InnoDB存储它的表&索引在一个表空间中,表空间可以包含数个文件(或原始磁盘分区)。InnoDB 表可以是任何尺寸,即使在文件尺寸被限制为2GB的操作系统上。*/",
"sb",
".",
"append",
"(",
"\"",
"CREATE TABLE ",
"\"",
")",
".",
"append",
"(",
"tableName",
")",
".",
"append",
"(",
"\"",
" ( ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"logid int(10) unsigned NOT NULL AUTO_INCREMENT, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"game varchar(40) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id char(32) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id_sql int(8) unsigned NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"n char(15) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"room smallint(6) NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"t1 int(10) unsigned not null default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"t2 int(10) unsigned not null default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"t varchar(40) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"a varchar(40) NOT NULL,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"line_n smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"c varchar(40) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"p1A varchar(40) NOT NULL,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"p1B int(10) unsigned not null default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"p2 varchar(40) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"PRIMARY KEY (logid)",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
")",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"engine=",
"\"",
")",
".",
"append",
"(",
"engine",
")",
".",
"append",
"(",
"\"",
" default charset=utf8 auto_increment=1",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"RCLogic",
".",
"TableEveryDayLogin",
".",
"equals",
"(",
"tableName",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"",
"CREATE TABLE ",
"\"",
")",
".",
"append",
"(",
"tableName",
")",
".",
"append",
"(",
"\"",
" ( ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"edlid int(10) unsigned NOT NULL AUTO_INCREMENT, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"game varchar(40) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id char(32) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id_sql int(8) unsigned NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"year_date smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"month_date smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"day_date smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"p1 int(8) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"n char(15) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"PRIMARY KEY (edlid)",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
")",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"engine=",
"\"",
")",
".",
"append",
"(",
"engine",
")",
".",
"append",
"(",
"\"",
" default charset=utf8 auto_increment=1",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"RCLogic",
".",
"TableLvl",
".",
"equals",
"(",
"tableName",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"",
"CREATE TABLE ",
"\"",
")",
".",
"append",
"(",
"tableName",
")",
".",
"append",
"(",
"\"",
" ( ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"lvlid int(10) unsigned NOT NULL AUTO_INCREMENT, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id char(32) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id_sql int(8) unsigned NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"game varchar(40) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"exp int(10) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"lvl smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"n char(15) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"PRIMARY KEY (lvlid)",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
")",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"engine=",
"\"",
")",
".",
"append",
"(",
"engine",
")",
".",
"append",
"(",
"\"",
" default charset=utf8 auto_increment=1",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"RCLogic",
".",
"TableLvlName",
".",
"equals",
"(",
"tableName",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"",
"CREATE TABLE ",
"\"",
")",
".",
"append",
"(",
"tableName",
")",
".",
"append",
"(",
"\"",
" ( ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"lvlNameId int(10) unsigned NOT NULL AUTO_INCREMENT, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"game varchar(40) NOT NULL, ",
"\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"9",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"\"",
"lvl_",
"\"",
")",
".",
"append",
"(",
"String",
".",
"valueOf",
"(",
"i",
")",
")",
".",
"append",
"(",
"\"",
"_exp int(10) unsigned NOT NULL default ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"String",
".",
"valueOf",
"(",
"i",
"*",
"1000",
")",
")",
".",
"append",
"(",
"\"",
",",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"lvl_",
"\"",
")",
".",
"append",
"(",
"String",
".",
"valueOf",
"(",
"i",
")",
")",
".",
"append",
"(",
"\"",
"_n varchar(40) NOT NULL default ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"'level",
"\"",
")",
".",
"append",
"(",
"String",
".",
"valueOf",
"(",
"i",
")",
")",
".",
"append",
"(",
"\"",
"',",
"\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"",
"PRIMARY KEY (lvlNameId)",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
")",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"engine=",
"\"",
")",
".",
"append",
"(",
"engine",
")",
".",
"append",
"(",
"\"",
" default charset=utf8 auto_increment=1",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"RCLogic",
".",
"TableHonor",
".",
"equals",
"(",
"tableName",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"",
"CREATE TABLE ",
"\"",
")",
".",
"append",
"(",
"tableName",
")",
".",
"append",
"(",
"\"",
" ( ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"honorId int(10) unsigned NOT NULL AUTO_INCREMENT, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id char(32) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id_sql int(8) unsigned NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"turn_over_a_card_in_a_row_win smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"turn_over_a_card_win int(8) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"turn_over_a_card_lost int(8) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"ddz_win int(8) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"ddz_slam_door smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"ddz_bomb_king smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"ddz_lost int(8) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"chchess_win int(8) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"chchess_lost int(8) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"n char(15) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"PRIMARY KEY (honorId)",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
")",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"engine=",
"\"",
")",
".",
"append",
"(",
"engine",
")",
".",
"append",
"(",
"\"",
" default charset=utf8 auto_increment=1",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"RCLogic",
".",
"TableUsers",
".",
"equals",
"(",
"tableName",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"",
"CREATE TABLE ",
"\"",
")",
".",
"append",
"(",
"tableName",
")",
".",
"append",
"(",
"\"",
" ( ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id char(32) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"id_sql int(8) unsigned NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"n char(15) NOT NULL, ",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"p varchar(12) NOT NULL,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"g int(10) NOT NULL default 2000,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"s smallint(6) unsigned NOT NULL default 0,",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"m varchar(15) NOT NULL default '',",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"vip smallint(6) NOT NULL DEFAULT '0',",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"cd varchar(32) NOT NULL default '',",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"ld varchar(32) NOT NULL default '',",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"PRIMARY KEY (id)",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
")",
"\"",
")",
";",
"sb",
".",
"append",
"(",
"\"",
"engine=",
"\"",
")",
".",
"append",
"(",
"engine",
")",
".",
"append",
"(",
"\"",
" default charset=utf8",
"\"",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"}"
] | Create table
@author ACER-FX | [
"Create",
"table",
"@author",
"ACER",
"-",
"FX"
] | [
"//",
"//默认初始数据",
"//",
"//这里有一个BUG,如果同时安装DISCUZ和PHPWDIN,数据库不删除",
"//则countTable为1 ,而且后面查不到该表,会出错,因为这张表在另一个数据库里 ",
"//用TABLE_SCHEMA解决试下",
"//countTableDs.getTables(0).Rows()[0][0].toString()",
"//默认数据",
"//",
"//",
"//",
"//默认数据 ",
"// ",
"//<Record t='11:39:31,676' a='mysql update' row='1' c='extcredits2' p1='add:1' p2='14717' n='admin' />",
"//对nick name的MD5值",
"//sb.Append( \"engine=innodb default charset=utf8 auto_increment=1); \");",
"//engine=innodb",
"//ENGINE=MyISAM",
"//foreign key(article_Id) references blog_article(article_Id) on delete cascade on update cascade, ",
"//foreign key(user_Name) references blog_user(user_Name) on delete cascade on update cascade",
"//)engine=innodb default charset=utf8 auto_increment=1); ",
"//sb.Append( \"uid int(8) unsigned NOT NULL default 0, \");",
"//对nick name的MD5值",
"//sb.Append( \"engine=innodb default charset=utf8 auto_increment=1); \");",
"//对nick name的MD5值",
"//sb.Append( \"engine=innodb default charset=utf8 auto_increment=1); \");",
"//sb.Append( \"engine=innodb default charset=utf8 auto_increment=1); \");",
"//对nick name的MD5值",
"//翻牌最高连胜次数",
"//一次性出完手里的牌,二家一张未出,关门总次数",
"//在一场比赛中遇到4个炸弹,并取得胜利,获得炸王称号,炸王总次数",
"//sb.Append( \"engine=innodb default charset=utf8 auto_increment=1; \";",
"// <u id=\"c6925d88597588b5542c022ab950dbf3\" n=\"老甜甜\" p=\"[email protected]\" s=\"0\" m=\"[email protected]\" cd=\"2013-11-21 0:21:47\" ld=\"2013-11-21 0:21:47\" />",
"// <u id=\"c4f96bf0bda95630c19e98a881050582\" n=\"撕破灬晨☼晓的\" p=\"[email protected]\" s=\"0\" m=\"[email protected]\" cd=\"2013-11-24 9:57:13\" ld=\"2013-11-24 10:50:05\" />",
"//对nick name的MD5值",
"//nickname",
"//password ",
"//金币",
"//初始会员2000积分 ",
"//sex",
"//mail",
"//vip",
"//create date",
"//last login date",
"//sb.Append( \"engine=innodb default charset=utf8 auto_increment=1; \";"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
cc41af5800be5b248596b03266955a09206431e8 | srcmaxim/mover-backend | src/main/java/mover/backend/model/Estimate.java | [
"MIT"
] | Java | Estimate | /**
* A Estimate represents additional products used in single Lead.
* For example: Big box, Packing tape.
*/ | A Estimate represents additional products used in single Lead.
For example: Big box, Packing tape. | [
"A",
"Estimate",
"represents",
"additional",
"products",
"used",
"in",
"single",
"Lead",
".",
"For",
"example",
":",
"Big",
"box",
"Packing",
"tape",
"."
] | @Embeddable
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(of = "name")
public class Estimate implements Cloneable{
@NotNull
@Column(name = "name", nullable = false)
private String name;
@DecimalMin(value = "0", inclusive = false)
@Column(name = "quantity", nullable = false)
private int quantity;
@DecimalMin(value = "0", inclusive = false)
@Column(name = "price", nullable = false)
private int price;
} | [
"@",
"Embeddable",
"@",
"Data",
"@",
"NoArgsConstructor",
"@",
"AllArgsConstructor",
"@",
"Accessors",
"(",
"chain",
"=",
"true",
")",
"@",
"EqualsAndHashCode",
"(",
"of",
"=",
"\"",
"name",
"\"",
")",
"public",
"class",
"Estimate",
"implements",
"Cloneable",
"{",
"@",
"NotNull",
"@",
"Column",
"(",
"name",
"=",
"\"",
"name",
"\"",
",",
"nullable",
"=",
"false",
")",
"private",
"String",
"name",
";",
"@",
"DecimalMin",
"(",
"value",
"=",
"\"",
"0",
"\"",
",",
"inclusive",
"=",
"false",
")",
"@",
"Column",
"(",
"name",
"=",
"\"",
"quantity",
"\"",
",",
"nullable",
"=",
"false",
")",
"private",
"int",
"quantity",
";",
"@",
"DecimalMin",
"(",
"value",
"=",
"\"",
"0",
"\"",
",",
"inclusive",
"=",
"false",
")",
"@",
"Column",
"(",
"name",
"=",
"\"",
"price",
"\"",
",",
"nullable",
"=",
"false",
")",
"private",
"int",
"price",
";",
"}"
] | A Estimate represents additional products used in single Lead. | [
"A",
"Estimate",
"represents",
"additional",
"products",
"used",
"in",
"single",
"Lead",
"."
] | [] | [
{
"param": "Cloneable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Cloneable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc42c57afc75a94ba4c498113361ac5037669abb | YC-S/LeetCode | src/explore/month_challenge/_2020_july/P27ConstructBinaryTree.java | [
"MIT"
] | Java | P27ConstructBinaryTree | /**
* @author shiyuanchen
* @project LeetCode
* @since 2020/07/27
*/ | @author shiyuanchen
@project LeetCode
@since 2020/07/27 | [
"@author",
"shiyuanchen",
"@project",
"LeetCode",
"@since",
"2020",
"/",
"07",
"/",
"27"
] | public class P27ConstructBinaryTree {
public TreeNode buildTree(int[] inorder, int[] postorder) {
return buildTree(inorder, inorder.length - 1, 0, postorder,
postorder.length - 1);
}
private TreeNode buildTree(int[] inorder, int inStart, int inEnd,
int[] postorder, int postStart) {
if (postStart < 0 || inStart < inEnd) {
return null;
}
// The last element in postorder is the root.
TreeNode root = new TreeNode(postorder[postStart]);
// find the index of the root from inorder. Iterating from the end.
int rIndex = inStart;
for (int i = inStart; i >= inEnd; i--) {
if (inorder[i] == postorder[postStart]) {
rIndex = i;
break;
}
}
// build right and left subtrees. Again, scanning from the end to find the
// sections.
root.right = buildTree(inorder, inStart, rIndex + 1, postorder,
postStart - 1);
root.left = buildTree(inorder, rIndex - 1, inEnd, postorder,
postStart - (inStart - rIndex) - 1);
return root;
}
} | [
"public",
"class",
"P27ConstructBinaryTree",
"{",
"public",
"TreeNode",
"buildTree",
"(",
"int",
"[",
"]",
"inorder",
",",
"int",
"[",
"]",
"postorder",
")",
"{",
"return",
"buildTree",
"(",
"inorder",
",",
"inorder",
".",
"length",
"-",
"1",
",",
"0",
",",
"postorder",
",",
"postorder",
".",
"length",
"-",
"1",
")",
";",
"}",
"private",
"TreeNode",
"buildTree",
"(",
"int",
"[",
"]",
"inorder",
",",
"int",
"inStart",
",",
"int",
"inEnd",
",",
"int",
"[",
"]",
"postorder",
",",
"int",
"postStart",
")",
"{",
"if",
"(",
"postStart",
"<",
"0",
"||",
"inStart",
"<",
"inEnd",
")",
"{",
"return",
"null",
";",
"}",
"TreeNode",
"root",
"=",
"new",
"TreeNode",
"(",
"postorder",
"[",
"postStart",
"]",
")",
";",
"int",
"rIndex",
"=",
"inStart",
";",
"for",
"(",
"int",
"i",
"=",
"inStart",
";",
"i",
">=",
"inEnd",
";",
"i",
"--",
")",
"{",
"if",
"(",
"inorder",
"[",
"i",
"]",
"==",
"postorder",
"[",
"postStart",
"]",
")",
"{",
"rIndex",
"=",
"i",
";",
"break",
";",
"}",
"}",
"root",
".",
"right",
"=",
"buildTree",
"(",
"inorder",
",",
"inStart",
",",
"rIndex",
"+",
"1",
",",
"postorder",
",",
"postStart",
"-",
"1",
")",
";",
"root",
".",
"left",
"=",
"buildTree",
"(",
"inorder",
",",
"rIndex",
"-",
"1",
",",
"inEnd",
",",
"postorder",
",",
"postStart",
"-",
"(",
"inStart",
"-",
"rIndex",
")",
"-",
"1",
")",
";",
"return",
"root",
";",
"}",
"}"
] | @author shiyuanchen
@project LeetCode
@since 2020/07/27 | [
"@author",
"shiyuanchen",
"@project",
"LeetCode",
"@since",
"2020",
"/",
"07",
"/",
"27"
] | [
"// The last element in postorder is the root.",
"// find the index of the root from inorder. Iterating from the end.",
"// build right and left subtrees. Again, scanning from the end to find the",
"// sections."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
cc45efc05f6211959cccd8d1b582fdebf905e883 | piotr-j/ld33monster | core/src/io/piotrjastrzebski/monster/game/processors/AssetInit.java | [
"MIT"
] | Java | AssetInit | /**
* Created by PiotrJ on 22/08/15.
*/ | Created by PiotrJ on 22/08/15. | [
"Created",
"by",
"PiotrJ",
"on",
"22",
"/",
"08",
"/",
"15",
"."
] | @Wire
public class AssetInit extends EntitySystem {
@Wire Assets assets;
protected ComponentMapper<RenderableDef> mRenderableDef;
public AssetInit () {
super(Aspect.all(RenderableDef.class));
}
@Override protected void inserted (int entityId) {
RenderableDef def = mRenderableDef.get(entityId);
EntityEdit edit = world.getEntity(entityId).edit();
Renderable renderable = edit.create(Renderable.class);
renderable.sprite = new TextureAtlas.AtlasSprite(assets.getRegion(def.path));
}
@Override protected void processSystem () {
}
} | [
"@",
"Wire",
"public",
"class",
"AssetInit",
"extends",
"EntitySystem",
"{",
"@",
"Wire",
"Assets",
"assets",
";",
"protected",
"ComponentMapper",
"<",
"RenderableDef",
">",
"mRenderableDef",
";",
"public",
"AssetInit",
"(",
")",
"{",
"super",
"(",
"Aspect",
".",
"all",
"(",
"RenderableDef",
".",
"class",
")",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"inserted",
"(",
"int",
"entityId",
")",
"{",
"RenderableDef",
"def",
"=",
"mRenderableDef",
".",
"get",
"(",
"entityId",
")",
";",
"EntityEdit",
"edit",
"=",
"world",
".",
"getEntity",
"(",
"entityId",
")",
".",
"edit",
"(",
")",
";",
"Renderable",
"renderable",
"=",
"edit",
".",
"create",
"(",
"Renderable",
".",
"class",
")",
";",
"renderable",
".",
"sprite",
"=",
"new",
"TextureAtlas",
".",
"AtlasSprite",
"(",
"assets",
".",
"getRegion",
"(",
"def",
".",
"path",
")",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"processSystem",
"(",
")",
"{",
"}",
"}"
] | Created by PiotrJ on 22/08/15. | [
"Created",
"by",
"PiotrJ",
"on",
"22",
"/",
"08",
"/",
"15",
"."
] | [] | [
{
"param": "EntitySystem",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "EntitySystem",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc463c82932bbc8a2660de18af96486f9c54907d | shreyventure/LeetCode-Solutions | Java/running-sum-of-1d-array.java | [
"MIT"
] | Java | Solution | /**
* Running Sum of 1d Array
*
* Time Complexity - O(n)
* Space Complexity - O(n)
*
* Runtime: 0 ms, faster than 100.00% of Java online submissions
*/ | Running Sum of 1d Array
Time Complexity - O(n)
Space Complexity - O(n)
0 ms, faster than 100.00% of Java online submissions | [
"Running",
"Sum",
"of",
"1d",
"Array",
"Time",
"Complexity",
"-",
"O",
"(",
"n",
")",
"Space",
"Complexity",
"-",
"O",
"(",
"n",
")",
"0",
"ms",
"faster",
"than",
"100",
".",
"00%",
"of",
"Java",
"online",
"submissions"
] | class Solution {
public int[] runningSum(int[] nums) {
int len = nums.length;
int[] runningSumAr = new int[len];
int sumSoFar = 0;
for(int i=0; i<len; i++){
sumSoFar += nums[i];
runningSumAr[i] = sumSoFar;
}
return runningSumAr;
}
} | [
"class",
"Solution",
"{",
"public",
"int",
"[",
"]",
"runningSum",
"(",
"int",
"[",
"]",
"nums",
")",
"{",
"int",
"len",
"=",
"nums",
".",
"length",
";",
"int",
"[",
"]",
"runningSumAr",
"=",
"new",
"int",
"[",
"len",
"]",
";",
"int",
"sumSoFar",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"sumSoFar",
"+=",
"nums",
"[",
"i",
"]",
";",
"runningSumAr",
"[",
"i",
"]",
"=",
"sumSoFar",
";",
"}",
"return",
"runningSumAr",
";",
"}",
"}"
] | Running Sum of 1d Array
Time Complexity - O(n)
Space Complexity - O(n) | [
"Running",
"Sum",
"of",
"1d",
"Array",
"Time",
"Complexity",
"-",
"O",
"(",
"n",
")",
"Space",
"Complexity",
"-",
"O",
"(",
"n",
")"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
cc47b257dab5b24aa07ab9105768d65d09e847a3 | jeje/restdocs-api-spec | restdocs-api-spec-postman-generator/src/main/java/com/epages/restdocs/apispec/postman/model/Certificate.java | [
"MIT"
] | Java | Certificate | /**
* Certificate
* <p>
* A representation of an ssl certificate
*
*/ | Certificate
A representation of an ssl certificate | [
"Certificate",
"A",
"representation",
"of",
"an",
"ssl",
"certificate"
] | @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"name",
"matches",
"key",
"cert",
"passphrase"
})
public class Certificate {
/**
* A name for the certificate for user reference
*
*/
@JsonProperty("name")
@JsonPropertyDescription("A name for the certificate for user reference")
private String name;
/**
* A list of Url match pattern strings, to identify Urls this certificate can be used for.
*
*/
@JsonProperty("matches")
@JsonPropertyDescription("A list of Url match pattern strings, to identify Urls this certificate can be used for.")
private List<Object> matches = new ArrayList<Object>();
/**
* An object containing path to file containing private key, on the file system
*
*/
@JsonProperty("key")
@JsonPropertyDescription("An object containing path to file containing private key, on the file system")
private Key key;
/**
* An object containing path to file certificate, on the file system
*
*/
@JsonProperty("cert")
@JsonPropertyDescription("An object containing path to file certificate, on the file system")
private Cert cert;
/**
* The passphrase for the certificate
*
*/
@JsonProperty("passphrase")
@JsonPropertyDescription("The passphrase for the certificate")
private String passphrase;
/**
* A name for the certificate for user reference
*
*/
@JsonProperty("name")
public String getName() {
return name;
}
/**
* A name for the certificate for user reference
*
*/
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
/**
* A list of Url match pattern strings, to identify Urls this certificate can be used for.
*
*/
@JsonProperty("matches")
public List<Object> getMatches() {
return matches;
}
/**
* A list of Url match pattern strings, to identify Urls this certificate can be used for.
*
*/
@JsonProperty("matches")
public void setMatches(List<Object> matches) {
this.matches = matches;
}
/**
* An object containing path to file containing private key, on the file system
*
*/
@JsonProperty("key")
public Key getKey() {
return key;
}
/**
* An object containing path to file containing private key, on the file system
*
*/
@JsonProperty("key")
public void setKey(Key key) {
this.key = key;
}
/**
* An object containing path to file certificate, on the file system
*
*/
@JsonProperty("cert")
public Cert getCert() {
return cert;
}
/**
* An object containing path to file certificate, on the file system
*
*/
@JsonProperty("cert")
public void setCert(Cert cert) {
this.cert = cert;
}
/**
* The passphrase for the certificate
*
*/
@JsonProperty("passphrase")
public String getPassphrase() {
return passphrase;
}
/**
* The passphrase for the certificate
*
*/
@JsonProperty("passphrase")
public void setPassphrase(String passphrase) {
this.passphrase = passphrase;
}
} | [
"@",
"JsonInclude",
"(",
"JsonInclude",
".",
"Include",
".",
"NON_NULL",
")",
"@",
"JsonPropertyOrder",
"(",
"{",
"\"",
"name",
"\"",
",",
"\"",
"matches",
"\"",
",",
"\"",
"key",
"\"",
",",
"\"",
"cert",
"\"",
",",
"\"",
"passphrase",
"\"",
"}",
")",
"public",
"class",
"Certificate",
"{",
"/**\n * A name for the certificate for user reference\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"name",
"\"",
")",
"@",
"JsonPropertyDescription",
"(",
"\"",
"A name for the certificate for user reference",
"\"",
")",
"private",
"String",
"name",
";",
"/**\n * A list of Url match pattern strings, to identify Urls this certificate can be used for.\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"matches",
"\"",
")",
"@",
"JsonPropertyDescription",
"(",
"\"",
"A list of Url match pattern strings, to identify Urls this certificate can be used for.",
"\"",
")",
"private",
"List",
"<",
"Object",
">",
"matches",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"/**\n * An object containing path to file containing private key, on the file system\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"key",
"\"",
")",
"@",
"JsonPropertyDescription",
"(",
"\"",
"An object containing path to file containing private key, on the file system",
"\"",
")",
"private",
"Key",
"key",
";",
"/**\n * An object containing path to file certificate, on the file system\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"cert",
"\"",
")",
"@",
"JsonPropertyDescription",
"(",
"\"",
"An object containing path to file certificate, on the file system",
"\"",
")",
"private",
"Cert",
"cert",
";",
"/**\n * The passphrase for the certificate\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"passphrase",
"\"",
")",
"@",
"JsonPropertyDescription",
"(",
"\"",
"The passphrase for the certificate",
"\"",
")",
"private",
"String",
"passphrase",
";",
"/**\n * A name for the certificate for user reference\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"name",
"\"",
")",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"/**\n * A name for the certificate for user reference\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"name",
"\"",
")",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"/**\n * A list of Url match pattern strings, to identify Urls this certificate can be used for.\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"matches",
"\"",
")",
"public",
"List",
"<",
"Object",
">",
"getMatches",
"(",
")",
"{",
"return",
"matches",
";",
"}",
"/**\n * A list of Url match pattern strings, to identify Urls this certificate can be used for.\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"matches",
"\"",
")",
"public",
"void",
"setMatches",
"(",
"List",
"<",
"Object",
">",
"matches",
")",
"{",
"this",
".",
"matches",
"=",
"matches",
";",
"}",
"/**\n * An object containing path to file containing private key, on the file system\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"key",
"\"",
")",
"public",
"Key",
"getKey",
"(",
")",
"{",
"return",
"key",
";",
"}",
"/**\n * An object containing path to file containing private key, on the file system\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"key",
"\"",
")",
"public",
"void",
"setKey",
"(",
"Key",
"key",
")",
"{",
"this",
".",
"key",
"=",
"key",
";",
"}",
"/**\n * An object containing path to file certificate, on the file system\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"cert",
"\"",
")",
"public",
"Cert",
"getCert",
"(",
")",
"{",
"return",
"cert",
";",
"}",
"/**\n * An object containing path to file certificate, on the file system\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"cert",
"\"",
")",
"public",
"void",
"setCert",
"(",
"Cert",
"cert",
")",
"{",
"this",
".",
"cert",
"=",
"cert",
";",
"}",
"/**\n * The passphrase for the certificate\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"passphrase",
"\"",
")",
"public",
"String",
"getPassphrase",
"(",
")",
"{",
"return",
"passphrase",
";",
"}",
"/**\n * The passphrase for the certificate\n * \n */",
"@",
"JsonProperty",
"(",
"\"",
"passphrase",
"\"",
")",
"public",
"void",
"setPassphrase",
"(",
"String",
"passphrase",
")",
"{",
"this",
".",
"passphrase",
"=",
"passphrase",
";",
"}",
"}"
] | Certificate
<p>
A representation of an ssl certificate | [
"Certificate",
"<p",
">",
"A",
"representation",
"of",
"an",
"ssl",
"certificate"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
cc4c9a148cbe1dc0395e15c996b8106e78159252 | danko-david/uartbus | source/java/uartbus/src/main/java/eu/javaexperience/electronic/uartbus/rpc/client/UartbusTransaction.java | [
"MIT"
] | Java | UartbusTransaction | /**
* I know, this is a blob but maybe it's easier to manager request-response
* as one unit.
* */ | I know, this is a blob but maybe it's easier to manager request-response
as one unit. | [
"I",
"know",
"this",
"is",
"a",
"blob",
"but",
"maybe",
"it",
"'",
"s",
"easier",
"to",
"manager",
"request",
"-",
"response",
"as",
"one",
"unit",
"."
] | public class UartbusTransaction implements Closeable
{
protected static final Logger LOG = JavaExperienceLoggingFacility.getLogger(new Loggable("UartbusTransaction"));
public final UartBus bus;
public boolean zeroNamespaceAnswer;
public int to;
public int from;
//if channel is negative, we send the request directly
public byte[] path;
public byte[] payload;
public volatile boolean revoked = false;
public volatile byte[] responsePayload;
public UartbusTransaction(UartBus bus)
{
this.bus = bus;
}
public byte[] toPacket()
{
return UbRpcTools.toPacket(to, from, payload);
}
public void send() throws IOException
{
if(isResponsed())
{
throw new IllegalOperationException("Request already sent and responded!");
}
//this also add the request to the pending list.
bus.addPendingRequest(this);
byte[] send = toPacket();
synchronized(this)
{
bus.sendPacket.publish(send);
}
if(LOG.mayLog(LogLevel.TRACE))
{
LoggingTools.tryLogFormat(LOG, LogLevel.TRACE, "Request sent: %s", hashCode());
}
}
@Override
public void close() throws IOException
{
revoked = true;
bus.revokePendingRequest(this);
}
@Override
protected void finalize() throws Throwable
{
//safety net
close();
}
/****************************** response section ******************************/
protected final WaitForSingleEvent wait = new WaitForSingleEvent();
public boolean isResponsed()
{
return null != responsePayload;
}
public boolean isRevoked()
{
return null != responsePayload && revoked;
}
public boolean waitResponse(long timeout, TimeUnit unit) throws InterruptedException
{
AssertArgument.assertTrue(!revoked, "Request has been revoked");
long t0 = System.currentTimeMillis();
wait.waitForEvent(timeout, unit);
AssertArgument.assertTrue(!revoked, "Request has been revoked");
if(LOG.mayLog(LogLevel.TRACE))
{
LoggingTools.tryLogFormat(LOG, LogLevel.TRACE, "waitResponse ended for %s after %s ms with result: %s", hashCode(), System.currentTimeMillis()-t0, null != responsePayload);
}
return null != responsePayload;
}
public byte[] ensureResponse(long timeout, TimeUnit unit) throws InterruptedException
{
return ensureResponse(timeout, unit, null);
}
public byte[] ensureResponse(long timeout, TimeUnit unit, String errAppendMsg) throws InterruptedException
{
if(!waitResponse(timeout, unit))
{
throw new TransactionException("Device (`"+to+"`) not responded within "+timeout+" "+unit+" for the request"+(null == errAppendMsg?"":": "+errAppendMsg));
}
return responsePayload;
}
protected void receiveResponse(byte[] data)
{
AssertArgument.assertNotNull(data, "data");
responsePayload = data;
if(LOG.mayLog(LogLevel.TRACE))
{
LoggingTools.tryLogFormat(LOG, LogLevel.TRACE, "Response received for request: %s", hashCode());
}
wait.evenOcurred();
}
public boolean tryAcceptResponse(ParsedUartBusPacket a)
{
//check response by address
if(a.to == this.from && a.from == this.to && a.payload.length + (zeroNamespaceAnswer?1:0) >= path.length)
{
int diff = 0;
if(zeroNamespaceAnswer)
{
if(0 != a.payload[0])
{
return false;
}
diff = 1;
}
//check response by rpc path
for(int i=0;i<path.length;++i)
{
if(path[i] != a.payload[diff+i])
{
return false;
}
}
//we got the response.
try
{
receiveResponse(a.payload);
}
catch(Exception e)
{
e.printStackTrace();
}
return true;
}
return false;
}
} | [
"public",
"class",
"UartbusTransaction",
"implements",
"Closeable",
"{",
"protected",
"static",
"final",
"Logger",
"LOG",
"=",
"JavaExperienceLoggingFacility",
".",
"getLogger",
"(",
"new",
"Loggable",
"(",
"\"",
"UartbusTransaction",
"\"",
")",
")",
";",
"public",
"final",
"UartBus",
"bus",
";",
"public",
"boolean",
"zeroNamespaceAnswer",
";",
"public",
"int",
"to",
";",
"public",
"int",
"from",
";",
"public",
"byte",
"[",
"]",
"path",
";",
"public",
"byte",
"[",
"]",
"payload",
";",
"public",
"volatile",
"boolean",
"revoked",
"=",
"false",
";",
"public",
"volatile",
"byte",
"[",
"]",
"responsePayload",
";",
"public",
"UartbusTransaction",
"(",
"UartBus",
"bus",
")",
"{",
"this",
".",
"bus",
"=",
"bus",
";",
"}",
"public",
"byte",
"[",
"]",
"toPacket",
"(",
")",
"{",
"return",
"UbRpcTools",
".",
"toPacket",
"(",
"to",
",",
"from",
",",
"payload",
")",
";",
"}",
"public",
"void",
"send",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"isResponsed",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalOperationException",
"(",
"\"",
"Request already sent and responded!",
"\"",
")",
";",
"}",
"bus",
".",
"addPendingRequest",
"(",
"this",
")",
";",
"byte",
"[",
"]",
"send",
"=",
"toPacket",
"(",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"bus",
".",
"sendPacket",
".",
"publish",
"(",
"send",
")",
";",
"}",
"if",
"(",
"LOG",
".",
"mayLog",
"(",
"LogLevel",
".",
"TRACE",
")",
")",
"{",
"LoggingTools",
".",
"tryLogFormat",
"(",
"LOG",
",",
"LogLevel",
".",
"TRACE",
",",
"\"",
"Request sent: %s",
"\"",
",",
"hashCode",
"(",
")",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"revoked",
"=",
"true",
";",
"bus",
".",
"revokePendingRequest",
"(",
"this",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"finalize",
"(",
")",
"throws",
"Throwable",
"{",
"close",
"(",
")",
";",
"}",
"/****************************** response section ******************************/",
"protected",
"final",
"WaitForSingleEvent",
"wait",
"=",
"new",
"WaitForSingleEvent",
"(",
")",
";",
"public",
"boolean",
"isResponsed",
"(",
")",
"{",
"return",
"null",
"!=",
"responsePayload",
";",
"}",
"public",
"boolean",
"isRevoked",
"(",
")",
"{",
"return",
"null",
"!=",
"responsePayload",
"&&",
"revoked",
";",
"}",
"public",
"boolean",
"waitResponse",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"AssertArgument",
".",
"assertTrue",
"(",
"!",
"revoked",
",",
"\"",
"Request has been revoked",
"\"",
")",
";",
"long",
"t0",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"wait",
".",
"waitForEvent",
"(",
"timeout",
",",
"unit",
")",
";",
"AssertArgument",
".",
"assertTrue",
"(",
"!",
"revoked",
",",
"\"",
"Request has been revoked",
"\"",
")",
";",
"if",
"(",
"LOG",
".",
"mayLog",
"(",
"LogLevel",
".",
"TRACE",
")",
")",
"{",
"LoggingTools",
".",
"tryLogFormat",
"(",
"LOG",
",",
"LogLevel",
".",
"TRACE",
",",
"\"",
"waitResponse ended for %s after %s ms with result: %s",
"\"",
",",
"hashCode",
"(",
")",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"t0",
",",
"null",
"!=",
"responsePayload",
")",
";",
"}",
"return",
"null",
"!=",
"responsePayload",
";",
"}",
"public",
"byte",
"[",
"]",
"ensureResponse",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"return",
"ensureResponse",
"(",
"timeout",
",",
"unit",
",",
"null",
")",
";",
"}",
"public",
"byte",
"[",
"]",
"ensureResponse",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
",",
"String",
"errAppendMsg",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"!",
"waitResponse",
"(",
"timeout",
",",
"unit",
")",
")",
"{",
"throw",
"new",
"TransactionException",
"(",
"\"",
"Device (`",
"\"",
"+",
"to",
"+",
"\"",
"`) not responded within ",
"\"",
"+",
"timeout",
"+",
"\"",
" ",
"\"",
"+",
"unit",
"+",
"\"",
" for the request",
"\"",
"+",
"(",
"null",
"==",
"errAppendMsg",
"?",
"\"",
"\"",
":",
"\"",
": ",
"\"",
"+",
"errAppendMsg",
")",
")",
";",
"}",
"return",
"responsePayload",
";",
"}",
"protected",
"void",
"receiveResponse",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"AssertArgument",
".",
"assertNotNull",
"(",
"data",
",",
"\"",
"data",
"\"",
")",
";",
"responsePayload",
"=",
"data",
";",
"if",
"(",
"LOG",
".",
"mayLog",
"(",
"LogLevel",
".",
"TRACE",
")",
")",
"{",
"LoggingTools",
".",
"tryLogFormat",
"(",
"LOG",
",",
"LogLevel",
".",
"TRACE",
",",
"\"",
"Response received for request: %s",
"\"",
",",
"hashCode",
"(",
")",
")",
";",
"}",
"wait",
".",
"evenOcurred",
"(",
")",
";",
"}",
"public",
"boolean",
"tryAcceptResponse",
"(",
"ParsedUartBusPacket",
"a",
")",
"{",
"if",
"(",
"a",
".",
"to",
"==",
"this",
".",
"from",
"&&",
"a",
".",
"from",
"==",
"this",
".",
"to",
"&&",
"a",
".",
"payload",
".",
"length",
"+",
"(",
"zeroNamespaceAnswer",
"?",
"1",
":",
"0",
")",
">=",
"path",
".",
"length",
")",
"{",
"int",
"diff",
"=",
"0",
";",
"if",
"(",
"zeroNamespaceAnswer",
")",
"{",
"if",
"(",
"0",
"!=",
"a",
".",
"payload",
"[",
"0",
"]",
")",
"{",
"return",
"false",
";",
"}",
"diff",
"=",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"path",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"path",
"[",
"i",
"]",
"!=",
"a",
".",
"payload",
"[",
"diff",
"+",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"try",
"{",
"receiveResponse",
"(",
"a",
".",
"payload",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"}"
] | I know, this is a blob but maybe it's easier to manager request-response
as one unit. | [
"I",
"know",
"this",
"is",
"a",
"blob",
"but",
"maybe",
"it",
"'",
"s",
"easier",
"to",
"manager",
"request",
"-",
"response",
"as",
"one",
"unit",
"."
] | [
"//if channel is negative, we send the request directly",
"//this also add the request to the pending list.",
"//safety net",
"//check response by address",
"//check response by rpc path",
"//we got the response."
] | [
{
"param": "Closeable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Closeable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc4cafa2858f6ad25daf8ce2521eafca55d5d558 | IgroGames2227/TinkersConstruct | src/main/java/slimeknights/tconstruct/library/recipe/modifiers/salvage/AbstractModifierSalvage.java | [
"MIT"
] | Java | AbstractModifierSalvage | /**
* Shared logic for main types of salvage recipes
*/ | Shared logic for main types of salvage recipes | [
"Shared",
"logic",
"for",
"main",
"types",
"of",
"salvage",
"recipes"
] | public abstract class AbstractModifierSalvage implements ICustomOutputRecipe<IInventory> {
@Getter
protected final ResourceLocation id;
/**
* Ingredient determining tools matched by this
*/
protected final Ingredient toolIngredient;
/**
* Modifier represented by this recipe
*/
@Getter
protected final Modifier modifier;
/**
* Minimum level of the modifier for this to be applicable
*/
protected final int minLevel;
/**
* Maximum level of the modifier for this to be applicable
*/
protected final int maxLevel;
/**
* Upgrade slots returned from this recipe
*/
protected final int upgradeSlots;
/**
* Ability slots returned from this recipe
*/
protected final int abilitySlots;
public AbstractModifierSalvage(ResourceLocation id, Ingredient toolIngredient, Modifier modifier, int minLevel, int maxLevel, int upgradeSlots, int abilitySlots) {
this.id = id;
this.toolIngredient = toolIngredient;
this.modifier = modifier;
this.minLevel = minLevel;
this.maxLevel = maxLevel;
this.upgradeSlots = upgradeSlots;
this.abilitySlots = abilitySlots;
}
/**
* Checks if the given tool stack and level are applicable for this salvage
* @param stack Tool item stack
* @param tool Tool stack instance, for potential extensions
* @param originalLevel Level to check
* @return True if this salvage is applicable
*/
public boolean matches(ItemStack stack, IModifierToolStack tool, int originalLevel) {
return originalLevel >= minLevel && originalLevel <= maxLevel && toolIngredient.test(stack);
}
/**
* Updates the tool data in light of removing this modifier
* @param tool Tool instance
*/
public void updateTool(IModifierToolStack tool) {
ModDataNBT persistentData = tool.getPersistentData();
persistentData.addUpgrades(upgradeSlots);
persistentData.addAbilities(abilitySlots);
}
/**
* Adds items from this salvage to the given consumer
* @param tool Tool instance before the modifier was removed. If you need to change the tool, use {@link #updateTool(IModifierToolStack)}
* @param stackConsumer Consumer for items
*/
public abstract void acceptItems(IModifierToolStack tool, Consumer<ItemStack> stackConsumer, Random random);
@Override
public IRecipeType<?> getType() {
return RecipeTypes.DATA;
}
/** @deprecated Use {@link #matches(ItemStack, IModifierToolStack, int)} */
@Deprecated
@Override
public boolean matches(IInventory inv, World worldIn) {
return false;
}
/**
* Serializer instance
*/
public static abstract class AbstractSerializer<T extends AbstractModifierSalvage> extends LoggingRecipeSerializer<T> {
/**
* Helper for int with a min value
*/
private static int readIntWithMin(JsonObject json, String key, int min) {
int value = JSONUtils.getInt(json, key, min);
if (value < min) {
throw new JsonSyntaxException(key + " must be at least " + min);
}
return value;
}
/**
* Finishes reading the recipe from JSON
* @param id Recipe ID
* @param json Recipe JSON
* @param toolIngredient Tool ingredient
* @param modifier Modifier
* @param minLevel Min modifier level
* @param maxLevel Max modifier level
* @param upgradeSlots Number of upgrade slots returned
* @param abilitySlots Number of ability slots returned
* @return Recipe
*/
protected abstract T read(ResourceLocation id, JsonObject json, Ingredient toolIngredient, Modifier modifier, int minLevel, int maxLevel, int upgradeSlots, int abilitySlots);
/**
* Finishes reading the recipe from JSON
* @param id Recipe ID
* @param buffer Packet buffer
* @param toolIngredient Tool ingredient
* @param modifier Modifier
* @param minLevel Min modifier level
* @param maxLevel Max modifier level
* @param upgradeSlots Number of upgrade slots returned
* @param abilitySlots Number of ability slots returned
* @return Recipe
*/
protected abstract T read(ResourceLocation id, PacketBuffer buffer, Ingredient toolIngredient, Modifier modifier, int minLevel, int maxLevel, int upgradeSlots, int abilitySlots);
@Override
public T read(ResourceLocation id, JsonObject json) {
Ingredient toolIngredient = Ingredient.deserialize(JsonHelper.getElement(json, "tools"));
Modifier modifier = ModifierEntry.deserializeModifier(json, "modifier");
int minLevel = readIntWithMin(json, "min_level", 1);
int maxLevel = JSONUtils.getInt(json, "max_level", Integer.MAX_VALUE);
if (maxLevel < minLevel) {
throw new JsonSyntaxException("Max level must be greater than or equal to min level");
}
int upgradeSlots = readIntWithMin(json, "upgrade_slots", 0);
int abilitySlots = readIntWithMin(json, "ability_slots", 0);
return read(id, json, toolIngredient, modifier, minLevel, maxLevel, upgradeSlots, abilitySlots);
}
@Nullable
@Override
protected T readSafe(ResourceLocation id, PacketBuffer buffer) {
Ingredient toolIngredient = Ingredient.read(buffer);
Modifier modifier = buffer.readRegistryIdUnsafe(TinkerRegistries.MODIFIERS);
int minLevel = buffer.readVarInt();
int maxLevel = buffer.readVarInt();
int upgradeSlots = buffer.readVarInt();
int abilitySlots = buffer.readVarInt();
return read(id, buffer, toolIngredient, modifier, minLevel, maxLevel, upgradeSlots, abilitySlots);
}
@Override
protected void writeSafe(PacketBuffer buffer, T recipe) {
recipe.toolIngredient.write(buffer);
buffer.writeRegistryIdUnsafe(TinkerRegistries.MODIFIERS, recipe.modifier);
buffer.writeVarInt(recipe.minLevel);
buffer.writeVarInt(recipe.maxLevel);
buffer.writeVarInt(recipe.upgradeSlots);
buffer.writeVarInt(recipe.abilitySlots);
}
}
} | [
"public",
"abstract",
"class",
"AbstractModifierSalvage",
"implements",
"ICustomOutputRecipe",
"<",
"IInventory",
">",
"{",
"@",
"Getter",
"protected",
"final",
"ResourceLocation",
"id",
";",
"/**\n * Ingredient determining tools matched by this\n */",
"protected",
"final",
"Ingredient",
"toolIngredient",
";",
"/**\n * Modifier represented by this recipe\n */",
"@",
"Getter",
"protected",
"final",
"Modifier",
"modifier",
";",
"/**\n * Minimum level of the modifier for this to be applicable\n */",
"protected",
"final",
"int",
"minLevel",
";",
"/**\n * Maximum level of the modifier for this to be applicable\n */",
"protected",
"final",
"int",
"maxLevel",
";",
"/**\n * Upgrade slots returned from this recipe\n */",
"protected",
"final",
"int",
"upgradeSlots",
";",
"/**\n * Ability slots returned from this recipe\n */",
"protected",
"final",
"int",
"abilitySlots",
";",
"public",
"AbstractModifierSalvage",
"(",
"ResourceLocation",
"id",
",",
"Ingredient",
"toolIngredient",
",",
"Modifier",
"modifier",
",",
"int",
"minLevel",
",",
"int",
"maxLevel",
",",
"int",
"upgradeSlots",
",",
"int",
"abilitySlots",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"toolIngredient",
"=",
"toolIngredient",
";",
"this",
".",
"modifier",
"=",
"modifier",
";",
"this",
".",
"minLevel",
"=",
"minLevel",
";",
"this",
".",
"maxLevel",
"=",
"maxLevel",
";",
"this",
".",
"upgradeSlots",
"=",
"upgradeSlots",
";",
"this",
".",
"abilitySlots",
"=",
"abilitySlots",
";",
"}",
"/**\n * Checks if the given tool stack and level are applicable for this salvage\n * @param stack Tool item stack\n * @param tool Tool stack instance, for potential extensions\n * @param originalLevel Level to check\n * @return True if this salvage is applicable\n */",
"public",
"boolean",
"matches",
"(",
"ItemStack",
"stack",
",",
"IModifierToolStack",
"tool",
",",
"int",
"originalLevel",
")",
"{",
"return",
"originalLevel",
">=",
"minLevel",
"&&",
"originalLevel",
"<=",
"maxLevel",
"&&",
"toolIngredient",
".",
"test",
"(",
"stack",
")",
";",
"}",
"/**\n * Updates the tool data in light of removing this modifier\n * @param tool Tool instance\n */",
"public",
"void",
"updateTool",
"(",
"IModifierToolStack",
"tool",
")",
"{",
"ModDataNBT",
"persistentData",
"=",
"tool",
".",
"getPersistentData",
"(",
")",
";",
"persistentData",
".",
"addUpgrades",
"(",
"upgradeSlots",
")",
";",
"persistentData",
".",
"addAbilities",
"(",
"abilitySlots",
")",
";",
"}",
"/**\n * Adds items from this salvage to the given consumer\n * @param tool Tool instance before the modifier was removed. If you need to change the tool, use {@link #updateTool(IModifierToolStack)}\n * @param stackConsumer Consumer for items\n */",
"public",
"abstract",
"void",
"acceptItems",
"(",
"IModifierToolStack",
"tool",
",",
"Consumer",
"<",
"ItemStack",
">",
"stackConsumer",
",",
"Random",
"random",
")",
";",
"@",
"Override",
"public",
"IRecipeType",
"<",
"?",
">",
"getType",
"(",
")",
"{",
"return",
"RecipeTypes",
".",
"DATA",
";",
"}",
"/** @deprecated Use {@link #matches(ItemStack, IModifierToolStack, int)} */",
"@",
"Deprecated",
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"IInventory",
"inv",
",",
"World",
"worldIn",
")",
"{",
"return",
"false",
";",
"}",
"/**\n * Serializer instance\n */",
"public",
"static",
"abstract",
"class",
"AbstractSerializer",
"<",
"T",
"extends",
"AbstractModifierSalvage",
">",
"extends",
"LoggingRecipeSerializer",
"<",
"T",
">",
"{",
"/**\n * Helper for int with a min value\n */",
"private",
"static",
"int",
"readIntWithMin",
"(",
"JsonObject",
"json",
",",
"String",
"key",
",",
"int",
"min",
")",
"{",
"int",
"value",
"=",
"JSONUtils",
".",
"getInt",
"(",
"json",
",",
"key",
",",
"min",
")",
";",
"if",
"(",
"value",
"<",
"min",
")",
"{",
"throw",
"new",
"JsonSyntaxException",
"(",
"key",
"+",
"\"",
" must be at least ",
"\"",
"+",
"min",
")",
";",
"}",
"return",
"value",
";",
"}",
"/**\n * Finishes reading the recipe from JSON\n * @param id Recipe ID\n * @param json Recipe JSON\n * @param toolIngredient Tool ingredient\n * @param modifier Modifier\n * @param minLevel Min modifier level\n * @param maxLevel Max modifier level\n * @param upgradeSlots Number of upgrade slots returned\n * @param abilitySlots Number of ability slots returned\n * @return Recipe\n */",
"protected",
"abstract",
"T",
"read",
"(",
"ResourceLocation",
"id",
",",
"JsonObject",
"json",
",",
"Ingredient",
"toolIngredient",
",",
"Modifier",
"modifier",
",",
"int",
"minLevel",
",",
"int",
"maxLevel",
",",
"int",
"upgradeSlots",
",",
"int",
"abilitySlots",
")",
";",
"/**\n * Finishes reading the recipe from JSON\n * @param id Recipe ID\n * @param buffer Packet buffer\n * @param toolIngredient Tool ingredient\n * @param modifier Modifier\n * @param minLevel Min modifier level\n * @param maxLevel Max modifier level\n * @param upgradeSlots Number of upgrade slots returned\n * @param abilitySlots Number of ability slots returned\n * @return Recipe\n */",
"protected",
"abstract",
"T",
"read",
"(",
"ResourceLocation",
"id",
",",
"PacketBuffer",
"buffer",
",",
"Ingredient",
"toolIngredient",
",",
"Modifier",
"modifier",
",",
"int",
"minLevel",
",",
"int",
"maxLevel",
",",
"int",
"upgradeSlots",
",",
"int",
"abilitySlots",
")",
";",
"@",
"Override",
"public",
"T",
"read",
"(",
"ResourceLocation",
"id",
",",
"JsonObject",
"json",
")",
"{",
"Ingredient",
"toolIngredient",
"=",
"Ingredient",
".",
"deserialize",
"(",
"JsonHelper",
".",
"getElement",
"(",
"json",
",",
"\"",
"tools",
"\"",
")",
")",
";",
"Modifier",
"modifier",
"=",
"ModifierEntry",
".",
"deserializeModifier",
"(",
"json",
",",
"\"",
"modifier",
"\"",
")",
";",
"int",
"minLevel",
"=",
"readIntWithMin",
"(",
"json",
",",
"\"",
"min_level",
"\"",
",",
"1",
")",
";",
"int",
"maxLevel",
"=",
"JSONUtils",
".",
"getInt",
"(",
"json",
",",
"\"",
"max_level",
"\"",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"if",
"(",
"maxLevel",
"<",
"minLevel",
")",
"{",
"throw",
"new",
"JsonSyntaxException",
"(",
"\"",
"Max level must be greater than or equal to min level",
"\"",
")",
";",
"}",
"int",
"upgradeSlots",
"=",
"readIntWithMin",
"(",
"json",
",",
"\"",
"upgrade_slots",
"\"",
",",
"0",
")",
";",
"int",
"abilitySlots",
"=",
"readIntWithMin",
"(",
"json",
",",
"\"",
"ability_slots",
"\"",
",",
"0",
")",
";",
"return",
"read",
"(",
"id",
",",
"json",
",",
"toolIngredient",
",",
"modifier",
",",
"minLevel",
",",
"maxLevel",
",",
"upgradeSlots",
",",
"abilitySlots",
")",
";",
"}",
"@",
"Nullable",
"@",
"Override",
"protected",
"T",
"readSafe",
"(",
"ResourceLocation",
"id",
",",
"PacketBuffer",
"buffer",
")",
"{",
"Ingredient",
"toolIngredient",
"=",
"Ingredient",
".",
"read",
"(",
"buffer",
")",
";",
"Modifier",
"modifier",
"=",
"buffer",
".",
"readRegistryIdUnsafe",
"(",
"TinkerRegistries",
".",
"MODIFIERS",
")",
";",
"int",
"minLevel",
"=",
"buffer",
".",
"readVarInt",
"(",
")",
";",
"int",
"maxLevel",
"=",
"buffer",
".",
"readVarInt",
"(",
")",
";",
"int",
"upgradeSlots",
"=",
"buffer",
".",
"readVarInt",
"(",
")",
";",
"int",
"abilitySlots",
"=",
"buffer",
".",
"readVarInt",
"(",
")",
";",
"return",
"read",
"(",
"id",
",",
"buffer",
",",
"toolIngredient",
",",
"modifier",
",",
"minLevel",
",",
"maxLevel",
",",
"upgradeSlots",
",",
"abilitySlots",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"writeSafe",
"(",
"PacketBuffer",
"buffer",
",",
"T",
"recipe",
")",
"{",
"recipe",
".",
"toolIngredient",
".",
"write",
"(",
"buffer",
")",
";",
"buffer",
".",
"writeRegistryIdUnsafe",
"(",
"TinkerRegistries",
".",
"MODIFIERS",
",",
"recipe",
".",
"modifier",
")",
";",
"buffer",
".",
"writeVarInt",
"(",
"recipe",
".",
"minLevel",
")",
";",
"buffer",
".",
"writeVarInt",
"(",
"recipe",
".",
"maxLevel",
")",
";",
"buffer",
".",
"writeVarInt",
"(",
"recipe",
".",
"upgradeSlots",
")",
";",
"buffer",
".",
"writeVarInt",
"(",
"recipe",
".",
"abilitySlots",
")",
";",
"}",
"}",
"}"
] | Shared logic for main types of salvage recipes | [
"Shared",
"logic",
"for",
"main",
"types",
"of",
"salvage",
"recipes"
] | [] | [
{
"param": "ICustomOutputRecipe<IInventory>",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ICustomOutputRecipe<IInventory>",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |