id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
140,400
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.startCommandPolling
public synchronized void startCommandPolling(final CommandImpl command) throws DevFailed { addCommandPolling(command); LOGGER.debug("starting command {} for polling on device {}", command.getName(), deviceName); if (command.getPollingPeriod() != 0) { commandCacheMap.get(command).startRefresh(POLLING_POOL); } }
java
public synchronized void startCommandPolling(final CommandImpl command) throws DevFailed { addCommandPolling(command); LOGGER.debug("starting command {} for polling on device {}", command.getName(), deviceName); if (command.getPollingPeriod() != 0) { commandCacheMap.get(command).startRefresh(POLLING_POOL); } }
[ "public", "synchronized", "void", "startCommandPolling", "(", "final", "CommandImpl", "command", ")", "throws", "DevFailed", "{", "addCommandPolling", "(", "command", ")", ";", "LOGGER", ".", "debug", "(", "\"starting command {} for polling on device {}\"", ",", "command", ".", "getName", "(", ")", ",", "deviceName", ")", ";", "if", "(", "command", ".", "getPollingPeriod", "(", ")", "!=", "0", ")", "{", "commandCacheMap", ".", "get", "(", "command", ")", ".", "startRefresh", "(", "POLLING_POOL", ")", ";", "}", "}" ]
Start command polling @param command The command to poll @throws DevFailed
[ "Start", "command", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L214-L220
140,401
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.addCommandPolling
private void addCommandPolling(final CommandImpl command) throws DevFailed { if (MANAGER == null) { startCache(); } removeCommandPolling(command); final CommandCache cache = new CommandCache(MANAGER, command, deviceName, deviceLock, aroundInvoke); if (command.getPollingPeriod() == 0) { extTrigCommandCacheMap.put(command, cache); } else { commandCacheMap.put(command, cache); } updatePoolConf(); }
java
private void addCommandPolling(final CommandImpl command) throws DevFailed { if (MANAGER == null) { startCache(); } removeCommandPolling(command); final CommandCache cache = new CommandCache(MANAGER, command, deviceName, deviceLock, aroundInvoke); if (command.getPollingPeriod() == 0) { extTrigCommandCacheMap.put(command, cache); } else { commandCacheMap.put(command, cache); } updatePoolConf(); }
[ "private", "void", "addCommandPolling", "(", "final", "CommandImpl", "command", ")", "throws", "DevFailed", "{", "if", "(", "MANAGER", "==", "null", ")", "{", "startCache", "(", ")", ";", "}", "removeCommandPolling", "(", "command", ")", ";", "final", "CommandCache", "cache", "=", "new", "CommandCache", "(", "MANAGER", ",", "command", ",", "deviceName", ",", "deviceLock", ",", "aroundInvoke", ")", ";", "if", "(", "command", ".", "getPollingPeriod", "(", ")", "==", "0", ")", "{", "extTrigCommandCacheMap", ".", "put", "(", "command", ",", "cache", ")", ";", "}", "else", "{", "commandCacheMap", ".", "put", "(", "command", ",", "cache", ")", ";", "}", "updatePoolConf", "(", ")", ";", "}" ]
Add command as polled @param command @throws DevFailed
[ "Add", "command", "as", "polled" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L228-L240
140,402
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.startAttributePolling
public synchronized void startAttributePolling(final AttributeImpl attr) throws DevFailed { addAttributePolling(attr); LOGGER.debug("starting attribute {} for polling on device {}", attr.getName(), deviceName); if (attr.getPollingPeriod() != 0) { attributeCacheMap.get(attr).startRefresh(POLLING_POOL); } }
java
public synchronized void startAttributePolling(final AttributeImpl attr) throws DevFailed { addAttributePolling(attr); LOGGER.debug("starting attribute {} for polling on device {}", attr.getName(), deviceName); if (attr.getPollingPeriod() != 0) { attributeCacheMap.get(attr).startRefresh(POLLING_POOL); } }
[ "public", "synchronized", "void", "startAttributePolling", "(", "final", "AttributeImpl", "attr", ")", "throws", "DevFailed", "{", "addAttributePolling", "(", "attr", ")", ";", "LOGGER", ".", "debug", "(", "\"starting attribute {} for polling on device {}\"", ",", "attr", ".", "getName", "(", ")", ",", "deviceName", ")", ";", "if", "(", "attr", ".", "getPollingPeriod", "(", ")", "!=", "0", ")", "{", "attributeCacheMap", ".", "get", "(", "attr", ")", ".", "startRefresh", "(", "POLLING_POOL", ")", ";", "}", "}" ]
Start attribute polling @param attr The attribute to poll @throws DevFailed
[ "Start", "attribute", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L249-L255
140,403
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.addAttributePolling
private void addAttributePolling(final AttributeImpl attr) throws DevFailed { if (MANAGER == null) { startCache(); } removeAttributePolling(attr); final AttributeCache cache = new AttributeCache(MANAGER, attr, deviceName, deviceLock, aroundInvoke); if (attr.getPollingPeriod() == 0) { extTrigAttributeCacheMap.put(attr, cache); } else { attributeCacheMap.put(attr, cache); } updatePoolConf(); }
java
private void addAttributePolling(final AttributeImpl attr) throws DevFailed { if (MANAGER == null) { startCache(); } removeAttributePolling(attr); final AttributeCache cache = new AttributeCache(MANAGER, attr, deviceName, deviceLock, aroundInvoke); if (attr.getPollingPeriod() == 0) { extTrigAttributeCacheMap.put(attr, cache); } else { attributeCacheMap.put(attr, cache); } updatePoolConf(); }
[ "private", "void", "addAttributePolling", "(", "final", "AttributeImpl", "attr", ")", "throws", "DevFailed", "{", "if", "(", "MANAGER", "==", "null", ")", "{", "startCache", "(", ")", ";", "}", "removeAttributePolling", "(", "attr", ")", ";", "final", "AttributeCache", "cache", "=", "new", "AttributeCache", "(", "MANAGER", ",", "attr", ",", "deviceName", ",", "deviceLock", ",", "aroundInvoke", ")", ";", "if", "(", "attr", ".", "getPollingPeriod", "(", ")", "==", "0", ")", "{", "extTrigAttributeCacheMap", ".", "put", "(", "attr", ",", "cache", ")", ";", "}", "else", "{", "attributeCacheMap", ".", "put", "(", "attr", ",", "cache", ")", ";", "}", "updatePoolConf", "(", ")", ";", "}" ]
Add attribute as polled @param attr @throws DevFailed
[ "Add", "attribute", "as", "polled" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L263-L275
140,404
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.removeAttributePolling
public synchronized void removeAttributePolling(final AttributeImpl attr) throws DevFailed { if (attributeCacheMap.containsKey(attr)) { final AttributeCache cache = attributeCacheMap.get(attr); cache.stopRefresh(); attributeCacheMap.remove(attr); } else if (extTrigAttributeCacheMap.containsKey(attr)) { extTrigAttributeCacheMap.remove(attr); } else if (attr.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME) && stateCache != null) { stateCache.stopRefresh(); stateCache = null; } else if (attr.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME) && statusCache != null) { statusCache.stopRefresh(); statusCache = null; } }
java
public synchronized void removeAttributePolling(final AttributeImpl attr) throws DevFailed { if (attributeCacheMap.containsKey(attr)) { final AttributeCache cache = attributeCacheMap.get(attr); cache.stopRefresh(); attributeCacheMap.remove(attr); } else if (extTrigAttributeCacheMap.containsKey(attr)) { extTrigAttributeCacheMap.remove(attr); } else if (attr.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME) && stateCache != null) { stateCache.stopRefresh(); stateCache = null; } else if (attr.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME) && statusCache != null) { statusCache.stopRefresh(); statusCache = null; } }
[ "public", "synchronized", "void", "removeAttributePolling", "(", "final", "AttributeImpl", "attr", ")", "throws", "DevFailed", "{", "if", "(", "attributeCacheMap", ".", "containsKey", "(", "attr", ")", ")", "{", "final", "AttributeCache", "cache", "=", "attributeCacheMap", ".", "get", "(", "attr", ")", ";", "cache", ".", "stopRefresh", "(", ")", ";", "attributeCacheMap", ".", "remove", "(", "attr", ")", ";", "}", "else", "if", "(", "extTrigAttributeCacheMap", ".", "containsKey", "(", "attr", ")", ")", "{", "extTrigAttributeCacheMap", ".", "remove", "(", "attr", ")", ";", "}", "else", "if", "(", "attr", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATE_NAME", ")", "&&", "stateCache", "!=", "null", ")", "{", "stateCache", ".", "stopRefresh", "(", ")", ";", "stateCache", "=", "null", ";", "}", "else", "if", "(", "attr", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATUS_NAME", ")", "&&", "statusCache", "!=", "null", ")", "{", "statusCache", ".", "stopRefresh", "(", ")", ";", "statusCache", "=", "null", ";", "}", "}" ]
Remove polling of an attribute @param attr @throws DevFailed
[ "Remove", "polling", "of", "an", "attribute" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L283-L297
140,405
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.removeAll
public synchronized void removeAll() { for (final AttributeCache cache : attributeCacheMap.values()) { cache.stopRefresh(); } attributeCacheMap.clear(); extTrigAttributeCacheMap.clear(); for (final CommandCache cache : commandCacheMap.values()) { cache.stopRefresh(); } commandCacheMap.clear(); extTrigCommandCacheMap.clear(); if (stateCache != null) { stateCache.stopRefresh(); stateCache = null; } if (statusCache != null) { statusCache.stopRefresh(); statusCache = null; } cacheList.remove(deviceName); }
java
public synchronized void removeAll() { for (final AttributeCache cache : attributeCacheMap.values()) { cache.stopRefresh(); } attributeCacheMap.clear(); extTrigAttributeCacheMap.clear(); for (final CommandCache cache : commandCacheMap.values()) { cache.stopRefresh(); } commandCacheMap.clear(); extTrigCommandCacheMap.clear(); if (stateCache != null) { stateCache.stopRefresh(); stateCache = null; } if (statusCache != null) { statusCache.stopRefresh(); statusCache = null; } cacheList.remove(deviceName); }
[ "public", "synchronized", "void", "removeAll", "(", ")", "{", "for", "(", "final", "AttributeCache", "cache", ":", "attributeCacheMap", ".", "values", "(", ")", ")", "{", "cache", ".", "stopRefresh", "(", ")", ";", "}", "attributeCacheMap", ".", "clear", "(", ")", ";", "extTrigAttributeCacheMap", ".", "clear", "(", ")", ";", "for", "(", "final", "CommandCache", "cache", ":", "commandCacheMap", ".", "values", "(", ")", ")", "{", "cache", ".", "stopRefresh", "(", ")", ";", "}", "commandCacheMap", ".", "clear", "(", ")", ";", "extTrigCommandCacheMap", ".", "clear", "(", ")", ";", "if", "(", "stateCache", "!=", "null", ")", "{", "stateCache", ".", "stopRefresh", "(", ")", ";", "stateCache", "=", "null", ";", "}", "if", "(", "statusCache", "!=", "null", ")", "{", "statusCache", ".", "stopRefresh", "(", ")", ";", "statusCache", "=", "null", ";", "}", "cacheList", ".", "remove", "(", "deviceName", ")", ";", "}" ]
Remove all polling
[ "Remove", "all", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L302-L322
140,406
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.removeCommandPolling
public synchronized void removeCommandPolling(final CommandImpl command) throws DevFailed { if (commandCacheMap.containsKey(command)) { final CommandCache cache = commandCacheMap.get(command); cache.stopRefresh(); commandCacheMap.remove(command); } else if (extTrigCommandCacheMap.containsKey(command)) { extTrigCommandCacheMap.remove(command); } else if (command.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME) && stateCache != null) { stateCache.stopRefresh(); stateCache = null; } else if (command.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME) && statusCache != null) { statusCache.stopRefresh(); statusCache = null; } }
java
public synchronized void removeCommandPolling(final CommandImpl command) throws DevFailed { if (commandCacheMap.containsKey(command)) { final CommandCache cache = commandCacheMap.get(command); cache.stopRefresh(); commandCacheMap.remove(command); } else if (extTrigCommandCacheMap.containsKey(command)) { extTrigCommandCacheMap.remove(command); } else if (command.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME) && stateCache != null) { stateCache.stopRefresh(); stateCache = null; } else if (command.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME) && statusCache != null) { statusCache.stopRefresh(); statusCache = null; } }
[ "public", "synchronized", "void", "removeCommandPolling", "(", "final", "CommandImpl", "command", ")", "throws", "DevFailed", "{", "if", "(", "commandCacheMap", ".", "containsKey", "(", "command", ")", ")", "{", "final", "CommandCache", "cache", "=", "commandCacheMap", ".", "get", "(", "command", ")", ";", "cache", ".", "stopRefresh", "(", ")", ";", "commandCacheMap", ".", "remove", "(", "command", ")", ";", "}", "else", "if", "(", "extTrigCommandCacheMap", ".", "containsKey", "(", "command", ")", ")", "{", "extTrigCommandCacheMap", ".", "remove", "(", "command", ")", ";", "}", "else", "if", "(", "command", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATE_NAME", ")", "&&", "stateCache", "!=", "null", ")", "{", "stateCache", ".", "stopRefresh", "(", ")", ";", "stateCache", "=", "null", ";", "}", "else", "if", "(", "command", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATUS_NAME", ")", "&&", "statusCache", "!=", "null", ")", "{", "statusCache", ".", "stopRefresh", "(", ")", ";", "statusCache", "=", "null", ";", "}", "}" ]
Remove polling of a command @param command @throws DevFailed
[ "Remove", "polling", "of", "a", "command" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L330-L344
140,407
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.start
public synchronized void start() { for (final AttributeCache cache : attributeCacheMap.values()) { cache.startRefresh(POLLING_POOL); } for (final CommandCache cache : commandCacheMap.values()) { cache.startRefresh(POLLING_POOL); } if (stateCache != null) { stateCache.startRefresh(POLLING_POOL); } if (statusCache != null) { statusCache.startRefresh(POLLING_POOL); } }
java
public synchronized void start() { for (final AttributeCache cache : attributeCacheMap.values()) { cache.startRefresh(POLLING_POOL); } for (final CommandCache cache : commandCacheMap.values()) { cache.startRefresh(POLLING_POOL); } if (stateCache != null) { stateCache.startRefresh(POLLING_POOL); } if (statusCache != null) { statusCache.startRefresh(POLLING_POOL); } }
[ "public", "synchronized", "void", "start", "(", ")", "{", "for", "(", "final", "AttributeCache", "cache", ":", "attributeCacheMap", ".", "values", "(", ")", ")", "{", "cache", ".", "startRefresh", "(", "POLLING_POOL", ")", ";", "}", "for", "(", "final", "CommandCache", "cache", ":", "commandCacheMap", ".", "values", "(", ")", ")", "{", "cache", ".", "startRefresh", "(", "POLLING_POOL", ")", ";", "}", "if", "(", "stateCache", "!=", "null", ")", "{", "stateCache", ".", "startRefresh", "(", "POLLING_POOL", ")", ";", "}", "if", "(", "statusCache", "!=", "null", ")", "{", "statusCache", ".", "startRefresh", "(", "POLLING_POOL", ")", ";", "}", "}" ]
Start all polling
[ "Start", "all", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L349-L362
140,408
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.stop
public synchronized void stop() { for (final AttributeCache cache : attributeCacheMap.values()) { cache.stopRefresh(); } for (final CommandCache cache : commandCacheMap.values()) { cache.stopRefresh(); } if (stateCache != null) { stateCache.stopRefresh(); } if (statusCache != null) { statusCache.stopRefresh(); } if (POLLING_POOL != null) { POLLING_POOL.shutdownNow(); POLLING_POOL = new ScheduledThreadPoolExecutor(poolSize, new TangoCacheThreadFactory()); } }
java
public synchronized void stop() { for (final AttributeCache cache : attributeCacheMap.values()) { cache.stopRefresh(); } for (final CommandCache cache : commandCacheMap.values()) { cache.stopRefresh(); } if (stateCache != null) { stateCache.stopRefresh(); } if (statusCache != null) { statusCache.stopRefresh(); } if (POLLING_POOL != null) { POLLING_POOL.shutdownNow(); POLLING_POOL = new ScheduledThreadPoolExecutor(poolSize, new TangoCacheThreadFactory()); } }
[ "public", "synchronized", "void", "stop", "(", ")", "{", "for", "(", "final", "AttributeCache", "cache", ":", "attributeCacheMap", ".", "values", "(", ")", ")", "{", "cache", ".", "stopRefresh", "(", ")", ";", "}", "for", "(", "final", "CommandCache", "cache", ":", "commandCacheMap", ".", "values", "(", ")", ")", "{", "cache", ".", "stopRefresh", "(", ")", ";", "}", "if", "(", "stateCache", "!=", "null", ")", "{", "stateCache", ".", "stopRefresh", "(", ")", ";", "}", "if", "(", "statusCache", "!=", "null", ")", "{", "statusCache", ".", "stopRefresh", "(", ")", ";", "}", "if", "(", "POLLING_POOL", "!=", "null", ")", "{", "POLLING_POOL", ".", "shutdownNow", "(", ")", ";", "POLLING_POOL", "=", "new", "ScheduledThreadPoolExecutor", "(", "poolSize", ",", "new", "TangoCacheThreadFactory", "(", ")", ")", ";", "}", "}" ]
Stop all polling
[ "Stop", "all", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L367-L384
140,409
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.getAttributeCache
public synchronized SelfPopulatingCache getAttributeCache(final AttributeImpl attr) throws NoCacheFoundException { if (attr.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME)) { return stateCache.getCache(); } else if (attr.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME)) { return statusCache.getCache(); } else { return tryGetAttributeCache(attr); } }
java
public synchronized SelfPopulatingCache getAttributeCache(final AttributeImpl attr) throws NoCacheFoundException { if (attr.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME)) { return stateCache.getCache(); } else if (attr.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME)) { return statusCache.getCache(); } else { return tryGetAttributeCache(attr); } }
[ "public", "synchronized", "SelfPopulatingCache", "getAttributeCache", "(", "final", "AttributeImpl", "attr", ")", "throws", "NoCacheFoundException", "{", "if", "(", "attr", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATE_NAME", ")", ")", "{", "return", "stateCache", ".", "getCache", "(", ")", ";", "}", "else", "if", "(", "attr", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATUS_NAME", ")", ")", "{", "return", "statusCache", ".", "getCache", "(", ")", ";", "}", "else", "{", "return", "tryGetAttributeCache", "(", "attr", ")", ";", "}", "}" ]
Get cache of an attribute @param attr the attribute @return the attribute cache @throws NoCacheFoundException if cache for the attribute is not found
[ "Get", "cache", "of", "an", "attribute" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L394-L402
140,410
tango-controls/JTango
server/src/main/java/org/tango/server/cache/TangoCacheManager.java
TangoCacheManager.getCommandCache
public synchronized SelfPopulatingCache getCommandCache(final CommandImpl cmd) { SelfPopulatingCache cache = null; if (cmd.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME)) { cache = stateCache.getCache(); } else if (cmd.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME)) { cache = statusCache.getCache(); } else { CommandCache cmdCache = commandCacheMap.get(cmd); if (cmdCache == null) { cmdCache = extTrigCommandCacheMap.get(cmd); } cache = cmdCache.getCache(); } return cache; }
java
public synchronized SelfPopulatingCache getCommandCache(final CommandImpl cmd) { SelfPopulatingCache cache = null; if (cmd.getName().equalsIgnoreCase(DeviceImpl.STATE_NAME)) { cache = stateCache.getCache(); } else if (cmd.getName().equalsIgnoreCase(DeviceImpl.STATUS_NAME)) { cache = statusCache.getCache(); } else { CommandCache cmdCache = commandCacheMap.get(cmd); if (cmdCache == null) { cmdCache = extTrigCommandCacheMap.get(cmd); } cache = cmdCache.getCache(); } return cache; }
[ "public", "synchronized", "SelfPopulatingCache", "getCommandCache", "(", "final", "CommandImpl", "cmd", ")", "{", "SelfPopulatingCache", "cache", "=", "null", ";", "if", "(", "cmd", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATE_NAME", ")", ")", "{", "cache", "=", "stateCache", ".", "getCache", "(", ")", ";", "}", "else", "if", "(", "cmd", ".", "getName", "(", ")", ".", "equalsIgnoreCase", "(", "DeviceImpl", ".", "STATUS_NAME", ")", ")", "{", "cache", "=", "statusCache", ".", "getCache", "(", ")", ";", "}", "else", "{", "CommandCache", "cmdCache", "=", "commandCacheMap", ".", "get", "(", "cmd", ")", ";", "if", "(", "cmdCache", "==", "null", ")", "{", "cmdCache", "=", "extTrigCommandCacheMap", ".", "get", "(", "cmd", ")", ";", "}", "cache", "=", "cmdCache", ".", "getCache", "(", ")", ";", "}", "return", "cache", ";", "}" ]
Get cache of a command @param cmd The command @return The command cache
[ "Get", "cache", "of", "a", "command" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/TangoCacheManager.java#L421-L435
140,411
tango-controls/JTango
server/src/main/java/org/tango/server/Chronometer.java
Chronometer.isOver
public boolean isOver() { if (!isOver) { final long now = System.currentTimeMillis(); isOver = now - startTime >= duration; } return isOver; }
java
public boolean isOver() { if (!isOver) { final long now = System.currentTimeMillis(); isOver = now - startTime >= duration; } return isOver; }
[ "public", "boolean", "isOver", "(", ")", "{", "if", "(", "!", "isOver", ")", "{", "final", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "isOver", "=", "now", "-", "startTime", ">=", "duration", ";", "}", "return", "isOver", ";", "}" ]
Check if the started duration is over @return true if over
[ "Check", "if", "the", "started", "duration", "is", "over" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/Chronometer.java#L79-L85
140,412
tango-controls/JTango
server/src/main/java/org/tango/server/properties/AttributePropertiesManager.java
AttributePropertiesManager.getAttributePropertyFromDB
public String getAttributePropertyFromDB(final String attributeName, final String propertyName) throws DevFailed { xlogger.entry(propertyName); String[] result = new String[] {}; final Map<String, String[]> prop = DatabaseFactory.getDatabase().getAttributeProperties(deviceName, attributeName); if (prop.get(propertyName) != null) { // get value result = prop.get(propertyName); logger.debug(attributeName + " property {} is {}", propertyName, Arrays.toString(result)); } xlogger.exit(); String single = ""; if (result.length == 1 && !result[0].isEmpty()) { single = result[0]; } return single; }
java
public String getAttributePropertyFromDB(final String attributeName, final String propertyName) throws DevFailed { xlogger.entry(propertyName); String[] result = new String[] {}; final Map<String, String[]> prop = DatabaseFactory.getDatabase().getAttributeProperties(deviceName, attributeName); if (prop.get(propertyName) != null) { // get value result = prop.get(propertyName); logger.debug(attributeName + " property {} is {}", propertyName, Arrays.toString(result)); } xlogger.exit(); String single = ""; if (result.length == 1 && !result[0].isEmpty()) { single = result[0]; } return single; }
[ "public", "String", "getAttributePropertyFromDB", "(", "final", "String", "attributeName", ",", "final", "String", "propertyName", ")", "throws", "DevFailed", "{", "xlogger", ".", "entry", "(", "propertyName", ")", ";", "String", "[", "]", "result", "=", "new", "String", "[", "]", "{", "}", ";", "final", "Map", "<", "String", ",", "String", "[", "]", ">", "prop", "=", "DatabaseFactory", ".", "getDatabase", "(", ")", ".", "getAttributeProperties", "(", "deviceName", ",", "attributeName", ")", ";", "if", "(", "prop", ".", "get", "(", "propertyName", ")", "!=", "null", ")", "{", "// get value", "result", "=", "prop", ".", "get", "(", "propertyName", ")", ";", "logger", ".", "debug", "(", "attributeName", "+", "\" property {} is {}\"", ",", "propertyName", ",", "Arrays", ".", "toString", "(", "result", ")", ")", ";", "}", "xlogger", ".", "exit", "(", ")", ";", "String", "single", "=", "\"\"", ";", "if", "(", "result", ".", "length", "==", "1", "&&", "!", "result", "[", "0", "]", ".", "isEmpty", "(", ")", ")", "{", "single", "=", "result", "[", "0", "]", ";", "}", "return", "single", ";", "}" ]
Get an attribute property from tango db @param attributeName @param propertyName @return The property @throws DevFailed
[ "Get", "an", "attribute", "property", "from", "tango", "db" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/properties/AttributePropertiesManager.java#L108-L124
140,413
tango-controls/JTango
server/src/main/java/org/tango/server/properties/AttributePropertiesManager.java
AttributePropertiesManager.setAttributePropertyInDB
public void setAttributePropertyInDB(final String attributeName, final String propertyName, final String value) throws DevFailed { xlogger.entry(propertyName); // insert value in db only if input value is different and not a // default value // if (checkCurrentValue) { // final String presentValue = getAttributePropertyFromDB(attributeName, propertyName); // final boolean isADefaultValue = presentValue.isEmpty() // && (value.equalsIgnoreCase(AttributePropertiesImpl.NOT_SPECIFIED) // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_DIPLAY_UNIT) // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_UNIT) || value // .equalsIgnoreCase(AttributePropertiesImpl.NO_STD_UNIT)); // if (!isADefaultValue && !presentValue.equals(value) && !value.isEmpty() && !value.equals("NaN")) { // LOGGER.debug("update in DB {}, property {}= {}", new Object[] { attributeName, propertyName, value }); // final Map<String, String[]> propInsert = new HashMap<String, String[]>(); // propInsert.put(propertyName, new String[] { value }); // DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert); // } // } else { logger.debug("update in DB {}, property {}= {}", new Object[] { attributeName, propertyName, value }); final Map<String, String[]> propInsert = new HashMap<String, String[]>(); propInsert.put(propertyName, new String[] { value }); DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert); // } xlogger.exit(); }
java
public void setAttributePropertyInDB(final String attributeName, final String propertyName, final String value) throws DevFailed { xlogger.entry(propertyName); // insert value in db only if input value is different and not a // default value // if (checkCurrentValue) { // final String presentValue = getAttributePropertyFromDB(attributeName, propertyName); // final boolean isADefaultValue = presentValue.isEmpty() // && (value.equalsIgnoreCase(AttributePropertiesImpl.NOT_SPECIFIED) // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_DIPLAY_UNIT) // || value.equalsIgnoreCase(AttributePropertiesImpl.NO_UNIT) || value // .equalsIgnoreCase(AttributePropertiesImpl.NO_STD_UNIT)); // if (!isADefaultValue && !presentValue.equals(value) && !value.isEmpty() && !value.equals("NaN")) { // LOGGER.debug("update in DB {}, property {}= {}", new Object[] { attributeName, propertyName, value }); // final Map<String, String[]> propInsert = new HashMap<String, String[]>(); // propInsert.put(propertyName, new String[] { value }); // DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert); // } // } else { logger.debug("update in DB {}, property {}= {}", new Object[] { attributeName, propertyName, value }); final Map<String, String[]> propInsert = new HashMap<String, String[]>(); propInsert.put(propertyName, new String[] { value }); DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert); // } xlogger.exit(); }
[ "public", "void", "setAttributePropertyInDB", "(", "final", "String", "attributeName", ",", "final", "String", "propertyName", ",", "final", "String", "value", ")", "throws", "DevFailed", "{", "xlogger", ".", "entry", "(", "propertyName", ")", ";", "// insert value in db only if input value is different and not a", "// default value", "// if (checkCurrentValue) {", "// final String presentValue = getAttributePropertyFromDB(attributeName, propertyName);", "// final boolean isADefaultValue = presentValue.isEmpty()", "// && (value.equalsIgnoreCase(AttributePropertiesImpl.NOT_SPECIFIED)", "// || value.equalsIgnoreCase(AttributePropertiesImpl.NO_DIPLAY_UNIT)", "// || value.equalsIgnoreCase(AttributePropertiesImpl.NO_UNIT) || value", "// .equalsIgnoreCase(AttributePropertiesImpl.NO_STD_UNIT));", "// if (!isADefaultValue && !presentValue.equals(value) && !value.isEmpty() && !value.equals(\"NaN\")) {", "// LOGGER.debug(\"update in DB {}, property {}= {}\", new Object[] { attributeName, propertyName, value });", "// final Map<String, String[]> propInsert = new HashMap<String, String[]>();", "// propInsert.put(propertyName, new String[] { value });", "// DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert);", "// }", "// } else {", "logger", ".", "debug", "(", "\"update in DB {}, property {}= {}\"", ",", "new", "Object", "[", "]", "{", "attributeName", ",", "propertyName", ",", "value", "}", ")", ";", "final", "Map", "<", "String", ",", "String", "[", "]", ">", "propInsert", "=", "new", "HashMap", "<", "String", ",", "String", "[", "]", ">", "(", ")", ";", "propInsert", ".", "put", "(", "propertyName", ",", "new", "String", "[", "]", "{", "value", "}", ")", ";", "DatabaseFactory", ".", "getDatabase", "(", ")", ".", "setAttributeProperties", "(", "deviceName", ",", "attributeName", ",", "propInsert", ")", ";", "// }", "xlogger", ".", "exit", "(", ")", ";", "}" ]
Set attribute property in tango db @param attributeName @param propertyName @param value @throws DevFailed
[ "Set", "attribute", "property", "in", "tango", "db" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/properties/AttributePropertiesManager.java#L134-L160
140,414
tango-controls/JTango
server/src/main/java/org/tango/server/properties/AttributePropertiesManager.java
AttributePropertiesManager.setAttributePropertiesInDB
public void setAttributePropertiesInDB(final String attributeName, final Map<String, String[]> properties) throws DevFailed { xlogger.entry(properties); final Map<String, String> currentValues = getAttributePropertiesFromDBSingle(attributeName); final Map<String, String[]> propInsert = new HashMap<String, String[]>(); for (final Entry<String, String[]> entry : properties.entrySet()) { final String propertyName = entry.getKey(); final String[] valueArray = entry.getValue(); // insert value in db only if input value is different and not a // default value if (valueArray.length == 1) { final String value = valueArray[0]; final String presentValue = currentValues.get(propertyName); boolean isADefaultValue = false; if (presentValue != null) { isADefaultValue = presentValue.isEmpty() && (value.equalsIgnoreCase(Constants.NOT_SPECIFIED) || value.equalsIgnoreCase(Constants.NO_DIPLAY_UNIT) || value.equalsIgnoreCase(Constants.NO_UNIT) || value .equalsIgnoreCase(Constants.NO_STD_UNIT)); } if (!isADefaultValue) { if (presentValue == null) { propInsert.put(propertyName, valueArray); } else if (!presentValue.equals(value) && !value.isEmpty() && !value.equals("NaN")) { propInsert.put(propertyName, valueArray); } } } else { // do not check if not a single value propInsert.put(propertyName, valueArray); } } logger.debug("update attribute {} properties {} in DB ", attributeName, properties.keySet()); DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert); xlogger.exit(); }
java
public void setAttributePropertiesInDB(final String attributeName, final Map<String, String[]> properties) throws DevFailed { xlogger.entry(properties); final Map<String, String> currentValues = getAttributePropertiesFromDBSingle(attributeName); final Map<String, String[]> propInsert = new HashMap<String, String[]>(); for (final Entry<String, String[]> entry : properties.entrySet()) { final String propertyName = entry.getKey(); final String[] valueArray = entry.getValue(); // insert value in db only if input value is different and not a // default value if (valueArray.length == 1) { final String value = valueArray[0]; final String presentValue = currentValues.get(propertyName); boolean isADefaultValue = false; if (presentValue != null) { isADefaultValue = presentValue.isEmpty() && (value.equalsIgnoreCase(Constants.NOT_SPECIFIED) || value.equalsIgnoreCase(Constants.NO_DIPLAY_UNIT) || value.equalsIgnoreCase(Constants.NO_UNIT) || value .equalsIgnoreCase(Constants.NO_STD_UNIT)); } if (!isADefaultValue) { if (presentValue == null) { propInsert.put(propertyName, valueArray); } else if (!presentValue.equals(value) && !value.isEmpty() && !value.equals("NaN")) { propInsert.put(propertyName, valueArray); } } } else { // do not check if not a single value propInsert.put(propertyName, valueArray); } } logger.debug("update attribute {} properties {} in DB ", attributeName, properties.keySet()); DatabaseFactory.getDatabase().setAttributeProperties(deviceName, attributeName, propInsert); xlogger.exit(); }
[ "public", "void", "setAttributePropertiesInDB", "(", "final", "String", "attributeName", ",", "final", "Map", "<", "String", ",", "String", "[", "]", ">", "properties", ")", "throws", "DevFailed", "{", "xlogger", ".", "entry", "(", "properties", ")", ";", "final", "Map", "<", "String", ",", "String", ">", "currentValues", "=", "getAttributePropertiesFromDBSingle", "(", "attributeName", ")", ";", "final", "Map", "<", "String", ",", "String", "[", "]", ">", "propInsert", "=", "new", "HashMap", "<", "String", ",", "String", "[", "]", ">", "(", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "String", "[", "]", ">", "entry", ":", "properties", ".", "entrySet", "(", ")", ")", "{", "final", "String", "propertyName", "=", "entry", ".", "getKey", "(", ")", ";", "final", "String", "[", "]", "valueArray", "=", "entry", ".", "getValue", "(", ")", ";", "// insert value in db only if input value is different and not a", "// default value", "if", "(", "valueArray", ".", "length", "==", "1", ")", "{", "final", "String", "value", "=", "valueArray", "[", "0", "]", ";", "final", "String", "presentValue", "=", "currentValues", ".", "get", "(", "propertyName", ")", ";", "boolean", "isADefaultValue", "=", "false", ";", "if", "(", "presentValue", "!=", "null", ")", "{", "isADefaultValue", "=", "presentValue", ".", "isEmpty", "(", ")", "&&", "(", "value", ".", "equalsIgnoreCase", "(", "Constants", ".", "NOT_SPECIFIED", ")", "||", "value", ".", "equalsIgnoreCase", "(", "Constants", ".", "NO_DIPLAY_UNIT", ")", "||", "value", ".", "equalsIgnoreCase", "(", "Constants", ".", "NO_UNIT", ")", "||", "value", ".", "equalsIgnoreCase", "(", "Constants", ".", "NO_STD_UNIT", ")", ")", ";", "}", "if", "(", "!", "isADefaultValue", ")", "{", "if", "(", "presentValue", "==", "null", ")", "{", "propInsert", ".", "put", "(", "propertyName", ",", "valueArray", ")", ";", "}", "else", "if", "(", "!", "presentValue", ".", "equals", "(", "value", ")", "&&", "!", "value", ".", "isEmpty", "(", ")", "&&", "!", "value", ".", "equals", "(", "\"NaN\"", ")", ")", "{", "propInsert", ".", "put", "(", "propertyName", ",", "valueArray", ")", ";", "}", "}", "}", "else", "{", "// do not check if not a single value", "propInsert", ".", "put", "(", "propertyName", ",", "valueArray", ")", ";", "}", "}", "logger", ".", "debug", "(", "\"update attribute {} properties {} in DB \"", ",", "attributeName", ",", "properties", ".", "keySet", "(", ")", ")", ";", "DatabaseFactory", ".", "getDatabase", "(", ")", ".", "setAttributeProperties", "(", "deviceName", ",", "attributeName", ",", "propInsert", ")", ";", "xlogger", ".", "exit", "(", ")", ";", "}" ]
Set attribute properties in tango db @param attributeName @param properties @throws DevFailed
[ "Set", "attribute", "properties", "in", "tango", "db" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/properties/AttributePropertiesManager.java#L169-L206
140,415
tango-controls/JTango
common/src/main/java/fr/esrf/Tango/factory/TangoFactory.java
TangoFactory.getPropertiesFile
private static Properties getPropertiesFile() { try { // We use the class loader to load the properties file. // This compatible with unix and windows. final InputStream stream = TangoFactory.class.getClassLoader().getResourceAsStream( FACTORY_PROPERTIES); final Properties properties = new Properties(); // We read the data in the properties file. if (stream != null) { // We need to use a Buffered Input Stream to load the datas final BufferedInputStream bufStream = new BufferedInputStream(stream); properties.clear(); properties.load(bufStream); } return properties; } catch (final Exception e) { e.printStackTrace(); return null; } }
java
private static Properties getPropertiesFile() { try { // We use the class loader to load the properties file. // This compatible with unix and windows. final InputStream stream = TangoFactory.class.getClassLoader().getResourceAsStream( FACTORY_PROPERTIES); final Properties properties = new Properties(); // We read the data in the properties file. if (stream != null) { // We need to use a Buffered Input Stream to load the datas final BufferedInputStream bufStream = new BufferedInputStream(stream); properties.clear(); properties.load(bufStream); } return properties; } catch (final Exception e) { e.printStackTrace(); return null; } }
[ "private", "static", "Properties", "getPropertiesFile", "(", ")", "{", "try", "{", "// We use the class loader to load the properties file.", "// This compatible with unix and windows.", "final", "InputStream", "stream", "=", "TangoFactory", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "FACTORY_PROPERTIES", ")", ";", "final", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "// We read the data in the properties file.", "if", "(", "stream", "!=", "null", ")", "{", "// We need to use a Buffered Input Stream to load the datas", "final", "BufferedInputStream", "bufStream", "=", "new", "BufferedInputStream", "(", "stream", ")", ";", "properties", ".", "clear", "(", ")", ";", "properties", ".", "load", "(", "bufStream", ")", ";", "}", "return", "properties", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
We get the properties file which contains default properties @return Properties
[ "We", "get", "the", "properties", "file", "which", "contains", "default", "properties" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/Tango/factory/TangoFactory.java#L84-L105
140,416
tango-controls/JTango
common/src/main/java/fr/esrf/Tango/factory/TangoFactory.java
TangoFactory.getObject
private static Object getObject(final String className) { try { // we get the class coresponding to the life cycle name final Class<?> clazz = Class.forName(className); // we get the default constructor (with no parameter) final Constructor<?> contructor = clazz.getConstructor(new Class[]{}); // we create an instance of the class using the constructor return contructor.newInstance(new Object[]{}); } catch (final Exception e) { e.printStackTrace(); } return null; }
java
private static Object getObject(final String className) { try { // we get the class coresponding to the life cycle name final Class<?> clazz = Class.forName(className); // we get the default constructor (with no parameter) final Constructor<?> contructor = clazz.getConstructor(new Class[]{}); // we create an instance of the class using the constructor return contructor.newInstance(new Object[]{}); } catch (final Exception e) { e.printStackTrace(); } return null; }
[ "private", "static", "Object", "getObject", "(", "final", "String", "className", ")", "{", "try", "{", "// we get the class coresponding to the life cycle name", "final", "Class", "<", "?", ">", "clazz", "=", "Class", ".", "forName", "(", "className", ")", ";", "// we get the default constructor (with no parameter)", "final", "Constructor", "<", "?", ">", "contructor", "=", "clazz", ".", "getConstructor", "(", "new", "Class", "[", "]", "{", "}", ")", ";", "// we create an instance of the class using the constructor", "return", "contructor", ".", "newInstance", "(", "new", "Object", "[", "]", "{", "}", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "null", ";", "}" ]
We instanciate the Component @param className @return Object
[ "We", "instanciate", "the", "Component" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/Tango/factory/TangoFactory.java#L113-L128
140,417
tango-controls/JTango
common/src/main/java/fr/esrf/Tango/factory/TangoFactory.java
TangoFactory.initTangoFactory
private void initTangoFactory() { // we get the properties with instance of objects final Properties properties = getPropertiesFile(); // if(properties == null || properties.size() == 0 || // !properties.containsKey(TANGO_FACTORY)) // { // //tangoFactory = new DefaultTangoFactoryImpl(); // //TANGO_FACTORY = fr.esrf.TangoApi.factory.WebTangoFactoryImpl // // tangoFactory = (ITangoFactory)getObject(""); // isDefaultFactory = false; // } // else // { String factoryClassName = properties.getProperty(TANGO_FACTORY); if (factoryClassName == null) { factoryClassName = "fr.esrf.TangoApi.factory.DefaultTangoFactoryImpl"; } //System.out.println("TANGO_FACTORY " + factoryClassName); tangoFactory = (ITangoFactory) getObject(factoryClassName); isDefaultFactory = false; // } }
java
private void initTangoFactory() { // we get the properties with instance of objects final Properties properties = getPropertiesFile(); // if(properties == null || properties.size() == 0 || // !properties.containsKey(TANGO_FACTORY)) // { // //tangoFactory = new DefaultTangoFactoryImpl(); // //TANGO_FACTORY = fr.esrf.TangoApi.factory.WebTangoFactoryImpl // // tangoFactory = (ITangoFactory)getObject(""); // isDefaultFactory = false; // } // else // { String factoryClassName = properties.getProperty(TANGO_FACTORY); if (factoryClassName == null) { factoryClassName = "fr.esrf.TangoApi.factory.DefaultTangoFactoryImpl"; } //System.out.println("TANGO_FACTORY " + factoryClassName); tangoFactory = (ITangoFactory) getObject(factoryClassName); isDefaultFactory = false; // } }
[ "private", "void", "initTangoFactory", "(", ")", "{", "// we get the properties with instance of objects", "final", "Properties", "properties", "=", "getPropertiesFile", "(", ")", ";", "// if(properties == null || properties.size() == 0 ||", "// !properties.containsKey(TANGO_FACTORY))", "// {", "// //tangoFactory = new DefaultTangoFactoryImpl();", "// //TANGO_FACTORY = fr.esrf.TangoApi.factory.WebTangoFactoryImpl", "//", "// tangoFactory = (ITangoFactory)getObject(\"\");", "// isDefaultFactory = false;", "// }", "// else", "// {", "String", "factoryClassName", "=", "properties", ".", "getProperty", "(", "TANGO_FACTORY", ")", ";", "if", "(", "factoryClassName", "==", "null", ")", "{", "factoryClassName", "=", "\"fr.esrf.TangoApi.factory.DefaultTangoFactoryImpl\"", ";", "}", "//System.out.println(\"TANGO_FACTORY \" + factoryClassName);", "tangoFactory", "=", "(", "ITangoFactory", ")", "getObject", "(", "factoryClassName", ")", ";", "isDefaultFactory", "=", "false", ";", "// }", "}" ]
Load properties with impl specification and create instances
[ "Load", "properties", "with", "impl", "specification", "and", "create", "instances" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/Tango/factory/TangoFactory.java#L134-L157
140,418
tango-controls/JTango
common/src/main/java/org/tango/utils/DevFailedUtils.java
DevFailedUtils.logDevFailed
public static void logDevFailed(final DevFailed e, final Logger logger) { if (e.errors != null) { for (int i = 0; i < e.errors.length; i++) { logger.error("Error Level {} :", i); logger.error("\t - desc: {}", e.errors[i].desc); logger.error("\t - origin: {}", e.errors[i].origin); logger.error("\t - reason: {}", e.errors[i].reason); String sev = ""; if (e.errors[i].severity.value() == ErrSeverity.ERR.value()) { sev = "ERROR"; } else if (e.errors[i].severity.value() == ErrSeverity.PANIC.value()) { sev = "PANIC"; } else if (e.errors[i].severity.value() == ErrSeverity.WARN.value()) { sev = "WARN"; } logger.error("\t - severity: {}", sev); } } else { logger.error("EMPTY DevFailed"); } }
java
public static void logDevFailed(final DevFailed e, final Logger logger) { if (e.errors != null) { for (int i = 0; i < e.errors.length; i++) { logger.error("Error Level {} :", i); logger.error("\t - desc: {}", e.errors[i].desc); logger.error("\t - origin: {}", e.errors[i].origin); logger.error("\t - reason: {}", e.errors[i].reason); String sev = ""; if (e.errors[i].severity.value() == ErrSeverity.ERR.value()) { sev = "ERROR"; } else if (e.errors[i].severity.value() == ErrSeverity.PANIC.value()) { sev = "PANIC"; } else if (e.errors[i].severity.value() == ErrSeverity.WARN.value()) { sev = "WARN"; } logger.error("\t - severity: {}", sev); } } else { logger.error("EMPTY DevFailed"); } }
[ "public", "static", "void", "logDevFailed", "(", "final", "DevFailed", "e", ",", "final", "Logger", "logger", ")", "{", "if", "(", "e", ".", "errors", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "e", ".", "errors", ".", "length", ";", "i", "++", ")", "{", "logger", ".", "error", "(", "\"Error Level {} :\"", ",", "i", ")", ";", "logger", ".", "error", "(", "\"\\t - desc: {}\"", ",", "e", ".", "errors", "[", "i", "]", ".", "desc", ")", ";", "logger", ".", "error", "(", "\"\\t - origin: {}\"", ",", "e", ".", "errors", "[", "i", "]", ".", "origin", ")", ";", "logger", ".", "error", "(", "\"\\t - reason: {}\"", ",", "e", ".", "errors", "[", "i", "]", ".", "reason", ")", ";", "String", "sev", "=", "\"\"", ";", "if", "(", "e", ".", "errors", "[", "i", "]", ".", "severity", ".", "value", "(", ")", "==", "ErrSeverity", ".", "ERR", ".", "value", "(", ")", ")", "{", "sev", "=", "\"ERROR\"", ";", "}", "else", "if", "(", "e", ".", "errors", "[", "i", "]", ".", "severity", ".", "value", "(", ")", "==", "ErrSeverity", ".", "PANIC", ".", "value", "(", ")", ")", "{", "sev", "=", "\"PANIC\"", ";", "}", "else", "if", "(", "e", ".", "errors", "[", "i", "]", ".", "severity", ".", "value", "(", ")", "==", "ErrSeverity", ".", "WARN", ".", "value", "(", ")", ")", "{", "sev", "=", "\"WARN\"", ";", "}", "logger", ".", "error", "(", "\"\\t - severity: {}\"", ",", "sev", ")", ";", "}", "}", "else", "{", "logger", ".", "error", "(", "\"EMPTY DevFailed\"", ")", ";", "}", "}" ]
Convert a DevFailed to a String @param e @return
[ "Convert", "a", "DevFailed", "to", "a", "String" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/org/tango/utils/DevFailedUtils.java#L124-L144
140,419
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoDs/Attribute.java
Attribute.get_properties
public void get_properties(AttributeConfig conf) { // // Copy mandatory properties // conf.writable = writable; conf.data_format = data_format; conf.max_dim_x = max_x; conf.max_dim_y = max_y; conf.data_type = data_type; conf.name = name; // // Copy optional properties // conf.label = label; conf.description = description; conf.unit = unit; conf.standard_unit = standard_unit; conf.display_unit = display_unit; conf.format = format; conf.writable_attr_name = writable_attr_name; conf.min_alarm = min_alarm_str; conf.max_alarm = max_alarm_str; conf.min_value = min_value_str; conf.max_value = max_value_str; // // No extension nowdays // conf.extensions = new String[0]; }
java
public void get_properties(AttributeConfig conf) { // // Copy mandatory properties // conf.writable = writable; conf.data_format = data_format; conf.max_dim_x = max_x; conf.max_dim_y = max_y; conf.data_type = data_type; conf.name = name; // // Copy optional properties // conf.label = label; conf.description = description; conf.unit = unit; conf.standard_unit = standard_unit; conf.display_unit = display_unit; conf.format = format; conf.writable_attr_name = writable_attr_name; conf.min_alarm = min_alarm_str; conf.max_alarm = max_alarm_str; conf.min_value = min_value_str; conf.max_value = max_value_str; // // No extension nowdays // conf.extensions = new String[0]; }
[ "public", "void", "get_properties", "(", "AttributeConfig", "conf", ")", "{", "//", "// Copy mandatory properties", "//", "conf", ".", "writable", "=", "writable", ";", "conf", ".", "data_format", "=", "data_format", ";", "conf", ".", "max_dim_x", "=", "max_x", ";", "conf", ".", "max_dim_y", "=", "max_y", ";", "conf", ".", "data_type", "=", "data_type", ";", "conf", ".", "name", "=", "name", ";", "//", "// Copy optional properties", "//", "conf", ".", "label", "=", "label", ";", "conf", ".", "description", "=", "description", ";", "conf", ".", "unit", "=", "unit", ";", "conf", ".", "standard_unit", "=", "standard_unit", ";", "conf", ".", "display_unit", "=", "display_unit", ";", "conf", ".", "format", "=", "format", ";", "conf", ".", "writable_attr_name", "=", "writable_attr_name", ";", "conf", ".", "min_alarm", "=", "min_alarm_str", ";", "conf", ".", "max_alarm", "=", "max_alarm_str", ";", "conf", ".", "min_value", "=", "min_value_str", ";", "conf", ".", "max_value", "=", "max_value_str", ";", "//", "// No extension nowdays", "//", "conf", ".", "extensions", "=", "new", "String", "[", "0", "]", ";", "}" ]
Get attribute properties. This method initialise the fields of a AttributeConfig object with the attribute properties value @param conf A AttributeConfig object.
[ "Get", "attribute", "properties", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/Attribute.java#L686-L721
140,420
tango-controls/JTango
common/src/main/java/fr/esrf/TangoApi/DbHistory.java
DbHistory.formatValue
private String formatValue(String[] value) { String ret = ""; for(int i=0;i<value.length;i++) { ret += value[i]; if(i<value.length-1) ret+="\n"; } return ret; }
java
private String formatValue(String[] value) { String ret = ""; for(int i=0;i<value.length;i++) { ret += value[i]; if(i<value.length-1) ret+="\n"; } return ret; }
[ "private", "String", "formatValue", "(", "String", "[", "]", "value", ")", "{", "String", "ret", "=", "\"\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "value", ".", "length", ";", "i", "++", ")", "{", "ret", "+=", "value", "[", "i", "]", ";", "if", "(", "i", "<", "value", ".", "length", "-", "1", ")", "ret", "+=", "\"\\n\"", ";", "}", "return", "ret", ";", "}" ]
Format the value in one string by adding "\n" after each string. @param value value to convert.
[ "Format", "the", "value", "in", "one", "string", "by", "adding", "\\", "n", "after", "each", "string", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/TangoApi/DbHistory.java#L121-L130
140,421
tango-controls/JTango
server/src/main/java/org/tango/server/dynamic/command/GroupCommand.java
GroupCommand.execute
@Override public Object execute(final Object arg) throws DevFailed { errorReportMap.clear(); String tmpReplyName = ""; boolean hasFailed = false; final List<DevError[]> errors = new ArrayList<DevError[]>(); int size = 0; final DeviceData argin = new DeviceData(); InsertExtractUtils.insert(argin, config.getInTangoType(), arg); final GroupCmdReplyList tmpReplyList = group.command_inout(name, argin, true); for (final Object tmpReply : tmpReplyList) { tmpReplyName = ((GroupReply) tmpReply).dev_name(); LOGGER.debug("getting answer for {}", tmpReplyName); try { ((GroupCmdReply) tmpReply).get_data(); } catch (final DevFailed e) { LOGGER.error("command failed on {}/{} - {}", new Object[] { tmpReplyName, name, DevFailedUtils.toString(e) }); hasFailed = true; errors.add(e.errors); size = +e.errors.length; errorReportMap.put(tmpReplyName, dateFormat.format(new Date()) + " : " + name + " result " + DevFailedUtils.toString(e)); } } if (hasFailed) { final DevError[] totalErrors = new DevError[errors.size() * size + 1]; totalErrors[0] = new DevError("CONNECTION_ERROR", ErrSeverity.ERR, "cannot execute command ", this .getClass().getCanonicalName() + ".executeCommand(" + name + ")"); int i = 1; for (final DevError[] devErrors : errors) { for (final DevError devError : devErrors) { totalErrors[i++] = devError; } } throw new DevFailed(totalErrors); } return null; }
java
@Override public Object execute(final Object arg) throws DevFailed { errorReportMap.clear(); String tmpReplyName = ""; boolean hasFailed = false; final List<DevError[]> errors = new ArrayList<DevError[]>(); int size = 0; final DeviceData argin = new DeviceData(); InsertExtractUtils.insert(argin, config.getInTangoType(), arg); final GroupCmdReplyList tmpReplyList = group.command_inout(name, argin, true); for (final Object tmpReply : tmpReplyList) { tmpReplyName = ((GroupReply) tmpReply).dev_name(); LOGGER.debug("getting answer for {}", tmpReplyName); try { ((GroupCmdReply) tmpReply).get_data(); } catch (final DevFailed e) { LOGGER.error("command failed on {}/{} - {}", new Object[] { tmpReplyName, name, DevFailedUtils.toString(e) }); hasFailed = true; errors.add(e.errors); size = +e.errors.length; errorReportMap.put(tmpReplyName, dateFormat.format(new Date()) + " : " + name + " result " + DevFailedUtils.toString(e)); } } if (hasFailed) { final DevError[] totalErrors = new DevError[errors.size() * size + 1]; totalErrors[0] = new DevError("CONNECTION_ERROR", ErrSeverity.ERR, "cannot execute command ", this .getClass().getCanonicalName() + ".executeCommand(" + name + ")"); int i = 1; for (final DevError[] devErrors : errors) { for (final DevError devError : devErrors) { totalErrors[i++] = devError; } } throw new DevFailed(totalErrors); } return null; }
[ "@", "Override", "public", "Object", "execute", "(", "final", "Object", "arg", ")", "throws", "DevFailed", "{", "errorReportMap", ".", "clear", "(", ")", ";", "String", "tmpReplyName", "=", "\"\"", ";", "boolean", "hasFailed", "=", "false", ";", "final", "List", "<", "DevError", "[", "]", ">", "errors", "=", "new", "ArrayList", "<", "DevError", "[", "]", ">", "(", ")", ";", "int", "size", "=", "0", ";", "final", "DeviceData", "argin", "=", "new", "DeviceData", "(", ")", ";", "InsertExtractUtils", ".", "insert", "(", "argin", ",", "config", ".", "getInTangoType", "(", ")", ",", "arg", ")", ";", "final", "GroupCmdReplyList", "tmpReplyList", "=", "group", ".", "command_inout", "(", "name", ",", "argin", ",", "true", ")", ";", "for", "(", "final", "Object", "tmpReply", ":", "tmpReplyList", ")", "{", "tmpReplyName", "=", "(", "(", "GroupReply", ")", "tmpReply", ")", ".", "dev_name", "(", ")", ";", "LOGGER", ".", "debug", "(", "\"getting answer for {}\"", ",", "tmpReplyName", ")", ";", "try", "{", "(", "(", "GroupCmdReply", ")", "tmpReply", ")", ".", "get_data", "(", ")", ";", "}", "catch", "(", "final", "DevFailed", "e", ")", "{", "LOGGER", ".", "error", "(", "\"command failed on {}/{} - {}\"", ",", "new", "Object", "[", "]", "{", "tmpReplyName", ",", "name", ",", "DevFailedUtils", ".", "toString", "(", "e", ")", "}", ")", ";", "hasFailed", "=", "true", ";", "errors", ".", "add", "(", "e", ".", "errors", ")", ";", "size", "=", "+", "e", ".", "errors", ".", "length", ";", "errorReportMap", ".", "put", "(", "tmpReplyName", ",", "dateFormat", ".", "format", "(", "new", "Date", "(", ")", ")", "+", "\" : \"", "+", "name", "+", "\" result \"", "+", "DevFailedUtils", ".", "toString", "(", "e", ")", ")", ";", "}", "}", "if", "(", "hasFailed", ")", "{", "final", "DevError", "[", "]", "totalErrors", "=", "new", "DevError", "[", "errors", ".", "size", "(", ")", "*", "size", "+", "1", "]", ";", "totalErrors", "[", "0", "]", "=", "new", "DevError", "(", "\"CONNECTION_ERROR\"", ",", "ErrSeverity", ".", "ERR", ",", "\"cannot execute command \"", ",", "this", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", "+", "\".executeCommand(\"", "+", "name", "+", "\")\"", ")", ";", "int", "i", "=", "1", ";", "for", "(", "final", "DevError", "[", "]", "devErrors", ":", "errors", ")", "{", "for", "(", "final", "DevError", "devError", ":", "devErrors", ")", "{", "totalErrors", "[", "i", "++", "]", "=", "devError", ";", "}", "}", "throw", "new", "DevFailed", "(", "totalErrors", ")", ";", "}", "return", "null", ";", "}" ]
execute all commands and read back all errors
[ "execute", "all", "commands", "and", "read", "back", "all", "errors" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/dynamic/command/GroupCommand.java#L113-L154
140,422
tango-controls/JTango
server/src/main/java/org/tango/server/events/EventUtilities.java
EventUtilities.cppAlignmentAdd8
static byte[] cppAlignmentAdd8(final byte[] data) { XLOGGER.entry(); final byte[] buffer = new byte[data.length + 8]; buffer[0] = (byte) 0xc0; buffer[1] = (byte) 0xde; buffer[2] = (byte) 0xc0; buffer[3] = (byte) 0xde; buffer[4] = (byte) 0xc0; buffer[5] = (byte) 0xde; buffer[6] = (byte) 0xc0; buffer[7] = (byte) 0xde; System.arraycopy(data, 0, buffer, 8, data.length); XLOGGER.exit(); return buffer; }
java
static byte[] cppAlignmentAdd8(final byte[] data) { XLOGGER.entry(); final byte[] buffer = new byte[data.length + 8]; buffer[0] = (byte) 0xc0; buffer[1] = (byte) 0xde; buffer[2] = (byte) 0xc0; buffer[3] = (byte) 0xde; buffer[4] = (byte) 0xc0; buffer[5] = (byte) 0xde; buffer[6] = (byte) 0xc0; buffer[7] = (byte) 0xde; System.arraycopy(data, 0, buffer, 8, data.length); XLOGGER.exit(); return buffer; }
[ "static", "byte", "[", "]", "cppAlignmentAdd8", "(", "final", "byte", "[", "]", "data", ")", "{", "XLOGGER", ".", "entry", "(", ")", ";", "final", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "data", ".", "length", "+", "8", "]", ";", "buffer", "[", "0", "]", "=", "(", "byte", ")", "0xc0", ";", "buffer", "[", "1", "]", "=", "(", "byte", ")", "0xde", ";", "buffer", "[", "2", "]", "=", "(", "byte", ")", "0xc0", ";", "buffer", "[", "3", "]", "=", "(", "byte", ")", "0xde", ";", "buffer", "[", "4", "]", "=", "(", "byte", ")", "0xc0", ";", "buffer", "[", "5", "]", "=", "(", "byte", ")", "0xde", ";", "buffer", "[", "6", "]", "=", "(", "byte", ")", "0xc0", ";", "buffer", "[", "7", "]", "=", "(", "byte", ")", "0xde", ";", "System", ".", "arraycopy", "(", "data", ",", "0", ",", "buffer", ",", "8", ",", "data", ".", "length", ")", ";", "XLOGGER", ".", "exit", "(", ")", ";", "return", "buffer", ";", "}" ]
Add 8 bytes at beginning for C++ alignment @param data buffer to be aligned @return buffer after c++ alignment.
[ "Add", "8", "bytes", "at", "beginning", "for", "C", "++", "alignment" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/events/EventUtilities.java#L137-L151
140,423
tango-controls/JTango
server/src/main/java/org/tango/server/events/EventUtilities.java
EventUtilities.marshall
static byte[] marshall(final DevFailed devFailed) throws DevFailed { XLOGGER.entry(); final CDROutputStream os = new CDROutputStream(); try { DevErrorListHelper.write(os, devFailed.errors); XLOGGER.exit(); return cppAlignment(os.getBufferCopy()); } finally { os.close(); } }
java
static byte[] marshall(final DevFailed devFailed) throws DevFailed { XLOGGER.entry(); final CDROutputStream os = new CDROutputStream(); try { DevErrorListHelper.write(os, devFailed.errors); XLOGGER.exit(); return cppAlignment(os.getBufferCopy()); } finally { os.close(); } }
[ "static", "byte", "[", "]", "marshall", "(", "final", "DevFailed", "devFailed", ")", "throws", "DevFailed", "{", "XLOGGER", ".", "entry", "(", ")", ";", "final", "CDROutputStream", "os", "=", "new", "CDROutputStream", "(", ")", ";", "try", "{", "DevErrorListHelper", ".", "write", "(", "os", ",", "devFailed", ".", "errors", ")", ";", "XLOGGER", ".", "exit", "(", ")", ";", "return", "cppAlignment", "(", "os", ".", "getBufferCopy", "(", ")", ")", ";", "}", "finally", "{", "os", ".", "close", "(", ")", ";", "}", "}" ]
Marshall the attribute with a DevFailed object @param devFailed DevFailed object to marshall @return result of the marshall action @throws DevFailed if marshall action failed
[ "Marshall", "the", "attribute", "with", "a", "DevFailed", "object" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/events/EventUtilities.java#L309-L319
140,424
tango-controls/JTango
server/src/main/java/org/tango/server/events/EventUtilities.java
EventUtilities.marshall
static byte[] marshall(final int counter, final boolean isException) throws DevFailed { XLOGGER.entry(); final ZmqCallInfo zmqCallInfo = new ZmqCallInfo(EventConstants.ZMQ_RELEASE, counter, EventConstants.EXECUTE_METHOD, EventConstants.OBJECT_IDENTIFIER, isException); final CDROutputStream os = new CDROutputStream(); try { ZmqCallInfoHelper.write(os, zmqCallInfo); XLOGGER.exit(); // EventManager.dump(os.getBufferCopy()); return os.getBufferCopy(); } finally { os.close(); } }
java
static byte[] marshall(final int counter, final boolean isException) throws DevFailed { XLOGGER.entry(); final ZmqCallInfo zmqCallInfo = new ZmqCallInfo(EventConstants.ZMQ_RELEASE, counter, EventConstants.EXECUTE_METHOD, EventConstants.OBJECT_IDENTIFIER, isException); final CDROutputStream os = new CDROutputStream(); try { ZmqCallInfoHelper.write(os, zmqCallInfo); XLOGGER.exit(); // EventManager.dump(os.getBufferCopy()); return os.getBufferCopy(); } finally { os.close(); } }
[ "static", "byte", "[", "]", "marshall", "(", "final", "int", "counter", ",", "final", "boolean", "isException", ")", "throws", "DevFailed", "{", "XLOGGER", ".", "entry", "(", ")", ";", "final", "ZmqCallInfo", "zmqCallInfo", "=", "new", "ZmqCallInfo", "(", "EventConstants", ".", "ZMQ_RELEASE", ",", "counter", ",", "EventConstants", ".", "EXECUTE_METHOD", ",", "EventConstants", ".", "OBJECT_IDENTIFIER", ",", "isException", ")", ";", "final", "CDROutputStream", "os", "=", "new", "CDROutputStream", "(", ")", ";", "try", "{", "ZmqCallInfoHelper", ".", "write", "(", "os", ",", "zmqCallInfo", ")", ";", "XLOGGER", ".", "exit", "(", ")", ";", "// EventManager.dump(os.getBufferCopy());", "return", "os", ".", "getBufferCopy", "(", ")", ";", "}", "finally", "{", "os", ".", "close", "(", ")", ";", "}", "}" ]
Marshall the ZmqCallInfo object @param counter event counter @param isException true if the attribute has failed @return result of the marshall action @throws DevFailed if marshall action failed
[ "Marshall", "the", "ZmqCallInfo", "object" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/events/EventUtilities.java#L329-L342
140,425
tango-controls/JTango
server/src/main/java/org/tango/server/events/EventUtilities.java
EventUtilities.getZmqVersion
static double getZmqVersion() { XLOGGER.entry(); if (zmqVersion < 0.0) { // Not already checked. zmqVersion = 0.0; try { String strVersion = org.zeromq.ZMQ.getVersionString(); final StringTokenizer stk = new StringTokenizer(strVersion, "."); final ArrayList<String> list = new ArrayList<String>(); while (stk.hasMoreTokens()) { list.add(stk.nextToken()); } strVersion = list.get(0) + "." + list.get(1); if (list.size() > 2) { strVersion += list.get(2); } try { zmqVersion = Double.parseDouble(strVersion); } catch (final NumberFormatException e) { } } catch (final Exception e) { /*System.err.println(e);*/ } catch (final Error e) { /*System.err.println(e);*/ } } XLOGGER.exit(); return zmqVersion; }
java
static double getZmqVersion() { XLOGGER.entry(); if (zmqVersion < 0.0) { // Not already checked. zmqVersion = 0.0; try { String strVersion = org.zeromq.ZMQ.getVersionString(); final StringTokenizer stk = new StringTokenizer(strVersion, "."); final ArrayList<String> list = new ArrayList<String>(); while (stk.hasMoreTokens()) { list.add(stk.nextToken()); } strVersion = list.get(0) + "." + list.get(1); if (list.size() > 2) { strVersion += list.get(2); } try { zmqVersion = Double.parseDouble(strVersion); } catch (final NumberFormatException e) { } } catch (final Exception e) { /*System.err.println(e);*/ } catch (final Error e) { /*System.err.println(e);*/ } } XLOGGER.exit(); return zmqVersion; }
[ "static", "double", "getZmqVersion", "(", ")", "{", "XLOGGER", ".", "entry", "(", ")", ";", "if", "(", "zmqVersion", "<", "0.0", ")", "{", "// Not already checked.", "zmqVersion", "=", "0.0", ";", "try", "{", "String", "strVersion", "=", "org", ".", "zeromq", ".", "ZMQ", ".", "getVersionString", "(", ")", ";", "final", "StringTokenizer", "stk", "=", "new", "StringTokenizer", "(", "strVersion", ",", "\".\"", ")", ";", "final", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "while", "(", "stk", ".", "hasMoreTokens", "(", ")", ")", "{", "list", ".", "add", "(", "stk", ".", "nextToken", "(", ")", ")", ";", "}", "strVersion", "=", "list", ".", "get", "(", "0", ")", "+", "\".\"", "+", "list", ".", "get", "(", "1", ")", ";", "if", "(", "list", ".", "size", "(", ")", ">", "2", ")", "{", "strVersion", "+=", "list", ".", "get", "(", "2", ")", ";", "}", "try", "{", "zmqVersion", "=", "Double", ".", "parseDouble", "(", "strVersion", ")", ";", "}", "catch", "(", "final", "NumberFormatException", "e", ")", "{", "}", "}", "catch", "(", "final", "Exception", "e", ")", "{", "/*System.err.println(e);*/", "}", "catch", "(", "final", "Error", "e", ")", "{", "/*System.err.println(e);*/", "}", "}", "XLOGGER", ".", "exit", "(", ")", ";", "return", "zmqVersion", ";", "}" ]
Return the zmq version as a double like 3.22 for "3.2.2" or 0.0 if zmq not available @return the TangORB version as a String
[ "Return", "the", "zmq", "version", "as", "a", "double", "like", "3", ".", "22", "for", "3", ".", "2", ".", "2", "or", "0", ".", "0", "if", "zmq", "not", "available" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/events/EventUtilities.java#L376-L402
140,426
tango-controls/JTango
server/src/main/java/org/tango/server/idl/CleverAttrValUnion.java
CleverAttrValUnion.get
public static Object get(final AttrValUnion union, final AttrDataFormat format) throws DevFailed { Object result = null; if (union != null) { final AttributeDataType discriminator = union.discriminator(); if (discriminator.value() == AttributeDataType._ATT_NO_DATA) { throw DevFailedUtils.newDevFailed("there is not data"); } try { final Method method = union.getClass().getMethod(METHOD_MAP.get(discriminator)); result = method.invoke(union); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { throw DevFailedUtils.newDevFailed(e.getCause()); } catch (final SecurityException e) { throw DevFailedUtils.newDevFailed(e); } catch (final NoSuchMethodException e) { throw DevFailedUtils.newDevFailed(e); } if (format.equals(AttrDataFormat.SCALAR) && !discriminator.equals(AttributeDataType.DEVICE_STATE)) { // for scalar except state, get only first value result = Array.get(result, 0); } } return result; }
java
public static Object get(final AttrValUnion union, final AttrDataFormat format) throws DevFailed { Object result = null; if (union != null) { final AttributeDataType discriminator = union.discriminator(); if (discriminator.value() == AttributeDataType._ATT_NO_DATA) { throw DevFailedUtils.newDevFailed("there is not data"); } try { final Method method = union.getClass().getMethod(METHOD_MAP.get(discriminator)); result = method.invoke(union); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { throw DevFailedUtils.newDevFailed(e.getCause()); } catch (final SecurityException e) { throw DevFailedUtils.newDevFailed(e); } catch (final NoSuchMethodException e) { throw DevFailedUtils.newDevFailed(e); } if (format.equals(AttrDataFormat.SCALAR) && !discriminator.equals(AttributeDataType.DEVICE_STATE)) { // for scalar except state, get only first value result = Array.get(result, 0); } } return result; }
[ "public", "static", "Object", "get", "(", "final", "AttrValUnion", "union", ",", "final", "AttrDataFormat", "format", ")", "throws", "DevFailed", "{", "Object", "result", "=", "null", ";", "if", "(", "union", "!=", "null", ")", "{", "final", "AttributeDataType", "discriminator", "=", "union", ".", "discriminator", "(", ")", ";", "if", "(", "discriminator", ".", "value", "(", ")", "==", "AttributeDataType", ".", "_ATT_NO_DATA", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "\"there is not data\"", ")", ";", "}", "try", "{", "final", "Method", "method", "=", "union", ".", "getClass", "(", ")", ".", "getMethod", "(", "METHOD_MAP", ".", "get", "(", "discriminator", ")", ")", ";", "result", "=", "method", ".", "invoke", "(", "union", ")", ";", "}", "catch", "(", "final", "IllegalArgumentException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "IllegalAccessException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "InvocationTargetException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ".", "getCause", "(", ")", ")", ";", "}", "catch", "(", "final", "SecurityException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "NoSuchMethodException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "if", "(", "format", ".", "equals", "(", "AttrDataFormat", ".", "SCALAR", ")", "&&", "!", "discriminator", ".", "equals", "(", "AttributeDataType", ".", "DEVICE_STATE", ")", ")", "{", "// for scalar except state, get only first value", "result", "=", "Array", ".", "get", "(", "result", ",", "0", ")", ";", "}", "}", "return", "result", ";", "}" ]
Get value from an AttrValUnion @param union @param format @return The value @throws DevFailed
[ "Get", "value", "from", "an", "AttrValUnion" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/idl/CleverAttrValUnion.java#L102-L129
140,427
tango-controls/JTango
server/src/main/java/org/tango/server/idl/CleverAttrValUnion.java
CleverAttrValUnion.set
public static AttrValUnion set(final int tangoType, final Object value) throws DevFailed { final AttributeDataType discriminator = AttributeTangoType.getTypeFromTango(tangoType).getAttributeDataType(); final AttrValUnion union = new AttrValUnion(); Object array = null; if (value.getClass().isArray()) { // convert to array of primitives if necessary array = org.tango.utils.ArrayUtils.toPrimitiveArray(value); } else { // put in an array before inserting for scalars array = Array.newInstance(AttributeTangoType.getTypeFromTango(tangoType).getType(), 1); try { Array.set(array, 0, value); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_OPT_PROP, value.getClass().getCanonicalName() + " is not of the good type"); } } try { final Method method = union.getClass().getMethod(METHOD_MAP.get(discriminator), PARAM_MAP.get(discriminator)); method.invoke(union, array); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_OPT_PROP, value.getClass().getCanonicalName() + " is not of the good type"); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { throw DevFailedUtils.newDevFailed(e.getCause()); } catch (final SecurityException e) { throw DevFailedUtils.newDevFailed(e); } catch (final NoSuchMethodException e) { throw DevFailedUtils.newDevFailed(e); } return union; }
java
public static AttrValUnion set(final int tangoType, final Object value) throws DevFailed { final AttributeDataType discriminator = AttributeTangoType.getTypeFromTango(tangoType).getAttributeDataType(); final AttrValUnion union = new AttrValUnion(); Object array = null; if (value.getClass().isArray()) { // convert to array of primitives if necessary array = org.tango.utils.ArrayUtils.toPrimitiveArray(value); } else { // put in an array before inserting for scalars array = Array.newInstance(AttributeTangoType.getTypeFromTango(tangoType).getType(), 1); try { Array.set(array, 0, value); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_OPT_PROP, value.getClass().getCanonicalName() + " is not of the good type"); } } try { final Method method = union.getClass().getMethod(METHOD_MAP.get(discriminator), PARAM_MAP.get(discriminator)); method.invoke(union, array); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_OPT_PROP, value.getClass().getCanonicalName() + " is not of the good type"); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { throw DevFailedUtils.newDevFailed(e.getCause()); } catch (final SecurityException e) { throw DevFailedUtils.newDevFailed(e); } catch (final NoSuchMethodException e) { throw DevFailedUtils.newDevFailed(e); } return union; }
[ "public", "static", "AttrValUnion", "set", "(", "final", "int", "tangoType", ",", "final", "Object", "value", ")", "throws", "DevFailed", "{", "final", "AttributeDataType", "discriminator", "=", "AttributeTangoType", ".", "getTypeFromTango", "(", "tangoType", ")", ".", "getAttributeDataType", "(", ")", ";", "final", "AttrValUnion", "union", "=", "new", "AttrValUnion", "(", ")", ";", "Object", "array", "=", "null", ";", "if", "(", "value", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ")", "{", "// convert to array of primitives if necessary", "array", "=", "org", ".", "tango", ".", "utils", ".", "ArrayUtils", ".", "toPrimitiveArray", "(", "value", ")", ";", "}", "else", "{", "// put in an array before inserting for scalars", "array", "=", "Array", ".", "newInstance", "(", "AttributeTangoType", ".", "getTypeFromTango", "(", "tangoType", ")", ".", "getType", "(", ")", ",", "1", ")", ";", "try", "{", "Array", ".", "set", "(", "array", ",", "0", ",", "value", ")", ";", "}", "catch", "(", "final", "IllegalArgumentException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "ExceptionMessages", ".", "ATTR_OPT_PROP", ",", "value", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", "+", "\" is not of the good type\"", ")", ";", "}", "}", "try", "{", "final", "Method", "method", "=", "union", ".", "getClass", "(", ")", ".", "getMethod", "(", "METHOD_MAP", ".", "get", "(", "discriminator", ")", ",", "PARAM_MAP", ".", "get", "(", "discriminator", ")", ")", ";", "method", ".", "invoke", "(", "union", ",", "array", ")", ";", "}", "catch", "(", "final", "IllegalArgumentException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "ExceptionMessages", ".", "ATTR_OPT_PROP", ",", "value", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", "+", "\" is not of the good type\"", ")", ";", "}", "catch", "(", "final", "IllegalAccessException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "InvocationTargetException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ".", "getCause", "(", ")", ")", ";", "}", "catch", "(", "final", "SecurityException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "NoSuchMethodException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "return", "union", ";", "}" ]
Set a value into an AttrValUnion @param tangoType @param value @return The union @throws DevFailed
[ "Set", "a", "value", "into", "an", "AttrValUnion" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/idl/CleverAttrValUnion.java#L139-L173
140,428
tango-controls/JTango
server/src/main/java/org/tango/server/cache/PollingManager.java
PollingManager.triggerPolling
public void triggerPolling(final String objectName) throws DevFailed { boolean isACommand = false; CommandImpl cmd = null; try { cmd = CommandGetter.getCommand(objectName, commandList); isACommand = true; } catch (final DevFailed e) { } if (!isACommand) { // polled object is not a command. May be an attribute AttributeImpl att = null; try { att = AttributeGetterSetter.getAttribute(objectName, attributeList); } catch (final DevFailed e) { logger.error(Constants.POLLED_OBJECT + objectName + " not found"); throw DevFailedUtils.newDevFailed(ExceptionMessages.POLL_OBJ_NOT_FOUND, Constants.POLLED_OBJECT + objectName + " not found"); } checkPolling(objectName, att); try { cacheManager.getAttributeCache(att).refresh(att.getName()); } catch (final CacheException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } catch (final NoCacheFoundException e) { throw DevFailedUtils.newDevFailed(e); } } else { checkPolling(objectName, cmd); try { cacheManager.getCommandCache(cmd).refresh(cmd.getName()); } catch (final CacheException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } }
java
public void triggerPolling(final String objectName) throws DevFailed { boolean isACommand = false; CommandImpl cmd = null; try { cmd = CommandGetter.getCommand(objectName, commandList); isACommand = true; } catch (final DevFailed e) { } if (!isACommand) { // polled object is not a command. May be an attribute AttributeImpl att = null; try { att = AttributeGetterSetter.getAttribute(objectName, attributeList); } catch (final DevFailed e) { logger.error(Constants.POLLED_OBJECT + objectName + " not found"); throw DevFailedUtils.newDevFailed(ExceptionMessages.POLL_OBJ_NOT_FOUND, Constants.POLLED_OBJECT + objectName + " not found"); } checkPolling(objectName, att); try { cacheManager.getAttributeCache(att).refresh(att.getName()); } catch (final CacheException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } catch (final NoCacheFoundException e) { throw DevFailedUtils.newDevFailed(e); } } else { checkPolling(objectName, cmd); try { cacheManager.getCommandCache(cmd).refresh(cmd.getName()); } catch (final CacheException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } }
[ "public", "void", "triggerPolling", "(", "final", "String", "objectName", ")", "throws", "DevFailed", "{", "boolean", "isACommand", "=", "false", ";", "CommandImpl", "cmd", "=", "null", ";", "try", "{", "cmd", "=", "CommandGetter", ".", "getCommand", "(", "objectName", ",", "commandList", ")", ";", "isACommand", "=", "true", ";", "}", "catch", "(", "final", "DevFailed", "e", ")", "{", "}", "if", "(", "!", "isACommand", ")", "{", "// polled object is not a command. May be an attribute\r", "AttributeImpl", "att", "=", "null", ";", "try", "{", "att", "=", "AttributeGetterSetter", ".", "getAttribute", "(", "objectName", ",", "attributeList", ")", ";", "}", "catch", "(", "final", "DevFailed", "e", ")", "{", "logger", ".", "error", "(", "Constants", ".", "POLLED_OBJECT", "+", "objectName", "+", "\" not found\"", ")", ";", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "ExceptionMessages", ".", "POLL_OBJ_NOT_FOUND", ",", "Constants", ".", "POLLED_OBJECT", "+", "objectName", "+", "\" not found\"", ")", ";", "}", "checkPolling", "(", "objectName", ",", "att", ")", ";", "try", "{", "cacheManager", ".", "getAttributeCache", "(", "att", ")", ".", "refresh", "(", "att", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "final", "CacheException", "e", ")", "{", "if", "(", "e", ".", "getCause", "(", ")", "instanceof", "DevFailed", ")", "{", "throw", "(", "DevFailed", ")", "e", ".", "getCause", "(", ")", ";", "}", "else", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ".", "getCause", "(", ")", ")", ";", "}", "}", "catch", "(", "final", "NoCacheFoundException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "}", "else", "{", "checkPolling", "(", "objectName", ",", "cmd", ")", ";", "try", "{", "cacheManager", ".", "getCommandCache", "(", "cmd", ")", ".", "refresh", "(", "cmd", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "final", "CacheException", "e", ")", "{", "if", "(", "e", ".", "getCause", "(", ")", "instanceof", "DevFailed", ")", "{", "throw", "(", "DevFailed", ")", "e", ".", "getCause", "(", ")", ";", "}", "else", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ".", "getCause", "(", ")", ")", ";", "}", "}", "}", "}" ]
Update polling cache @param objectName The command or attribute to update @throws DevFailed
[ "Update", "polling", "cache" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/PollingManager.java#L177-L219
140,429
tango-controls/JTango
server/src/main/java/org/tango/server/cache/PollingManager.java
PollingManager.addCommandPolling
public void addCommandPolling(final String commandName, final int pollingPeriod) throws DevFailed { checkPollingLimits(commandName, pollingPeriod, minCommandPolling); final CommandImpl command = CommandGetter.getCommand(commandName, commandList); if (!command.getName().equals(DeviceImpl.INIT_CMD) && command.getInType().equals(CommandTangoType.VOID)) { command.configurePolling(pollingPeriod); if (command.getName().equals(DeviceImpl.STATE_NAME) || command.getName().equals(DeviceImpl.STATUS_NAME)) { // command is also set as polled final AttributeImpl attribute = AttributeGetterSetter.getAttribute(command.getName(), attributeList); attribute.configurePolling(pollingPeriod); pollAttributes.put(attribute.getName().toLowerCase(Locale.ENGLISH), pollingPeriod); cacheManager.startStateStatusPolling(command, attribute); pollAttributes.put(attribute.getName().toLowerCase(Locale.ENGLISH), pollingPeriod); savePollingConfig(); } else { cacheManager.startCommandPolling(command); } } }
java
public void addCommandPolling(final String commandName, final int pollingPeriod) throws DevFailed { checkPollingLimits(commandName, pollingPeriod, minCommandPolling); final CommandImpl command = CommandGetter.getCommand(commandName, commandList); if (!command.getName().equals(DeviceImpl.INIT_CMD) && command.getInType().equals(CommandTangoType.VOID)) { command.configurePolling(pollingPeriod); if (command.getName().equals(DeviceImpl.STATE_NAME) || command.getName().equals(DeviceImpl.STATUS_NAME)) { // command is also set as polled final AttributeImpl attribute = AttributeGetterSetter.getAttribute(command.getName(), attributeList); attribute.configurePolling(pollingPeriod); pollAttributes.put(attribute.getName().toLowerCase(Locale.ENGLISH), pollingPeriod); cacheManager.startStateStatusPolling(command, attribute); pollAttributes.put(attribute.getName().toLowerCase(Locale.ENGLISH), pollingPeriod); savePollingConfig(); } else { cacheManager.startCommandPolling(command); } } }
[ "public", "void", "addCommandPolling", "(", "final", "String", "commandName", ",", "final", "int", "pollingPeriod", ")", "throws", "DevFailed", "{", "checkPollingLimits", "(", "commandName", ",", "pollingPeriod", ",", "minCommandPolling", ")", ";", "final", "CommandImpl", "command", "=", "CommandGetter", ".", "getCommand", "(", "commandName", ",", "commandList", ")", ";", "if", "(", "!", "command", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "INIT_CMD", ")", "&&", "command", ".", "getInType", "(", ")", ".", "equals", "(", "CommandTangoType", ".", "VOID", ")", ")", "{", "command", ".", "configurePolling", "(", "pollingPeriod", ")", ";", "if", "(", "command", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATE_NAME", ")", "||", "command", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATUS_NAME", ")", ")", "{", "// command is also set as polled\r", "final", "AttributeImpl", "attribute", "=", "AttributeGetterSetter", ".", "getAttribute", "(", "command", ".", "getName", "(", ")", ",", "attributeList", ")", ";", "attribute", ".", "configurePolling", "(", "pollingPeriod", ")", ";", "pollAttributes", ".", "put", "(", "attribute", ".", "getName", "(", ")", ".", "toLowerCase", "(", "Locale", ".", "ENGLISH", ")", ",", "pollingPeriod", ")", ";", "cacheManager", ".", "startStateStatusPolling", "(", "command", ",", "attribute", ")", ";", "pollAttributes", ".", "put", "(", "attribute", ".", "getName", "(", ")", ".", "toLowerCase", "(", "Locale", ".", "ENGLISH", ")", ",", "pollingPeriod", ")", ";", "savePollingConfig", "(", ")", ";", "}", "else", "{", "cacheManager", ".", "startCommandPolling", "(", "command", ")", ";", "}", "}", "}" ]
Add command polling. Init command cannot be polled. Only command with parameter void can be polled @param commandName the command to poll @param pollingPeriod the polling period @throws DevFailed
[ "Add", "command", "polling", ".", "Init", "command", "cannot", "be", "polled", ".", "Only", "command", "with", "parameter", "void", "can", "be", "polled" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/PollingManager.java#L239-L257
140,430
tango-controls/JTango
server/src/main/java/org/tango/server/cache/PollingManager.java
PollingManager.addAttributePolling
public void addAttributePolling(final String attributeName, final int pollingPeriod) throws DevFailed { logger.debug("add {} polling with period {}", attributeName, pollingPeriod); checkPollingLimits(attributeName, pollingPeriod, minAttributePolling); final AttributeImpl attribute = AttributeGetterSetter.getAttribute(attributeName, attributeList); if (attribute.getBehavior() instanceof ForwardedAttribute) { throw DevFailedUtils.newDevFailed(attributeName + " not pollable because it is a forwarded attribute"); } attribute.configurePolling(pollingPeriod); if (attribute.getName().equals(DeviceImpl.STATE_NAME) || attribute.getName().equals(DeviceImpl.STATUS_NAME)) { // command is also set as polled final CommandImpl cmd = CommandGetter.getCommand(attribute.getName(), commandList); cmd.configurePolling(pollingPeriod); cacheManager.startStateStatusPolling(cmd, attribute); } else { cacheManager.startAttributePolling(attribute); } pollAttributes.put(attributeName.toLowerCase(Locale.ENGLISH), pollingPeriod); savePollingConfig(); }
java
public void addAttributePolling(final String attributeName, final int pollingPeriod) throws DevFailed { logger.debug("add {} polling with period {}", attributeName, pollingPeriod); checkPollingLimits(attributeName, pollingPeriod, minAttributePolling); final AttributeImpl attribute = AttributeGetterSetter.getAttribute(attributeName, attributeList); if (attribute.getBehavior() instanceof ForwardedAttribute) { throw DevFailedUtils.newDevFailed(attributeName + " not pollable because it is a forwarded attribute"); } attribute.configurePolling(pollingPeriod); if (attribute.getName().equals(DeviceImpl.STATE_NAME) || attribute.getName().equals(DeviceImpl.STATUS_NAME)) { // command is also set as polled final CommandImpl cmd = CommandGetter.getCommand(attribute.getName(), commandList); cmd.configurePolling(pollingPeriod); cacheManager.startStateStatusPolling(cmd, attribute); } else { cacheManager.startAttributePolling(attribute); } pollAttributes.put(attributeName.toLowerCase(Locale.ENGLISH), pollingPeriod); savePollingConfig(); }
[ "public", "void", "addAttributePolling", "(", "final", "String", "attributeName", ",", "final", "int", "pollingPeriod", ")", "throws", "DevFailed", "{", "logger", ".", "debug", "(", "\"add {} polling with period {}\"", ",", "attributeName", ",", "pollingPeriod", ")", ";", "checkPollingLimits", "(", "attributeName", ",", "pollingPeriod", ",", "minAttributePolling", ")", ";", "final", "AttributeImpl", "attribute", "=", "AttributeGetterSetter", ".", "getAttribute", "(", "attributeName", ",", "attributeList", ")", ";", "if", "(", "attribute", ".", "getBehavior", "(", ")", "instanceof", "ForwardedAttribute", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "attributeName", "+", "\" not pollable because it is a forwarded attribute\"", ")", ";", "}", "attribute", ".", "configurePolling", "(", "pollingPeriod", ")", ";", "if", "(", "attribute", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATE_NAME", ")", "||", "attribute", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATUS_NAME", ")", ")", "{", "// command is also set as polled\r", "final", "CommandImpl", "cmd", "=", "CommandGetter", ".", "getCommand", "(", "attribute", ".", "getName", "(", ")", ",", "commandList", ")", ";", "cmd", ".", "configurePolling", "(", "pollingPeriod", ")", ";", "cacheManager", ".", "startStateStatusPolling", "(", "cmd", ",", "attribute", ")", ";", "}", "else", "{", "cacheManager", ".", "startAttributePolling", "(", "attribute", ")", ";", "}", "pollAttributes", ".", "put", "(", "attributeName", ".", "toLowerCase", "(", "Locale", ".", "ENGLISH", ")", ",", "pollingPeriod", ")", ";", "savePollingConfig", "(", ")", ";", "}" ]
Add attribute polling @param attributeName the attribute to poll @param pollingPeriod the polling period @throws DevFailed
[ "Add", "attribute", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/PollingManager.java#L293-L312
140,431
tango-controls/JTango
server/src/main/java/org/tango/server/cache/PollingManager.java
PollingManager.removeAttributePolling
public void removeAttributePolling(final String attributeName) throws DevFailed { // jive sends value with lower case, so manage it final AttributeImpl attribute = AttributeGetterSetter.getAttribute(attributeName, attributeList); attribute.resetPolling(); cacheManager.removeAttributePolling(attribute); pollAttributes.remove(attributeName.toLowerCase(Locale.ENGLISH)); if (attribute.getName().equals(DeviceImpl.STATE_NAME) || attribute.getName().equals(DeviceImpl.STATUS_NAME)) { // command is also set as polled final CommandImpl cmd = CommandGetter.getCommand(attribute.getName(), commandList); cmd.resetPolling(); cacheManager.removeCommandPolling(cmd); } savePollingConfig(); }
java
public void removeAttributePolling(final String attributeName) throws DevFailed { // jive sends value with lower case, so manage it final AttributeImpl attribute = AttributeGetterSetter.getAttribute(attributeName, attributeList); attribute.resetPolling(); cacheManager.removeAttributePolling(attribute); pollAttributes.remove(attributeName.toLowerCase(Locale.ENGLISH)); if (attribute.getName().equals(DeviceImpl.STATE_NAME) || attribute.getName().equals(DeviceImpl.STATUS_NAME)) { // command is also set as polled final CommandImpl cmd = CommandGetter.getCommand(attribute.getName(), commandList); cmd.resetPolling(); cacheManager.removeCommandPolling(cmd); } savePollingConfig(); }
[ "public", "void", "removeAttributePolling", "(", "final", "String", "attributeName", ")", "throws", "DevFailed", "{", "// jive sends value with lower case, so manage it\r", "final", "AttributeImpl", "attribute", "=", "AttributeGetterSetter", ".", "getAttribute", "(", "attributeName", ",", "attributeList", ")", ";", "attribute", ".", "resetPolling", "(", ")", ";", "cacheManager", ".", "removeAttributePolling", "(", "attribute", ")", ";", "pollAttributes", ".", "remove", "(", "attributeName", ".", "toLowerCase", "(", "Locale", ".", "ENGLISH", ")", ")", ";", "if", "(", "attribute", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATE_NAME", ")", "||", "attribute", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATUS_NAME", ")", ")", "{", "// command is also set as polled\r", "final", "CommandImpl", "cmd", "=", "CommandGetter", ".", "getCommand", "(", "attribute", ".", "getName", "(", ")", ",", "commandList", ")", ";", "cmd", ".", "resetPolling", "(", ")", ";", "cacheManager", ".", "removeCommandPolling", "(", "cmd", ")", ";", "}", "savePollingConfig", "(", ")", ";", "}" ]
Remove attribute polling @param attributeName the attribute @throws DevFailed
[ "Remove", "attribute", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/PollingManager.java#L320-L333
140,432
tango-controls/JTango
server/src/main/java/org/tango/server/cache/PollingManager.java
PollingManager.removeCommandPolling
public void removeCommandPolling(final String commandName) throws DevFailed { final CommandImpl command = CommandGetter.getCommand(commandName, commandList); command.resetPolling(); cacheManager.removeCommandPolling(command); if (command.getName().equals(DeviceImpl.STATE_NAME) || command.getName().equals(DeviceImpl.STATUS_NAME)) { // attribute is also set as polled final AttributeImpl attribute = AttributeGetterSetter.getAttribute(command.getName(), attributeList); attribute.resetPolling(); cacheManager.removeAttributePolling(attribute); pollAttributes.remove(command.getName().toLowerCase(Locale.ENGLISH)); savePollingConfig(); } }
java
public void removeCommandPolling(final String commandName) throws DevFailed { final CommandImpl command = CommandGetter.getCommand(commandName, commandList); command.resetPolling(); cacheManager.removeCommandPolling(command); if (command.getName().equals(DeviceImpl.STATE_NAME) || command.getName().equals(DeviceImpl.STATUS_NAME)) { // attribute is also set as polled final AttributeImpl attribute = AttributeGetterSetter.getAttribute(command.getName(), attributeList); attribute.resetPolling(); cacheManager.removeAttributePolling(attribute); pollAttributes.remove(command.getName().toLowerCase(Locale.ENGLISH)); savePollingConfig(); } }
[ "public", "void", "removeCommandPolling", "(", "final", "String", "commandName", ")", "throws", "DevFailed", "{", "final", "CommandImpl", "command", "=", "CommandGetter", ".", "getCommand", "(", "commandName", ",", "commandList", ")", ";", "command", ".", "resetPolling", "(", ")", ";", "cacheManager", ".", "removeCommandPolling", "(", "command", ")", ";", "if", "(", "command", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATE_NAME", ")", "||", "command", ".", "getName", "(", ")", ".", "equals", "(", "DeviceImpl", ".", "STATUS_NAME", ")", ")", "{", "// attribute is also set as polled\r", "final", "AttributeImpl", "attribute", "=", "AttributeGetterSetter", ".", "getAttribute", "(", "command", ".", "getName", "(", ")", ",", "attributeList", ")", ";", "attribute", ".", "resetPolling", "(", ")", ";", "cacheManager", ".", "removeAttributePolling", "(", "attribute", ")", ";", "pollAttributes", ".", "remove", "(", "command", ".", "getName", "(", ")", ".", "toLowerCase", "(", "Locale", ".", "ENGLISH", ")", ")", ";", "savePollingConfig", "(", ")", ";", "}", "}" ]
Remove command polling @param commandName the command @throws DevFailed
[ "Remove", "command", "polling" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/cache/PollingManager.java#L341-L353
140,433
tango-controls/JTango
client/src/main/java/fr/soleil/tango/attributecomposer/AttributeGroupScheduler.java
AttributeGroupScheduler.start
public void start(final AttributeGroupReader valueReader, final long readingPeriod) { this.valueReader = valueReader; this.readingPeriod = readingPeriod; // create a timer to read attributes executor = Executors.newScheduledThreadPool(1); future = executor.scheduleAtFixedRate(valueReader, 0L, readingPeriod, TimeUnit.MILLISECONDS); }
java
public void start(final AttributeGroupReader valueReader, final long readingPeriod) { this.valueReader = valueReader; this.readingPeriod = readingPeriod; // create a timer to read attributes executor = Executors.newScheduledThreadPool(1); future = executor.scheduleAtFixedRate(valueReader, 0L, readingPeriod, TimeUnit.MILLISECONDS); }
[ "public", "void", "start", "(", "final", "AttributeGroupReader", "valueReader", ",", "final", "long", "readingPeriod", ")", "{", "this", ".", "valueReader", "=", "valueReader", ";", "this", ".", "readingPeriod", "=", "readingPeriod", ";", "// create a timer to read attributes\r", "executor", "=", "Executors", ".", "newScheduledThreadPool", "(", "1", ")", ";", "future", "=", "executor", ".", "scheduleAtFixedRate", "(", "valueReader", ",", "0L", ",", "readingPeriod", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}" ]
Start the periodic update @param valueReader the group reader @param readingPeriod the period in milliseconds
[ "Start", "the", "periodic", "update" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/fr/soleil/tango/attributecomposer/AttributeGroupScheduler.java#L29-L35
140,434
tango-controls/JTango
client/src/main/java/fr/soleil/tango/attributecomposer/AttributeGroupScheduler.java
AttributeGroupScheduler.stop
public void stop() { if (future != null) { future.cancel(true); } if (executor != null) { executor.shutdownNow(); } }
java
public void stop() { if (future != null) { future.cancel(true); } if (executor != null) { executor.shutdownNow(); } }
[ "public", "void", "stop", "(", ")", "{", "if", "(", "future", "!=", "null", ")", "{", "future", ".", "cancel", "(", "true", ")", ";", "}", "if", "(", "executor", "!=", "null", ")", "{", "executor", ".", "shutdownNow", "(", ")", ";", "}", "}" ]
Stop the refresh
[ "Stop", "the", "refresh" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/fr/soleil/tango/attributecomposer/AttributeGroupScheduler.java#L40-L47
140,435
tango-controls/JTango
client/src/main/java/fr/soleil/tango/attributecomposer/AttributeGroupScheduler.java
AttributeGroupScheduler.updateAttributeGroup
public void updateAttributeGroup(final TangoGroupAttribute attributeGroup) { stop(); final AttributeGroupReader newValueReader = new AttributeGroupReader(valueReader.getAttributeGroupListener(), attributeGroup, valueReader.isReadWriteValue(), valueReader.isReadQuality(), valueReader.isReadAttributeInfo()); start(newValueReader, readingPeriod); }
java
public void updateAttributeGroup(final TangoGroupAttribute attributeGroup) { stop(); final AttributeGroupReader newValueReader = new AttributeGroupReader(valueReader.getAttributeGroupListener(), attributeGroup, valueReader.isReadWriteValue(), valueReader.isReadQuality(), valueReader.isReadAttributeInfo()); start(newValueReader, readingPeriod); }
[ "public", "void", "updateAttributeGroup", "(", "final", "TangoGroupAttribute", "attributeGroup", ")", "{", "stop", "(", ")", ";", "final", "AttributeGroupReader", "newValueReader", "=", "new", "AttributeGroupReader", "(", "valueReader", ".", "getAttributeGroupListener", "(", ")", ",", "attributeGroup", ",", "valueReader", ".", "isReadWriteValue", "(", ")", ",", "valueReader", ".", "isReadQuality", "(", ")", ",", "valueReader", ".", "isReadAttributeInfo", "(", ")", ")", ";", "start", "(", "newValueReader", ",", "readingPeriod", ")", ";", "}" ]
Update the group of attributes @param attributeGroup
[ "Update", "the", "group", "of", "attributes" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/fr/soleil/tango/attributecomposer/AttributeGroupScheduler.java#L54-L60
140,436
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.insert
public static void insert(final Object value, final DeviceAttribute deviceAttributeWritten, final int dimX, final int dimY) throws DevFailed { if (value instanceof Short) { AttributeHelper.insertFromShort((Short) value, deviceAttributeWritten); } else if (value instanceof String) { AttributeHelper.insertFromString((String) value, deviceAttributeWritten); } else if (value instanceof Integer) { AttributeHelper.insertFromInteger((Integer) value, deviceAttributeWritten); } else if (value instanceof Long) { AttributeHelper.insertFromLong((Long) value, deviceAttributeWritten); } else if (value instanceof Float) { AttributeHelper.insertFromFloat((Float) value, deviceAttributeWritten); } else if (value instanceof Boolean) { AttributeHelper.insertFromBoolean((Boolean) value, deviceAttributeWritten); } else if (value instanceof Double) { AttributeHelper.insertFromDouble((Double) value, deviceAttributeWritten); } else if (value instanceof DevState) { AttributeHelper.insertFromDevState((DevState) value, deviceAttributeWritten); } else if (value instanceof WAttribute) { AttributeHelper.insertFromWAttribute((WAttribute) value, deviceAttributeWritten); } else if (value instanceof Vector) { AttributeHelper.insertFromArray(((Vector) value).toArray(), deviceAttributeWritten, dimX, dimY); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + value.getClass() + " not supported", "AttributeHelper.insert(Object value,deviceAttributeWritten)"); } }
java
public static void insert(final Object value, final DeviceAttribute deviceAttributeWritten, final int dimX, final int dimY) throws DevFailed { if (value instanceof Short) { AttributeHelper.insertFromShort((Short) value, deviceAttributeWritten); } else if (value instanceof String) { AttributeHelper.insertFromString((String) value, deviceAttributeWritten); } else if (value instanceof Integer) { AttributeHelper.insertFromInteger((Integer) value, deviceAttributeWritten); } else if (value instanceof Long) { AttributeHelper.insertFromLong((Long) value, deviceAttributeWritten); } else if (value instanceof Float) { AttributeHelper.insertFromFloat((Float) value, deviceAttributeWritten); } else if (value instanceof Boolean) { AttributeHelper.insertFromBoolean((Boolean) value, deviceAttributeWritten); } else if (value instanceof Double) { AttributeHelper.insertFromDouble((Double) value, deviceAttributeWritten); } else if (value instanceof DevState) { AttributeHelper.insertFromDevState((DevState) value, deviceAttributeWritten); } else if (value instanceof WAttribute) { AttributeHelper.insertFromWAttribute((WAttribute) value, deviceAttributeWritten); } else if (value instanceof Vector) { AttributeHelper.insertFromArray(((Vector) value).toArray(), deviceAttributeWritten, dimX, dimY); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + value.getClass() + " not supported", "AttributeHelper.insert(Object value,deviceAttributeWritten)"); } }
[ "public", "static", "void", "insert", "(", "final", "Object", "value", ",", "final", "DeviceAttribute", "deviceAttributeWritten", ",", "final", "int", "dimX", ",", "final", "int", "dimY", ")", "throws", "DevFailed", "{", "if", "(", "value", "instanceof", "Short", ")", "{", "AttributeHelper", ".", "insertFromShort", "(", "(", "Short", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "AttributeHelper", ".", "insertFromString", "(", "(", "String", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "AttributeHelper", ".", "insertFromInteger", "(", "(", "Integer", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "AttributeHelper", ".", "insertFromLong", "(", "(", "Long", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "AttributeHelper", ".", "insertFromFloat", "(", "(", "Float", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "AttributeHelper", ".", "insertFromBoolean", "(", "(", "Boolean", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "AttributeHelper", ".", "insertFromDouble", "(", "(", "Double", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "AttributeHelper", ".", "insertFromDevState", "(", "(", "DevState", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "WAttribute", ")", "{", "AttributeHelper", ".", "insertFromWAttribute", "(", "(", "WAttribute", ")", "value", ",", "deviceAttributeWritten", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Vector", ")", "{", "AttributeHelper", ".", "insertFromArray", "(", "(", "(", "Vector", ")", "value", ")", ".", "toArray", "(", ")", ",", "deviceAttributeWritten", ",", "dimX", ",", "dimY", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.insert(Object value,deviceAttributeWritten)\"", ")", ";", "}", "}" ]
Insert data in DeviceAttribute from an Object @param value the value to write on DeviceAttribute, possibles Class : Short, String, Long, Float, Boolean, Integer, Double, DevState or Vector. @param deviceAttributeWritten the DeviceAttribute attribute to write @param dimX the custom X dimension of the attribute to write use only if it is a Vector @param dimY the custom Y dimension of the attribute to write use only if it is a Vector @throws DevFailed
[ "Insert", "data", "in", "DeviceAttribute", "from", "an", "Object" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L299-L328
140,437
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extract
public static Object extract(final DeviceAttribute deviceAttributeRead) throws DevFailed { Object argout = null; if (deviceAttributeRead.getDimX() != 1 || deviceAttributeRead.getDimY() != 0) { argout = extractArray(deviceAttributeRead); } else { switch (deviceAttributeRead.getType()) { case TangoConst.Tango_DEV_SHORT: argout = Short.valueOf(deviceAttributeRead.extractShort()); break; case TangoConst.Tango_DEV_USHORT: argout = Integer.valueOf(deviceAttributeRead.extractUShort()).shortValue(); break; case TangoConst.Tango_DEV_CHAR: // VH : a char correspond to a Byte in java // but deviceAttribute doesn't have a extractchar method !!! Except.throw_exception("TANGO_WRONG_DATA_ERROR", "out type Tango_DEV_CHAR not supported", "AttributeHelper.extract(deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: argout = Short.valueOf(deviceAttributeRead.extractUChar()).shortValue(); break; case TangoConst.Tango_DEV_LONG: argout = Integer.valueOf(deviceAttributeRead.extractLong()); break; case TangoConst.Tango_DEV_ULONG: argout = Long.valueOf(deviceAttributeRead.extractULong()); break; case TangoConst.Tango_DEV_LONG64: argout = Long.valueOf(deviceAttributeRead.extractLong64()); break; case TangoConst.Tango_DEV_ULONG64: argout = Long.valueOf(deviceAttributeRead.extractULong64()); break; case TangoConst.Tango_DEV_INT: argout = Integer.valueOf(deviceAttributeRead.extractLong()); break; case TangoConst.Tango_DEV_FLOAT: argout = Float.valueOf(deviceAttributeRead.extractFloat()); break; case TangoConst.Tango_DEV_DOUBLE: argout = Double.valueOf(deviceAttributeRead.extractDouble()); break; case TangoConst.Tango_DEV_STRING: argout = deviceAttributeRead.extractString(); break; case TangoConst.Tango_DEV_BOOLEAN: argout = Boolean.valueOf(deviceAttributeRead.extractBoolean()); break; case TangoConst.Tango_DEV_STATE: argout = deviceAttributeRead.extractDevState(); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + deviceAttributeRead.getType() + " not supported", "AttributeHelper.extract(Short value,deviceAttributeWritten)"); break; } } return argout; }
java
public static Object extract(final DeviceAttribute deviceAttributeRead) throws DevFailed { Object argout = null; if (deviceAttributeRead.getDimX() != 1 || deviceAttributeRead.getDimY() != 0) { argout = extractArray(deviceAttributeRead); } else { switch (deviceAttributeRead.getType()) { case TangoConst.Tango_DEV_SHORT: argout = Short.valueOf(deviceAttributeRead.extractShort()); break; case TangoConst.Tango_DEV_USHORT: argout = Integer.valueOf(deviceAttributeRead.extractUShort()).shortValue(); break; case TangoConst.Tango_DEV_CHAR: // VH : a char correspond to a Byte in java // but deviceAttribute doesn't have a extractchar method !!! Except.throw_exception("TANGO_WRONG_DATA_ERROR", "out type Tango_DEV_CHAR not supported", "AttributeHelper.extract(deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: argout = Short.valueOf(deviceAttributeRead.extractUChar()).shortValue(); break; case TangoConst.Tango_DEV_LONG: argout = Integer.valueOf(deviceAttributeRead.extractLong()); break; case TangoConst.Tango_DEV_ULONG: argout = Long.valueOf(deviceAttributeRead.extractULong()); break; case TangoConst.Tango_DEV_LONG64: argout = Long.valueOf(deviceAttributeRead.extractLong64()); break; case TangoConst.Tango_DEV_ULONG64: argout = Long.valueOf(deviceAttributeRead.extractULong64()); break; case TangoConst.Tango_DEV_INT: argout = Integer.valueOf(deviceAttributeRead.extractLong()); break; case TangoConst.Tango_DEV_FLOAT: argout = Float.valueOf(deviceAttributeRead.extractFloat()); break; case TangoConst.Tango_DEV_DOUBLE: argout = Double.valueOf(deviceAttributeRead.extractDouble()); break; case TangoConst.Tango_DEV_STRING: argout = deviceAttributeRead.extractString(); break; case TangoConst.Tango_DEV_BOOLEAN: argout = Boolean.valueOf(deviceAttributeRead.extractBoolean()); break; case TangoConst.Tango_DEV_STATE: argout = deviceAttributeRead.extractDevState(); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + deviceAttributeRead.getType() + " not supported", "AttributeHelper.extract(Short value,deviceAttributeWritten)"); break; } } return argout; }
[ "public", "static", "Object", "extract", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "Object", "argout", "=", "null", ";", "if", "(", "deviceAttributeRead", ".", "getDimX", "(", ")", "!=", "1", "||", "deviceAttributeRead", ".", "getDimY", "(", ")", "!=", "0", ")", "{", "argout", "=", "extractArray", "(", "deviceAttributeRead", ")", ";", "}", "else", "{", "switch", "(", "deviceAttributeRead", ".", "getType", "(", ")", ")", "{", "case", "TangoConst", ".", "Tango_DEV_SHORT", ":", "argout", "=", "Short", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractShort", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_USHORT", ":", "argout", "=", "Integer", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractUShort", "(", ")", ")", ".", "shortValue", "(", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_CHAR", ":", "// VH : a char correspond to a Byte in java", "// but deviceAttribute doesn't have a extractchar method !!!", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"out type Tango_DEV_CHAR not supported\"", ",", "\"AttributeHelper.extract(deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_UCHAR", ":", "argout", "=", "Short", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractUChar", "(", ")", ")", ".", "shortValue", "(", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG", ":", "argout", "=", "Integer", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractLong", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG", ":", "argout", "=", "Long", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractULong", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG64", ":", "argout", "=", "Long", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractLong64", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG64", ":", "argout", "=", "Long", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractULong64", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_INT", ":", "argout", "=", "Integer", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractLong", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_FLOAT", ":", "argout", "=", "Float", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractFloat", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_DOUBLE", ":", "argout", "=", "Double", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractDouble", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STRING", ":", "argout", "=", "deviceAttributeRead", ".", "extractString", "(", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_BOOLEAN", ":", "argout", "=", "Boolean", ".", "valueOf", "(", "deviceAttributeRead", ".", "extractBoolean", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STATE", ":", "argout", "=", "deviceAttributeRead", ".", "extractDevState", "(", ")", ";", "break", ";", "default", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "deviceAttributeRead", ".", "getType", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extract(Short value,deviceAttributeWritten)\"", ")", ";", "break", ";", "}", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to an Object @param deviceAttributeRead the DeviceAttribute to read @return Object possibles Class : Short, String, Long, Float, Boolean, Integer, Double, DevState or Vector. @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "an", "Object" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L339-L400
140,438
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extractToShort
public static Short extractToShort(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Short argout = null; if (value instanceof Short) { argout = (Short) value; } else if (value instanceof String) { try { argout = Short.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToShort(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Short.valueOf(((Integer) value).shortValue()); } else if (value instanceof Long) { argout = Short.valueOf(((Long) value).shortValue()); } else if (value instanceof Float) { argout = Short.valueOf(((Float) value).shortValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Short.valueOf((short) 1); } else { argout = Short.valueOf((short) 0); } } else if (value instanceof Double) { argout = Short.valueOf(((Double) value).shortValue()); } else if (value instanceof DevState) { argout = Short.valueOf(Integer.valueOf(((DevState) value).value()).shortValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToShort(Object value,deviceAttributeWritten)"); } return argout; }
java
public static Short extractToShort(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Short argout = null; if (value instanceof Short) { argout = (Short) value; } else if (value instanceof String) { try { argout = Short.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToShort(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Short.valueOf(((Integer) value).shortValue()); } else if (value instanceof Long) { argout = Short.valueOf(((Long) value).shortValue()); } else if (value instanceof Float) { argout = Short.valueOf(((Float) value).shortValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Short.valueOf((short) 1); } else { argout = Short.valueOf((short) 0); } } else if (value instanceof Double) { argout = Short.valueOf(((Double) value).shortValue()); } else if (value instanceof DevState) { argout = Short.valueOf(Integer.valueOf(((DevState) value).value()).shortValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToShort(Object value,deviceAttributeWritten)"); } return argout; }
[ "public", "static", "Short", "extractToShort", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "final", "Object", "value", "=", "AttributeHelper", ".", "extract", "(", "deviceAttributeRead", ")", ";", "Short", "argout", "=", "null", ";", "if", "(", "value", "instanceof", "Short", ")", "{", "argout", "=", "(", "Short", ")", "value", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "try", "{", "argout", "=", "Short", ".", "valueOf", "(", "(", "String", ")", "value", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", "+", "\" is not a numerical\"", ",", "\"AttributeHelper.extractToShort(deviceAttributeWritten)\"", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "argout", "=", "Short", ".", "valueOf", "(", "(", "(", "Integer", ")", "value", ")", ".", "shortValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "argout", "=", "Short", ".", "valueOf", "(", "(", "(", "Long", ")", "value", ")", ".", "shortValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "argout", "=", "Short", ".", "valueOf", "(", "(", "(", "Float", ")", "value", ")", ".", "shortValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "if", "(", "(", "(", "Boolean", ")", "value", ")", ".", "booleanValue", "(", ")", ")", "{", "argout", "=", "Short", ".", "valueOf", "(", "(", "short", ")", "1", ")", ";", "}", "else", "{", "argout", "=", "Short", ".", "valueOf", "(", "(", "short", ")", "0", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "argout", "=", "Short", ".", "valueOf", "(", "(", "(", "Double", ")", "value", ")", ".", "shortValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "argout", "=", "Short", ".", "valueOf", "(", "Integer", ".", "valueOf", "(", "(", "(", "DevState", ")", "value", ")", ".", "value", "(", ")", ")", ".", "shortValue", "(", ")", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extractToShort(Object value,deviceAttributeWritten)\"", ")", ";", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to a Short @param deviceAttributeRead the DeviceAttribute attribute to read @return Short, the result in Short format @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "a", "Short" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L684-L720
140,439
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extractToString
public static String extractToString(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); String argout = null; if (value instanceof Short) { argout = ((Short) value).toString(); } else if (value instanceof String) { argout = (String) value; } else if (value instanceof Integer) { argout = ((Integer) value).toString(); } else if (value instanceof Long) { argout = ((Long) value).toString(); } else if (value instanceof Float) { argout = ((Float) value).toString(); } else if (value instanceof Boolean) { argout = ((Boolean) value).toString(); } else if (value instanceof Double) { argout = ((Double) value).toString(); } else if (value instanceof DevState) { argout = StateUtilities.getNameForState((DevState) value); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToString(Object value,deviceAttributeWritten)"); } return argout; }
java
public static String extractToString(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); String argout = null; if (value instanceof Short) { argout = ((Short) value).toString(); } else if (value instanceof String) { argout = (String) value; } else if (value instanceof Integer) { argout = ((Integer) value).toString(); } else if (value instanceof Long) { argout = ((Long) value).toString(); } else if (value instanceof Float) { argout = ((Float) value).toString(); } else if (value instanceof Boolean) { argout = ((Boolean) value).toString(); } else if (value instanceof Double) { argout = ((Double) value).toString(); } else if (value instanceof DevState) { argout = StateUtilities.getNameForState((DevState) value); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToString(Object value,deviceAttributeWritten)"); } return argout; }
[ "public", "static", "String", "extractToString", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "final", "Object", "value", "=", "AttributeHelper", ".", "extract", "(", "deviceAttributeRead", ")", ";", "String", "argout", "=", "null", ";", "if", "(", "value", "instanceof", "Short", ")", "{", "argout", "=", "(", "(", "Short", ")", "value", ")", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "argout", "=", "(", "String", ")", "value", ";", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "argout", "=", "(", "(", "Integer", ")", "value", ")", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "argout", "=", "(", "(", "Long", ")", "value", ")", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "argout", "=", "(", "(", "Float", ")", "value", ")", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "argout", "=", "(", "(", "Boolean", ")", "value", ")", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "argout", "=", "(", "(", "Double", ")", "value", ")", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "argout", "=", "StateUtilities", ".", "getNameForState", "(", "(", "DevState", ")", "value", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extractToString(Object value,deviceAttributeWritten)\"", ")", ";", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to a String @param deviceAttributeRead the DeviceAttribute attribute to read @return String, the result in String format @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "a", "String" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L730-L757
140,440
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extractToInteger
public static Integer extractToInteger(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Integer argout = null; if (value instanceof Short) { argout = Integer.valueOf(((Short) value).intValue()); } else if (value instanceof String) { try { argout = Integer.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToInteger(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = (Integer) value; } else if (value instanceof Long) { argout = Integer.valueOf(((Long) value).intValue()); } else if (value instanceof Float) { argout = Integer.valueOf(((Float) value).intValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Integer.valueOf(1); } else { argout = Integer.valueOf(0); } } else if (value instanceof Double) { argout = Integer.valueOf(((Double) value).intValue()); } else if (value instanceof DevState) { argout = Integer.valueOf(((DevState) value).value()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToInteger(Object value,deviceAttributeWritten)"); } return argout; }
java
public static Integer extractToInteger(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Integer argout = null; if (value instanceof Short) { argout = Integer.valueOf(((Short) value).intValue()); } else if (value instanceof String) { try { argout = Integer.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToInteger(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = (Integer) value; } else if (value instanceof Long) { argout = Integer.valueOf(((Long) value).intValue()); } else if (value instanceof Float) { argout = Integer.valueOf(((Float) value).intValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Integer.valueOf(1); } else { argout = Integer.valueOf(0); } } else if (value instanceof Double) { argout = Integer.valueOf(((Double) value).intValue()); } else if (value instanceof DevState) { argout = Integer.valueOf(((DevState) value).value()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToInteger(Object value,deviceAttributeWritten)"); } return argout; }
[ "public", "static", "Integer", "extractToInteger", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "final", "Object", "value", "=", "AttributeHelper", ".", "extract", "(", "deviceAttributeRead", ")", ";", "Integer", "argout", "=", "null", ";", "if", "(", "value", "instanceof", "Short", ")", "{", "argout", "=", "Integer", ".", "valueOf", "(", "(", "(", "Short", ")", "value", ")", ".", "intValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "try", "{", "argout", "=", "Integer", ".", "valueOf", "(", "(", "String", ")", "value", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", "+", "\" is not a numerical\"", ",", "\"AttributeHelper.extractToInteger(deviceAttributeWritten)\"", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "argout", "=", "(", "Integer", ")", "value", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "argout", "=", "Integer", ".", "valueOf", "(", "(", "(", "Long", ")", "value", ")", ".", "intValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "argout", "=", "Integer", ".", "valueOf", "(", "(", "(", "Float", ")", "value", ")", ".", "intValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "if", "(", "(", "(", "Boolean", ")", "value", ")", ".", "booleanValue", "(", ")", ")", "{", "argout", "=", "Integer", ".", "valueOf", "(", "1", ")", ";", "}", "else", "{", "argout", "=", "Integer", ".", "valueOf", "(", "0", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "argout", "=", "Integer", ".", "valueOf", "(", "(", "(", "Double", ")", "value", ")", ".", "intValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "argout", "=", "Integer", ".", "valueOf", "(", "(", "(", "DevState", ")", "value", ")", ".", "value", "(", ")", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extractToInteger(Object value,deviceAttributeWritten)\"", ")", ";", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to an Integer @param deviceAttributeRead the DeviceAttribute attribute to read @return Integer, the result in Integer format @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "an", "Integer" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L767-L804
140,441
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extractToLong
public static Long extractToLong(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Long argout = null; if (value instanceof Short) { argout = Long.valueOf(((Short) value).longValue()); } else if (value instanceof String) { try { argout = Long.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToLong(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Long.valueOf(((Integer) value).longValue()); } else if (value instanceof Long) { argout = Long.valueOf(((Long) value).longValue()); } else if (value instanceof Float) { argout = Long.valueOf(((Float) value).longValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Long.valueOf(1); } else { argout = Long.valueOf(0); } } else if (value instanceof Double) { argout = Long.valueOf(((Double) value).longValue()); } else if (value instanceof DevState) { argout = Long.valueOf(Integer.valueOf(((DevState) value).value()).longValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToLong(Object value,deviceAttributeWritten)"); } return argout; }
java
public static Long extractToLong(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Long argout = null; if (value instanceof Short) { argout = Long.valueOf(((Short) value).longValue()); } else if (value instanceof String) { try { argout = Long.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToLong(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Long.valueOf(((Integer) value).longValue()); } else if (value instanceof Long) { argout = Long.valueOf(((Long) value).longValue()); } else if (value instanceof Float) { argout = Long.valueOf(((Float) value).longValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Long.valueOf(1); } else { argout = Long.valueOf(0); } } else if (value instanceof Double) { argout = Long.valueOf(((Double) value).longValue()); } else if (value instanceof DevState) { argout = Long.valueOf(Integer.valueOf(((DevState) value).value()).longValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToLong(Object value,deviceAttributeWritten)"); } return argout; }
[ "public", "static", "Long", "extractToLong", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "final", "Object", "value", "=", "AttributeHelper", ".", "extract", "(", "deviceAttributeRead", ")", ";", "Long", "argout", "=", "null", ";", "if", "(", "value", "instanceof", "Short", ")", "{", "argout", "=", "Long", ".", "valueOf", "(", "(", "(", "Short", ")", "value", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "try", "{", "argout", "=", "Long", ".", "valueOf", "(", "(", "String", ")", "value", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", "+", "\" is not a numerical\"", ",", "\"AttributeHelper.extractToLong(deviceAttributeWritten)\"", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "argout", "=", "Long", ".", "valueOf", "(", "(", "(", "Integer", ")", "value", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "argout", "=", "Long", ".", "valueOf", "(", "(", "(", "Long", ")", "value", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "argout", "=", "Long", ".", "valueOf", "(", "(", "(", "Float", ")", "value", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "if", "(", "(", "(", "Boolean", ")", "value", ")", ".", "booleanValue", "(", ")", ")", "{", "argout", "=", "Long", ".", "valueOf", "(", "1", ")", ";", "}", "else", "{", "argout", "=", "Long", ".", "valueOf", "(", "0", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "argout", "=", "Long", ".", "valueOf", "(", "(", "(", "Double", ")", "value", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "argout", "=", "Long", ".", "valueOf", "(", "Integer", ".", "valueOf", "(", "(", "(", "DevState", ")", "value", ")", ".", "value", "(", ")", ")", ".", "longValue", "(", ")", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extractToLong(Object value,deviceAttributeWritten)\"", ")", ";", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to a Long @param deviceAttributeRead the DeviceAttribute attribute to read @return Long, the result in Long format @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "a", "Long" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L814-L850
140,442
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extractToFloat
public static Float extractToFloat(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Float argout = null; if (value instanceof Short) { argout = Float.valueOf(((Short) value).floatValue()); } else if (value instanceof String) { try { argout = Float.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToFloat(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Float.valueOf(((Integer) value).floatValue()); } else if (value instanceof Long) { argout = Float.valueOf(((Long) value).floatValue()); } else if (value instanceof Float) { argout = Float.valueOf(((Float) value).floatValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Float.valueOf(1); } else { argout = Float.valueOf(0); } } else if (value instanceof Double) { argout = Float.valueOf(((Double) value).floatValue()); } else if (value instanceof DevState) { argout = Float.valueOf(Integer.valueOf(((DevState) value).value()).floatValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)"); } return argout; }
java
public static Float extractToFloat(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Float argout = null; if (value instanceof Short) { argout = Float.valueOf(((Short) value).floatValue()); } else if (value instanceof String) { try { argout = Float.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToFloat(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Float.valueOf(((Integer) value).floatValue()); } else if (value instanceof Long) { argout = Float.valueOf(((Long) value).floatValue()); } else if (value instanceof Float) { argout = Float.valueOf(((Float) value).floatValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Float.valueOf(1); } else { argout = Float.valueOf(0); } } else if (value instanceof Double) { argout = Float.valueOf(((Double) value).floatValue()); } else if (value instanceof DevState) { argout = Float.valueOf(Integer.valueOf(((DevState) value).value()).floatValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)"); } return argout; }
[ "public", "static", "Float", "extractToFloat", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "final", "Object", "value", "=", "AttributeHelper", ".", "extract", "(", "deviceAttributeRead", ")", ";", "Float", "argout", "=", "null", ";", "if", "(", "value", "instanceof", "Short", ")", "{", "argout", "=", "Float", ".", "valueOf", "(", "(", "(", "Short", ")", "value", ")", ".", "floatValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "try", "{", "argout", "=", "Float", ".", "valueOf", "(", "(", "String", ")", "value", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", "+", "\" is not a numerical\"", ",", "\"AttributeHelper.extractToFloat(deviceAttributeWritten)\"", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "argout", "=", "Float", ".", "valueOf", "(", "(", "(", "Integer", ")", "value", ")", ".", "floatValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "argout", "=", "Float", ".", "valueOf", "(", "(", "(", "Long", ")", "value", ")", ".", "floatValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "argout", "=", "Float", ".", "valueOf", "(", "(", "(", "Float", ")", "value", ")", ".", "floatValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "if", "(", "(", "(", "Boolean", ")", "value", ")", ".", "booleanValue", "(", ")", ")", "{", "argout", "=", "Float", ".", "valueOf", "(", "1", ")", ";", "}", "else", "{", "argout", "=", "Float", ".", "valueOf", "(", "0", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "argout", "=", "Float", ".", "valueOf", "(", "(", "(", "Double", ")", "value", ")", ".", "floatValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "argout", "=", "Float", ".", "valueOf", "(", "Integer", ".", "valueOf", "(", "(", "(", "DevState", ")", "value", ")", ".", "value", "(", ")", ")", ".", "floatValue", "(", ")", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)\"", ")", ";", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to a Float @param deviceAttributeRead the DeviceAttribute attribute to read @return Float the result in Float format @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "a", "Float" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L860-L896
140,443
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extractToBoolean
public static Boolean extractToBoolean(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); int boolValue = 0; Boolean argout = Boolean.FALSE; ; if (value instanceof Short) { boolValue = ((Short) value).intValue(); } else if (value instanceof String) { try { if (Boolean.getBoolean((String) value)) { boolValue = 1; } } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a boolean", "AttributeHelper.extractToBoolean(deviceAttributeWritten)"); } } else if (value instanceof Integer) { boolValue = ((Integer) value).intValue(); } else if (value instanceof Long) { boolValue = ((Long) value).intValue(); } else if (value instanceof Float) { boolValue = ((Float) value).intValue(); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { boolValue = 1; } } else if (value instanceof Double) { boolValue = ((Double) value).intValue(); } else if (value instanceof DevState) { boolValue = ((DevState) value).value(); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToBoolean(Object value,deviceAttributeWritten)"); } if (boolValue == 1) { argout = Boolean.TRUE; } return argout; }
java
public static Boolean extractToBoolean(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); int boolValue = 0; Boolean argout = Boolean.FALSE; ; if (value instanceof Short) { boolValue = ((Short) value).intValue(); } else if (value instanceof String) { try { if (Boolean.getBoolean((String) value)) { boolValue = 1; } } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a boolean", "AttributeHelper.extractToBoolean(deviceAttributeWritten)"); } } else if (value instanceof Integer) { boolValue = ((Integer) value).intValue(); } else if (value instanceof Long) { boolValue = ((Long) value).intValue(); } else if (value instanceof Float) { boolValue = ((Float) value).intValue(); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { boolValue = 1; } } else if (value instanceof Double) { boolValue = ((Double) value).intValue(); } else if (value instanceof DevState) { boolValue = ((DevState) value).value(); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToBoolean(Object value,deviceAttributeWritten)"); } if (boolValue == 1) { argout = Boolean.TRUE; } return argout; }
[ "public", "static", "Boolean", "extractToBoolean", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "final", "Object", "value", "=", "AttributeHelper", ".", "extract", "(", "deviceAttributeRead", ")", ";", "int", "boolValue", "=", "0", ";", "Boolean", "argout", "=", "Boolean", ".", "FALSE", ";", ";", "if", "(", "value", "instanceof", "Short", ")", "{", "boolValue", "=", "(", "(", "Short", ")", "value", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "try", "{", "if", "(", "Boolean", ".", "getBoolean", "(", "(", "String", ")", "value", ")", ")", "{", "boolValue", "=", "1", ";", "}", "}", "catch", "(", "final", "Exception", "e", ")", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", "+", "\" is not a boolean\"", ",", "\"AttributeHelper.extractToBoolean(deviceAttributeWritten)\"", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "boolValue", "=", "(", "(", "Integer", ")", "value", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "boolValue", "=", "(", "(", "Long", ")", "value", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "boolValue", "=", "(", "(", "Float", ")", "value", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "if", "(", "(", "(", "Boolean", ")", "value", ")", ".", "booleanValue", "(", ")", ")", "{", "boolValue", "=", "1", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "boolValue", "=", "(", "(", "Double", ")", "value", ")", ".", "intValue", "(", ")", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "boolValue", "=", "(", "(", "DevState", ")", "value", ")", ".", "value", "(", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extractToBoolean(Object value,deviceAttributeWritten)\"", ")", ";", "}", "if", "(", "boolValue", "==", "1", ")", "{", "argout", "=", "Boolean", ".", "TRUE", ";", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to a Boolean. @param deviceAttributeRead the DeviceAttribute attribute to read @return Boolean the result in Boolean format @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "a", "Boolean", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L906-L950
140,444
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.extractToDouble
public static Double extractToDouble(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Double argout = null; if (value instanceof Short) { argout = Double.valueOf(((Short) value).doubleValue()); } else if (value instanceof String) { try { argout = Double.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToFloat(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Double.valueOf(((Integer) value).doubleValue()); } else if (value instanceof Long) { argout = Double.valueOf(((Long) value).doubleValue()); } else if (value instanceof Float) { argout = Double.valueOf(((Float) value).doubleValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Double.valueOf(1); } else { argout = Double.valueOf(0); } } else if (value instanceof Double) { argout = (Double) value; } else if (value instanceof DevState) { argout = Double.valueOf(Integer.valueOf(((DevState) value).value()).doubleValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)"); } return argout; }
java
public static Double extractToDouble(final DeviceAttribute deviceAttributeRead) throws DevFailed { final Object value = AttributeHelper.extract(deviceAttributeRead); Double argout = null; if (value instanceof Short) { argout = Double.valueOf(((Short) value).doubleValue()); } else if (value instanceof String) { try { argout = Double.valueOf((String) value); } catch (final Exception e) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value + " is not a numerical", "AttributeHelper.extractToFloat(deviceAttributeWritten)"); } } else if (value instanceof Integer) { argout = Double.valueOf(((Integer) value).doubleValue()); } else if (value instanceof Long) { argout = Double.valueOf(((Long) value).doubleValue()); } else if (value instanceof Float) { argout = Double.valueOf(((Float) value).doubleValue()); } else if (value instanceof Boolean) { if (((Boolean) value).booleanValue()) { argout = Double.valueOf(1); } else { argout = Double.valueOf(0); } } else if (value instanceof Double) { argout = (Double) value; } else if (value instanceof DevState) { argout = Double.valueOf(Integer.valueOf(((DevState) value).value()).doubleValue()); } else { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type " + value.getClass() + " not supported", "AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)"); } return argout; }
[ "public", "static", "Double", "extractToDouble", "(", "final", "DeviceAttribute", "deviceAttributeRead", ")", "throws", "DevFailed", "{", "final", "Object", "value", "=", "AttributeHelper", ".", "extract", "(", "deviceAttributeRead", ")", ";", "Double", "argout", "=", "null", ";", "if", "(", "value", "instanceof", "Short", ")", "{", "argout", "=", "Double", ".", "valueOf", "(", "(", "(", "Short", ")", "value", ")", ".", "doubleValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "String", ")", "{", "try", "{", "argout", "=", "Double", ".", "valueOf", "(", "(", "String", ")", "value", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", "+", "\" is not a numerical\"", ",", "\"AttributeHelper.extractToFloat(deviceAttributeWritten)\"", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Integer", ")", "{", "argout", "=", "Double", ".", "valueOf", "(", "(", "(", "Integer", ")", "value", ")", ".", "doubleValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Long", ")", "{", "argout", "=", "Double", ".", "valueOf", "(", "(", "(", "Long", ")", "value", ")", ".", "doubleValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Float", ")", "{", "argout", "=", "Double", ".", "valueOf", "(", "(", "(", "Float", ")", "value", ")", ".", "doubleValue", "(", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Boolean", ")", "{", "if", "(", "(", "(", "Boolean", ")", "value", ")", ".", "booleanValue", "(", ")", ")", "{", "argout", "=", "Double", ".", "valueOf", "(", "1", ")", ";", "}", "else", "{", "argout", "=", "Double", ".", "valueOf", "(", "0", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "Double", ")", "{", "argout", "=", "(", "Double", ")", "value", ";", "}", "else", "if", "(", "value", "instanceof", "DevState", ")", "{", "argout", "=", "Double", ".", "valueOf", "(", "Integer", ".", "valueOf", "(", "(", "(", "DevState", ")", "value", ")", ".", "value", "(", ")", ")", ".", "doubleValue", "(", ")", ")", ";", "}", "else", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"output type \"", "+", "value", ".", "getClass", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.extractToFloat(Object value,deviceAttributeWritten)\"", ")", ";", "}", "return", "argout", ";", "}" ]
Extract data from DeviceAttribute to a Double. @param deviceAttributeRead the DeviceAttribute attribute to read @return Double the result in Double format @throws DevFailed
[ "Extract", "data", "from", "DeviceAttribute", "to", "a", "Double", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L960-L997
140,445
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.insertFromInteger
public static void insertFromInteger(final Integer integerValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { switch (deviceAttributeWritten.getType()) { case TangoConst.Tango_DEV_SHORT: deviceAttributeWritten.insert(integerValue.shortValue()); break; case TangoConst.Tango_DEV_USHORT: deviceAttributeWritten.insert_us(integerValue.shortValue()); break; case TangoConst.Tango_DEV_CHAR: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: deviceAttributeWritten.insert_uc(integerValue.shortValue()); break; case TangoConst.Tango_DEV_LONG: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_ULONG: deviceAttributeWritten.insert_ul(integerValue.longValue()); break; case TangoConst.Tango_DEV_LONG64: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_LONG64 not supported", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_ULONG64: deviceAttributeWritten.insert_u64(integerValue.longValue()); break; case TangoConst.Tango_DEV_INT: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_FLOAT: deviceAttributeWritten.insert(integerValue.floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: deviceAttributeWritten.insert(integerValue.doubleValue()); break; case TangoConst.Tango_DEV_STRING: deviceAttributeWritten.insert(integerValue.toString()); break; case TangoConst.Tango_DEV_BOOLEAN: if (integerValue.doubleValue() == 1) { deviceAttributeWritten.insert(true); } else { deviceAttributeWritten.insert(false); } break; case TangoConst.Tango_DEV_STATE: try { deviceAttributeWritten.insert(DevState.from_int(integerValue.intValue())); } catch (final org.omg.CORBA.BAD_PARAM badParam) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "Cannot sent" + integerValue.intValue() + "for input Tango_DEV_STATE type", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); } break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); break; } }
java
public static void insertFromInteger(final Integer integerValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { switch (deviceAttributeWritten.getType()) { case TangoConst.Tango_DEV_SHORT: deviceAttributeWritten.insert(integerValue.shortValue()); break; case TangoConst.Tango_DEV_USHORT: deviceAttributeWritten.insert_us(integerValue.shortValue()); break; case TangoConst.Tango_DEV_CHAR: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: deviceAttributeWritten.insert_uc(integerValue.shortValue()); break; case TangoConst.Tango_DEV_LONG: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_ULONG: deviceAttributeWritten.insert_ul(integerValue.longValue()); break; case TangoConst.Tango_DEV_LONG64: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_LONG64 not supported", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_ULONG64: deviceAttributeWritten.insert_u64(integerValue.longValue()); break; case TangoConst.Tango_DEV_INT: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_FLOAT: deviceAttributeWritten.insert(integerValue.floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: deviceAttributeWritten.insert(integerValue.doubleValue()); break; case TangoConst.Tango_DEV_STRING: deviceAttributeWritten.insert(integerValue.toString()); break; case TangoConst.Tango_DEV_BOOLEAN: if (integerValue.doubleValue() == 1) { deviceAttributeWritten.insert(true); } else { deviceAttributeWritten.insert(false); } break; case TangoConst.Tango_DEV_STATE: try { deviceAttributeWritten.insert(DevState.from_int(integerValue.intValue())); } catch (final org.omg.CORBA.BAD_PARAM badParam) { Except.throw_exception("TANGO_WRONG_DATA_ERROR", "Cannot sent" + integerValue.intValue() + "for input Tango_DEV_STATE type", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); } break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)"); break; } }
[ "public", "static", "void", "insertFromInteger", "(", "final", "Integer", "integerValue", ",", "final", "DeviceAttribute", "deviceAttributeWritten", ")", "throws", "DevFailed", "{", "switch", "(", "deviceAttributeWritten", ".", "getType", "(", ")", ")", "{", "case", "TangoConst", ".", "Tango_DEV_SHORT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_USHORT", ":", "deviceAttributeWritten", ".", "insert_us", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_CHAR", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_CHAR not supported\"", ",", "\"AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_UCHAR", ":", "deviceAttributeWritten", ".", "insert_uc", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "intValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG", ":", "deviceAttributeWritten", ".", "insert_ul", "(", "integerValue", ".", "longValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG64", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_LONG64 not supported\"", ",", "\"AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG64", ":", "deviceAttributeWritten", ".", "insert_u64", "(", "integerValue", ".", "longValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_INT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "intValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_FLOAT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "floatValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_DOUBLE", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "doubleValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STRING", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "toString", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_BOOLEAN", ":", "if", "(", "integerValue", ".", "doubleValue", "(", ")", "==", "1", ")", "{", "deviceAttributeWritten", ".", "insert", "(", "true", ")", ";", "}", "else", "{", "deviceAttributeWritten", ".", "insert", "(", "false", ")", ";", "}", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STATE", ":", "try", "{", "deviceAttributeWritten", ".", "insert", "(", "DevState", ".", "from_int", "(", "integerValue", ".", "intValue", "(", ")", ")", ")", ";", "}", "catch", "(", "final", "org", ".", "omg", ".", "CORBA", ".", "BAD_PARAM", "badParam", ")", "{", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"Cannot sent\"", "+", "integerValue", ".", "intValue", "(", ")", "+", "\"for input Tango_DEV_STATE type\"", ",", "\"AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)\"", ")", ";", "}", "break", ";", "default", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type \"", "+", "deviceAttributeWritten", ".", "getType", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.insertFromInteger(Integer value,deviceAttributeWritten)\"", ")", ";", "break", ";", "}", "}" ]
Insert data in DeviceAttribute from a Integer. @param integerValue the value to insert on DeviceAttribute @param deviceAttributeWritten the DeviceAttribute attribute to write @throws DevFailed
[ "Insert", "data", "in", "DeviceAttribute", "from", "a", "Integer", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L3460-L3526
140,446
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.insertFromBoolean
public static void insertFromBoolean(final Boolean booleanValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { Integer integerValue = 0; if (booleanValue.booleanValue()) { integerValue = 1; } switch (deviceAttributeWritten.getType()) { case TangoConst.Tango_DEV_SHORT: deviceAttributeWritten.insert(integerValue.shortValue()); break; case TangoConst.Tango_DEV_USHORT: deviceAttributeWritten.insert_us(integerValue.shortValue()); break; case TangoConst.Tango_DEV_CHAR: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: deviceAttributeWritten.insert_uc(integerValue.shortValue()); break; case TangoConst.Tango_DEV_LONG: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_ULONG: deviceAttributeWritten.insert_ul(integerValue.longValue()); break; case TangoConst.Tango_DEV_LONG64: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_LONG64 not supported", "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_ULONG64: deviceAttributeWritten.insert_u64(integerValue.longValue()); break; case TangoConst.Tango_DEV_INT: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_FLOAT: deviceAttributeWritten.insert(integerValue.floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: deviceAttributeWritten.insert(integerValue.doubleValue()); break; case TangoConst.Tango_DEV_STRING: deviceAttributeWritten.insert(Boolean.toString(booleanValue.booleanValue())); break; case TangoConst.Tango_DEV_BOOLEAN: deviceAttributeWritten.insert(booleanValue.booleanValue()); break; case TangoConst.Tango_DEV_STATE: deviceAttributeWritten.insert(DevState.from_int(integerValue.intValue())); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)"); break; } }
java
public static void insertFromBoolean(final Boolean booleanValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { Integer integerValue = 0; if (booleanValue.booleanValue()) { integerValue = 1; } switch (deviceAttributeWritten.getType()) { case TangoConst.Tango_DEV_SHORT: deviceAttributeWritten.insert(integerValue.shortValue()); break; case TangoConst.Tango_DEV_USHORT: deviceAttributeWritten.insert_us(integerValue.shortValue()); break; case TangoConst.Tango_DEV_CHAR: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: deviceAttributeWritten.insert_uc(integerValue.shortValue()); break; case TangoConst.Tango_DEV_LONG: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_ULONG: deviceAttributeWritten.insert_ul(integerValue.longValue()); break; case TangoConst.Tango_DEV_LONG64: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_LONG64 not supported", "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_ULONG64: deviceAttributeWritten.insert_u64(integerValue.longValue()); break; case TangoConst.Tango_DEV_INT: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_FLOAT: deviceAttributeWritten.insert(integerValue.floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: deviceAttributeWritten.insert(integerValue.doubleValue()); break; case TangoConst.Tango_DEV_STRING: deviceAttributeWritten.insert(Boolean.toString(booleanValue.booleanValue())); break; case TangoConst.Tango_DEV_BOOLEAN: deviceAttributeWritten.insert(booleanValue.booleanValue()); break; case TangoConst.Tango_DEV_STATE: deviceAttributeWritten.insert(DevState.from_int(integerValue.intValue())); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)"); break; } }
[ "public", "static", "void", "insertFromBoolean", "(", "final", "Boolean", "booleanValue", ",", "final", "DeviceAttribute", "deviceAttributeWritten", ")", "throws", "DevFailed", "{", "Integer", "integerValue", "=", "0", ";", "if", "(", "booleanValue", ".", "booleanValue", "(", ")", ")", "{", "integerValue", "=", "1", ";", "}", "switch", "(", "deviceAttributeWritten", ".", "getType", "(", ")", ")", "{", "case", "TangoConst", ".", "Tango_DEV_SHORT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_USHORT", ":", "deviceAttributeWritten", ".", "insert_us", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_CHAR", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_CHAR not supported\"", ",", "\"AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_UCHAR", ":", "deviceAttributeWritten", ".", "insert_uc", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "intValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG", ":", "deviceAttributeWritten", ".", "insert_ul", "(", "integerValue", ".", "longValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG64", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_LONG64 not supported\"", ",", "\"AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG64", ":", "deviceAttributeWritten", ".", "insert_u64", "(", "integerValue", ".", "longValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_INT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "intValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_FLOAT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "floatValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_DOUBLE", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "doubleValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STRING", ":", "deviceAttributeWritten", ".", "insert", "(", "Boolean", ".", "toString", "(", "booleanValue", ".", "booleanValue", "(", ")", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_BOOLEAN", ":", "deviceAttributeWritten", ".", "insert", "(", "booleanValue", ".", "booleanValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STATE", ":", "deviceAttributeWritten", ".", "insert", "(", "DevState", ".", "from_int", "(", "integerValue", ".", "intValue", "(", ")", ")", ")", ";", "break", ";", "default", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type \"", "+", "deviceAttributeWritten", ".", "getType", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.insertFromBoolean(Boolean value,deviceAttributeWritten)\"", ")", ";", "break", ";", "}", "}" ]
Insert data in DeviceAttribute from a Boolean. @param booleanValue the value to insert on DeviceAttribute @param deviceAttributeWritten the DeviceAttribute attribute to write @throws DevFailed
[ "Insert", "data", "in", "DeviceAttribute", "from", "a", "Boolean", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L3691-L3752
140,447
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.insertFromWAttribute
public static void insertFromWAttribute(final WAttribute wAttributeValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { Object value = null; switch (wAttributeValue.get_data_type()) { case TangoConst.Tango_DEV_SHORT: value = Short.valueOf(wAttributeValue.getShortWriteValue()); break; case TangoConst.Tango_DEV_USHORT: value = Integer.valueOf(wAttributeValue.getUShortWriteValue()); break; case TangoConst.Tango_DEV_CHAR: Except .throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: Except .throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_UCHAR not supported", "AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_LONG: value = Integer.valueOf(wAttributeValue.getLongWriteValue()); break; case TangoConst.Tango_DEV_ULONG: value = Long.valueOf(wAttributeValue.getULongWriteValue()); break; case TangoConst.Tango_DEV_LONG64: value = Long.valueOf(wAttributeValue.getLong64WriteValue()); break; case TangoConst.Tango_DEV_ULONG64: value = Long.valueOf(wAttributeValue.getULong64WriteValue()); break; case TangoConst.Tango_DEV_INT: value = Integer.valueOf(wAttributeValue.getLongWriteValue()); break; case TangoConst.Tango_DEV_FLOAT: value = Float.valueOf(Double.valueOf(wAttributeValue.getDoubleWriteValue()) .floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: value = Double.valueOf(wAttributeValue.getDoubleWriteValue()); break; case TangoConst.Tango_DEV_STRING: value = wAttributeValue.getStringWriteValue(); break; case TangoConst.Tango_DEV_BOOLEAN: value = Boolean.valueOf(wAttributeValue.getBooleanWriteValue()); break; case TangoConst.Tango_DEV_STATE: value = wAttributeValue.getStateWriteValue(); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromDouble(Double value,deviceAttributeWritten)"); break; } insert(value, deviceAttributeWritten); }
java
public static void insertFromWAttribute(final WAttribute wAttributeValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { Object value = null; switch (wAttributeValue.get_data_type()) { case TangoConst.Tango_DEV_SHORT: value = Short.valueOf(wAttributeValue.getShortWriteValue()); break; case TangoConst.Tango_DEV_USHORT: value = Integer.valueOf(wAttributeValue.getUShortWriteValue()); break; case TangoConst.Tango_DEV_CHAR: Except .throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: Except .throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_UCHAR not supported", "AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_LONG: value = Integer.valueOf(wAttributeValue.getLongWriteValue()); break; case TangoConst.Tango_DEV_ULONG: value = Long.valueOf(wAttributeValue.getULongWriteValue()); break; case TangoConst.Tango_DEV_LONG64: value = Long.valueOf(wAttributeValue.getLong64WriteValue()); break; case TangoConst.Tango_DEV_ULONG64: value = Long.valueOf(wAttributeValue.getULong64WriteValue()); break; case TangoConst.Tango_DEV_INT: value = Integer.valueOf(wAttributeValue.getLongWriteValue()); break; case TangoConst.Tango_DEV_FLOAT: value = Float.valueOf(Double.valueOf(wAttributeValue.getDoubleWriteValue()) .floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: value = Double.valueOf(wAttributeValue.getDoubleWriteValue()); break; case TangoConst.Tango_DEV_STRING: value = wAttributeValue.getStringWriteValue(); break; case TangoConst.Tango_DEV_BOOLEAN: value = Boolean.valueOf(wAttributeValue.getBooleanWriteValue()); break; case TangoConst.Tango_DEV_STATE: value = wAttributeValue.getStateWriteValue(); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromDouble(Double value,deviceAttributeWritten)"); break; } insert(value, deviceAttributeWritten); }
[ "public", "static", "void", "insertFromWAttribute", "(", "final", "WAttribute", "wAttributeValue", ",", "final", "DeviceAttribute", "deviceAttributeWritten", ")", "throws", "DevFailed", "{", "Object", "value", "=", "null", ";", "switch", "(", "wAttributeValue", ".", "get_data_type", "(", ")", ")", "{", "case", "TangoConst", ".", "Tango_DEV_SHORT", ":", "value", "=", "Short", ".", "valueOf", "(", "wAttributeValue", ".", "getShortWriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_USHORT", ":", "value", "=", "Integer", ".", "valueOf", "(", "wAttributeValue", ".", "getUShortWriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_CHAR", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_CHAR not supported\"", ",", "\"AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_UCHAR", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_UCHAR not supported\"", ",", "\"AttributeHelper.insertFromWAttribute(WAttribute wAttributeValue,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG", ":", "value", "=", "Integer", ".", "valueOf", "(", "wAttributeValue", ".", "getLongWriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG", ":", "value", "=", "Long", ".", "valueOf", "(", "wAttributeValue", ".", "getULongWriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG64", ":", "value", "=", "Long", ".", "valueOf", "(", "wAttributeValue", ".", "getLong64WriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG64", ":", "value", "=", "Long", ".", "valueOf", "(", "wAttributeValue", ".", "getULong64WriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_INT", ":", "value", "=", "Integer", ".", "valueOf", "(", "wAttributeValue", ".", "getLongWriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_FLOAT", ":", "value", "=", "Float", ".", "valueOf", "(", "Double", ".", "valueOf", "(", "wAttributeValue", ".", "getDoubleWriteValue", "(", ")", ")", ".", "floatValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_DOUBLE", ":", "value", "=", "Double", ".", "valueOf", "(", "wAttributeValue", ".", "getDoubleWriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STRING", ":", "value", "=", "wAttributeValue", ".", "getStringWriteValue", "(", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_BOOLEAN", ":", "value", "=", "Boolean", ".", "valueOf", "(", "wAttributeValue", ".", "getBooleanWriteValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STATE", ":", "value", "=", "wAttributeValue", ".", "getStateWriteValue", "(", ")", ";", "break", ";", "default", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type \"", "+", "deviceAttributeWritten", ".", "getType", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.insertFromDouble(Double value,deviceAttributeWritten)\"", ")", ";", "break", ";", "}", "insert", "(", "value", ",", "deviceAttributeWritten", ")", ";", "}" ]
Insert data in DeviceAttribute from a WAttribute. @param wAttributeValue the value to insert on DeviceAttribute @param deviceAttributeWritten the DeviceAttribute attribute to write @throws DevFailed
[ "Insert", "data", "in", "DeviceAttribute", "from", "a", "WAttribute", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L3843-L3904
140,448
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.insertFromDevState
public static void insertFromDevState(final DevState devStateValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { final Integer integerValue = Integer.valueOf(devStateValue.value()); switch (deviceAttributeWritten.getType()) { case TangoConst.Tango_DEV_SHORT: deviceAttributeWritten.insert(integerValue.shortValue()); break; case TangoConst.Tango_DEV_USHORT: deviceAttributeWritten.insert_us(integerValue.shortValue()); break; case TangoConst.Tango_DEV_CHAR: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: deviceAttributeWritten.insert_uc(integerValue.shortValue()); break; case TangoConst.Tango_DEV_LONG: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_ULONG: deviceAttributeWritten.insert_ul(integerValue.longValue()); break; case TangoConst.Tango_DEV_LONG64: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_LONG64 not supported", "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_ULONG64: deviceAttributeWritten.insert_u64(integerValue.longValue()); break; case TangoConst.Tango_DEV_INT: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_FLOAT: deviceAttributeWritten.insert(integerValue.floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: deviceAttributeWritten.insert(integerValue.doubleValue()); break; case TangoConst.Tango_DEV_STRING: deviceAttributeWritten.insert(integerValue.toString()); break; case TangoConst.Tango_DEV_BOOLEAN: if (integerValue.doubleValue() == 1) { deviceAttributeWritten.insert(true); } else { deviceAttributeWritten.insert(false); } break; case TangoConst.Tango_DEV_STATE: deviceAttributeWritten.insert(devStateValue); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)"); break; } }
java
public static void insertFromDevState(final DevState devStateValue, final DeviceAttribute deviceAttributeWritten) throws DevFailed { final Integer integerValue = Integer.valueOf(devStateValue.value()); switch (deviceAttributeWritten.getType()) { case TangoConst.Tango_DEV_SHORT: deviceAttributeWritten.insert(integerValue.shortValue()); break; case TangoConst.Tango_DEV_USHORT: deviceAttributeWritten.insert_us(integerValue.shortValue()); break; case TangoConst.Tango_DEV_CHAR: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_CHAR not supported", "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_UCHAR: deviceAttributeWritten.insert_uc(integerValue.shortValue()); break; case TangoConst.Tango_DEV_LONG: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_ULONG: deviceAttributeWritten.insert_ul(integerValue.longValue()); break; case TangoConst.Tango_DEV_LONG64: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type Tango_DEV_LONG64 not supported", "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)"); break; case TangoConst.Tango_DEV_ULONG64: deviceAttributeWritten.insert_u64(integerValue.longValue()); break; case TangoConst.Tango_DEV_INT: deviceAttributeWritten.insert(integerValue.intValue()); break; case TangoConst.Tango_DEV_FLOAT: deviceAttributeWritten.insert(integerValue.floatValue()); break; case TangoConst.Tango_DEV_DOUBLE: deviceAttributeWritten.insert(integerValue.doubleValue()); break; case TangoConst.Tango_DEV_STRING: deviceAttributeWritten.insert(integerValue.toString()); break; case TangoConst.Tango_DEV_BOOLEAN: if (integerValue.doubleValue() == 1) { deviceAttributeWritten.insert(true); } else { deviceAttributeWritten.insert(false); } break; case TangoConst.Tango_DEV_STATE: deviceAttributeWritten.insert(devStateValue); break; default: Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type " + deviceAttributeWritten.getType() + " not supported", "AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)"); break; } }
[ "public", "static", "void", "insertFromDevState", "(", "final", "DevState", "devStateValue", ",", "final", "DeviceAttribute", "deviceAttributeWritten", ")", "throws", "DevFailed", "{", "final", "Integer", "integerValue", "=", "Integer", ".", "valueOf", "(", "devStateValue", ".", "value", "(", ")", ")", ";", "switch", "(", "deviceAttributeWritten", ".", "getType", "(", ")", ")", "{", "case", "TangoConst", ".", "Tango_DEV_SHORT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_USHORT", ":", "deviceAttributeWritten", ".", "insert_us", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_CHAR", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_CHAR not supported\"", ",", "\"AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_UCHAR", ":", "deviceAttributeWritten", ".", "insert_uc", "(", "integerValue", ".", "shortValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "intValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG", ":", "deviceAttributeWritten", ".", "insert_ul", "(", "integerValue", ".", "longValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_LONG64", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type Tango_DEV_LONG64 not supported\"", ",", "\"AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)\"", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_ULONG64", ":", "deviceAttributeWritten", ".", "insert_u64", "(", "integerValue", ".", "longValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_INT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "intValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_FLOAT", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "floatValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_DOUBLE", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "doubleValue", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STRING", ":", "deviceAttributeWritten", ".", "insert", "(", "integerValue", ".", "toString", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_BOOLEAN", ":", "if", "(", "integerValue", ".", "doubleValue", "(", ")", "==", "1", ")", "{", "deviceAttributeWritten", ".", "insert", "(", "true", ")", ";", "}", "else", "{", "deviceAttributeWritten", ".", "insert", "(", "false", ")", ";", "}", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STATE", ":", "deviceAttributeWritten", ".", "insert", "(", "devStateValue", ")", ";", "break", ";", "default", ":", "Except", ".", "throw_exception", "(", "\"TANGO_WRONG_DATA_ERROR\"", ",", "\"input type \"", "+", "deviceAttributeWritten", ".", "getType", "(", ")", "+", "\" not supported\"", ",", "\"AttributeHelper.insertFromDevState(DevState value,deviceAttributeWritten)\"", ")", ";", "break", ";", "}", "}" ]
Insert data in DeviceAttribute from a DevState. @param devStateValue the value to insert on DeviceAttribute @param deviceAttributeWritten the DeviceAttribute attribute to write @throws DevFailed
[ "Insert", "data", "in", "DeviceAttribute", "from", "a", "DevState", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L3915-L3976
140,449
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java
AttributeHelper.fillDbDatumFromDeviceAttribute
public final static void fillDbDatumFromDeviceAttribute(final DbDatum dbDatum, final DeviceAttribute deviceAttribute) throws DevFailed { switch (deviceAttribute.getType()) { case TangoConst.Tango_DEV_VOID: // nothing to do break; case TangoConst.Tango_DEV_BOOLEAN: dbDatum.insert(deviceAttribute.extractBoolean()); break; case TangoConst.Tango_DEV_SHORT: dbDatum.insert(deviceAttribute.extractShort()); break; case TangoConst.Tango_DEV_USHORT: dbDatum.insert(deviceAttribute.extractUShort()); break; // Loading isn t supported // case TangoConst.Tango_DEV_LONG: // datum.insert(dbattr.extractLong()); // break; // Loading isn t supported // case TangoConst.Tango_DEV_ULONG: // datum.insert(dbattr.extractULong()); // break; case TangoConst.Tango_DEV_FLOAT: dbDatum.insert(deviceAttribute.extractFloat()); break; case TangoConst.Tango_DEV_DOUBLE: dbDatum.insert(deviceAttribute.extractDouble()); break; case TangoConst.Tango_DEV_STRING: dbDatum.insert(deviceAttribute.extractString()); break; // Loading isn t supported // case TangoConst.Tango_DEVVAR_CHARARRAY: // datum.insert(dbattr.extractCharArray()); // break; case TangoConst.Tango_DEVVAR_SHORTARRAY: dbDatum.insert(deviceAttribute.extractShortArray()); break; case TangoConst.Tango_DEVVAR_USHORTARRAY: dbDatum.insert(deviceAttribute.extractUShortArray()); break; case TangoConst.Tango_DEVVAR_LONGARRAY: dbDatum.insert(deviceAttribute.extractLongArray()); break; case TangoConst.Tango_DEVVAR_FLOATARRAY: dbDatum.insert(deviceAttribute.extractFloatArray()); break; case TangoConst.Tango_DEVVAR_DOUBLEARRAY: dbDatum.insert(deviceAttribute.extractDoubleArray()); break; case TangoConst.Tango_DEVVAR_STRINGARRAY: dbDatum.insert(deviceAttribute.extractStringArray()); break; case TangoConst.Tango_DEVVAR_LONGSTRINGARRAY: dbDatum.insert(deviceAttribute.extractLongArray()); dbDatum.insert(deviceAttribute.extractStringArray()); break; case TangoConst.Tango_DEVVAR_DOUBLESTRINGARRAY: dbDatum.insert(deviceAttribute.extractDoubleArray()); dbDatum.insert(deviceAttribute.extractStringArray()); break; case TangoConst.Tango_DEVVAR_CHARARRAY: case TangoConst.Tango_DEVVAR_ULONGARRAY: case TangoConst.Tango_DEV_LONG: case TangoConst.Tango_DEV_ULONG: default: throw new UnsupportedOperationException( "Tango_DEVVAR_CHARARRAY, Tango_DEVVAR_ULONGARRAY, Tango_DEV_LONG, Tango_DEV_ULONG are not supported by DbDatum or DeviceAttribute"); } }
java
public final static void fillDbDatumFromDeviceAttribute(final DbDatum dbDatum, final DeviceAttribute deviceAttribute) throws DevFailed { switch (deviceAttribute.getType()) { case TangoConst.Tango_DEV_VOID: // nothing to do break; case TangoConst.Tango_DEV_BOOLEAN: dbDatum.insert(deviceAttribute.extractBoolean()); break; case TangoConst.Tango_DEV_SHORT: dbDatum.insert(deviceAttribute.extractShort()); break; case TangoConst.Tango_DEV_USHORT: dbDatum.insert(deviceAttribute.extractUShort()); break; // Loading isn t supported // case TangoConst.Tango_DEV_LONG: // datum.insert(dbattr.extractLong()); // break; // Loading isn t supported // case TangoConst.Tango_DEV_ULONG: // datum.insert(dbattr.extractULong()); // break; case TangoConst.Tango_DEV_FLOAT: dbDatum.insert(deviceAttribute.extractFloat()); break; case TangoConst.Tango_DEV_DOUBLE: dbDatum.insert(deviceAttribute.extractDouble()); break; case TangoConst.Tango_DEV_STRING: dbDatum.insert(deviceAttribute.extractString()); break; // Loading isn t supported // case TangoConst.Tango_DEVVAR_CHARARRAY: // datum.insert(dbattr.extractCharArray()); // break; case TangoConst.Tango_DEVVAR_SHORTARRAY: dbDatum.insert(deviceAttribute.extractShortArray()); break; case TangoConst.Tango_DEVVAR_USHORTARRAY: dbDatum.insert(deviceAttribute.extractUShortArray()); break; case TangoConst.Tango_DEVVAR_LONGARRAY: dbDatum.insert(deviceAttribute.extractLongArray()); break; case TangoConst.Tango_DEVVAR_FLOATARRAY: dbDatum.insert(deviceAttribute.extractFloatArray()); break; case TangoConst.Tango_DEVVAR_DOUBLEARRAY: dbDatum.insert(deviceAttribute.extractDoubleArray()); break; case TangoConst.Tango_DEVVAR_STRINGARRAY: dbDatum.insert(deviceAttribute.extractStringArray()); break; case TangoConst.Tango_DEVVAR_LONGSTRINGARRAY: dbDatum.insert(deviceAttribute.extractLongArray()); dbDatum.insert(deviceAttribute.extractStringArray()); break; case TangoConst.Tango_DEVVAR_DOUBLESTRINGARRAY: dbDatum.insert(deviceAttribute.extractDoubleArray()); dbDatum.insert(deviceAttribute.extractStringArray()); break; case TangoConst.Tango_DEVVAR_CHARARRAY: case TangoConst.Tango_DEVVAR_ULONGARRAY: case TangoConst.Tango_DEV_LONG: case TangoConst.Tango_DEV_ULONG: default: throw new UnsupportedOperationException( "Tango_DEVVAR_CHARARRAY, Tango_DEVVAR_ULONGARRAY, Tango_DEV_LONG, Tango_DEV_ULONG are not supported by DbDatum or DeviceAttribute"); } }
[ "public", "final", "static", "void", "fillDbDatumFromDeviceAttribute", "(", "final", "DbDatum", "dbDatum", ",", "final", "DeviceAttribute", "deviceAttribute", ")", "throws", "DevFailed", "{", "switch", "(", "deviceAttribute", ".", "getType", "(", ")", ")", "{", "case", "TangoConst", ".", "Tango_DEV_VOID", ":", "// nothing to do", "break", ";", "case", "TangoConst", ".", "Tango_DEV_BOOLEAN", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractBoolean", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_SHORT", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractShort", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_USHORT", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractUShort", "(", ")", ")", ";", "break", ";", "// Loading isn t supported", "// case TangoConst.Tango_DEV_LONG:", "// datum.insert(dbattr.extractLong());", "// break;", "// Loading isn t supported", "// case TangoConst.Tango_DEV_ULONG:", "// datum.insert(dbattr.extractULong());", "// break;", "case", "TangoConst", ".", "Tango_DEV_FLOAT", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractFloat", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_DOUBLE", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractDouble", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEV_STRING", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractString", "(", ")", ")", ";", "break", ";", "// Loading isn t supported", "// case TangoConst.Tango_DEVVAR_CHARARRAY:", "// datum.insert(dbattr.extractCharArray());", "// break;", "case", "TangoConst", ".", "Tango_DEVVAR_SHORTARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractShortArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_USHORTARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractUShortArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_LONGARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractLongArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_FLOATARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractFloatArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_DOUBLEARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractDoubleArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_STRINGARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractStringArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_LONGSTRINGARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractLongArray", "(", ")", ")", ";", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractStringArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_DOUBLESTRINGARRAY", ":", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractDoubleArray", "(", ")", ")", ";", "dbDatum", ".", "insert", "(", "deviceAttribute", ".", "extractStringArray", "(", ")", ")", ";", "break", ";", "case", "TangoConst", ".", "Tango_DEVVAR_CHARARRAY", ":", "case", "TangoConst", ".", "Tango_DEVVAR_ULONGARRAY", ":", "case", "TangoConst", ".", "Tango_DEV_LONG", ":", "case", "TangoConst", ".", "Tango_DEV_ULONG", ":", "default", ":", "throw", "new", "UnsupportedOperationException", "(", "\"Tango_DEVVAR_CHARARRAY, Tango_DEVVAR_ULONGARRAY, Tango_DEV_LONG, Tango_DEV_ULONG are not supported by DbDatum or DeviceAttribute\"", ")", ";", "}", "}" ]
Fill DbDatum from value of deviceAttribute Doesn't work for case TangoConst.Tango_DEVVAR_CHARARRAY: case TangoConst.Tango_DEVVAR_ULONGARRAY: case TangoConst.Tango_DEV_LONG: case TangoConst.Tango_DEV_ULONG: @param dbDatum the DbDatum to fill @param deviceAttribute the DeviceAttribute that contains value @throws DevFailed
[ "Fill", "DbDatum", "from", "value", "of", "deviceAttribute" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/AttributeHelper.java#L4062-L4151
140,450
tango-controls/JTango
server/src/main/java/org/tango/server/device/AroundInvokeImpl.java
AroundInvokeImpl.aroundInvoke
public void aroundInvoke(final InvocationContext ctx) throws DevFailed { xlogger.entry(); if (aroundInvokeMethod != null) { try { aroundInvokeMethod.invoke(businessObject, ctx); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } xlogger.exit(); }
java
public void aroundInvoke(final InvocationContext ctx) throws DevFailed { xlogger.entry(); if (aroundInvokeMethod != null) { try { aroundInvokeMethod.invoke(businessObject, ctx); } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } xlogger.exit(); }
[ "public", "void", "aroundInvoke", "(", "final", "InvocationContext", "ctx", ")", "throws", "DevFailed", "{", "xlogger", ".", "entry", "(", ")", ";", "if", "(", "aroundInvokeMethod", "!=", "null", ")", "{", "try", "{", "aroundInvokeMethod", ".", "invoke", "(", "businessObject", ",", "ctx", ")", ";", "}", "catch", "(", "final", "IllegalArgumentException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "IllegalAccessException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "InvocationTargetException", "e", ")", "{", "if", "(", "e", ".", "getCause", "(", ")", "instanceof", "DevFailed", ")", "{", "throw", "(", "DevFailed", ")", "e", ".", "getCause", "(", ")", ";", "}", "else", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ".", "getCause", "(", ")", ")", ";", "}", "}", "}", "xlogger", ".", "exit", "(", ")", ";", "}" ]
Call aroundInvoke implementation @param ctx invocation context @throws DevFailed
[ "Call", "aroundInvoke", "implementation" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/device/AroundInvokeImpl.java#L73-L91
140,451
tango-controls/JTango
server/src/main/java/org/tango/server/build/BuilderUtils.java
BuilderUtils.checkStatic
static void checkStatic(final Field field) throws DevFailed { if (Modifier.isStatic(field.getModifiers())) { throw DevFailedUtils.newDevFailed(DevFailedUtils.TANGO_BUILD_FAILED, field + MUST_NOT_BE_STATIC); } }
java
static void checkStatic(final Field field) throws DevFailed { if (Modifier.isStatic(field.getModifiers())) { throw DevFailedUtils.newDevFailed(DevFailedUtils.TANGO_BUILD_FAILED, field + MUST_NOT_BE_STATIC); } }
[ "static", "void", "checkStatic", "(", "final", "Field", "field", ")", "throws", "DevFailed", "{", "if", "(", "Modifier", ".", "isStatic", "(", "field", ".", "getModifiers", "(", ")", ")", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "DevFailedUtils", ".", "TANGO_BUILD_FAILED", ",", "field", "+", "MUST_NOT_BE_STATIC", ")", ";", "}", "}" ]
Check if a field is static @param field @throws DevFailed if static
[ "Check", "if", "a", "field", "is", "static" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/build/BuilderUtils.java#L109-L113
140,452
tango-controls/JTango
server/src/main/java/org/tango/server/build/BuilderUtils.java
BuilderUtils.setEnumLabelProperty
static AttributePropertiesImpl setEnumLabelProperty(final Class<?> type, final AttributePropertiesImpl props) throws DevFailed { // if is is an enum set enum values in properties if (AttributeTangoType.getTypeFromClass(type).equals(AttributeTangoType.DEVENUM)) { // final Class<Enum<?>> enumType = (Class<Enum<?>>) field.getType(); final Object[] enumValues = type.getEnumConstants(); final String[] enumLabels = new String[enumValues.length]; for (int i = 0; i < enumLabels.length; i++) { enumLabels[i] = enumValues[i].toString(); } props.setEnumLabels(enumLabels, false); } return props; }
java
static AttributePropertiesImpl setEnumLabelProperty(final Class<?> type, final AttributePropertiesImpl props) throws DevFailed { // if is is an enum set enum values in properties if (AttributeTangoType.getTypeFromClass(type).equals(AttributeTangoType.DEVENUM)) { // final Class<Enum<?>> enumType = (Class<Enum<?>>) field.getType(); final Object[] enumValues = type.getEnumConstants(); final String[] enumLabels = new String[enumValues.length]; for (int i = 0; i < enumLabels.length; i++) { enumLabels[i] = enumValues[i].toString(); } props.setEnumLabels(enumLabels, false); } return props; }
[ "static", "AttributePropertiesImpl", "setEnumLabelProperty", "(", "final", "Class", "<", "?", ">", "type", ",", "final", "AttributePropertiesImpl", "props", ")", "throws", "DevFailed", "{", "// if is is an enum set enum values in properties", "if", "(", "AttributeTangoType", ".", "getTypeFromClass", "(", "type", ")", ".", "equals", "(", "AttributeTangoType", ".", "DEVENUM", ")", ")", "{", "// final Class<Enum<?>> enumType = (Class<Enum<?>>) field.getType();", "final", "Object", "[", "]", "enumValues", "=", "type", ".", "getEnumConstants", "(", ")", ";", "final", "String", "[", "]", "enumLabels", "=", "new", "String", "[", "enumValues", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "enumLabels", ".", "length", ";", "i", "++", ")", "{", "enumLabels", "[", "i", "]", "=", "enumValues", "[", "i", "]", ".", "toString", "(", ")", ";", "}", "props", ".", "setEnumLabels", "(", "enumLabels", ",", "false", ")", ";", "}", "return", "props", ";", "}" ]
Set enum label for Enum types @param type @param props @throws DevFailed
[ "Set", "enum", "label", "for", "Enum", "types" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/build/BuilderUtils.java#L174-L187
140,453
tango-controls/JTango
server/src/main/java/org/tango/server/device/StateImpl.java
StateImpl.updateState
public DevState updateState() throws DevFailed { xlogger.entry(); Object getState; if (getStateMethod != null) { try { getState = getStateMethod.invoke(businessObject); if (getState != null) { if (getState instanceof DeviceState) { state = ((DeviceState) getState).getDevState(); } else { state = (DevState) getState; } } } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } // if (!attributeAlarm.isEmpty()) { // state = DevState.ALARM; // } xlogger.exit(); return state; }
java
public DevState updateState() throws DevFailed { xlogger.entry(); Object getState; if (getStateMethod != null) { try { getState = getStateMethod.invoke(businessObject); if (getState != null) { if (getState instanceof DeviceState) { state = ((DeviceState) getState).getDevState(); } else { state = (DevState) getState; } } } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } // if (!attributeAlarm.isEmpty()) { // state = DevState.ALARM; // } xlogger.exit(); return state; }
[ "public", "DevState", "updateState", "(", ")", "throws", "DevFailed", "{", "xlogger", ".", "entry", "(", ")", ";", "Object", "getState", ";", "if", "(", "getStateMethod", "!=", "null", ")", "{", "try", "{", "getState", "=", "getStateMethod", ".", "invoke", "(", "businessObject", ")", ";", "if", "(", "getState", "!=", "null", ")", "{", "if", "(", "getState", "instanceof", "DeviceState", ")", "{", "state", "=", "(", "(", "DeviceState", ")", "getState", ")", ".", "getDevState", "(", ")", ";", "}", "else", "{", "state", "=", "(", "DevState", ")", "getState", ";", "}", "}", "}", "catch", "(", "final", "IllegalArgumentException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "IllegalAccessException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "InvocationTargetException", "e", ")", "{", "if", "(", "e", ".", "getCause", "(", ")", "instanceof", "DevFailed", ")", "{", "throw", "(", "DevFailed", ")", "e", ".", "getCause", "(", ")", ";", "}", "else", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ".", "getCause", "(", ")", ")", ";", "}", "}", "}", "//\tif (!attributeAlarm.isEmpty()) {", "//\t state = DevState.ALARM;", "//\t}", "xlogger", ".", "exit", "(", ")", ";", "return", "state", ";", "}" ]
get the state from the device @return the state @throws DevFailed
[ "get", "the", "state", "from", "the", "device" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/device/StateImpl.java#L89-L119
140,454
tango-controls/JTango
server/src/main/java/org/tango/server/device/StateImpl.java
StateImpl.stateMachine
public synchronized void stateMachine(final DeviceState state) throws DevFailed { if (state != null) { this.state = state.getDevState(); if (setStateMethod != null) { logger.debug("Changing state to {}", state); try { if (setStateMethod.getParameterTypes()[0].equals(DeviceState.class)) { setStateMethod.invoke(businessObject, state); } else { setStateMethod.invoke(businessObject, this.state); } } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } } }
java
public synchronized void stateMachine(final DeviceState state) throws DevFailed { if (state != null) { this.state = state.getDevState(); if (setStateMethod != null) { logger.debug("Changing state to {}", state); try { if (setStateMethod.getParameterTypes()[0].equals(DeviceState.class)) { setStateMethod.invoke(businessObject, state); } else { setStateMethod.invoke(businessObject, this.state); } } catch (final IllegalArgumentException e) { throw DevFailedUtils.newDevFailed(e); } catch (final IllegalAccessException e) { throw DevFailedUtils.newDevFailed(e); } catch (final InvocationTargetException e) { if (e.getCause() instanceof DevFailed) { throw (DevFailed) e.getCause(); } else { throw DevFailedUtils.newDevFailed(e.getCause()); } } } } }
[ "public", "synchronized", "void", "stateMachine", "(", "final", "DeviceState", "state", ")", "throws", "DevFailed", "{", "if", "(", "state", "!=", "null", ")", "{", "this", ".", "state", "=", "state", ".", "getDevState", "(", ")", ";", "if", "(", "setStateMethod", "!=", "null", ")", "{", "logger", ".", "debug", "(", "\"Changing state to {}\"", ",", "state", ")", ";", "try", "{", "if", "(", "setStateMethod", ".", "getParameterTypes", "(", ")", "[", "0", "]", ".", "equals", "(", "DeviceState", ".", "class", ")", ")", "{", "setStateMethod", ".", "invoke", "(", "businessObject", ",", "state", ")", ";", "}", "else", "{", "setStateMethod", ".", "invoke", "(", "businessObject", ",", "this", ".", "state", ")", ";", "}", "}", "catch", "(", "final", "IllegalArgumentException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "IllegalAccessException", "e", ")", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ")", ";", "}", "catch", "(", "final", "InvocationTargetException", "e", ")", "{", "if", "(", "e", ".", "getCause", "(", ")", "instanceof", "DevFailed", ")", "{", "throw", "(", "DevFailed", ")", "e", ".", "getCause", "(", ")", ";", "}", "else", "{", "throw", "DevFailedUtils", ".", "newDevFailed", "(", "e", ".", "getCause", "(", ")", ")", ";", "}", "}", "}", "}", "}" ]
change state of the device @param state @throws DevFailed
[ "change", "state", "of", "the", "device" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/device/StateImpl.java#L136-L160
140,455
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoDs/Util.java
Util.connect_db
public synchronized void connect_db() { // // Try to connect to the database // if (_daemon == true) { boolean connected = false; while (connected == false) { try { db = ApiUtil.get_db_obj(); if (db == null) { Util.out4.println("Can't contact db server, will try later"); try { wait(_sleep_between_connect * 1000); } catch (final InterruptedException ex) { } } else { connected = true; } } catch (final Exception e) { Util.out4.println("Can't contact db server, will try later"); try { wait(_sleep_between_connect * 1000); } catch (final InterruptedException ex) { } } } } else { try { db = ApiUtil.get_db_obj(); if (db == null) { System.err.println("Can't build connection to TANGO database server, exiting"); System.err.println("DB server host = " + db_host); System.exit(-1); } } catch (final Exception ex) { System.err.println("Can't build connection to TANGO database server, exiting"); System.err.println("DB server host = " + db_host); System.exit(-1); } } Util.out4.println("Connected to database"); }
java
public synchronized void connect_db() { // // Try to connect to the database // if (_daemon == true) { boolean connected = false; while (connected == false) { try { db = ApiUtil.get_db_obj(); if (db == null) { Util.out4.println("Can't contact db server, will try later"); try { wait(_sleep_between_connect * 1000); } catch (final InterruptedException ex) { } } else { connected = true; } } catch (final Exception e) { Util.out4.println("Can't contact db server, will try later"); try { wait(_sleep_between_connect * 1000); } catch (final InterruptedException ex) { } } } } else { try { db = ApiUtil.get_db_obj(); if (db == null) { System.err.println("Can't build connection to TANGO database server, exiting"); System.err.println("DB server host = " + db_host); System.exit(-1); } } catch (final Exception ex) { System.err.println("Can't build connection to TANGO database server, exiting"); System.err.println("DB server host = " + db_host); System.exit(-1); } } Util.out4.println("Connected to database"); }
[ "public", "synchronized", "void", "connect_db", "(", ")", "{", "//", "// Try to connect to the database", "//", "if", "(", "_daemon", "==", "true", ")", "{", "boolean", "connected", "=", "false", ";", "while", "(", "connected", "==", "false", ")", "{", "try", "{", "db", "=", "ApiUtil", ".", "get_db_obj", "(", ")", ";", "if", "(", "db", "==", "null", ")", "{", "Util", ".", "out4", ".", "println", "(", "\"Can't contact db server, will try later\"", ")", ";", "try", "{", "wait", "(", "_sleep_between_connect", "*", "1000", ")", ";", "}", "catch", "(", "final", "InterruptedException", "ex", ")", "{", "}", "}", "else", "{", "connected", "=", "true", ";", "}", "}", "catch", "(", "final", "Exception", "e", ")", "{", "Util", ".", "out4", ".", "println", "(", "\"Can't contact db server, will try later\"", ")", ";", "try", "{", "wait", "(", "_sleep_between_connect", "*", "1000", ")", ";", "}", "catch", "(", "final", "InterruptedException", "ex", ")", "{", "}", "}", "}", "}", "else", "{", "try", "{", "db", "=", "ApiUtil", ".", "get_db_obj", "(", ")", ";", "if", "(", "db", "==", "null", ")", "{", "System", ".", "err", ".", "println", "(", "\"Can't build connection to TANGO database server, exiting\"", ")", ";", "System", ".", "err", ".", "println", "(", "\"DB server host = \"", "+", "db_host", ")", ";", "System", ".", "exit", "(", "-", "1", ")", ";", "}", "}", "catch", "(", "final", "Exception", "ex", ")", "{", "System", ".", "err", ".", "println", "(", "\"Can't build connection to TANGO database server, exiting\"", ")", ";", "System", ".", "err", ".", "println", "(", "\"DB server host = \"", "+", "db_host", ")", ";", "System", ".", "exit", "(", "-", "1", ")", ";", "}", "}", "Util", ".", "out4", ".", "println", "(", "\"Connected to database\"", ")", ";", "}" ]
Connect the process to the TANGO database. If the connection to the database failed, a message is displayed on the screen and the process is aborted
[ "Connect", "the", "process", "to", "the", "TANGO", "database", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/Util.java#L848-L892
140,456
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoDs/Util.java
Util.get_device_list
public Vector get_device_list(String pattern) { // - The returned list final Vector dl = new Vector(); // ------------------------------------------------------------------ // CASE I: pattern does not contain any '*' char - it's a device name if (pattern.indexOf('*') == -1) { DeviceImpl dev = null; try { dev = get_device_by_name(pattern); } catch (final DevFailed df) { // - Ignore exception } if (dev != null) { dl.add(dev); return dl; } } // - For the two remaining cases, we need the list of all DeviceClasses. final Vector dcl = get_class_list(); // - A temp vector to store a given class' devices Vector temp_dl; // ------------------------------------------------------------------ // CASE II: pattern == "*" - return a list containing all devices if (pattern.equals("*")) { for (int i = 0; i < dcl.size(); i++) { temp_dl = ((DeviceClass) dcl.elementAt(i)).get_device_list(); for (final Object aTemp_dl : temp_dl) { final DeviceImpl dev = (DeviceImpl) aTemp_dl; dl.add(dev); } } return dl; } // ------------------------------------------------------------------ // CASE III: pattern contains at least one '*' char Iterator dl_it; String dev_name; DeviceImpl dev; final Iterator dcl_it = dcl.iterator(); // - Compile the pattern pattern = pattern.replace('*', '.'); final Pattern p = Pattern.compile(pattern); // - For each DeviceClass... while (dcl_it.hasNext()) { // ...get device list temp_dl = ((DeviceClass) dcl_it.next()).get_device_list(); // for each device in in list... dl_it = temp_dl.iterator(); while (dl_it.hasNext()) { // ...get device ... dev = (DeviceImpl) dl_it.next(); // ...and device name dev_name = dev.get_name().toLowerCase(); // then look for token(s) in device name if (p.matcher(dev_name).matches()) { dl.add(dev); } } } return dl; }
java
public Vector get_device_list(String pattern) { // - The returned list final Vector dl = new Vector(); // ------------------------------------------------------------------ // CASE I: pattern does not contain any '*' char - it's a device name if (pattern.indexOf('*') == -1) { DeviceImpl dev = null; try { dev = get_device_by_name(pattern); } catch (final DevFailed df) { // - Ignore exception } if (dev != null) { dl.add(dev); return dl; } } // - For the two remaining cases, we need the list of all DeviceClasses. final Vector dcl = get_class_list(); // - A temp vector to store a given class' devices Vector temp_dl; // ------------------------------------------------------------------ // CASE II: pattern == "*" - return a list containing all devices if (pattern.equals("*")) { for (int i = 0; i < dcl.size(); i++) { temp_dl = ((DeviceClass) dcl.elementAt(i)).get_device_list(); for (final Object aTemp_dl : temp_dl) { final DeviceImpl dev = (DeviceImpl) aTemp_dl; dl.add(dev); } } return dl; } // ------------------------------------------------------------------ // CASE III: pattern contains at least one '*' char Iterator dl_it; String dev_name; DeviceImpl dev; final Iterator dcl_it = dcl.iterator(); // - Compile the pattern pattern = pattern.replace('*', '.'); final Pattern p = Pattern.compile(pattern); // - For each DeviceClass... while (dcl_it.hasNext()) { // ...get device list temp_dl = ((DeviceClass) dcl_it.next()).get_device_list(); // for each device in in list... dl_it = temp_dl.iterator(); while (dl_it.hasNext()) { // ...get device ... dev = (DeviceImpl) dl_it.next(); // ...and device name dev_name = dev.get_name().toLowerCase(); // then look for token(s) in device name if (p.matcher(dev_name).matches()) { dl.add(dev); } } } return dl; }
[ "public", "Vector", "get_device_list", "(", "String", "pattern", ")", "{", "// - The returned list", "final", "Vector", "dl", "=", "new", "Vector", "(", ")", ";", "// ------------------------------------------------------------------", "// CASE I: pattern does not contain any '*' char - it's a device name", "if", "(", "pattern", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "DeviceImpl", "dev", "=", "null", ";", "try", "{", "dev", "=", "get_device_by_name", "(", "pattern", ")", ";", "}", "catch", "(", "final", "DevFailed", "df", ")", "{", "// - Ignore exception", "}", "if", "(", "dev", "!=", "null", ")", "{", "dl", ".", "add", "(", "dev", ")", ";", "return", "dl", ";", "}", "}", "// - For the two remaining cases, we need the list of all DeviceClasses.", "final", "Vector", "dcl", "=", "get_class_list", "(", ")", ";", "// - A temp vector to store a given class' devices", "Vector", "temp_dl", ";", "// ------------------------------------------------------------------", "// CASE II: pattern == \"*\" - return a list containing all devices", "if", "(", "pattern", ".", "equals", "(", "\"*\"", ")", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dcl", ".", "size", "(", ")", ";", "i", "++", ")", "{", "temp_dl", "=", "(", "(", "DeviceClass", ")", "dcl", ".", "elementAt", "(", "i", ")", ")", ".", "get_device_list", "(", ")", ";", "for", "(", "final", "Object", "aTemp_dl", ":", "temp_dl", ")", "{", "final", "DeviceImpl", "dev", "=", "(", "DeviceImpl", ")", "aTemp_dl", ";", "dl", ".", "add", "(", "dev", ")", ";", "}", "}", "return", "dl", ";", "}", "// ------------------------------------------------------------------", "// CASE III: pattern contains at least one '*' char", "Iterator", "dl_it", ";", "String", "dev_name", ";", "DeviceImpl", "dev", ";", "final", "Iterator", "dcl_it", "=", "dcl", ".", "iterator", "(", ")", ";", "// - Compile the pattern", "pattern", "=", "pattern", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "final", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "pattern", ")", ";", "// - For each DeviceClass...", "while", "(", "dcl_it", ".", "hasNext", "(", ")", ")", "{", "// ...get device list", "temp_dl", "=", "(", "(", "DeviceClass", ")", "dcl_it", ".", "next", "(", ")", ")", ".", "get_device_list", "(", ")", ";", "// for each device in in list...", "dl_it", "=", "temp_dl", ".", "iterator", "(", ")", ";", "while", "(", "dl_it", ".", "hasNext", "(", ")", ")", "{", "// ...get device ...", "dev", "=", "(", "DeviceImpl", ")", "dl_it", ".", "next", "(", ")", ";", "// ...and device name", "dev_name", "=", "dev", ".", "get_name", "(", ")", ".", "toLowerCase", "(", ")", ";", "// then look for token(s) in device name", "if", "(", "p", ".", "matcher", "(", "dev_name", ")", ".", "matches", "(", ")", ")", "{", "dl", ".", "add", "(", "dev", ")", ";", "}", "}", "}", "return", "dl", ";", "}" ]
Get the list of device references which name name match the specified pattern Returns a null vector in case there is no device matching the pattern @param pattern The device name pattern
[ "Get", "the", "list", "of", "device", "references", "which", "name", "name", "match", "the", "specified", "pattern", "Returns", "a", "null", "vector", "in", "case", "there", "is", "no", "device", "matching", "the", "pattern" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/Util.java#L1027-L1091
140,457
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoDs/Util.java
Util.get_device_list_by_class
public Vector get_device_list_by_class(final String class_name) throws DevFailed { // // Retrieve class list. Don't use the get_dserver_device() method // followed by // the get_class_list(). In case of several classes embedded within // the same server and the use of this method in the object creation, it // will fail because the end of the dserver object creation is after the // end of the last server device creation. // final Vector cl_list = class_list; // // Check if the wanted class really exists // final int nb_class = cl_list.size(); int i; for (i = 0; i < nb_class; i++) { if (((DeviceClass) cl_list.elementAt(i)).get_name().equals(class_name) == true) { break; } } // // Throw exception if the class is not found // if (i == nb_class) { final StringBuffer o = new StringBuffer("Class "); o.append(class_name); o.append(" not found"); Except.throw_exception("API_ClassNotFound", o.toString(), "Util::get_device_list_by_class()"); } return ((DeviceClass) cl_list.elementAt(i)).get_device_list(); }
java
public Vector get_device_list_by_class(final String class_name) throws DevFailed { // // Retrieve class list. Don't use the get_dserver_device() method // followed by // the get_class_list(). In case of several classes embedded within // the same server and the use of this method in the object creation, it // will fail because the end of the dserver object creation is after the // end of the last server device creation. // final Vector cl_list = class_list; // // Check if the wanted class really exists // final int nb_class = cl_list.size(); int i; for (i = 0; i < nb_class; i++) { if (((DeviceClass) cl_list.elementAt(i)).get_name().equals(class_name) == true) { break; } } // // Throw exception if the class is not found // if (i == nb_class) { final StringBuffer o = new StringBuffer("Class "); o.append(class_name); o.append(" not found"); Except.throw_exception("API_ClassNotFound", o.toString(), "Util::get_device_list_by_class()"); } return ((DeviceClass) cl_list.elementAt(i)).get_device_list(); }
[ "public", "Vector", "get_device_list_by_class", "(", "final", "String", "class_name", ")", "throws", "DevFailed", "{", "//", "// Retrieve class list. Don't use the get_dserver_device() method", "// followed by", "// the get_class_list(). In case of several classes embedded within", "// the same server and the use of this method in the object creation, it", "// will fail because the end of the dserver object creation is after the", "// end of the last server device creation.", "//", "final", "Vector", "cl_list", "=", "class_list", ";", "//", "// Check if the wanted class really exists", "//", "final", "int", "nb_class", "=", "cl_list", ".", "size", "(", ")", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "nb_class", ";", "i", "++", ")", "{", "if", "(", "(", "(", "DeviceClass", ")", "cl_list", ".", "elementAt", "(", "i", ")", ")", ".", "get_name", "(", ")", ".", "equals", "(", "class_name", ")", "==", "true", ")", "{", "break", ";", "}", "}", "//", "// Throw exception if the class is not found", "//", "if", "(", "i", "==", "nb_class", ")", "{", "final", "StringBuffer", "o", "=", "new", "StringBuffer", "(", "\"Class \"", ")", ";", "o", ".", "append", "(", "class_name", ")", ";", "o", ".", "append", "(", "\" not found\"", ")", ";", "Except", ".", "throw_exception", "(", "\"API_ClassNotFound\"", ",", "o", ".", "toString", "(", ")", ",", "\"Util::get_device_list_by_class()\"", ")", ";", "}", "return", "(", "(", "DeviceClass", ")", "cl_list", ".", "elementAt", "(", "i", ")", ")", ".", "get_device_list", "(", ")", ";", "}" ]
Get the list of device references for a given TANGO class. Return the list of references for all devices served by one implementation of the TANGO device pattern implemented in the process @param class_name The TANGO device class name @return The device reference list @exception DevFailed If in the device server process there is no TANGO device pattern implemented the TANGO device class given as parameter Click <a href="../../tango_basic/idl_html/Tango.html#DevFailed" >here</a> to read <b>DevFailed</b> exception specification
[ "Get", "the", "list", "of", "device", "references", "for", "a", "given", "TANGO", "class", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/Util.java#L1110-L1149
140,458
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoDs/Util.java
Util.get_device_by_name
public DeviceImpl get_device_by_name(String dev_name) throws DevFailed { // // Retrieve class list. Don't use the get_dserver_device() method // followed by // the get_class_list(). In case of several classes embedded within // the same server and the use of this method in the object creation, it // will fail because the end of the dserver object creation is after the // end of the last server device creation. // final Vector cl_list = class_list; // // Check if the wanted device exists in each class // dev_name = dev_name.toLowerCase(); Vector dev_list = get_device_list_by_class(((DeviceClass) cl_list.elementAt(0)).get_name()); final int nb_class = cl_list.size(); int i, j, nb_dev; j = nb_dev = 0; boolean found = false; for (i = 0; i < nb_class; i++) { dev_list = get_device_list_by_class(((DeviceClass) cl_list.elementAt(i)).get_name()); nb_dev = dev_list.size(); for (j = 0; j < nb_dev; j++) { if (((DeviceImpl) dev_list.elementAt(j)).get_name().toLowerCase().equals(dev_name) == true) { found = true; break; } } if (found == true) { break; } } // // Check also the dserver device // if (found == false) { final DServerClass ds_class = DServerClass.instance(); dev_list = ds_class.get_device_list(); final String name = ((DeviceImpl) dev_list.elementAt(0)).get_name(); if (name.compareToIgnoreCase(dev_name) == 0) { j = 0; } } // // Throw exception if the class is not found // if (i == nb_class && j == nb_dev) { final StringBuffer o = new StringBuffer("Device "); o.append(dev_name); o.append(" not found"); Except .throw_exception("API_DeviceNotFound", o.toString(), "Util::get_device_by_name()"); } return (DeviceImpl) dev_list.elementAt(j); }
java
public DeviceImpl get_device_by_name(String dev_name) throws DevFailed { // // Retrieve class list. Don't use the get_dserver_device() method // followed by // the get_class_list(). In case of several classes embedded within // the same server and the use of this method in the object creation, it // will fail because the end of the dserver object creation is after the // end of the last server device creation. // final Vector cl_list = class_list; // // Check if the wanted device exists in each class // dev_name = dev_name.toLowerCase(); Vector dev_list = get_device_list_by_class(((DeviceClass) cl_list.elementAt(0)).get_name()); final int nb_class = cl_list.size(); int i, j, nb_dev; j = nb_dev = 0; boolean found = false; for (i = 0; i < nb_class; i++) { dev_list = get_device_list_by_class(((DeviceClass) cl_list.elementAt(i)).get_name()); nb_dev = dev_list.size(); for (j = 0; j < nb_dev; j++) { if (((DeviceImpl) dev_list.elementAt(j)).get_name().toLowerCase().equals(dev_name) == true) { found = true; break; } } if (found == true) { break; } } // // Check also the dserver device // if (found == false) { final DServerClass ds_class = DServerClass.instance(); dev_list = ds_class.get_device_list(); final String name = ((DeviceImpl) dev_list.elementAt(0)).get_name(); if (name.compareToIgnoreCase(dev_name) == 0) { j = 0; } } // // Throw exception if the class is not found // if (i == nb_class && j == nb_dev) { final StringBuffer o = new StringBuffer("Device "); o.append(dev_name); o.append(" not found"); Except .throw_exception("API_DeviceNotFound", o.toString(), "Util::get_device_by_name()"); } return (DeviceImpl) dev_list.elementAt(j); }
[ "public", "DeviceImpl", "get_device_by_name", "(", "String", "dev_name", ")", "throws", "DevFailed", "{", "//", "// Retrieve class list. Don't use the get_dserver_device() method", "// followed by", "// the get_class_list(). In case of several classes embedded within", "// the same server and the use of this method in the object creation, it", "// will fail because the end of the dserver object creation is after the", "// end of the last server device creation.", "//", "final", "Vector", "cl_list", "=", "class_list", ";", "//", "// Check if the wanted device exists in each class", "//", "dev_name", "=", "dev_name", ".", "toLowerCase", "(", ")", ";", "Vector", "dev_list", "=", "get_device_list_by_class", "(", "(", "(", "DeviceClass", ")", "cl_list", ".", "elementAt", "(", "0", ")", ")", ".", "get_name", "(", ")", ")", ";", "final", "int", "nb_class", "=", "cl_list", ".", "size", "(", ")", ";", "int", "i", ",", "j", ",", "nb_dev", ";", "j", "=", "nb_dev", "=", "0", ";", "boolean", "found", "=", "false", ";", "for", "(", "i", "=", "0", ";", "i", "<", "nb_class", ";", "i", "++", ")", "{", "dev_list", "=", "get_device_list_by_class", "(", "(", "(", "DeviceClass", ")", "cl_list", ".", "elementAt", "(", "i", ")", ")", ".", "get_name", "(", ")", ")", ";", "nb_dev", "=", "dev_list", ".", "size", "(", ")", ";", "for", "(", "j", "=", "0", ";", "j", "<", "nb_dev", ";", "j", "++", ")", "{", "if", "(", "(", "(", "DeviceImpl", ")", "dev_list", ".", "elementAt", "(", "j", ")", ")", ".", "get_name", "(", ")", ".", "toLowerCase", "(", ")", ".", "equals", "(", "dev_name", ")", "==", "true", ")", "{", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "found", "==", "true", ")", "{", "break", ";", "}", "}", "//", "// Check also the dserver device", "//", "if", "(", "found", "==", "false", ")", "{", "final", "DServerClass", "ds_class", "=", "DServerClass", ".", "instance", "(", ")", ";", "dev_list", "=", "ds_class", ".", "get_device_list", "(", ")", ";", "final", "String", "name", "=", "(", "(", "DeviceImpl", ")", "dev_list", ".", "elementAt", "(", "0", ")", ")", ".", "get_name", "(", ")", ";", "if", "(", "name", ".", "compareToIgnoreCase", "(", "dev_name", ")", "==", "0", ")", "{", "j", "=", "0", ";", "}", "}", "//", "// Throw exception if the class is not found", "//", "if", "(", "i", "==", "nb_class", "&&", "j", "==", "nb_dev", ")", "{", "final", "StringBuffer", "o", "=", "new", "StringBuffer", "(", "\"Device \"", ")", ";", "o", ".", "append", "(", "dev_name", ")", ";", "o", ".", "append", "(", "\" not found\"", ")", ";", "Except", ".", "throw_exception", "(", "\"API_DeviceNotFound\"", ",", "o", ".", "toString", "(", ")", ",", "\"Util::get_device_by_name()\"", ")", ";", "}", "return", "(", "DeviceImpl", ")", "dev_list", ".", "elementAt", "(", "j", ")", ";", "}" ]
Get a device reference from its name @param dev_name The TANGO device name @return The device reference @exception DevFailed If in the device is not served by one device pattern implemented in this process. Click <a href="../../tango_basic/idl_html/Tango.html#DevFailed" >here</a> to read <b>DevFailed</b> exception specification
[ "Get", "a", "device", "reference", "from", "its", "name" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/Util.java#L1164-L1229
140,459
tango-controls/JTango
dao/src/main/java/fr/esrf/TangoDs/Util.java
Util.unregister_server
public void unregister_server() { Util.out4.println("Entering Tango::unregister_server method"); if (Util._UseDb == true) { // // Mark all the devices belonging to this server as unexported // try { db.unexport_server(ds_name.toString()); } catch (final SystemException e) { Except.print_exception(e); System.exit(-1); } catch (final DevFailed e) { Except.print_exception(e); System.exit(-1); } catch (final UserException e) { Except.print_exception(e); System.exit(-1); } } Util.out4.println("Leaving Tango::unregister_server method"); }
java
public void unregister_server() { Util.out4.println("Entering Tango::unregister_server method"); if (Util._UseDb == true) { // // Mark all the devices belonging to this server as unexported // try { db.unexport_server(ds_name.toString()); } catch (final SystemException e) { Except.print_exception(e); System.exit(-1); } catch (final DevFailed e) { Except.print_exception(e); System.exit(-1); } catch (final UserException e) { Except.print_exception(e); System.exit(-1); } } Util.out4.println("Leaving Tango::unregister_server method"); }
[ "public", "void", "unregister_server", "(", ")", "{", "Util", ".", "out4", ".", "println", "(", "\"Entering Tango::unregister_server method\"", ")", ";", "if", "(", "Util", ".", "_UseDb", "==", "true", ")", "{", "//", "// Mark all the devices belonging to this server as unexported", "//", "try", "{", "db", ".", "unexport_server", "(", "ds_name", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "final", "SystemException", "e", ")", "{", "Except", ".", "print_exception", "(", "e", ")", ";", "System", ".", "exit", "(", "-", "1", ")", ";", "}", "catch", "(", "final", "DevFailed", "e", ")", "{", "Except", ".", "print_exception", "(", "e", ")", ";", "System", ".", "exit", "(", "-", "1", ")", ";", "}", "catch", "(", "final", "UserException", "e", ")", "{", "Except", ".", "print_exception", "(", "e", ")", ";", "System", ".", "exit", "(", "-", "1", ")", ";", "}", "}", "Util", ".", "out4", ".", "println", "(", "\"Leaving Tango::unregister_server method\"", ")", ";", "}" ]
Unregister a device server process from the TANGO database. If the database call fails, a message is displayed on the screen and the process is aborted
[ "Unregister", "a", "device", "server", "process", "from", "the", "TANGO", "database", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/Util.java#L1249-L1273
140,460
tango-controls/JTango
server/src/main/java/org/tango/server/device/InitImpl.java
InitImpl.execute
public synchronized void execute(final StateImpl stateImpl, final StatusImpl statusImpl) { if (isLazy && !isInitInProgress()) { final Callable<Void> initRunnable = new Callable<Void>() { @Override public Void call() throws DevFailed { logger.debug("Lazy init in"); MDC.setContextMap(contextMap); doInit(stateImpl, statusImpl); logger.debug("Lazy init out"); return null; } }; future = executor.submit(initRunnable); } else { doInit(stateImpl, statusImpl); } }
java
public synchronized void execute(final StateImpl stateImpl, final StatusImpl statusImpl) { if (isLazy && !isInitInProgress()) { final Callable<Void> initRunnable = new Callable<Void>() { @Override public Void call() throws DevFailed { logger.debug("Lazy init in"); MDC.setContextMap(contextMap); doInit(stateImpl, statusImpl); logger.debug("Lazy init out"); return null; } }; future = executor.submit(initRunnable); } else { doInit(stateImpl, statusImpl); } }
[ "public", "synchronized", "void", "execute", "(", "final", "StateImpl", "stateImpl", ",", "final", "StatusImpl", "statusImpl", ")", "{", "if", "(", "isLazy", "&&", "!", "isInitInProgress", "(", ")", ")", "{", "final", "Callable", "<", "Void", ">", "initRunnable", "=", "new", "Callable", "<", "Void", ">", "(", ")", "{", "@", "Override", "public", "Void", "call", "(", ")", "throws", "DevFailed", "{", "logger", ".", "debug", "(", "\"Lazy init in\"", ")", ";", "MDC", ".", "setContextMap", "(", "contextMap", ")", ";", "doInit", "(", "stateImpl", ",", "statusImpl", ")", ";", "logger", ".", "debug", "(", "\"Lazy init out\"", ")", ";", "return", "null", ";", "}", "}", ";", "future", "=", "executor", ".", "submit", "(", "initRunnable", ")", ";", "}", "else", "{", "doInit", "(", "stateImpl", ",", "statusImpl", ")", ";", "}", "}" ]
Execute the init @param stateImpl @param statusImpl @throws DevFailed
[ "Execute", "the", "init" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/device/InitImpl.java#L117-L134
140,461
tango-controls/JTango
common/src/main/java/fr/esrf/TangoApi/PipeBlobBuilder.java
PipeBlobBuilder.add
public PipeBlobBuilder add(String name, Object value){ elements.add(PipeDataElement.newInstance(name, value)); return this; }
java
public PipeBlobBuilder add(String name, Object value){ elements.add(PipeDataElement.newInstance(name, value)); return this; }
[ "public", "PipeBlobBuilder", "add", "(", "String", "name", ",", "Object", "value", ")", "{", "elements", ".", "add", "(", "PipeDataElement", ".", "newInstance", "(", "name", ",", "value", ")", ")", ";", "return", "this", ";", "}" ]
Adds a generic array to this PipeBlob @throws IllegalArgumentException if value is not an array
[ "Adds", "a", "generic", "array", "to", "this", "PipeBlob" ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/TangoApi/PipeBlobBuilder.java#L138-L141
140,462
tango-controls/JTango
common/src/main/java/org/tango/utils/TangoUtil.java
TangoUtil.splitDeviceEntity
public static final Entry<String, String> splitDeviceEntity(final String entityName) throws DevFailed { Entry<String, String> result = null; final Matcher matcher = ENTITY_SPLIT_PATTERN.matcher(entityName.trim()); if (matcher.matches()) { String device = null; String entity = null; final String prefixGroup = matcher.group(PREFIX_INDEX); final boolean noDb = matcher.group(NO_DB_INDEX) != null; if (noDb) { // TODO cas device alias qui marche soleil if (matcher.group(DEVICE_NAME_INDEX) != null && matcher.group(ENTITY_INDEX) != null) { final String deviceNameGroup = matcher.group(DEVICE_NAME_INDEX); final String entityGroup = matcher.group(ENTITY_INDEX); device = prefixGroup + deviceNameGroup; entity = entityGroup; } } else { if (matcher.group(ATTRIBUTE_ALIAS_INDEX) != null) { final String attributeAliasGroup = matcher.group(ATTRIBUTE_ALIAS_INDEX); final String fullAttributeName = ApiUtil.get_db_obj().get_attribute_from_alias(attributeAliasGroup); final int lastIndexOf = fullAttributeName.lastIndexOf(DEVICE_SEPARATOR); device = prefixGroup + fullAttributeName.substring(0, lastIndexOf);// TODO exception ? entity = fullAttributeName.substring(lastIndexOf + 1); } else if (matcher.group(DEVICE_ALIAS_INDEX) != null) { final String deviceAliasGroup = matcher.group(DEVICE_ALIAS_INDEX); final String entityGroup = matcher.group(ENTITY_INDEX); final String fullDeviceName = ApiUtil.get_db_obj().get_device_from_alias(deviceAliasGroup); device = prefixGroup + fullDeviceName; entity = entityGroup; } else { final String deviceNameGroup = matcher.group(DEVICE_NAME_INDEX); final String entityGroup = matcher.group(ENTITY_INDEX); device = prefixGroup + deviceNameGroup; entity = entityGroup; } } if (device != null && entity != null) { result = new SimpleEntry<String, String>(device, entity); } } return result; }
java
public static final Entry<String, String> splitDeviceEntity(final String entityName) throws DevFailed { Entry<String, String> result = null; final Matcher matcher = ENTITY_SPLIT_PATTERN.matcher(entityName.trim()); if (matcher.matches()) { String device = null; String entity = null; final String prefixGroup = matcher.group(PREFIX_INDEX); final boolean noDb = matcher.group(NO_DB_INDEX) != null; if (noDb) { // TODO cas device alias qui marche soleil if (matcher.group(DEVICE_NAME_INDEX) != null && matcher.group(ENTITY_INDEX) != null) { final String deviceNameGroup = matcher.group(DEVICE_NAME_INDEX); final String entityGroup = matcher.group(ENTITY_INDEX); device = prefixGroup + deviceNameGroup; entity = entityGroup; } } else { if (matcher.group(ATTRIBUTE_ALIAS_INDEX) != null) { final String attributeAliasGroup = matcher.group(ATTRIBUTE_ALIAS_INDEX); final String fullAttributeName = ApiUtil.get_db_obj().get_attribute_from_alias(attributeAliasGroup); final int lastIndexOf = fullAttributeName.lastIndexOf(DEVICE_SEPARATOR); device = prefixGroup + fullAttributeName.substring(0, lastIndexOf);// TODO exception ? entity = fullAttributeName.substring(lastIndexOf + 1); } else if (matcher.group(DEVICE_ALIAS_INDEX) != null) { final String deviceAliasGroup = matcher.group(DEVICE_ALIAS_INDEX); final String entityGroup = matcher.group(ENTITY_INDEX); final String fullDeviceName = ApiUtil.get_db_obj().get_device_from_alias(deviceAliasGroup); device = prefixGroup + fullDeviceName; entity = entityGroup; } else { final String deviceNameGroup = matcher.group(DEVICE_NAME_INDEX); final String entityGroup = matcher.group(ENTITY_INDEX); device = prefixGroup + deviceNameGroup; entity = entityGroup; } } if (device != null && entity != null) { result = new SimpleEntry<String, String>(device, entity); } } return result; }
[ "public", "static", "final", "Entry", "<", "String", ",", "String", ">", "splitDeviceEntity", "(", "final", "String", "entityName", ")", "throws", "DevFailed", "{", "Entry", "<", "String", ",", "String", ">", "result", "=", "null", ";", "final", "Matcher", "matcher", "=", "ENTITY_SPLIT_PATTERN", ".", "matcher", "(", "entityName", ".", "trim", "(", ")", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "String", "device", "=", "null", ";", "String", "entity", "=", "null", ";", "final", "String", "prefixGroup", "=", "matcher", ".", "group", "(", "PREFIX_INDEX", ")", ";", "final", "boolean", "noDb", "=", "matcher", ".", "group", "(", "NO_DB_INDEX", ")", "!=", "null", ";", "if", "(", "noDb", ")", "{", "// TODO cas device alias qui marche soleil", "if", "(", "matcher", ".", "group", "(", "DEVICE_NAME_INDEX", ")", "!=", "null", "&&", "matcher", ".", "group", "(", "ENTITY_INDEX", ")", "!=", "null", ")", "{", "final", "String", "deviceNameGroup", "=", "matcher", ".", "group", "(", "DEVICE_NAME_INDEX", ")", ";", "final", "String", "entityGroup", "=", "matcher", ".", "group", "(", "ENTITY_INDEX", ")", ";", "device", "=", "prefixGroup", "+", "deviceNameGroup", ";", "entity", "=", "entityGroup", ";", "}", "}", "else", "{", "if", "(", "matcher", ".", "group", "(", "ATTRIBUTE_ALIAS_INDEX", ")", "!=", "null", ")", "{", "final", "String", "attributeAliasGroup", "=", "matcher", ".", "group", "(", "ATTRIBUTE_ALIAS_INDEX", ")", ";", "final", "String", "fullAttributeName", "=", "ApiUtil", ".", "get_db_obj", "(", ")", ".", "get_attribute_from_alias", "(", "attributeAliasGroup", ")", ";", "final", "int", "lastIndexOf", "=", "fullAttributeName", ".", "lastIndexOf", "(", "DEVICE_SEPARATOR", ")", ";", "device", "=", "prefixGroup", "+", "fullAttributeName", ".", "substring", "(", "0", ",", "lastIndexOf", ")", ";", "// TODO exception ?", "entity", "=", "fullAttributeName", ".", "substring", "(", "lastIndexOf", "+", "1", ")", ";", "}", "else", "if", "(", "matcher", ".", "group", "(", "DEVICE_ALIAS_INDEX", ")", "!=", "null", ")", "{", "final", "String", "deviceAliasGroup", "=", "matcher", ".", "group", "(", "DEVICE_ALIAS_INDEX", ")", ";", "final", "String", "entityGroup", "=", "matcher", ".", "group", "(", "ENTITY_INDEX", ")", ";", "final", "String", "fullDeviceName", "=", "ApiUtil", ".", "get_db_obj", "(", ")", ".", "get_device_from_alias", "(", "deviceAliasGroup", ")", ";", "device", "=", "prefixGroup", "+", "fullDeviceName", ";", "entity", "=", "entityGroup", ";", "}", "else", "{", "final", "String", "deviceNameGroup", "=", "matcher", ".", "group", "(", "DEVICE_NAME_INDEX", ")", ";", "final", "String", "entityGroup", "=", "matcher", ".", "group", "(", "ENTITY_INDEX", ")", ";", "device", "=", "prefixGroup", "+", "deviceNameGroup", ";", "entity", "=", "entityGroup", ";", "}", "}", "if", "(", "device", "!=", "null", "&&", "entity", "!=", "null", ")", "{", "result", "=", "new", "SimpleEntry", "<", "String", ",", "String", ">", "(", "device", ",", "entity", ")", ";", "}", "}", "return", "result", ";", "}" ]
Splits an entity name into full device name and attribute name. Aliases will be resolved against tango db first. @param entityName the entity name to split. It can contain aliases for device or attribute @return a Map.Entry containing the full device name as key and the attribute name as value, or null if split was not possible @throws DevFailed in case of DB access problem
[ "Splits", "an", "entity", "name", "into", "full", "device", "name", "and", "attribute", "name", ".", "Aliases", "will", "be", "resolved", "against", "tango", "db", "first", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/org/tango/utils/TangoUtil.java#L173-L219
140,463
tango-controls/JTango
common/src/main/java/org/tango/utils/TangoUtil.java
TangoUtil.splitDeviceEntities
public static Map<String, Collection<String>> splitDeviceEntities(final Collection<String> entityNames) { final Map<String, Collection<String>> result = new HashMap<String, Collection<String>>(); String device; String entity; for (final String entityName : entityNames) { try { final Entry<String, String> deviceEntity = splitDeviceEntity(entityName); if (deviceEntity != null) { device = deviceEntity.getKey(); entity = deviceEntity.getValue(); if (device != null && entity != null) { Collection<String> attributes = result.get(device); if (attributes == null) { attributes = new HashSet<String>(); result.put(device, attributes); } attributes.add(entity); } } } catch (final DevFailed e) { // nop } } return result; }
java
public static Map<String, Collection<String>> splitDeviceEntities(final Collection<String> entityNames) { final Map<String, Collection<String>> result = new HashMap<String, Collection<String>>(); String device; String entity; for (final String entityName : entityNames) { try { final Entry<String, String> deviceEntity = splitDeviceEntity(entityName); if (deviceEntity != null) { device = deviceEntity.getKey(); entity = deviceEntity.getValue(); if (device != null && entity != null) { Collection<String> attributes = result.get(device); if (attributes == null) { attributes = new HashSet<String>(); result.put(device, attributes); } attributes.add(entity); } } } catch (final DevFailed e) { // nop } } return result; }
[ "public", "static", "Map", "<", "String", ",", "Collection", "<", "String", ">", ">", "splitDeviceEntities", "(", "final", "Collection", "<", "String", ">", "entityNames", ")", "{", "final", "Map", "<", "String", ",", "Collection", "<", "String", ">", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Collection", "<", "String", ">", ">", "(", ")", ";", "String", "device", ";", "String", "entity", ";", "for", "(", "final", "String", "entityName", ":", "entityNames", ")", "{", "try", "{", "final", "Entry", "<", "String", ",", "String", ">", "deviceEntity", "=", "splitDeviceEntity", "(", "entityName", ")", ";", "if", "(", "deviceEntity", "!=", "null", ")", "{", "device", "=", "deviceEntity", ".", "getKey", "(", ")", ";", "entity", "=", "deviceEntity", ".", "getValue", "(", ")", ";", "if", "(", "device", "!=", "null", "&&", "entity", "!=", "null", ")", "{", "Collection", "<", "String", ">", "attributes", "=", "result", ".", "get", "(", "device", ")", ";", "if", "(", "attributes", "==", "null", ")", "{", "attributes", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "result", ".", "put", "(", "device", ",", "attributes", ")", ";", "}", "attributes", ".", "add", "(", "entity", ")", ";", "}", "}", "}", "catch", "(", "final", "DevFailed", "e", ")", "{", "// nop", "}", "}", "return", "result", ";", "}" ]
Splits a collection of entity names and group attributes by device. @param entityNames a list of entity names to split @return a map containing a list of attributes for each device.
[ "Splits", "a", "collection", "of", "entity", "names", "and", "group", "attributes", "by", "device", "." ]
1ccc9dcb83e6de2359a9f1906d170571cacf1345
https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/org/tango/utils/TangoUtil.java#L227-L253
140,464
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/CredentialFactory.java
CredentialFactory.getApplicationDefaultCredential
public static GoogleCredential getApplicationDefaultCredential() { try { GoogleCredential credential = GoogleCredential.getApplicationDefault(); if (credential.createScopedRequired()) { credential = credential.createScoped(Arrays.asList("https://www.googleapis.com/auth/genomics")); } return credential; } catch (IOException e) { throw new RuntimeException(MISSING_ADC_EXCEPTION_MESSAGE, e); } }
java
public static GoogleCredential getApplicationDefaultCredential() { try { GoogleCredential credential = GoogleCredential.getApplicationDefault(); if (credential.createScopedRequired()) { credential = credential.createScoped(Arrays.asList("https://www.googleapis.com/auth/genomics")); } return credential; } catch (IOException e) { throw new RuntimeException(MISSING_ADC_EXCEPTION_MESSAGE, e); } }
[ "public", "static", "GoogleCredential", "getApplicationDefaultCredential", "(", ")", "{", "try", "{", "GoogleCredential", "credential", "=", "GoogleCredential", ".", "getApplicationDefault", "(", ")", ";", "if", "(", "credential", ".", "createScopedRequired", "(", ")", ")", "{", "credential", "=", "credential", ".", "createScoped", "(", "Arrays", ".", "asList", "(", "\"https://www.googleapis.com/auth/genomics\"", ")", ")", ";", "}", "return", "credential", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "MISSING_ADC_EXCEPTION_MESSAGE", ",", "e", ")", ";", "}", "}" ]
Obtain the Application Default com.google.api.client.auth.oauth2.Credential @return the Application Default Credential
[ "Obtain", "the", "Application", "Default", "com", ".", "google", ".", "api", ".", "client", ".", "auth", ".", "oauth2", ".", "Credential" ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/CredentialFactory.java#L79-L90
140,465
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/CredentialFactory.java
CredentialFactory.getCredentialFromClientSecrets
public static Credential getCredentialFromClientSecrets(String clientSecretsFile, String credentialId) { Preconditions.checkArgument(clientSecretsFile != null); Preconditions.checkArgument(credentialId != null); HttpTransport httpTransport; try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); } catch (IOException | GeneralSecurityException e) { throw new RuntimeException("Could not create HTTPS transport for use in credential creation", e); } JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); GoogleClientSecrets clientSecrets; try { clientSecrets = GoogleClientSecrets.load(jsonFactory, new FileReader(clientSecretsFile)); } catch (IOException e) { throw new RuntimeException( "Could not read the client secrets from file: " + clientSecretsFile, e); } FileDataStoreFactory dataStoreFactory; try { dataStoreFactory = new FileDataStoreFactory(CREDENTIAL_STORE); } catch (IOException e) { throw new RuntimeException("Could not create persisten credential store " + CREDENTIAL_STORE, e); } GoogleAuthorizationCodeFlow flow; try { flow = new GoogleAuthorizationCodeFlow.Builder( httpTransport, jsonFactory, clientSecrets, SCOPES) .setDataStoreFactory(dataStoreFactory) .build(); } catch (IOException e) { throw new RuntimeException("Could not build credential authorization flow", e); } // The credentialId identifies the credential in the persistent credential store. Credential credential; try { credential = new AuthorizationCodeInstalledApp(flow, new PromptReceiver()) .authorize(credentialId); } catch (IOException e) { throw new RuntimeException("Could not perform credential authorization flow", e); } return credential; }
java
public static Credential getCredentialFromClientSecrets(String clientSecretsFile, String credentialId) { Preconditions.checkArgument(clientSecretsFile != null); Preconditions.checkArgument(credentialId != null); HttpTransport httpTransport; try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); } catch (IOException | GeneralSecurityException e) { throw new RuntimeException("Could not create HTTPS transport for use in credential creation", e); } JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); GoogleClientSecrets clientSecrets; try { clientSecrets = GoogleClientSecrets.load(jsonFactory, new FileReader(clientSecretsFile)); } catch (IOException e) { throw new RuntimeException( "Could not read the client secrets from file: " + clientSecretsFile, e); } FileDataStoreFactory dataStoreFactory; try { dataStoreFactory = new FileDataStoreFactory(CREDENTIAL_STORE); } catch (IOException e) { throw new RuntimeException("Could not create persisten credential store " + CREDENTIAL_STORE, e); } GoogleAuthorizationCodeFlow flow; try { flow = new GoogleAuthorizationCodeFlow.Builder( httpTransport, jsonFactory, clientSecrets, SCOPES) .setDataStoreFactory(dataStoreFactory) .build(); } catch (IOException e) { throw new RuntimeException("Could not build credential authorization flow", e); } // The credentialId identifies the credential in the persistent credential store. Credential credential; try { credential = new AuthorizationCodeInstalledApp(flow, new PromptReceiver()) .authorize(credentialId); } catch (IOException e) { throw new RuntimeException("Could not perform credential authorization flow", e); } return credential; }
[ "public", "static", "Credential", "getCredentialFromClientSecrets", "(", "String", "clientSecretsFile", ",", "String", "credentialId", ")", "{", "Preconditions", ".", "checkArgument", "(", "clientSecretsFile", "!=", "null", ")", ";", "Preconditions", ".", "checkArgument", "(", "credentialId", "!=", "null", ")", ";", "HttpTransport", "httpTransport", ";", "try", "{", "httpTransport", "=", "GoogleNetHttpTransport", ".", "newTrustedTransport", "(", ")", ";", "}", "catch", "(", "IOException", "|", "GeneralSecurityException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not create HTTPS transport for use in credential creation\"", ",", "e", ")", ";", "}", "JsonFactory", "jsonFactory", "=", "JacksonFactory", ".", "getDefaultInstance", "(", ")", ";", "GoogleClientSecrets", "clientSecrets", ";", "try", "{", "clientSecrets", "=", "GoogleClientSecrets", ".", "load", "(", "jsonFactory", ",", "new", "FileReader", "(", "clientSecretsFile", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not read the client secrets from file: \"", "+", "clientSecretsFile", ",", "e", ")", ";", "}", "FileDataStoreFactory", "dataStoreFactory", ";", "try", "{", "dataStoreFactory", "=", "new", "FileDataStoreFactory", "(", "CREDENTIAL_STORE", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not create persisten credential store \"", "+", "CREDENTIAL_STORE", ",", "e", ")", ";", "}", "GoogleAuthorizationCodeFlow", "flow", ";", "try", "{", "flow", "=", "new", "GoogleAuthorizationCodeFlow", ".", "Builder", "(", "httpTransport", ",", "jsonFactory", ",", "clientSecrets", ",", "SCOPES", ")", ".", "setDataStoreFactory", "(", "dataStoreFactory", ")", ".", "build", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not build credential authorization flow\"", ",", "e", ")", ";", "}", "// The credentialId identifies the credential in the persistent credential store.", "Credential", "credential", ";", "try", "{", "credential", "=", "new", "AuthorizationCodeInstalledApp", "(", "flow", ",", "new", "PromptReceiver", "(", ")", ")", ".", "authorize", "(", "credentialId", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not perform credential authorization flow\"", ",", "e", ")", ";", "}", "return", "credential", ";", "}" ]
Creates an OAuth2 credential from client secrets, which may require an interactive authorization prompt. Use this method when the Application Default Credential is not sufficient. @param clientSecretsFile The {@code client_secrets.json} file path. @param credentialId The credentialId for use in identifying the credential in the persistent credential store. @return The user credential
[ "Creates", "an", "OAuth2", "credential", "from", "client", "secrets", "which", "may", "require", "an", "interactive", "authorization", "prompt", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/CredentialFactory.java#L117-L167
140,466
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/grpc/VariantUtils.java
VariantUtils.isOverlapping
public static boolean isOverlapping(Variant blockRecord, Variant.Builder variant) { return blockRecord.getStart() <= variant.getStart() && blockRecord.getEnd() >= variant.getStart() + 1; }
java
public static boolean isOverlapping(Variant blockRecord, Variant.Builder variant) { return blockRecord.getStart() <= variant.getStart() && blockRecord.getEnd() >= variant.getStart() + 1; }
[ "public", "static", "boolean", "isOverlapping", "(", "Variant", "blockRecord", ",", "Variant", ".", "Builder", "variant", ")", "{", "return", "blockRecord", ".", "getStart", "(", ")", "<=", "variant", ".", "getStart", "(", ")", "&&", "blockRecord", ".", "getEnd", "(", ")", ">=", "variant", ".", "getStart", "(", ")", "+", "1", ";", "}" ]
Determine whether the first variant overlaps the second variant. This is particularly useful when determining whether a non-variant segment overlaps a variant. @param blockRecord @param variant @return true, if the first variant overlaps the second variant
[ "Determine", "whether", "the", "first", "variant", "overlaps", "the", "second", "variant", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/grpc/VariantUtils.java#L246-L249
140,467
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/grpc/VariantUtils.java
VariantUtils.isSameVariantSite
public static final boolean isSameVariantSite(Variant.Builder variant1, Variant variant2) { return variant1.getReferenceName().equals(variant2.getReferenceName()) && variant1.getReferenceBases().equals(variant2.getReferenceBases()) && variant1.getStart() == variant2.getStart(); }
java
public static final boolean isSameVariantSite(Variant.Builder variant1, Variant variant2) { return variant1.getReferenceName().equals(variant2.getReferenceName()) && variant1.getReferenceBases().equals(variant2.getReferenceBases()) && variant1.getStart() == variant2.getStart(); }
[ "public", "static", "final", "boolean", "isSameVariantSite", "(", "Variant", ".", "Builder", "variant1", ",", "Variant", "variant2", ")", "{", "return", "variant1", ".", "getReferenceName", "(", ")", ".", "equals", "(", "variant2", ".", "getReferenceName", "(", ")", ")", "&&", "variant1", ".", "getReferenceBases", "(", ")", ".", "equals", "(", "variant2", ".", "getReferenceBases", "(", ")", ")", "&&", "variant1", ".", "getStart", "(", ")", "==", "variant2", ".", "getStart", "(", ")", ";", "}" ]
Determine whether two variants occur at the same site in the genome, where "site" is defined by reference name, start position, and reference bases. The reference bases are taken into account particularly for indels. @param variant1 @param variant2 @return true, if they occur at the same site
[ "Determine", "whether", "two", "variants", "occur", "at", "the", "same", "site", "in", "the", "genome", "where", "site", "is", "defined", "by", "reference", "name", "start", "position", "and", "reference", "bases", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/grpc/VariantUtils.java#L261-L265
140,468
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/grpc/GenomicsChannel.java
GenomicsChannel.fromCreds
public static ManagedChannel fromCreds(GoogleCredentials creds, String fields) throws SSLException { List<ClientInterceptor> interceptors = new ArrayList(); interceptors.add(new ClientAuthInterceptor(creds.createScoped(Arrays.asList(GENOMICS_SCOPE)), Executors.newSingleThreadExecutor())); if (!Strings.isNullOrEmpty(fields)) { Metadata headers = new Metadata(); Metadata.Key<String> partialResponseHeader = Metadata.Key.of(PARTIAL_RESPONSE_HEADER, Metadata.ASCII_STRING_MARSHALLER); headers.put(partialResponseHeader, fields); interceptors.add(MetadataUtils.newAttachHeadersInterceptor(headers)); } return getGenomicsManagedChannel(interceptors); }
java
public static ManagedChannel fromCreds(GoogleCredentials creds, String fields) throws SSLException { List<ClientInterceptor> interceptors = new ArrayList(); interceptors.add(new ClientAuthInterceptor(creds.createScoped(Arrays.asList(GENOMICS_SCOPE)), Executors.newSingleThreadExecutor())); if (!Strings.isNullOrEmpty(fields)) { Metadata headers = new Metadata(); Metadata.Key<String> partialResponseHeader = Metadata.Key.of(PARTIAL_RESPONSE_HEADER, Metadata.ASCII_STRING_MARSHALLER); headers.put(partialResponseHeader, fields); interceptors.add(MetadataUtils.newAttachHeadersInterceptor(headers)); } return getGenomicsManagedChannel(interceptors); }
[ "public", "static", "ManagedChannel", "fromCreds", "(", "GoogleCredentials", "creds", ",", "String", "fields", ")", "throws", "SSLException", "{", "List", "<", "ClientInterceptor", ">", "interceptors", "=", "new", "ArrayList", "(", ")", ";", "interceptors", ".", "add", "(", "new", "ClientAuthInterceptor", "(", "creds", ".", "createScoped", "(", "Arrays", ".", "asList", "(", "GENOMICS_SCOPE", ")", ")", ",", "Executors", ".", "newSingleThreadExecutor", "(", ")", ")", ")", ";", "if", "(", "!", "Strings", ".", "isNullOrEmpty", "(", "fields", ")", ")", "{", "Metadata", "headers", "=", "new", "Metadata", "(", ")", ";", "Metadata", ".", "Key", "<", "String", ">", "partialResponseHeader", "=", "Metadata", ".", "Key", ".", "of", "(", "PARTIAL_RESPONSE_HEADER", ",", "Metadata", ".", "ASCII_STRING_MARSHALLER", ")", ";", "headers", ".", "put", "(", "partialResponseHeader", ",", "fields", ")", ";", "interceptors", ".", "add", "(", "MetadataUtils", ".", "newAttachHeadersInterceptor", "(", "headers", ")", ")", ";", "}", "return", "getGenomicsManagedChannel", "(", "interceptors", ")", ";", "}" ]
Create a new gRPC channel to the Google Genomics API, using the provided credentials for auth. @param creds The credential. @param fields Which fields to return in the partial response, or null for none. @return The ManagedChannel. @throws SSLException
[ "Create", "a", "new", "gRPC", "channel", "to", "the", "Google", "Genomics", "API", "using", "the", "provided", "credentials", "for", "auth", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/grpc/GenomicsChannel.java#L74-L86
140,469
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/grpc/GenomicsChannel.java
GenomicsChannel.fromDefaultCreds
public static ManagedChannel fromDefaultCreds(String fields) throws SSLException, IOException { return fromCreds(CredentialFactory.getApplicationDefaultCredentials(), fields); }
java
public static ManagedChannel fromDefaultCreds(String fields) throws SSLException, IOException { return fromCreds(CredentialFactory.getApplicationDefaultCredentials(), fields); }
[ "public", "static", "ManagedChannel", "fromDefaultCreds", "(", "String", "fields", ")", "throws", "SSLException", ",", "IOException", "{", "return", "fromCreds", "(", "CredentialFactory", ".", "getApplicationDefaultCredentials", "(", ")", ",", "fields", ")", ";", "}" ]
Create a new gRPC channel to the Google Genomics API, using the application default credentials for auth. @param fields Which fields to return in the partial response, or null for none. @return The ManagedChannel. @throws SSLException @throws IOException
[ "Create", "a", "new", "gRPC", "channel", "to", "the", "Google", "Genomics", "API", "using", "the", "application", "default", "credentials", "for", "auth", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/grpc/GenomicsChannel.java#L109-L111
140,470
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/grpc/GenomicsChannel.java
GenomicsChannel.fromOfflineAuth
public static ManagedChannel fromOfflineAuth(OfflineAuth auth, String fields) throws IOException, GeneralSecurityException { return fromCreds(auth.getCredentials(), fields); }
java
public static ManagedChannel fromOfflineAuth(OfflineAuth auth, String fields) throws IOException, GeneralSecurityException { return fromCreds(auth.getCredentials(), fields); }
[ "public", "static", "ManagedChannel", "fromOfflineAuth", "(", "OfflineAuth", "auth", ",", "String", "fields", ")", "throws", "IOException", ",", "GeneralSecurityException", "{", "return", "fromCreds", "(", "auth", ".", "getCredentials", "(", ")", ",", "fields", ")", ";", "}" ]
Create a new gRPC channel to the Google Genomics API, using either OfflineAuth or the application default credentials. This library will work with both the newer and older versions of OAuth2 client-side support. https://developers.google.com/identity/protocols/application-default-credentials @param auth The OfflineAuth object. @param fields Which fields to return in the partial response, or null for none. @return The ManagedChannel. @throws IOException @throws GeneralSecurityException
[ "Create", "a", "new", "gRPC", "channel", "to", "the", "Google", "Genomics", "API", "using", "either", "OfflineAuth", "or", "the", "application", "default", "credentials", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/grpc/GenomicsChannel.java#L145-L148
140,471
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getReadGroupSetIds
public static List<String> getReadGroupSetIds(String datasetId, OfflineAuth auth) throws IOException { List<String> output = Lists.newArrayList(); Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); Iterable<ReadGroupSet> rgs = Paginator.ReadGroupSets.create(genomics) .search(new SearchReadGroupSetsRequest().setDatasetIds(Lists.newArrayList(datasetId)), "readGroupSets(id),nextPageToken"); for (ReadGroupSet r : rgs) { output.add(r.getId()); } if (output.isEmpty()) { throw new IOException("Dataset " + datasetId + " does not contain any ReadGroupSets"); } return output; }
java
public static List<String> getReadGroupSetIds(String datasetId, OfflineAuth auth) throws IOException { List<String> output = Lists.newArrayList(); Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); Iterable<ReadGroupSet> rgs = Paginator.ReadGroupSets.create(genomics) .search(new SearchReadGroupSetsRequest().setDatasetIds(Lists.newArrayList(datasetId)), "readGroupSets(id),nextPageToken"); for (ReadGroupSet r : rgs) { output.add(r.getId()); } if (output.isEmpty()) { throw new IOException("Dataset " + datasetId + " does not contain any ReadGroupSets"); } return output; }
[ "public", "static", "List", "<", "String", ">", "getReadGroupSetIds", "(", "String", "datasetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "List", "<", "String", ">", "output", "=", "Lists", ".", "newArrayList", "(", ")", ";", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "Iterable", "<", "ReadGroupSet", ">", "rgs", "=", "Paginator", ".", "ReadGroupSets", ".", "create", "(", "genomics", ")", ".", "search", "(", "new", "SearchReadGroupSetsRequest", "(", ")", ".", "setDatasetIds", "(", "Lists", ".", "newArrayList", "(", "datasetId", ")", ")", ",", "\"readGroupSets(id),nextPageToken\"", ")", ";", "for", "(", "ReadGroupSet", "r", ":", "rgs", ")", "{", "output", ".", "add", "(", "r", ".", "getId", "(", ")", ")", ";", "}", "if", "(", "output", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IOException", "(", "\"Dataset \"", "+", "datasetId", "+", "\" does not contain any ReadGroupSets\"", ")", ";", "}", "return", "output", ";", "}" ]
Gets ReadGroupSetIds from a given datasetId using the Genomics API. @param datasetId The id of the dataset to query. @param auth The OfflineAuth for the API request. @return The list of readGroupSetIds in the dataset. @throws IOException If dataset does not contain any readGroupSets.
[ "Gets", "ReadGroupSetIds", "from", "a", "given", "datasetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L47-L60
140,472
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getReferenceSetId
public static String getReferenceSetId(String readGroupSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); ReadGroupSet readGroupSet = genomics.readgroupsets().get(readGroupSetId) .setFields("referenceSetId").execute(); return readGroupSet.getReferenceSetId(); }
java
public static String getReferenceSetId(String readGroupSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); ReadGroupSet readGroupSet = genomics.readgroupsets().get(readGroupSetId) .setFields("referenceSetId").execute(); return readGroupSet.getReferenceSetId(); }
[ "public", "static", "String", "getReferenceSetId", "(", "String", "readGroupSetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "ReadGroupSet", "readGroupSet", "=", "genomics", ".", "readgroupsets", "(", ")", ".", "get", "(", "readGroupSetId", ")", ".", "setFields", "(", "\"referenceSetId\"", ")", ".", "execute", "(", ")", ";", "return", "readGroupSet", ".", "getReferenceSetId", "(", ")", ";", "}" ]
Gets the ReferenceSetId for a given readGroupSetId using the Genomics API. @param readGroupSetId The id of the readGroupSet to query. @param auth The OfflineAuth for the API request. @return The referenceSetId for the redGroupSet (which may be null). @throws IOException
[ "Gets", "the", "ReferenceSetId", "for", "a", "given", "readGroupSetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L70-L76
140,473
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getCoverageBuckets
public static List<CoverageBucket> getCoverageBuckets(String readGroupSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); ListCoverageBucketsResponse response = genomics.readgroupsets().coveragebuckets().list(readGroupSetId).execute(); // Requests of this form return one result per reference name, so therefore many fewer than // the default page size, but verify that the assumption holds true. if (!Strings.isNullOrEmpty(response.getNextPageToken())) { throw new IllegalArgumentException("Read group set " + readGroupSetId + " has more Coverage Buckets than the default page size for the CoverageBuckets list operation."); } return response.getCoverageBuckets(); }
java
public static List<CoverageBucket> getCoverageBuckets(String readGroupSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); ListCoverageBucketsResponse response = genomics.readgroupsets().coveragebuckets().list(readGroupSetId).execute(); // Requests of this form return one result per reference name, so therefore many fewer than // the default page size, but verify that the assumption holds true. if (!Strings.isNullOrEmpty(response.getNextPageToken())) { throw new IllegalArgumentException("Read group set " + readGroupSetId + " has more Coverage Buckets than the default page size for the CoverageBuckets list operation."); } return response.getCoverageBuckets(); }
[ "public", "static", "List", "<", "CoverageBucket", ">", "getCoverageBuckets", "(", "String", "readGroupSetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "ListCoverageBucketsResponse", "response", "=", "genomics", ".", "readgroupsets", "(", ")", ".", "coveragebuckets", "(", ")", ".", "list", "(", "readGroupSetId", ")", ".", "execute", "(", ")", ";", "// Requests of this form return one result per reference name, so therefore many fewer than", "// the default page size, but verify that the assumption holds true.", "if", "(", "!", "Strings", ".", "isNullOrEmpty", "(", "response", ".", "getNextPageToken", "(", ")", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Read group set \"", "+", "readGroupSetId", "+", "\" has more Coverage Buckets than the default page size for the CoverageBuckets list operation.\"", ")", ";", "}", "return", "response", ".", "getCoverageBuckets", "(", ")", ";", "}" ]
Gets the CoverageBuckets for a given readGroupSetId using the Genomics API. @param readGroupSetId The id of the readGroupSet to query. @param auth The OfflineAuth for the API request. @return The list of reference bounds in the variantSet. @throws IOException
[ "Gets", "the", "CoverageBuckets", "for", "a", "given", "readGroupSetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L86-L98
140,474
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getReferences
public static Iterable<Reference> getReferences(String referenceSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); return Paginator.References.create( genomics).search(new SearchReferencesRequest().setReferenceSetId(referenceSetId)); }
java
public static Iterable<Reference> getReferences(String referenceSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); return Paginator.References.create( genomics).search(new SearchReferencesRequest().setReferenceSetId(referenceSetId)); }
[ "public", "static", "Iterable", "<", "Reference", ">", "getReferences", "(", "String", "referenceSetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "return", "Paginator", ".", "References", ".", "create", "(", "genomics", ")", ".", "search", "(", "new", "SearchReferencesRequest", "(", ")", ".", "setReferenceSetId", "(", "referenceSetId", ")", ")", ";", "}" ]
Gets the references for a given referenceSetId using the Genomics API. @param referenceSetId The id of the referenceSet to query. @param auth The OfflineAuth for the API request. @return The list of references in the referenceSet. @throws IOException
[ "Gets", "the", "references", "for", "a", "given", "referenceSetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L109-L114
140,475
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getVariantSetIds
public static List<String> getVariantSetIds(String datasetId, OfflineAuth auth) throws IOException { List<String> output = Lists.newArrayList(); Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); Iterable<VariantSet> vs = Paginator.Variantsets.create(genomics) .search(new SearchVariantSetsRequest().setDatasetIds(Lists.newArrayList(datasetId)), "variantSets(id),nextPageToken"); for (VariantSet v : vs) { output.add(v.getId()); } if (output.isEmpty()) { throw new IOException("Dataset " + datasetId + " does not contain any VariantSets"); } return output; }
java
public static List<String> getVariantSetIds(String datasetId, OfflineAuth auth) throws IOException { List<String> output = Lists.newArrayList(); Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); Iterable<VariantSet> vs = Paginator.Variantsets.create(genomics) .search(new SearchVariantSetsRequest().setDatasetIds(Lists.newArrayList(datasetId)), "variantSets(id),nextPageToken"); for (VariantSet v : vs) { output.add(v.getId()); } if (output.isEmpty()) { throw new IOException("Dataset " + datasetId + " does not contain any VariantSets"); } return output; }
[ "public", "static", "List", "<", "String", ">", "getVariantSetIds", "(", "String", "datasetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "List", "<", "String", ">", "output", "=", "Lists", ".", "newArrayList", "(", ")", ";", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "Iterable", "<", "VariantSet", ">", "vs", "=", "Paginator", ".", "Variantsets", ".", "create", "(", "genomics", ")", ".", "search", "(", "new", "SearchVariantSetsRequest", "(", ")", ".", "setDatasetIds", "(", "Lists", ".", "newArrayList", "(", "datasetId", ")", ")", ",", "\"variantSets(id),nextPageToken\"", ")", ";", "for", "(", "VariantSet", "v", ":", "vs", ")", "{", "output", ".", "add", "(", "v", ".", "getId", "(", ")", ")", ";", "}", "if", "(", "output", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IOException", "(", "\"Dataset \"", "+", "datasetId", "+", "\" does not contain any VariantSets\"", ")", ";", "}", "return", "output", ";", "}" ]
Gets VariantSetIds from a given datasetId using the Genomics API. @param datasetId The id of the dataset to query. @param auth The OfflineAuth for the API request. @return The list of variantSetIds in the dataset. @throws IOException If dataset does not contain any variantSets.
[ "Gets", "VariantSetIds", "from", "a", "given", "datasetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L124-L138
140,476
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getCallSets
public static Iterable<CallSet> getCallSets(String variantSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); return Paginator.Callsets.create(genomics) .search(new SearchCallSetsRequest().setVariantSetIds(Lists.newArrayList(variantSetId)), "callSets,nextPageToken"); }
java
public static Iterable<CallSet> getCallSets(String variantSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); return Paginator.Callsets.create(genomics) .search(new SearchCallSetsRequest().setVariantSetIds(Lists.newArrayList(variantSetId)), "callSets,nextPageToken"); }
[ "public", "static", "Iterable", "<", "CallSet", ">", "getCallSets", "(", "String", "variantSetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "return", "Paginator", ".", "Callsets", ".", "create", "(", "genomics", ")", ".", "search", "(", "new", "SearchCallSetsRequest", "(", ")", ".", "setVariantSetIds", "(", "Lists", ".", "newArrayList", "(", "variantSetId", ")", ")", ",", "\"callSets,nextPageToken\"", ")", ";", "}" ]
Gets CallSets for a given variantSetId using the Genomics API. @param variantSetId The id of the variantSet to query. @param auth The OfflineAuth for the API request. @return The list of callSet names in the variantSet. @throws IOException If variantSet does not contain any CallSets.
[ "Gets", "CallSets", "for", "a", "given", "variantSetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L148-L154
140,477
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getCallSetsNames
public static List<String> getCallSetsNames(String variantSetId, OfflineAuth auth) throws IOException { List<String> output = Lists.newArrayList(); Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); Iterable<CallSet> cs = Paginator.Callsets.create(genomics) .search(new SearchCallSetsRequest().setVariantSetIds(Lists.newArrayList(variantSetId)), "callSets(name),nextPageToken"); for (CallSet c : cs) { output.add(c.getName()); } if (output.isEmpty()) { throw new IOException("VariantSet " + variantSetId + " does not contain any CallSets"); } return output; }
java
public static List<String> getCallSetsNames(String variantSetId, OfflineAuth auth) throws IOException { List<String> output = Lists.newArrayList(); Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); Iterable<CallSet> cs = Paginator.Callsets.create(genomics) .search(new SearchCallSetsRequest().setVariantSetIds(Lists.newArrayList(variantSetId)), "callSets(name),nextPageToken"); for (CallSet c : cs) { output.add(c.getName()); } if (output.isEmpty()) { throw new IOException("VariantSet " + variantSetId + " does not contain any CallSets"); } return output; }
[ "public", "static", "List", "<", "String", ">", "getCallSetsNames", "(", "String", "variantSetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "List", "<", "String", ">", "output", "=", "Lists", ".", "newArrayList", "(", ")", ";", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "Iterable", "<", "CallSet", ">", "cs", "=", "Paginator", ".", "Callsets", ".", "create", "(", "genomics", ")", ".", "search", "(", "new", "SearchCallSetsRequest", "(", ")", ".", "setVariantSetIds", "(", "Lists", ".", "newArrayList", "(", "variantSetId", ")", ")", ",", "\"callSets(name),nextPageToken\"", ")", ";", "for", "(", "CallSet", "c", ":", "cs", ")", "{", "output", ".", "add", "(", "c", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "output", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IOException", "(", "\"VariantSet \"", "+", "variantSetId", "+", "\" does not contain any CallSets\"", ")", ";", "}", "return", "output", ";", "}" ]
Gets CallSets Names for a given variantSetId using the Genomics API. @param variantSetId The id of the variantSet to query. @param auth The OfflineAuth for the API request. @return The list of callSet names in the variantSet. @throws IOException If variantSet does not contain any CallSets.
[ "Gets", "CallSets", "Names", "for", "a", "given", "variantSetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L164-L178
140,478
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java
GenomicsUtils.getReferenceBounds
public static List<ReferenceBound> getReferenceBounds(String variantSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); VariantSet variantSet = genomics.variantsets().get(variantSetId).execute(); return variantSet.getReferenceBounds(); }
java
public static List<ReferenceBound> getReferenceBounds(String variantSetId, OfflineAuth auth) throws IOException { Genomics genomics = GenomicsFactory.builder().build().fromOfflineAuth(auth); VariantSet variantSet = genomics.variantsets().get(variantSetId).execute(); return variantSet.getReferenceBounds(); }
[ "public", "static", "List", "<", "ReferenceBound", ">", "getReferenceBounds", "(", "String", "variantSetId", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "Genomics", "genomics", "=", "GenomicsFactory", ".", "builder", "(", ")", ".", "build", "(", ")", ".", "fromOfflineAuth", "(", "auth", ")", ";", "VariantSet", "variantSet", "=", "genomics", ".", "variantsets", "(", ")", ".", "get", "(", "variantSetId", ")", ".", "execute", "(", ")", ";", "return", "variantSet", ".", "getReferenceBounds", "(", ")", ";", "}" ]
Gets the ReferenceBounds for a given variantSetId using the Genomics API. @param variantSetId The id of the variantSet to query. @param auth The OfflineAuth for the API request. @return The list of reference bounds in the variantSet. @throws IOException
[ "Gets", "the", "ReferenceBounds", "for", "a", "given", "variantSetId", "using", "the", "Genomics", "API", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsUtils.java#L188-L193
140,479
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Contig.java
Contig.parseContigsFromCommandLine
public static Iterable<Contig> parseContigsFromCommandLine(String contigsArgument) { return Iterables.transform(Splitter.on(",").split(contigsArgument), new Function<String, Contig>() { @Override public Contig apply(String contigString) { ArrayList<String> contigInfo = newArrayList(Splitter.on(":").split(contigString)); Long start = Long.valueOf(contigInfo.get(1)); Long end = Long.valueOf(contigInfo.get(2)); Preconditions.checkArgument(start <= end, "Contig coordinates are incorrectly specified: start " + start + " is greater than end " + end); return new Contig(contigInfo.get(0), start, end); } }); }
java
public static Iterable<Contig> parseContigsFromCommandLine(String contigsArgument) { return Iterables.transform(Splitter.on(",").split(contigsArgument), new Function<String, Contig>() { @Override public Contig apply(String contigString) { ArrayList<String> contigInfo = newArrayList(Splitter.on(":").split(contigString)); Long start = Long.valueOf(contigInfo.get(1)); Long end = Long.valueOf(contigInfo.get(2)); Preconditions.checkArgument(start <= end, "Contig coordinates are incorrectly specified: start " + start + " is greater than end " + end); return new Contig(contigInfo.get(0), start, end); } }); }
[ "public", "static", "Iterable", "<", "Contig", ">", "parseContigsFromCommandLine", "(", "String", "contigsArgument", ")", "{", "return", "Iterables", ".", "transform", "(", "Splitter", ".", "on", "(", "\",\"", ")", ".", "split", "(", "contigsArgument", ")", ",", "new", "Function", "<", "String", ",", "Contig", ">", "(", ")", "{", "@", "Override", "public", "Contig", "apply", "(", "String", "contigString", ")", "{", "ArrayList", "<", "String", ">", "contigInfo", "=", "newArrayList", "(", "Splitter", ".", "on", "(", "\":\"", ")", ".", "split", "(", "contigString", ")", ")", ";", "Long", "start", "=", "Long", ".", "valueOf", "(", "contigInfo", ".", "get", "(", "1", ")", ")", ";", "Long", "end", "=", "Long", ".", "valueOf", "(", "contigInfo", ".", "get", "(", "2", ")", ")", ";", "Preconditions", ".", "checkArgument", "(", "start", "<=", "end", ",", "\"Contig coordinates are incorrectly specified: start \"", "+", "start", "+", "\" is greater than end \"", "+", "end", ")", ";", "return", "new", "Contig", "(", "contigInfo", ".", "get", "(", "0", ")", ",", "start", ",", "end", ")", ";", "}", "}", ")", ";", "}" ]
Parse the list of Contigs expressed in the string argument. The common use case is to parse the value of a command line parameter. @param contigsArgument - a string expressing the specified contiguous region(s) of the genome. The format is chromosome:start:end[,chromosome:start:end] @return a list of Contig objects
[ "Parse", "the", "list", "of", "Contigs", "expressed", "in", "the", "string", "argument", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Contig.java#L80-L93
140,480
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Contig.java
Contig.getShards
List<Contig> getShards(long numberOfBasesPerShard) { double shardCount = (end - start) / (double) numberOfBasesPerShard; List<Contig> shards = Lists.newArrayList(); for (int i = 0; i < shardCount; i++) { long shardStart = start + (i * numberOfBasesPerShard); long shardEnd = Math.min(end, shardStart + numberOfBasesPerShard); shards.add(new Contig(referenceName, shardStart, shardEnd)); } return shards; }
java
List<Contig> getShards(long numberOfBasesPerShard) { double shardCount = (end - start) / (double) numberOfBasesPerShard; List<Contig> shards = Lists.newArrayList(); for (int i = 0; i < shardCount; i++) { long shardStart = start + (i * numberOfBasesPerShard); long shardEnd = Math.min(end, shardStart + numberOfBasesPerShard); shards.add(new Contig(referenceName, shardStart, shardEnd)); } return shards; }
[ "List", "<", "Contig", ">", "getShards", "(", "long", "numberOfBasesPerShard", ")", "{", "double", "shardCount", "=", "(", "end", "-", "start", ")", "/", "(", "double", ")", "numberOfBasesPerShard", ";", "List", "<", "Contig", ">", "shards", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "shardCount", ";", "i", "++", ")", "{", "long", "shardStart", "=", "start", "+", "(", "i", "*", "numberOfBasesPerShard", ")", ";", "long", "shardEnd", "=", "Math", ".", "min", "(", "end", ",", "shardStart", "+", "numberOfBasesPerShard", ")", ";", "shards", ".", "add", "(", "new", "Contig", "(", "referenceName", ",", "shardStart", ",", "shardEnd", ")", ")", ";", "}", "return", "shards", ";", "}" ]
being returned to clients.
[ "being", "returned", "to", "clients", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Contig.java#L98-L108
140,481
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Contig.java
Contig.getStreamVariantsRequest
@Deprecated public StreamVariantsRequest getStreamVariantsRequest(String variantSetId) { return StreamVariantsRequest.newBuilder() .setVariantSetId(variantSetId) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
java
@Deprecated public StreamVariantsRequest getStreamVariantsRequest(String variantSetId) { return StreamVariantsRequest.newBuilder() .setVariantSetId(variantSetId) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
[ "@", "Deprecated", "public", "StreamVariantsRequest", "getStreamVariantsRequest", "(", "String", "variantSetId", ")", "{", "return", "StreamVariantsRequest", ".", "newBuilder", "(", ")", ".", "setVariantSetId", "(", "variantSetId", ")", ".", "setReferenceName", "(", "referenceName", ")", ".", "setStart", "(", "start", ")", ".", "setEnd", "(", "end", ")", ".", "build", "(", ")", ";", "}" ]
Construct a StreamVariantsRequest for the Contig. @param variantSetId @return the request object
[ "Construct", "a", "StreamVariantsRequest", "for", "the", "Contig", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Contig.java#L115-L123
140,482
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Contig.java
Contig.getStreamReadsRequest
@Deprecated public StreamReadsRequest getStreamReadsRequest(String readGroupSetId) { return StreamReadsRequest.newBuilder() .setReadGroupSetId(readGroupSetId) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
java
@Deprecated public StreamReadsRequest getStreamReadsRequest(String readGroupSetId) { return StreamReadsRequest.newBuilder() .setReadGroupSetId(readGroupSetId) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
[ "@", "Deprecated", "public", "StreamReadsRequest", "getStreamReadsRequest", "(", "String", "readGroupSetId", ")", "{", "return", "StreamReadsRequest", ".", "newBuilder", "(", ")", ".", "setReadGroupSetId", "(", "readGroupSetId", ")", ".", "setReferenceName", "(", "referenceName", ")", ".", "setStart", "(", "start", ")", ".", "setEnd", "(", "end", ")", ".", "build", "(", ")", ";", "}" ]
Construct a StreamReadsRequest for the Contig. @param readGroupSetId @return the request object
[ "Construct", "a", "StreamReadsRequest", "for", "the", "Contig", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Contig.java#L130-L138
140,483
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Contig.java
Contig.getStreamVariantsRequest
public StreamVariantsRequest getStreamVariantsRequest(StreamVariantsRequest prototype) { return StreamVariantsRequest.newBuilder(prototype) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
java
public StreamVariantsRequest getStreamVariantsRequest(StreamVariantsRequest prototype) { return StreamVariantsRequest.newBuilder(prototype) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
[ "public", "StreamVariantsRequest", "getStreamVariantsRequest", "(", "StreamVariantsRequest", "prototype", ")", "{", "return", "StreamVariantsRequest", ".", "newBuilder", "(", "prototype", ")", ".", "setReferenceName", "(", "referenceName", ")", ".", "setStart", "(", "start", ")", ".", "setEnd", "(", "end", ")", ".", "build", "(", ")", ";", "}" ]
Construct a StreamVariantsRequest for the Contig using a prototype using a prototype request. @param prototype A partially filled in request object. @return the request object
[ "Construct", "a", "StreamVariantsRequest", "for", "the", "Contig", "using", "a", "prototype", "using", "a", "prototype", "request", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Contig.java#L146-L152
140,484
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Contig.java
Contig.getStreamReadsRequest
public StreamReadsRequest getStreamReadsRequest(StreamReadsRequest prototype) { return StreamReadsRequest.newBuilder(prototype) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
java
public StreamReadsRequest getStreamReadsRequest(StreamReadsRequest prototype) { return StreamReadsRequest.newBuilder(prototype) .setReferenceName(referenceName) .setStart(start) .setEnd(end) .build(); }
[ "public", "StreamReadsRequest", "getStreamReadsRequest", "(", "StreamReadsRequest", "prototype", ")", "{", "return", "StreamReadsRequest", ".", "newBuilder", "(", "prototype", ")", ".", "setReferenceName", "(", "referenceName", ")", ".", "setStart", "(", "start", ")", ".", "setEnd", "(", "end", ")", ".", "build", "(", ")", ";", "}" ]
Construct a StreamReadsRequest for the Contig using a prototype request. @param prototype A partially filled in request object. @return the request object
[ "Construct", "a", "StreamReadsRequest", "for", "the", "Contig", "using", "a", "prototype", "request", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Contig.java#L160-L166
140,485
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/OfflineAuth.java
OfflineAuth.getCredential
public Credential getCredential() { if (hasStoredCredential()) { HttpTransport httpTransport; try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); } catch (IOException | GeneralSecurityException e) { throw new RuntimeException("Could not create HTTPS transport for use in credential creation", e); } return new GoogleCredential.Builder() .setJsonFactory(JacksonFactory.getDefaultInstance()) .setTransport(httpTransport) .setClientSecrets(getClientId(), getClientSecret()) .build() .setRefreshToken(getRefreshToken()); } return CredentialFactory.getApplicationDefaultCredential(); }
java
public Credential getCredential() { if (hasStoredCredential()) { HttpTransport httpTransport; try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); } catch (IOException | GeneralSecurityException e) { throw new RuntimeException("Could not create HTTPS transport for use in credential creation", e); } return new GoogleCredential.Builder() .setJsonFactory(JacksonFactory.getDefaultInstance()) .setTransport(httpTransport) .setClientSecrets(getClientId(), getClientSecret()) .build() .setRefreshToken(getRefreshToken()); } return CredentialFactory.getApplicationDefaultCredential(); }
[ "public", "Credential", "getCredential", "(", ")", "{", "if", "(", "hasStoredCredential", "(", ")", ")", "{", "HttpTransport", "httpTransport", ";", "try", "{", "httpTransport", "=", "GoogleNetHttpTransport", ".", "newTrustedTransport", "(", ")", ";", "}", "catch", "(", "IOException", "|", "GeneralSecurityException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not create HTTPS transport for use in credential creation\"", ",", "e", ")", ";", "}", "return", "new", "GoogleCredential", ".", "Builder", "(", ")", ".", "setJsonFactory", "(", "JacksonFactory", ".", "getDefaultInstance", "(", ")", ")", ".", "setTransport", "(", "httpTransport", ")", ".", "setClientSecrets", "(", "getClientId", "(", ")", ",", "getClientSecret", "(", ")", ")", ".", "build", "(", ")", ".", "setRefreshToken", "(", "getRefreshToken", "(", ")", ")", ";", "}", "return", "CredentialFactory", ".", "getApplicationDefaultCredential", "(", ")", ";", "}" ]
Return the stored user credential, if applicable, or fall back to the Application Default Credential. @return The com.google.api.client.auth.oauth2.Credential object.
[ "Return", "the", "stored", "user", "credential", "if", "applicable", "or", "fall", "back", "to", "the", "Application", "Default", "Credential", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/OfflineAuth.java#L141-L158
140,486
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java
GenomicsFactory.fromApiKey
public <T extends AbstractGoogleJsonClient.Builder> T fromApiKey(T builder, String apiKey) { Preconditions.checkNotNull(builder); Preconditions.checkNotNull(apiKey); return prepareBuilder(builder, null, new CommonGoogleClientRequestInitializer(apiKey)); }
java
public <T extends AbstractGoogleJsonClient.Builder> T fromApiKey(T builder, String apiKey) { Preconditions.checkNotNull(builder); Preconditions.checkNotNull(apiKey); return prepareBuilder(builder, null, new CommonGoogleClientRequestInitializer(apiKey)); }
[ "public", "<", "T", "extends", "AbstractGoogleJsonClient", ".", "Builder", ">", "T", "fromApiKey", "(", "T", "builder", ",", "String", "apiKey", ")", "{", "Preconditions", ".", "checkNotNull", "(", "builder", ")", ";", "Preconditions", ".", "checkNotNull", "(", "apiKey", ")", ";", "return", "prepareBuilder", "(", "builder", ",", "null", ",", "new", "CommonGoogleClientRequestInitializer", "(", "apiKey", ")", ")", ";", "}" ]
Prepare an AbstractGoogleJsonClient.Builder using an API key. @param builder The builder to be prepared. @param apiKey The API key of the Google Cloud Platform project. @return The passed in builder, for easy chaining.
[ "Prepare", "an", "AbstractGoogleJsonClient", ".", "Builder", "using", "an", "API", "key", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java#L353-L357
140,487
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java
GenomicsFactory.fromCredential
public <T extends AbstractGoogleJsonClient.Builder> T fromCredential(T builder, Credential credential) { Preconditions.checkNotNull(builder); Preconditions.checkNotNull(credential); return prepareBuilder(builder, credential, null); }
java
public <T extends AbstractGoogleJsonClient.Builder> T fromCredential(T builder, Credential credential) { Preconditions.checkNotNull(builder); Preconditions.checkNotNull(credential); return prepareBuilder(builder, credential, null); }
[ "public", "<", "T", "extends", "AbstractGoogleJsonClient", ".", "Builder", ">", "T", "fromCredential", "(", "T", "builder", ",", "Credential", "credential", ")", "{", "Preconditions", ".", "checkNotNull", "(", "builder", ")", ";", "Preconditions", ".", "checkNotNull", "(", "credential", ")", ";", "return", "prepareBuilder", "(", "builder", ",", "credential", ",", "null", ")", ";", "}" ]
Prepare an AbstractGoogleJsonClient.Builder using a credential. @param builder The builder to be prepared. @param credential The credential to be used for requests. @return The passed in builder, for easy chaining.
[ "Prepare", "an", "AbstractGoogleJsonClient", ".", "Builder", "using", "a", "credential", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java#L405-L409
140,488
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java
GenomicsFactory.fromApplicationDefaultCredential
public <T extends AbstractGoogleJsonClient.Builder> T fromApplicationDefaultCredential(T builder) { Preconditions.checkNotNull(builder); return fromCredential(builder, CredentialFactory.getApplicationDefaultCredential()); }
java
public <T extends AbstractGoogleJsonClient.Builder> T fromApplicationDefaultCredential(T builder) { Preconditions.checkNotNull(builder); return fromCredential(builder, CredentialFactory.getApplicationDefaultCredential()); }
[ "public", "<", "T", "extends", "AbstractGoogleJsonClient", ".", "Builder", ">", "T", "fromApplicationDefaultCredential", "(", "T", "builder", ")", "{", "Preconditions", ".", "checkNotNull", "(", "builder", ")", ";", "return", "fromCredential", "(", "builder", ",", "CredentialFactory", ".", "getApplicationDefaultCredential", "(", ")", ")", ";", "}" ]
Prepare an AbstractGoogleJsonClient.Builder using the Application Default Credential. @param builder The builder to be prepared. @return The passed in builder, for easy chaining.
[ "Prepare", "an", "AbstractGoogleJsonClient", ".", "Builder", "using", "the", "Application", "Default", "Credential", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java#L426-L429
140,489
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java
GenomicsFactory.fromOfflineAuth
public Genomics fromOfflineAuth(OfflineAuth auth) { Preconditions.checkNotNull(auth); return fromOfflineAuth(getGenomicsBuilder(), auth).build(); }
java
public Genomics fromOfflineAuth(OfflineAuth auth) { Preconditions.checkNotNull(auth); return fromOfflineAuth(getGenomicsBuilder(), auth).build(); }
[ "public", "Genomics", "fromOfflineAuth", "(", "OfflineAuth", "auth", ")", "{", "Preconditions", ".", "checkNotNull", "(", "auth", ")", ";", "return", "fromOfflineAuth", "(", "getGenomicsBuilder", "(", ")", ",", "auth", ")", ".", "build", "(", ")", ";", "}" ]
Create a new genomics stub from the given OfflineAuth object. @param auth The OfflineAuth @return The new {@code Genomics} stub
[ "Create", "a", "new", "genomics", "stub", "from", "the", "given", "OfflineAuth", "object", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java#L478-L481
140,490
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java
GenomicsFactory.fromOfflineAuth
public <T extends AbstractGoogleJsonClient.Builder> T fromOfflineAuth(T builder, OfflineAuth auth) { Preconditions.checkNotNull(builder); Preconditions.checkNotNull(auth); if(auth.hasApiKey()) { return fromApiKey(builder, auth.getApiKey()); } return fromCredential(builder, auth.getCredential()); }
java
public <T extends AbstractGoogleJsonClient.Builder> T fromOfflineAuth(T builder, OfflineAuth auth) { Preconditions.checkNotNull(builder); Preconditions.checkNotNull(auth); if(auth.hasApiKey()) { return fromApiKey(builder, auth.getApiKey()); } return fromCredential(builder, auth.getCredential()); }
[ "public", "<", "T", "extends", "AbstractGoogleJsonClient", ".", "Builder", ">", "T", "fromOfflineAuth", "(", "T", "builder", ",", "OfflineAuth", "auth", ")", "{", "Preconditions", ".", "checkNotNull", "(", "builder", ")", ";", "Preconditions", ".", "checkNotNull", "(", "auth", ")", ";", "if", "(", "auth", ".", "hasApiKey", "(", ")", ")", "{", "return", "fromApiKey", "(", "builder", ",", "auth", ".", "getApiKey", "(", ")", ")", ";", "}", "return", "fromCredential", "(", "builder", ",", "auth", ".", "getCredential", "(", ")", ")", ";", "}" ]
Prepare an AbstractGoogleJsonClient.Builder with the given OfflineAuth object. @param builder The builder to be prepared. @param auth The OfflineAuth @return The passed in builder, for easy chaining.
[ "Prepare", "an", "AbstractGoogleJsonClient", ".", "Builder", "with", "the", "given", "OfflineAuth", "object", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/GenomicsFactory.java#L490-L497
140,491
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/CallSetUtils.java
CallSetUtils.getCallSetNameMapping
public static final BiMap<String, String> getCallSetNameMapping(Iterable<CallSet> callSets) { BiMap<String, String> idToName = HashBiMap.create(); for(CallSet callSet : callSets) { // Dev Note: Be sure to keep this map loading as id -> name since it ensures that // the values are unique. idToName.put(callSet.getId(), callSet.getName()); } return idToName.inverse(); }
java
public static final BiMap<String, String> getCallSetNameMapping(Iterable<CallSet> callSets) { BiMap<String, String> idToName = HashBiMap.create(); for(CallSet callSet : callSets) { // Dev Note: Be sure to keep this map loading as id -> name since it ensures that // the values are unique. idToName.put(callSet.getId(), callSet.getName()); } return idToName.inverse(); }
[ "public", "static", "final", "BiMap", "<", "String", ",", "String", ">", "getCallSetNameMapping", "(", "Iterable", "<", "CallSet", ">", "callSets", ")", "{", "BiMap", "<", "String", ",", "String", ">", "idToName", "=", "HashBiMap", ".", "create", "(", ")", ";", "for", "(", "CallSet", "callSet", ":", "callSets", ")", "{", "// Dev Note: Be sure to keep this map loading as id -> name since it ensures that", "// the values are unique.", "idToName", ".", "put", "(", "callSet", ".", "getId", "(", ")", ",", "callSet", ".", "getName", "(", ")", ")", ";", "}", "return", "idToName", ".", "inverse", "(", ")", ";", "}" ]
Create a bi-directional map of names to ids for a collection of callsets. As a side effect, this will throw an IllegalArgumentException when the collection of callsets is malformed due to multiple is mapping to the same name. @param callSets @return the bi-directional map
[ "Create", "a", "bi", "-", "directional", "map", "of", "names", "to", "ids", "for", "a", "collection", "of", "callsets", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/CallSetUtils.java#L58-L66
140,492
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Paginator.java
Paginator.search
public final Iterable<ItemT> search(final RequestT request) { return search(request, DEFAULT_INITIALIZER, RetryPolicy.defaultPolicy()); }
java
public final Iterable<ItemT> search(final RequestT request) { return search(request, DEFAULT_INITIALIZER, RetryPolicy.defaultPolicy()); }
[ "public", "final", "Iterable", "<", "ItemT", ">", "search", "(", "final", "RequestT", "request", ")", "{", "return", "search", "(", "request", ",", "DEFAULT_INITIALIZER", ",", "RetryPolicy", ".", "defaultPolicy", "(", ")", ")", ";", "}" ]
Search for objects. @param request The search request. @return the stream of search results.
[ "Search", "for", "objects", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Paginator.java#L1017-L1019
140,493
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Paginator.java
Paginator.search
public final <F> F search( RequestT request, GenomicsRequestInitializer<? super RequestSubT> initializer, Callback<ItemT, ? extends F> callback, RetryPolicy retryPolicy) throws IOException { try { return callback.consumeResponses(search(request, initializer, retryPolicy)); } catch (SearchException e) { throw e.getCause(); } }
java
public final <F> F search( RequestT request, GenomicsRequestInitializer<? super RequestSubT> initializer, Callback<ItemT, ? extends F> callback, RetryPolicy retryPolicy) throws IOException { try { return callback.consumeResponses(search(request, initializer, retryPolicy)); } catch (SearchException e) { throw e.getCause(); } }
[ "public", "final", "<", "F", ">", "F", "search", "(", "RequestT", "request", ",", "GenomicsRequestInitializer", "<", "?", "super", "RequestSubT", ">", "initializer", ",", "Callback", "<", "ItemT", ",", "?", "extends", "F", ">", "callback", ",", "RetryPolicy", "retryPolicy", ")", "throws", "IOException", "{", "try", "{", "return", "callback", ".", "consumeResponses", "(", "search", "(", "request", ",", "initializer", ",", "retryPolicy", ")", ")", ";", "}", "catch", "(", "SearchException", "e", ")", "{", "throw", "e", ".", "getCause", "(", ")", ";", "}", "}" ]
An exception safe way of consuming search results. Client code supplies a callback which is used to consume the result stream and accumulate a value, which becomes the value returned from this method. @param request The search request. @param initializer The {@link GenomicsRequestInitializer} with which to initialize requests. @param callback The {@link Callback} used to consume search results. @param retryPolicy A retry policy specifying behavior when a request fails (usually due to SocketTimeoutExceptions) @return whatever value {@link Callback#consumeResponses} returned. @throws IOException if an IOException occurred while consuming search results.
[ "An", "exception", "safe", "way", "of", "consuming", "search", "results", ".", "Client", "code", "supplies", "a", "callback", "which", "is", "used", "to", "consume", "the", "result", "stream", "and", "accumulate", "a", "value", "which", "becomes", "the", "value", "returned", "from", "this", "method", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Paginator.java#L1104-L1114
140,494
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/Paginator.java
Paginator.search
public final Iterable<ItemT> search(final RequestT request, final String fields) { return search(request, setFieldsInitializer(fields), RetryPolicy.defaultPolicy()); }
java
public final Iterable<ItemT> search(final RequestT request, final String fields) { return search(request, setFieldsInitializer(fields), RetryPolicy.defaultPolicy()); }
[ "public", "final", "Iterable", "<", "ItemT", ">", "search", "(", "final", "RequestT", "request", ",", "final", "String", "fields", ")", "{", "return", "search", "(", "request", ",", "setFieldsInitializer", "(", "fields", ")", ",", "RetryPolicy", ".", "defaultPolicy", "(", ")", ")", ";", "}" ]
Search for objects with a partial response. A convenience method that allows the client code to specify the value of {@link GenomicsRequest#setFields} using a {@link GenomicsRequestInitializer}. @param request The search request. @param fields The fields to set. @return the stream of search results.
[ "Search", "for", "objects", "with", "a", "partial", "response", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/Paginator.java#L1126-L1128
140,495
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/ShardUtils.java
ShardUtils.getReadRequests
public static ImmutableList<StreamReadsRequest> getReadRequests(final StreamReadsRequest prototype, SexChromosomeFilter sexChromosomeFilter, long numberOfBasesPerShard, OfflineAuth auth) throws IOException { Iterable<Contig> shards = getAllShardsInReadGroupSet(prototype.getReadGroupSetId(), sexChromosomeFilter, numberOfBasesPerShard, auth); return FluentIterable.from(shards) .transform(new Function<Contig, StreamReadsRequest>() { @Override public StreamReadsRequest apply(Contig shard) { return shard.getStreamReadsRequest(prototype); } }).toList(); }
java
public static ImmutableList<StreamReadsRequest> getReadRequests(final StreamReadsRequest prototype, SexChromosomeFilter sexChromosomeFilter, long numberOfBasesPerShard, OfflineAuth auth) throws IOException { Iterable<Contig> shards = getAllShardsInReadGroupSet(prototype.getReadGroupSetId(), sexChromosomeFilter, numberOfBasesPerShard, auth); return FluentIterable.from(shards) .transform(new Function<Contig, StreamReadsRequest>() { @Override public StreamReadsRequest apply(Contig shard) { return shard.getStreamReadsRequest(prototype); } }).toList(); }
[ "public", "static", "ImmutableList", "<", "StreamReadsRequest", ">", "getReadRequests", "(", "final", "StreamReadsRequest", "prototype", ",", "SexChromosomeFilter", "sexChromosomeFilter", ",", "long", "numberOfBasesPerShard", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "Iterable", "<", "Contig", ">", "shards", "=", "getAllShardsInReadGroupSet", "(", "prototype", ".", "getReadGroupSetId", "(", ")", ",", "sexChromosomeFilter", ",", "numberOfBasesPerShard", ",", "auth", ")", ";", "return", "FluentIterable", ".", "from", "(", "shards", ")", ".", "transform", "(", "new", "Function", "<", "Contig", ",", "StreamReadsRequest", ">", "(", ")", "{", "@", "Override", "public", "StreamReadsRequest", "apply", "(", "Contig", "shard", ")", "{", "return", "shard", ".", "getStreamReadsRequest", "(", "prototype", ")", ";", "}", "}", ")", ".", "toList", "(", ")", ";", "}" ]
Constructs sharded StreamReadsRequest for the all references in the readGroupSet. @param prototype The prototype request. @param sexChromosomeFilter An enum value indicating how sex chromosomes should be handled in the result. @param numberOfBasesPerShard The maximum number of bases to include per shard. @param auth The OfflineAuth to be used to get the reference bounds for the variantSet. @return The shuffled list of sharded request objects. @throws IOException
[ "Constructs", "sharded", "StreamReadsRequest", "for", "the", "all", "references", "in", "the", "readGroupSet", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/ShardUtils.java#L163-L175
140,496
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/ShardUtils.java
ShardUtils.getVariantRequests
@Deprecated public static ImmutableList<StreamVariantsRequest> getVariantRequests(final String variantSetId, SexChromosomeFilter sexChromosomeFilter, long numberOfBasesPerShard, OfflineAuth auth) throws IOException { Iterable<Contig> shards = getAllShardsInVariantSet(variantSetId, sexChromosomeFilter, numberOfBasesPerShard, auth); return FluentIterable.from(shards) .transform(new Function<Contig, StreamVariantsRequest>() { @Override public StreamVariantsRequest apply(Contig shard) { return shard.getStreamVariantsRequest(variantSetId); } }).toList(); }
java
@Deprecated public static ImmutableList<StreamVariantsRequest> getVariantRequests(final String variantSetId, SexChromosomeFilter sexChromosomeFilter, long numberOfBasesPerShard, OfflineAuth auth) throws IOException { Iterable<Contig> shards = getAllShardsInVariantSet(variantSetId, sexChromosomeFilter, numberOfBasesPerShard, auth); return FluentIterable.from(shards) .transform(new Function<Contig, StreamVariantsRequest>() { @Override public StreamVariantsRequest apply(Contig shard) { return shard.getStreamVariantsRequest(variantSetId); } }).toList(); }
[ "@", "Deprecated", "public", "static", "ImmutableList", "<", "StreamVariantsRequest", ">", "getVariantRequests", "(", "final", "String", "variantSetId", ",", "SexChromosomeFilter", "sexChromosomeFilter", ",", "long", "numberOfBasesPerShard", ",", "OfflineAuth", "auth", ")", "throws", "IOException", "{", "Iterable", "<", "Contig", ">", "shards", "=", "getAllShardsInVariantSet", "(", "variantSetId", ",", "sexChromosomeFilter", ",", "numberOfBasesPerShard", ",", "auth", ")", ";", "return", "FluentIterable", ".", "from", "(", "shards", ")", ".", "transform", "(", "new", "Function", "<", "Contig", ",", "StreamVariantsRequest", ">", "(", ")", "{", "@", "Override", "public", "StreamVariantsRequest", "apply", "(", "Contig", "shard", ")", "{", "return", "shard", ".", "getStreamVariantsRequest", "(", "variantSetId", ")", ";", "}", "}", ")", ".", "toList", "(", ")", ";", "}" ]
Constructs sharded StreamVariantsRequests for the all references in the variantSet. @param variantSetId The variantSetId. @param sexChromosomeFilter An enum value indicating how sex chromosomes should be handled in the result. @param numberOfBasesPerShard The maximum number of bases to include per shard. @param auth The OfflineAuth to be used to get the reference bounds for the variantSet. @return The shuffled list of sharded request objects. @throws IOException
[ "Constructs", "sharded", "StreamVariantsRequests", "for", "the", "all", "references", "in", "the", "variantSet", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/ShardUtils.java#L209-L222
140,497
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/ShardBoundary.java
ShardBoundary.getStrictVariantPredicate
public static Predicate<Variant> getStrictVariantPredicate(final long start, String fields) { Preconditions .checkArgument(Strings.isNullOrEmpty(fields) || VARIANT_FIELD_PATTERN.matcher(fields).matches(), "Insufficient fields requested in partial response. At a minimum " + "include 'variants(start)' to enforce a strict shard boundary."); return new Predicate<Variant>() { @Override public boolean apply(Variant variant) { return variant.getStart() >= start; } }; }
java
public static Predicate<Variant> getStrictVariantPredicate(final long start, String fields) { Preconditions .checkArgument(Strings.isNullOrEmpty(fields) || VARIANT_FIELD_PATTERN.matcher(fields).matches(), "Insufficient fields requested in partial response. At a minimum " + "include 'variants(start)' to enforce a strict shard boundary."); return new Predicate<Variant>() { @Override public boolean apply(Variant variant) { return variant.getStart() >= start; } }; }
[ "public", "static", "Predicate", "<", "Variant", ">", "getStrictVariantPredicate", "(", "final", "long", "start", ",", "String", "fields", ")", "{", "Preconditions", ".", "checkArgument", "(", "Strings", ".", "isNullOrEmpty", "(", "fields", ")", "||", "VARIANT_FIELD_PATTERN", ".", "matcher", "(", "fields", ")", ".", "matches", "(", ")", ",", "\"Insufficient fields requested in partial response. At a minimum \"", "+", "\"include 'variants(start)' to enforce a strict shard boundary.\"", ")", ";", "return", "new", "Predicate", "<", "Variant", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "Variant", "variant", ")", "{", "return", "variant", ".", "getStart", "(", ")", ">=", "start", ";", "}", "}", ";", "}" ]
Predicate expressing the logic for which variants should and should not be included in the shard. @param start The start position of the shard. @return Whether the variant would be included in a strict shard boundary.
[ "Predicate", "expressing", "the", "logic", "for", "which", "variants", "should", "and", "should", "not", "be", "included", "in", "the", "shard", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/ShardBoundary.java#L54-L66
140,498
googlegenomics/utils-java
src/main/java/com/google/cloud/genomics/utils/ShardBoundary.java
ShardBoundary.getStrictReadPredicate
public static Predicate<Read> getStrictReadPredicate(final long start, final String fields) { Preconditions .checkArgument(Strings.isNullOrEmpty(fields) || READ_FIELD_PATTERN.matcher(fields).matches(), "Insufficient fields requested in partial response. At a minimum " + "include 'alignments(alignment)' to enforce a strict shard boundary."); return new Predicate<Read>() { @Override public boolean apply(Read read) { return read.getAlignment().getPosition().getPosition() >= start; } }; }
java
public static Predicate<Read> getStrictReadPredicate(final long start, final String fields) { Preconditions .checkArgument(Strings.isNullOrEmpty(fields) || READ_FIELD_PATTERN.matcher(fields).matches(), "Insufficient fields requested in partial response. At a minimum " + "include 'alignments(alignment)' to enforce a strict shard boundary."); return new Predicate<Read>() { @Override public boolean apply(Read read) { return read.getAlignment().getPosition().getPosition() >= start; } }; }
[ "public", "static", "Predicate", "<", "Read", ">", "getStrictReadPredicate", "(", "final", "long", "start", ",", "final", "String", "fields", ")", "{", "Preconditions", ".", "checkArgument", "(", "Strings", ".", "isNullOrEmpty", "(", "fields", ")", "||", "READ_FIELD_PATTERN", ".", "matcher", "(", "fields", ")", ".", "matches", "(", ")", ",", "\"Insufficient fields requested in partial response. At a minimum \"", "+", "\"include 'alignments(alignment)' to enforce a strict shard boundary.\"", ")", ";", "return", "new", "Predicate", "<", "Read", ">", "(", ")", "{", "@", "Override", "public", "boolean", "apply", "(", "Read", "read", ")", "{", "return", "read", ".", "getAlignment", "(", ")", ".", "getPosition", "(", ")", ".", "getPosition", "(", ")", ">=", "start", ";", "}", "}", ";", "}" ]
Predicate expressing the logic for which reads should and should not be included in the shard. @param start The start position of the shard. @return Whether the read would be included in a strict shard boundary.
[ "Predicate", "expressing", "the", "logic", "for", "which", "reads", "should", "and", "should", "not", "be", "included", "in", "the", "shard", "." ]
7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612
https://github.com/googlegenomics/utils-java/blob/7205d5b4e4f61fc6b93acb4bdd76b93df5b5f612/src/main/java/com/google/cloud/genomics/utils/ShardBoundary.java#L74-L86
140,499
amazon-archives/aws-sdk-java-resources
aws-resources-core/src/main/java/com/amazonaws/resources/internal/ActionUtils.java
ActionUtils.generateRequest
private static AmazonWebServiceRequest generateRequest( ActionContext context, Class<?> type, RequestModel model, AmazonWebServiceRequest request, Object token) throws InstantiationException, IllegalAccessException { if (request == null) { request = (AmazonWebServiceRequest) type.newInstance(); } request.getRequestClientOptions().appendUserAgent(USER_AGENT); for (PathTargetMapping mapping : model.getIdentifierMappings()) { Object value = context.getIdentifier(mapping.getSource()); if (value == null) { throw new IllegalStateException( "Action has a mapping for identifier " + mapping.getSource() + ", but the target has no " + "identifier of that name!"); } ReflectionUtils.setByPath(request, value, mapping.getTarget()); } for (PathTargetMapping mapping : model.getAttributeMappings()) { Object value = context.getAttribute(mapping.getSource()); if (value == null) { // TODO: Is this ever valid? throw new IllegalStateException( "Action has a mapping for attribute " + mapping.getSource() + ", but the target has no " + "attribute of that name!"); } ReflectionUtils.setByPath(request, value, mapping.getTarget()); } for (PathTargetMapping mapping : model.getConstantMappings()) { // TODO: This only works for strings; can we do better? ReflectionUtils.setByPath( request, mapping.getSource(), mapping.getTarget()); } if (token != null) { List<String> tokenPath = model.getTokenPath(); if (tokenPath == null) { throw new IllegalArgumentException( "Cannot pass a token with a null token path"); } ReflectionUtils.setByPath(request, token, tokenPath); } return request; }
java
private static AmazonWebServiceRequest generateRequest( ActionContext context, Class<?> type, RequestModel model, AmazonWebServiceRequest request, Object token) throws InstantiationException, IllegalAccessException { if (request == null) { request = (AmazonWebServiceRequest) type.newInstance(); } request.getRequestClientOptions().appendUserAgent(USER_AGENT); for (PathTargetMapping mapping : model.getIdentifierMappings()) { Object value = context.getIdentifier(mapping.getSource()); if (value == null) { throw new IllegalStateException( "Action has a mapping for identifier " + mapping.getSource() + ", but the target has no " + "identifier of that name!"); } ReflectionUtils.setByPath(request, value, mapping.getTarget()); } for (PathTargetMapping mapping : model.getAttributeMappings()) { Object value = context.getAttribute(mapping.getSource()); if (value == null) { // TODO: Is this ever valid? throw new IllegalStateException( "Action has a mapping for attribute " + mapping.getSource() + ", but the target has no " + "attribute of that name!"); } ReflectionUtils.setByPath(request, value, mapping.getTarget()); } for (PathTargetMapping mapping : model.getConstantMappings()) { // TODO: This only works for strings; can we do better? ReflectionUtils.setByPath( request, mapping.getSource(), mapping.getTarget()); } if (token != null) { List<String> tokenPath = model.getTokenPath(); if (tokenPath == null) { throw new IllegalArgumentException( "Cannot pass a token with a null token path"); } ReflectionUtils.setByPath(request, token, tokenPath); } return request; }
[ "private", "static", "AmazonWebServiceRequest", "generateRequest", "(", "ActionContext", "context", ",", "Class", "<", "?", ">", "type", ",", "RequestModel", "model", ",", "AmazonWebServiceRequest", "request", ",", "Object", "token", ")", "throws", "InstantiationException", ",", "IllegalAccessException", "{", "if", "(", "request", "==", "null", ")", "{", "request", "=", "(", "AmazonWebServiceRequest", ")", "type", ".", "newInstance", "(", ")", ";", "}", "request", ".", "getRequestClientOptions", "(", ")", ".", "appendUserAgent", "(", "USER_AGENT", ")", ";", "for", "(", "PathTargetMapping", "mapping", ":", "model", ".", "getIdentifierMappings", "(", ")", ")", "{", "Object", "value", "=", "context", ".", "getIdentifier", "(", "mapping", ".", "getSource", "(", ")", ")", ";", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Action has a mapping for identifier \"", "+", "mapping", ".", "getSource", "(", ")", "+", "\", but the target has no \"", "+", "\"identifier of that name!\"", ")", ";", "}", "ReflectionUtils", ".", "setByPath", "(", "request", ",", "value", ",", "mapping", ".", "getTarget", "(", ")", ")", ";", "}", "for", "(", "PathTargetMapping", "mapping", ":", "model", ".", "getAttributeMappings", "(", ")", ")", "{", "Object", "value", "=", "context", ".", "getAttribute", "(", "mapping", ".", "getSource", "(", ")", ")", ";", "if", "(", "value", "==", "null", ")", "{", "// TODO: Is this ever valid?", "throw", "new", "IllegalStateException", "(", "\"Action has a mapping for attribute \"", "+", "mapping", ".", "getSource", "(", ")", "+", "\", but the target has no \"", "+", "\"attribute of that name!\"", ")", ";", "}", "ReflectionUtils", ".", "setByPath", "(", "request", ",", "value", ",", "mapping", ".", "getTarget", "(", ")", ")", ";", "}", "for", "(", "PathTargetMapping", "mapping", ":", "model", ".", "getConstantMappings", "(", ")", ")", "{", "// TODO: This only works for strings; can we do better?", "ReflectionUtils", ".", "setByPath", "(", "request", ",", "mapping", ".", "getSource", "(", ")", ",", "mapping", ".", "getTarget", "(", ")", ")", ";", "}", "if", "(", "token", "!=", "null", ")", "{", "List", "<", "String", ">", "tokenPath", "=", "model", ".", "getTokenPath", "(", ")", ";", "if", "(", "tokenPath", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Cannot pass a token with a null token path\"", ")", ";", "}", "ReflectionUtils", ".", "setByPath", "(", "request", ",", "token", ",", "tokenPath", ")", ";", "}", "return", "request", ";", "}" ]
Generates a client-level request by extracting the user parameters (if
[ "Generates", "a", "client", "-", "level", "request", "by", "extracting", "the", "user", "parameters", "(", "if" ]
0f4fef2615d9687997b70a36eed1d62dd42df035
https://github.com/amazon-archives/aws-sdk-java-resources/blob/0f4fef2615d9687997b70a36eed1d62dd42df035/aws-resources-core/src/main/java/com/amazonaws/resources/internal/ActionUtils.java#L147-L201