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
partition
stringclasses
1 value
threerings/nenya
core/src/main/java/com/threerings/miso/client/MisoScenePanel.java
MisoScenePanel.getBaseTile
protected BaseTile getBaseTile (int tx, int ty) { SceneBlock block = getBlock(tx, ty); return (block == null) ? null : block.getBaseTile(tx, ty); }
java
protected BaseTile getBaseTile (int tx, int ty) { SceneBlock block = getBlock(tx, ty); return (block == null) ? null : block.getBaseTile(tx, ty); }
[ "protected", "BaseTile", "getBaseTile", "(", "int", "tx", ",", "int", "ty", ")", "{", "SceneBlock", "block", "=", "getBlock", "(", "tx", ",", "ty", ")", ";", "return", "(", "block", "==", "null", ")", "?", "null", ":", "block", ".", "getBaseTile", "(...
Returns the base tile for the specified tile coordinate.
[ "Returns", "the", "base", "tile", "for", "the", "specified", "tile", "coordinate", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/MisoScenePanel.java#L1385-L1389
train
threerings/nenya
core/src/main/java/com/threerings/miso/client/MisoScenePanel.java
MisoScenePanel.getFringeTile
protected BaseTile getFringeTile (int tx, int ty) { SceneBlock block = getBlock(tx, ty); return (block == null) ? null : block.getFringeTile(tx, ty); }
java
protected BaseTile getFringeTile (int tx, int ty) { SceneBlock block = getBlock(tx, ty); return (block == null) ? null : block.getFringeTile(tx, ty); }
[ "protected", "BaseTile", "getFringeTile", "(", "int", "tx", ",", "int", "ty", ")", "{", "SceneBlock", "block", "=", "getBlock", "(", "tx", ",", "ty", ")", ";", "return", "(", "block", "==", "null", ")", "?", "null", ":", "block", ".", "getFringeTile", ...
Returns the fringe tile for the specified tile coordinate.
[ "Returns", "the", "fringe", "tile", "for", "the", "specified", "tile", "coordinate", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/MisoScenePanel.java#L1392-L1396
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/BuilderModel.java
BuilderModel.notifyListeners
protected void notifyListeners (int event) { int size = _listeners.size(); for (int ii = 0; ii < size; ii++) { _listeners.get(ii).modelChanged(event); } }
java
protected void notifyListeners (int event) { int size = _listeners.size(); for (int ii = 0; ii < size; ii++) { _listeners.get(ii).modelChanged(event); } }
[ "protected", "void", "notifyListeners", "(", "int", "event", ")", "{", "int", "size", "=", "_listeners", ".", "size", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "size", ";", "ii", "++", ")", "{", "_listeners", ".", "get", "...
Notifies all model listeners that the builder model has changed.
[ "Notifies", "all", "model", "listeners", "that", "the", "builder", "model", "has", "changed", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/BuilderModel.java#L64-L70
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/BuilderModel.java
BuilderModel.getComponents
public List<Integer> getComponents (ComponentClass cclass) { List<Integer> list = _components.get(cclass); if (list == null) { list = Lists.newArrayList(); } return list; }
java
public List<Integer> getComponents (ComponentClass cclass) { List<Integer> list = _components.get(cclass); if (list == null) { list = Lists.newArrayList(); } return list; }
[ "public", "List", "<", "Integer", ">", "getComponents", "(", "ComponentClass", "cclass", ")", "{", "List", "<", "Integer", ">", "list", "=", "_components", ".", "get", "(", "cclass", ")", ";", "if", "(", "list", "==", "null", ")", "{", "list", "=", "...
Returns the list of components available in the specified class.
[ "Returns", "the", "list", "of", "components", "available", "in", "the", "specified", "class", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/BuilderModel.java#L83-L90
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/BuilderModel.java
BuilderModel.getSelectedComponents
public int[] getSelectedComponents () { int[] values = new int[_selected.size()]; Iterator<Integer> iter = _selected.values().iterator(); for (int ii = 0; iter.hasNext(); ii++) { values[ii] = iter.next().intValue(); } return values; }
java
public int[] getSelectedComponents () { int[] values = new int[_selected.size()]; Iterator<Integer> iter = _selected.values().iterator(); for (int ii = 0; iter.hasNext(); ii++) { values[ii] = iter.next().intValue(); } return values; }
[ "public", "int", "[", "]", "getSelectedComponents", "(", ")", "{", "int", "[", "]", "values", "=", "new", "int", "[", "_selected", ".", "size", "(", ")", "]", ";", "Iterator", "<", "Integer", ">", "iter", "=", "_selected", ".", "values", "(", ")", ...
Returns the selected components in an array.
[ "Returns", "the", "selected", "components", "in", "an", "array", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/BuilderModel.java#L95-L103
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/BuilderModel.java
BuilderModel.setSelectedComponent
public void setSelectedComponent (ComponentClass cclass, int cid) { _selected.put(cclass, Integer.valueOf(cid)); notifyListeners(BuilderModelListener.COMPONENT_CHANGED); }
java
public void setSelectedComponent (ComponentClass cclass, int cid) { _selected.put(cclass, Integer.valueOf(cid)); notifyListeners(BuilderModelListener.COMPONENT_CHANGED); }
[ "public", "void", "setSelectedComponent", "(", "ComponentClass", "cclass", ",", "int", "cid", ")", "{", "_selected", ".", "put", "(", "cclass", ",", "Integer", ".", "valueOf", "(", "cid", ")", ")", ";", "notifyListeners", "(", "BuilderModelListener", ".", "C...
Sets the selected component for the given component class.
[ "Sets", "the", "selected", "component", "for", "the", "given", "component", "class", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/BuilderModel.java#L108-L112
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/BuilderModel.java
BuilderModel.gatherComponentInfo
protected void gatherComponentInfo (ComponentRepository crepo) { // get the list of all component classes Iterators.addAll(_classes, crepo.enumerateComponentClasses()); for (int ii = 0; ii < _classes.size(); ii++) { // get the list of components available for this class ComponentClass cclass = _classes.get(ii); Iterator<Integer> iter = crepo.enumerateComponentIds(cclass); while (iter.hasNext()) { Integer cid = iter.next(); ArrayList<Integer> clist = _components.get(cclass); if (clist == null) { _components.put(cclass, clist = Lists.newArrayList()); } clist.add(cid); } } }
java
protected void gatherComponentInfo (ComponentRepository crepo) { // get the list of all component classes Iterators.addAll(_classes, crepo.enumerateComponentClasses()); for (int ii = 0; ii < _classes.size(); ii++) { // get the list of components available for this class ComponentClass cclass = _classes.get(ii); Iterator<Integer> iter = crepo.enumerateComponentIds(cclass); while (iter.hasNext()) { Integer cid = iter.next(); ArrayList<Integer> clist = _components.get(cclass); if (clist == null) { _components.put(cclass, clist = Lists.newArrayList()); } clist.add(cid); } } }
[ "protected", "void", "gatherComponentInfo", "(", "ComponentRepository", "crepo", ")", "{", "// get the list of all component classes", "Iterators", ".", "addAll", "(", "_classes", ",", "crepo", ".", "enumerateComponentClasses", "(", ")", ")", ";", "for", "(", "int", ...
Gathers component class and component information from the character manager for later reference by others.
[ "Gathers", "component", "class", "and", "component", "information", "from", "the", "character", "manager", "for", "later", "reference", "by", "others", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/BuilderModel.java#L118-L138
train
threerings/nenya
core/src/main/java/com/threerings/util/FileUtil.java
FileUtil.getOldestLastModified
public static long getOldestLastModified (File dir) { long oldest = dir.lastModified(); File[] files = dir.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { oldest = Math.min(oldest, getOldestLastModified(file)); } else { oldest = Math.min(oldest, file.lastModified()); } } } return oldest; }
java
public static long getOldestLastModified (File dir) { long oldest = dir.lastModified(); File[] files = dir.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { oldest = Math.min(oldest, getOldestLastModified(file)); } else { oldest = Math.min(oldest, file.lastModified()); } } } return oldest; }
[ "public", "static", "long", "getOldestLastModified", "(", "File", "dir", ")", "{", "long", "oldest", "=", "dir", ".", "lastModified", "(", ")", ";", "File", "[", "]", "files", "=", "dir", ".", "listFiles", "(", ")", ";", "if", "(", "files", "!=", "nu...
Returns the timestamp of the oldest modification date of any file within the directory.
[ "Returns", "the", "timestamp", "of", "the", "oldest", "modification", "date", "of", "any", "file", "within", "the", "directory", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/util/FileUtil.java#L29-L43
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java
NamedResolverMap.intKeySet
public Set<Integer> intKeySet() { return data.keySet().stream() .map(Any2::getLeft) .flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toSet()); }
java
public Set<Integer> intKeySet() { return data.keySet().stream() .map(Any2::getLeft) .flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toSet()); }
[ "public", "Set", "<", "Integer", ">", "intKeySet", "(", ")", "{", "return", "data", ".", "keySet", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "Any2", "::", "getLeft", ")", ".", "flatMap", "(", "opt", "->", "opt", ".", "map", "(", "Stream...
The numeric set of keys held by the resolver map. @return the numberic set of keys held by the resolver map.
[ "The", "numeric", "set", "of", "keys", "held", "by", "the", "resolver", "map", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java#L211-L216
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java
NamedResolverMap.stringKeySet
public Set<String> stringKeySet() { return data.keySet().stream() .map(Any2::getRight) .flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toSet()); }
java
public Set<String> stringKeySet() { return data.keySet().stream() .map(Any2::getRight) .flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toSet()); }
[ "public", "Set", "<", "String", ">", "stringKeySet", "(", ")", "{", "return", "data", ".", "keySet", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "Any2", "::", "getRight", ")", ".", "flatMap", "(", "opt", "->", "opt", ".", "map", "(", "Str...
The string set of keys held by the resolver map. @return the string set of keys held by the resolver map.
[ "The", "string", "set", "of", "keys", "held", "by", "the", "resolver", "map", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java#L223-L228
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java
NamedResolverMap.getRawMap
public Map<Any2<Integer, String>, Any3<Boolean, Integer, String>> getRawMap() { return unmodifiableMap(data); }
java
public Map<Any2<Integer, String>, Any3<Boolean, Integer, String>> getRawMap() { return unmodifiableMap(data); }
[ "public", "Map", "<", "Any2", "<", "Integer", ",", "String", ">", ",", "Any3", "<", "Boolean", ",", "Integer", ",", "String", ">", ">", "getRawMap", "(", ")", "{", "return", "unmodifiableMap", "(", "data", ")", ";", "}" ]
Get the underlying map of data. @return The raw map underlying this NamedResolverMap.
[ "Get", "the", "underlying", "map", "of", "data", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java#L319-L321
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java
NamedResolverMap.getStringMap
public Map<Any2<Integer, String>, String> getStringMap() { return data.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mapCombine(Object::toString, Object::toString, Object::toString))); }
java
public Map<Any2<Integer, String>, String> getStringMap() { return data.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().mapCombine(Object::toString, Object::toString, Object::toString))); }
[ "public", "Map", "<", "Any2", "<", "Integer", ",", "String", ">", ",", "String", ">", "getStringMap", "(", ")", "{", "return", "data", ".", "entrySet", "(", ")", ".", "stream", "(", ")", ".", "collect", "(", "Collectors", ".", "toMap", "(", "Map", ...
Get the underlying map, but with all values converted to string. @return The raw map with every value converted to a string.
[ "Get", "the", "underlying", "map", "but", "with", "all", "values", "converted", "to", "string", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/resolver/NamedResolverMap.java#L328-L331
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/SpritePanel.java
SpritePanel.generateSprite
protected void generateSprite () { int components[] = _model.getSelectedComponents(); CharacterDescriptor desc = new CharacterDescriptor(components, null); CharacterSprite sprite = _charmgr.getCharacter(desc); setSprite(sprite); }
java
protected void generateSprite () { int components[] = _model.getSelectedComponents(); CharacterDescriptor desc = new CharacterDescriptor(components, null); CharacterSprite sprite = _charmgr.getCharacter(desc); setSprite(sprite); }
[ "protected", "void", "generateSprite", "(", ")", "{", "int", "components", "[", "]", "=", "_model", ".", "getSelectedComponents", "(", ")", ";", "CharacterDescriptor", "desc", "=", "new", "CharacterDescriptor", "(", "components", ",", "null", ")", ";", "Charac...
Generates a new character sprite for display to reflect the currently selected character components.
[ "Generates", "a", "new", "character", "sprite", "for", "display", "to", "reflect", "the", "currently", "selected", "character", "components", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/SpritePanel.java#L88-L94
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/SpritePanel.java
SpritePanel.setSprite
protected void setSprite (CharacterSprite sprite) { sprite.setActionSequence(StandardActions.STANDING); sprite.setOrientation(WEST); _sprite = sprite; centerSprite(); repaint(); }
java
protected void setSprite (CharacterSprite sprite) { sprite.setActionSequence(StandardActions.STANDING); sprite.setOrientation(WEST); _sprite = sprite; centerSprite(); repaint(); }
[ "protected", "void", "setSprite", "(", "CharacterSprite", "sprite", ")", "{", "sprite", ".", "setActionSequence", "(", "StandardActions", ".", "STANDING", ")", ";", "sprite", ".", "setOrientation", "(", "WEST", ")", ";", "_sprite", "=", "sprite", ";", "centerS...
Sets the sprite to be displayed.
[ "Sets", "the", "sprite", "to", "be", "displayed", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/SpritePanel.java#L99-L106
train
threerings/nenya
core/src/main/java/com/threerings/cast/builder/SpritePanel.java
SpritePanel.centerSprite
protected void centerSprite () { if (_sprite != null) { Dimension d = getSize(); int shei = _sprite.getHeight(); int x = d.width / 2, y = (d.height + shei) / 2; _sprite.setLocation(x, y); } }
java
protected void centerSprite () { if (_sprite != null) { Dimension d = getSize(); int shei = _sprite.getHeight(); int x = d.width / 2, y = (d.height + shei) / 2; _sprite.setLocation(x, y); } }
[ "protected", "void", "centerSprite", "(", ")", "{", "if", "(", "_sprite", "!=", "null", ")", "{", "Dimension", "d", "=", "getSize", "(", ")", ";", "int", "shei", "=", "_sprite", ".", "getHeight", "(", ")", ";", "int", "x", "=", "d", ".", "width", ...
Sets the sprite's location to render it centered within the panel.
[ "Sets", "the", "sprite", "s", "location", "to", "render", "it", "centered", "within", "the", "panel", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/builder/SpritePanel.java#L111-L119
train
threerings/nenya
tools/src/main/java/com/threerings/miso/tools/xml/SimpleMisoSceneParser.java
SimpleMisoSceneParser.parseScene
public SimpleMisoSceneModel parseScene (InputStream in) throws IOException, SAXException { _model = null; _digester.push(this); _digester.parse(in); return _model; }
java
public SimpleMisoSceneModel parseScene (InputStream in) throws IOException, SAXException { _model = null; _digester.push(this); _digester.parse(in); return _model; }
[ "public", "SimpleMisoSceneModel", "parseScene", "(", "InputStream", "in", ")", "throws", "IOException", ",", "SAXException", "{", "_model", "=", "null", ";", "_digester", ".", "push", "(", "this", ")", ";", "_digester", ".", "parse", "(", "in", ")", ";", "...
Parses the XML file on the supplied input stream into a scene model instance.
[ "Parses", "the", "XML", "file", "on", "the", "supplied", "input", "stream", "into", "a", "scene", "model", "instance", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/miso/tools/xml/SimpleMisoSceneParser.java#L77-L84
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.setGain
public void setGain (float gain) { _gain = gain; if (_fadeMode == FadeMode.NONE) { _source.setGain(_gain); } }
java
public void setGain (float gain) { _gain = gain; if (_fadeMode == FadeMode.NONE) { _source.setGain(_gain); } }
[ "public", "void", "setGain", "(", "float", "gain", ")", "{", "_gain", "=", "gain", ";", "if", "(", "_fadeMode", "==", "FadeMode", ".", "NONE", ")", "{", "_source", ".", "setGain", "(", "_gain", ")", ";", "}", "}" ]
Sets the base gain of the stream.
[ "Sets", "the", "base", "gain", "of", "the", "stream", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L59-L65
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.play
public void play () { if (_state == AL10.AL_PLAYING) { log.warning("Tried to play stream already playing."); return; } if (_state == AL10.AL_INITIAL) { _qidx = _qlen = 0; queueBuffers(_buffers.length); } _source.play(); _state = AL10.AL_PLAYING; }
java
public void play () { if (_state == AL10.AL_PLAYING) { log.warning("Tried to play stream already playing."); return; } if (_state == AL10.AL_INITIAL) { _qidx = _qlen = 0; queueBuffers(_buffers.length); } _source.play(); _state = AL10.AL_PLAYING; }
[ "public", "void", "play", "(", ")", "{", "if", "(", "_state", "==", "AL10", ".", "AL_PLAYING", ")", "{", "log", ".", "warning", "(", "\"Tried to play stream already playing.\"", ")", ";", "return", ";", "}", "if", "(", "_state", "==", "AL10", ".", "AL_IN...
Starts playing this stream.
[ "Starts", "playing", "this", "stream", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L86-L98
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.pause
public void pause () { if (_state != AL10.AL_PLAYING) { log.warning("Tried to pause stream that wasn't playing."); return; } _source.pause(); _state = AL10.AL_PAUSED; }
java
public void pause () { if (_state != AL10.AL_PLAYING) { log.warning("Tried to pause stream that wasn't playing."); return; } _source.pause(); _state = AL10.AL_PAUSED; }
[ "public", "void", "pause", "(", ")", "{", "if", "(", "_state", "!=", "AL10", ".", "AL_PLAYING", ")", "{", "log", ".", "warning", "(", "\"Tried to pause stream that wasn't playing.\"", ")", ";", "return", ";", "}", "_source", ".", "pause", "(", ")", ";", ...
Pauses this stream.
[ "Pauses", "this", "stream", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L103-L111
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.stop
public void stop () { if (_state == AL10.AL_STOPPED) { log.warning("Tried to stop stream that was already stopped."); return; } _source.stop(); _state = AL10.AL_STOPPED; }
java
public void stop () { if (_state == AL10.AL_STOPPED) { log.warning("Tried to stop stream that was already stopped."); return; } _source.stop(); _state = AL10.AL_STOPPED; }
[ "public", "void", "stop", "(", ")", "{", "if", "(", "_state", "==", "AL10", ".", "AL_STOPPED", ")", "{", "log", ".", "warning", "(", "\"Tried to stop stream that was already stopped.\"", ")", ";", "return", ";", "}", "_source", ".", "stop", "(", ")", ";", ...
Stops this stream.
[ "Stops", "this", "stream", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L116-L124
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.fadeIn
public void fadeIn (float interval) { if (_state != AL10.AL_PLAYING) { play(); } _source.setGain(0f); _fadeMode = FadeMode.IN; _fadeInterval = interval; _fadeElapsed = 0f; }
java
public void fadeIn (float interval) { if (_state != AL10.AL_PLAYING) { play(); } _source.setGain(0f); _fadeMode = FadeMode.IN; _fadeInterval = interval; _fadeElapsed = 0f; }
[ "public", "void", "fadeIn", "(", "float", "interval", ")", "{", "if", "(", "_state", "!=", "AL10", ".", "AL_PLAYING", ")", "{", "play", "(", ")", ";", "}", "_source", ".", "setGain", "(", "0f", ")", ";", "_fadeMode", "=", "FadeMode", ".", "IN", ";"...
Fades this stream in over the specified interval. If the stream isn't playing, it will be started.
[ "Fades", "this", "stream", "in", "over", "the", "specified", "interval", ".", "If", "the", "stream", "isn", "t", "playing", "it", "will", "be", "started", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L130-L139
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.fadeOut
public void fadeOut (float interval, boolean dispose) { _fadeMode = dispose ? FadeMode.OUT_DISPOSE : FadeMode.OUT; _fadeInterval = interval; _fadeElapsed = 0f; }
java
public void fadeOut (float interval, boolean dispose) { _fadeMode = dispose ? FadeMode.OUT_DISPOSE : FadeMode.OUT; _fadeInterval = interval; _fadeElapsed = 0f; }
[ "public", "void", "fadeOut", "(", "float", "interval", ",", "boolean", "dispose", ")", "{", "_fadeMode", "=", "dispose", "?", "FadeMode", ".", "OUT_DISPOSE", ":", "FadeMode", ".", "OUT", ";", "_fadeInterval", "=", "interval", ";", "_fadeElapsed", "=", "0f", ...
Fades this stream out over the specified interval. @param dispose if true, dispose of the stream when done fading out
[ "Fades", "this", "stream", "out", "over", "the", "specified", "interval", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L146-L151
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.dispose
public void dispose () { // make sure the stream is stopped if (_state != AL10.AL_STOPPED) { stop(); } // delete the source and buffers _source.delete(); for (Buffer buffer : _buffers) { buffer.delete(); } // remove from manager _soundmgr.removeStream(this); }
java
public void dispose () { // make sure the stream is stopped if (_state != AL10.AL_STOPPED) { stop(); } // delete the source and buffers _source.delete(); for (Buffer buffer : _buffers) { buffer.delete(); } // remove from manager _soundmgr.removeStream(this); }
[ "public", "void", "dispose", "(", ")", "{", "// make sure the stream is stopped", "if", "(", "_state", "!=", "AL10", ".", "AL_STOPPED", ")", "{", "stop", "(", ")", ";", "}", "// delete the source and buffers", "_source", ".", "delete", "(", ")", ";", "for", ...
Releases the resources held by this stream and removes it from the manager.
[ "Releases", "the", "resources", "held", "by", "this", "stream", "and", "removes", "it", "from", "the", "manager", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L156-L171
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.updateFade
protected void updateFade (float time) { if (_fadeMode == FadeMode.NONE) { return; } float alpha = Math.min((_fadeElapsed += time) / _fadeInterval, 1f); _source.setGain(_gain * (_fadeMode == FadeMode.IN ? alpha : (1f - alpha))); if (alpha == 1f) { if (_fadeMode == FadeMode.OUT) { stop(); } else if (_fadeMode == FadeMode.OUT_DISPOSE) { dispose(); } _fadeMode = FadeMode.NONE; } }
java
protected void updateFade (float time) { if (_fadeMode == FadeMode.NONE) { return; } float alpha = Math.min((_fadeElapsed += time) / _fadeInterval, 1f); _source.setGain(_gain * (_fadeMode == FadeMode.IN ? alpha : (1f - alpha))); if (alpha == 1f) { if (_fadeMode == FadeMode.OUT) { stop(); } else if (_fadeMode == FadeMode.OUT_DISPOSE) { dispose(); } _fadeMode = FadeMode.NONE; } }
[ "protected", "void", "updateFade", "(", "float", "time", ")", "{", "if", "(", "_fadeMode", "==", "FadeMode", ".", "NONE", ")", "{", "return", ";", "}", "float", "alpha", "=", "Math", ".", "min", "(", "(", "_fadeElapsed", "+=", "time", ")", "/", "_fad...
Updates the gain of the stream according to the fade state.
[ "Updates", "the", "gain", "of", "the", "stream", "according", "to", "the", "fade", "state", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L211-L226
train
threerings/nenya
core/src/main/java/com/threerings/openal/Stream.java
Stream.populateBuffer
protected boolean populateBuffer (Buffer buffer) { if (_abuf == null) { _abuf = ByteBuffer.allocateDirect(getBufferSize()).order(ByteOrder.nativeOrder()); } _abuf.clear(); int read = 0; try { read = Math.max(populateBuffer(_abuf), 0); } catch (IOException e) { log.warning("Error reading audio stream [error=" + e + "]."); } if (read <= 0) { return false; } _abuf.rewind().limit(read); buffer.setData(getFormat(), _abuf, getFrequency()); return true; }
java
protected boolean populateBuffer (Buffer buffer) { if (_abuf == null) { _abuf = ByteBuffer.allocateDirect(getBufferSize()).order(ByteOrder.nativeOrder()); } _abuf.clear(); int read = 0; try { read = Math.max(populateBuffer(_abuf), 0); } catch (IOException e) { log.warning("Error reading audio stream [error=" + e + "]."); } if (read <= 0) { return false; } _abuf.rewind().limit(read); buffer.setData(getFormat(), _abuf, getFrequency()); return true; }
[ "protected", "boolean", "populateBuffer", "(", "Buffer", "buffer", ")", "{", "if", "(", "_abuf", "==", "null", ")", "{", "_abuf", "=", "ByteBuffer", ".", "allocateDirect", "(", "getBufferSize", "(", ")", ")", ".", "order", "(", "ByteOrder", ".", "nativeOrd...
Populates the identified buffer with as much data as it can hold. @return true if data was read into the buffer and it should be enqueued, false if the end of the stream has been reached and no data was read into the buffer
[ "Populates", "the", "identified", "buffer", "with", "as", "much", "data", "as", "it", "can", "hold", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Stream.java#L250-L268
train
groupon/monsoon
impl/src/main/java/com/groupon/lex/metrics/misc/MonitorMonitor.java
MonitorMonitor.get_metrics_
private Map<MetricName, MetricValue> get_metrics_(DateTime now, Context ctx) { final Consumer<Alert> alert_manager = ctx.getAlertManager(); final long failed_collections = registry_.getFailedCollections(); final boolean has_config = registry_.hasConfig(); final Optional<Duration> scrape_duration = registry_.getScrapeDuration(); final Optional<Duration> rule_eval_duration = registry_.getRuleEvalDuration(); final Optional<Duration> processor_duration = registry_.getProcessorDuration(); first_scrape_ts_.compareAndSet(null, now); // First time, register the timestamp. final Duration uptime = new Duration(first_scrape_ts_.get(), now); final Optional<DateTime> last_scrape = last_scrape_; last_scrape_ = Optional.of(now); final long metric_count = ctx.getTSData().getCurrentCollection().getTSValues().stream() .map(TimeSeriesValue::getMetrics) .collect(Collectors.summingLong(Map::size)); alert_manager.accept(new Alert(now, MONITOR_FAIL_ALERT, () -> "builtin rule", Optional.of(failed_collections != 0), MON_ALERT_DURATION, "builtin rule: some collectors failed", EMPTY_MAP)); alert_manager.accept(new Alert(now, HAS_CONFIG_ALERT, () -> "builtin rule", Optional.of(!has_config), Duration.ZERO, "builtin rule: monitor has no configuration file", EMPTY_MAP)); Map<MetricName, MetricValue> result = new HashMap<>(); result.put(FAILED_COLLECTIONS_METRIC, MetricValue.fromIntValue(failed_collections)); result.put(GROUP_COUNT_METRIC, MetricValue.fromIntValue(ctx.getTSData().getCurrentCollection().getGroups(x -> true).size())); result.put(METRIC_COUNT_METRIC, MetricValue.fromIntValue(metric_count)); result.put(CONFIG_PRESENT_METRIC, MetricValue.fromBoolean(has_config)); result.put(SCRAPE_DURATION, opt_duration_to_metricvalue_(scrape_duration)); result.put(RULE_EVAL_DURATION, opt_duration_to_metricvalue_(rule_eval_duration)); result.put(PROCESSOR_DURATION, opt_duration_to_metricvalue_(processor_duration)); result.put(UPTIME_DURATION, duration_to_metricvalue_(uptime)); result.put(SCRAPE_COUNT, MetricValue.fromIntValue(++scrape_count_)); result.put(SCRAPE_INTERVAL, opt_duration_to_metricvalue_(last_scrape.map(prev -> new Duration(prev, now)))); result.put(SCRAPE_TS, MetricValue.fromIntValue(now.getMillis())); return result; }
java
private Map<MetricName, MetricValue> get_metrics_(DateTime now, Context ctx) { final Consumer<Alert> alert_manager = ctx.getAlertManager(); final long failed_collections = registry_.getFailedCollections(); final boolean has_config = registry_.hasConfig(); final Optional<Duration> scrape_duration = registry_.getScrapeDuration(); final Optional<Duration> rule_eval_duration = registry_.getRuleEvalDuration(); final Optional<Duration> processor_duration = registry_.getProcessorDuration(); first_scrape_ts_.compareAndSet(null, now); // First time, register the timestamp. final Duration uptime = new Duration(first_scrape_ts_.get(), now); final Optional<DateTime> last_scrape = last_scrape_; last_scrape_ = Optional.of(now); final long metric_count = ctx.getTSData().getCurrentCollection().getTSValues().stream() .map(TimeSeriesValue::getMetrics) .collect(Collectors.summingLong(Map::size)); alert_manager.accept(new Alert(now, MONITOR_FAIL_ALERT, () -> "builtin rule", Optional.of(failed_collections != 0), MON_ALERT_DURATION, "builtin rule: some collectors failed", EMPTY_MAP)); alert_manager.accept(new Alert(now, HAS_CONFIG_ALERT, () -> "builtin rule", Optional.of(!has_config), Duration.ZERO, "builtin rule: monitor has no configuration file", EMPTY_MAP)); Map<MetricName, MetricValue> result = new HashMap<>(); result.put(FAILED_COLLECTIONS_METRIC, MetricValue.fromIntValue(failed_collections)); result.put(GROUP_COUNT_METRIC, MetricValue.fromIntValue(ctx.getTSData().getCurrentCollection().getGroups(x -> true).size())); result.put(METRIC_COUNT_METRIC, MetricValue.fromIntValue(metric_count)); result.put(CONFIG_PRESENT_METRIC, MetricValue.fromBoolean(has_config)); result.put(SCRAPE_DURATION, opt_duration_to_metricvalue_(scrape_duration)); result.put(RULE_EVAL_DURATION, opt_duration_to_metricvalue_(rule_eval_duration)); result.put(PROCESSOR_DURATION, opt_duration_to_metricvalue_(processor_duration)); result.put(UPTIME_DURATION, duration_to_metricvalue_(uptime)); result.put(SCRAPE_COUNT, MetricValue.fromIntValue(++scrape_count_)); result.put(SCRAPE_INTERVAL, opt_duration_to_metricvalue_(last_scrape.map(prev -> new Duration(prev, now)))); result.put(SCRAPE_TS, MetricValue.fromIntValue(now.getMillis())); return result; }
[ "private", "Map", "<", "MetricName", ",", "MetricValue", ">", "get_metrics_", "(", "DateTime", "now", ",", "Context", "ctx", ")", "{", "final", "Consumer", "<", "Alert", ">", "alert_manager", "=", "ctx", ".", "getAlertManager", "(", ")", ";", "final", "lon...
Get metrics for the monitor. @return All metrics for the monitor.
[ "Get", "metrics", "for", "the", "monitor", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/misc/MonitorMonitor.java#L96-L129
train
groupon/monsoon
impl/src/main/java/com/groupon/lex/metrics/misc/MonitorMonitor.java
MonitorMonitor.transform
@Override public void transform(Context<MutableTimeSeriesCollectionPair> ctx) { DateTime now = ctx.getTSData().getCurrentCollection().getTimestamp(); ctx.getTSData().getCurrentCollection().addMetrics(MONITOR_GROUP, get_metrics_(now, ctx)); ctx.getAlertManager().accept(new Alert(now, MONITOR_DOWN_ALERT, () -> "builtin rule", Optional.of(false), Duration.ZERO, "builtin rule: monitor is not running for some time", EMPTY_MAP)); }
java
@Override public void transform(Context<MutableTimeSeriesCollectionPair> ctx) { DateTime now = ctx.getTSData().getCurrentCollection().getTimestamp(); ctx.getTSData().getCurrentCollection().addMetrics(MONITOR_GROUP, get_metrics_(now, ctx)); ctx.getAlertManager().accept(new Alert(now, MONITOR_DOWN_ALERT, () -> "builtin rule", Optional.of(false), Duration.ZERO, "builtin rule: monitor is not running for some time", EMPTY_MAP)); }
[ "@", "Override", "public", "void", "transform", "(", "Context", "<", "MutableTimeSeriesCollectionPair", ">", "ctx", ")", "{", "DateTime", "now", "=", "ctx", ".", "getTSData", "(", ")", ".", "getCurrentCollection", "(", ")", ".", "getTimestamp", "(", ")", ";"...
Emit an alert monitor.down, which is in the OK state. @param ctx Rule evaluation context.
[ "Emit", "an", "alert", "monitor", ".", "down", "which", "is", "in", "the", "OK", "state", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/misc/MonitorMonitor.java#L136-L143
train
groupon/monsoon
impl/src/main/java/com/groupon/lex/metrics/misc/MonitorMonitor.java
MonitorMonitor.opt_duration_to_metricvalue_
private static MetricValue opt_duration_to_metricvalue_(Optional<Duration> duration) { return duration .map(MonitorMonitor::duration_to_metricvalue_) .orElse(MetricValue.EMPTY); }
java
private static MetricValue opt_duration_to_metricvalue_(Optional<Duration> duration) { return duration .map(MonitorMonitor::duration_to_metricvalue_) .orElse(MetricValue.EMPTY); }
[ "private", "static", "MetricValue", "opt_duration_to_metricvalue_", "(", "Optional", "<", "Duration", ">", "duration", ")", "{", "return", "duration", ".", "map", "(", "MonitorMonitor", "::", "duration_to_metricvalue_", ")", ".", "orElse", "(", "MetricValue", ".", ...
Convert an optional duration to a metric value. The returned metric value is expressed as the duration in milliseconds. If the Optional is empty, an empty metric value is emitted. @param duration The duration to express. @return A metric value representing the duration.
[ "Convert", "an", "optional", "duration", "to", "a", "metric", "value", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/misc/MonitorMonitor.java#L154-L158
train
groupon/monsoon
expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java
InterpolatedTSC.validate
private void validate() { try { DateTime ts; ts = current.getTimestamp(); for (TimeSeriesCollection b : backward) { if (b.getTimestamp().isAfter(ts)) throw new IllegalArgumentException("backwards collection must be before current and be ordered in reverse chronological order"); ts = b.getTimestamp(); } ts = current.getTimestamp(); for (TimeSeriesCollection f : forward) { if (f.getTimestamp().isBefore(ts)) throw new IllegalArgumentException("forwards collection must be after current and be ordered in chronological order"); ts = f.getTimestamp(); } } catch (IllegalArgumentException ex) { LOG.log(Level.SEVERE, "programmer error in creating interpolated TimeSeriesCollection", ex); final List<DateTime> backward_ts = backward.stream().map(TimeSeriesCollection::getTimestamp).collect(Collectors.toList()); final List<DateTime> forward_ts = forward.stream().map(TimeSeriesCollection::getTimestamp).collect(Collectors.toList()); LOG.log(Level.INFO, "current = {0}, backward = {1}, forward = {2}", new Object[]{current.getTimestamp(), backward_ts, forward_ts}); throw ex; } }
java
private void validate() { try { DateTime ts; ts = current.getTimestamp(); for (TimeSeriesCollection b : backward) { if (b.getTimestamp().isAfter(ts)) throw new IllegalArgumentException("backwards collection must be before current and be ordered in reverse chronological order"); ts = b.getTimestamp(); } ts = current.getTimestamp(); for (TimeSeriesCollection f : forward) { if (f.getTimestamp().isBefore(ts)) throw new IllegalArgumentException("forwards collection must be after current and be ordered in chronological order"); ts = f.getTimestamp(); } } catch (IllegalArgumentException ex) { LOG.log(Level.SEVERE, "programmer error in creating interpolated TimeSeriesCollection", ex); final List<DateTime> backward_ts = backward.stream().map(TimeSeriesCollection::getTimestamp).collect(Collectors.toList()); final List<DateTime> forward_ts = forward.stream().map(TimeSeriesCollection::getTimestamp).collect(Collectors.toList()); LOG.log(Level.INFO, "current = {0}, backward = {1}, forward = {2}", new Object[]{current.getTimestamp(), backward_ts, forward_ts}); throw ex; } }
[ "private", "void", "validate", "(", ")", "{", "try", "{", "DateTime", "ts", ";", "ts", "=", "current", ".", "getTimestamp", "(", ")", ";", "for", "(", "TimeSeriesCollection", "b", ":", "backward", ")", "{", "if", "(", "b", ".", "getTimestamp", "(", "...
Check the forward and backward invariants.
[ "Check", "the", "forward", "and", "backward", "invariants", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java#L88-L112
train
groupon/monsoon
expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java
InterpolatedTSC.calculateNames
private static Set<GroupName> calculateNames(TimeSeriesCollection current, Collection<TimeSeriesCollection> backward, Collection<TimeSeriesCollection> forward) { final Set<GroupName> names = backward.stream() .flatMap(tsc -> tsc.getGroups(x -> true).stream()) .collect(Collectors.toCollection(THashSet::new)); names.retainAll(forward.stream() .flatMap(tsc -> tsc.getGroups(x -> true).stream()) .collect(Collectors.toSet())); names.removeAll(current.getGroups(x -> true)); return names; }
java
private static Set<GroupName> calculateNames(TimeSeriesCollection current, Collection<TimeSeriesCollection> backward, Collection<TimeSeriesCollection> forward) { final Set<GroupName> names = backward.stream() .flatMap(tsc -> tsc.getGroups(x -> true).stream()) .collect(Collectors.toCollection(THashSet::new)); names.retainAll(forward.stream() .flatMap(tsc -> tsc.getGroups(x -> true).stream()) .collect(Collectors.toSet())); names.removeAll(current.getGroups(x -> true)); return names; }
[ "private", "static", "Set", "<", "GroupName", ">", "calculateNames", "(", "TimeSeriesCollection", "current", ",", "Collection", "<", "TimeSeriesCollection", ">", "backward", ",", "Collection", "<", "TimeSeriesCollection", ">", "forward", ")", "{", "final", "Set", ...
Calculate all names that can be interpolated. The returned set will not have any names present in the current collection.
[ "Calculate", "all", "names", "that", "can", "be", "interpolated", ".", "The", "returned", "set", "will", "not", "have", "any", "names", "present", "in", "the", "current", "collection", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java#L171-L180
train
groupon/monsoon
expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java
InterpolatedTSC.interpolateTSV
private TimeSeriesValue interpolateTSV(GroupName name) { final Map.Entry<DateTime, TimeSeriesValue> backTSV = findName(backward, name), forwTSV = findName(forward, name); final long backMillis = max(new Duration(backTSV.getKey(), getTimestamp()).getMillis(), 0), forwMillis = max(new Duration(getTimestamp(), forwTSV.getKey()).getMillis(), 0); final double totalMillis = forwMillis + backMillis; final double backWeight = forwMillis / totalMillis; final double forwWeight = backMillis / totalMillis; return new InterpolatedTSV(name, backTSV.getValue().getMetrics(), forwTSV.getValue().getMetrics(), backWeight, forwWeight); }
java
private TimeSeriesValue interpolateTSV(GroupName name) { final Map.Entry<DateTime, TimeSeriesValue> backTSV = findName(backward, name), forwTSV = findName(forward, name); final long backMillis = max(new Duration(backTSV.getKey(), getTimestamp()).getMillis(), 0), forwMillis = max(new Duration(getTimestamp(), forwTSV.getKey()).getMillis(), 0); final double totalMillis = forwMillis + backMillis; final double backWeight = forwMillis / totalMillis; final double forwWeight = backMillis / totalMillis; return new InterpolatedTSV(name, backTSV.getValue().getMetrics(), forwTSV.getValue().getMetrics(), backWeight, forwWeight); }
[ "private", "TimeSeriesValue", "interpolateTSV", "(", "GroupName", "name", ")", "{", "final", "Map", ".", "Entry", "<", "DateTime", ",", "TimeSeriesValue", ">", "backTSV", "=", "findName", "(", "backward", ",", "name", ")", ",", "forwTSV", "=", "findName", "(...
Interpolates a group name, based on the most recent backward and oldest forward occurence. @param name The name of the group to interpolate. @return The interpolated name of the group.
[ "Interpolates", "a", "group", "name", "based", "on", "the", "most", "recent", "backward", "and", "oldest", "forward", "occurence", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java#L189-L200
train
groupon/monsoon
expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java
InterpolatedTSC.findName
private static Map.Entry<DateTime, TimeSeriesValue> findName(List<TimeSeriesCollection> c, GroupName name) { ListIterator<TimeSeriesCollection> iter = c.listIterator(); while (iter.hasNext()) { final int idx = iter.nextIndex(); final TimeSeriesCollection tsdata = iter.next(); final Optional<TimeSeriesValue> found = tsdata.get(name); if (found.isPresent()) return SimpleMapEntry.create(tsdata.getTimestamp(), found.get()); } throw new IllegalStateException("name not present in list of time series collections"); }
java
private static Map.Entry<DateTime, TimeSeriesValue> findName(List<TimeSeriesCollection> c, GroupName name) { ListIterator<TimeSeriesCollection> iter = c.listIterator(); while (iter.hasNext()) { final int idx = iter.nextIndex(); final TimeSeriesCollection tsdata = iter.next(); final Optional<TimeSeriesValue> found = tsdata.get(name); if (found.isPresent()) return SimpleMapEntry.create(tsdata.getTimestamp(), found.get()); } throw new IllegalStateException("name not present in list of time series collections"); }
[ "private", "static", "Map", ".", "Entry", "<", "DateTime", ",", "TimeSeriesValue", ">", "findName", "(", "List", "<", "TimeSeriesCollection", ">", "c", ",", "GroupName", "name", ")", "{", "ListIterator", "<", "TimeSeriesCollection", ">", "iter", "=", "c", "....
Finds the first resolution of name in the given TimeSeriesCollections. The cache is used and updated to skip the linear search phase. @param c TimeSeriesCollection instances in which to search. @param name The searched for name. Note that the name must be present in the collection. @param cache Cache used and updated during lookups, to skip the linear search. @return The first TimeSeriesValue in the list of TSCollections with the given name. @throws IllegalStateException if the name was not found.
[ "Finds", "the", "first", "resolution", "of", "name", "in", "the", "given", "TimeSeriesCollections", ".", "The", "cache", "is", "used", "and", "updated", "to", "skip", "the", "linear", "search", "phase", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/timeseries/InterpolatedTSC.java#L215-L227
train
threerings/nenya
core/src/main/java/com/threerings/media/BackFrameManager.java
BackFrameManager.createBackBuffer
protected void createBackBuffer (GraphicsConfiguration gc) { // if we have an old image, clear it out if (_backimg != null) { _backimg.flush(); _bgfx.dispose(); } // create the offscreen buffer int width = _window.getWidth(), height = _window.getHeight(); _backimg = gc.createCompatibleVolatileImage(width, height); // fill the back buffer with white _bgfx = (Graphics2D)_backimg.getGraphics(); _bgfx.fillRect(0, 0, width, height); // clear out our frame graphics in case that became invalid for // the same reasons our back buffer became invalid if (_fgfx != null) { _fgfx.dispose(); _fgfx = null; } // Log.info("Created back buffer [" + width + "x" + height + "]."); }
java
protected void createBackBuffer (GraphicsConfiguration gc) { // if we have an old image, clear it out if (_backimg != null) { _backimg.flush(); _bgfx.dispose(); } // create the offscreen buffer int width = _window.getWidth(), height = _window.getHeight(); _backimg = gc.createCompatibleVolatileImage(width, height); // fill the back buffer with white _bgfx = (Graphics2D)_backimg.getGraphics(); _bgfx.fillRect(0, 0, width, height); // clear out our frame graphics in case that became invalid for // the same reasons our back buffer became invalid if (_fgfx != null) { _fgfx.dispose(); _fgfx = null; } // Log.info("Created back buffer [" + width + "x" + height + "]."); }
[ "protected", "void", "createBackBuffer", "(", "GraphicsConfiguration", "gc", ")", "{", "// if we have an old image, clear it out", "if", "(", "_backimg", "!=", "null", ")", "{", "_backimg", ".", "flush", "(", ")", ";", "_bgfx", ".", "dispose", "(", ")", ";", "...
Creates the off-screen buffer used to perform double buffered rendering of the animated panel.
[ "Creates", "the", "off", "-", "screen", "buffer", "used", "to", "perform", "double", "buffered", "rendering", "of", "the", "animated", "panel", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/BackFrameManager.java#L120-L144
train
threerings/nenya
core/src/main/java/com/threerings/media/tile/util/TileSetTrimmer.java
TileSetTrimmer.trimTileSet
public static void trimTileSet ( TileSet source, OutputStream destImage, TrimMetricsReceiver tmr) throws IOException { trimTileSet(source, destImage, tmr, FastImageIO.FILE_SUFFIX); }
java
public static void trimTileSet ( TileSet source, OutputStream destImage, TrimMetricsReceiver tmr) throws IOException { trimTileSet(source, destImage, tmr, FastImageIO.FILE_SUFFIX); }
[ "public", "static", "void", "trimTileSet", "(", "TileSet", "source", ",", "OutputStream", "destImage", ",", "TrimMetricsReceiver", "tmr", ")", "throws", "IOException", "{", "trimTileSet", "(", "source", ",", "destImage", ",", "tmr", ",", "FastImageIO", ".", "FIL...
Convenience function to trim the tile set using FastImageIO to save the result.
[ "Convenience", "function", "to", "trim", "the", "tile", "set", "using", "FastImageIO", "to", "save", "the", "result", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/tile/util/TileSetTrimmer.java#L76-L81
train
jdillon/gshell
gshell-util/src/main/java/com/planet57/gshell/util/converter/Converters.java
Converters.setRegisterWithVM
public static void setRegisterWithVM(final boolean registerWithVM) { if (Converters.registerWithVM != registerWithVM) { Converters.registerWithVM = registerWithVM; // register all converters with the VM if (registerWithVM) { for (Entry<Class, Converter> entry : REGISTRY.entrySet()) { Class type = entry.getKey(); Converter converter = entry.getValue(); PropertyEditorManager.registerEditor(type, converter.getClass()); } } } }
java
public static void setRegisterWithVM(final boolean registerWithVM) { if (Converters.registerWithVM != registerWithVM) { Converters.registerWithVM = registerWithVM; // register all converters with the VM if (registerWithVM) { for (Entry<Class, Converter> entry : REGISTRY.entrySet()) { Class type = entry.getKey(); Converter converter = entry.getValue(); PropertyEditorManager.registerEditor(type, converter.getClass()); } } } }
[ "public", "static", "void", "setRegisterWithVM", "(", "final", "boolean", "registerWithVM", ")", "{", "if", "(", "Converters", ".", "registerWithVM", "!=", "registerWithVM", ")", "{", "Converters", ".", "registerWithVM", "=", "registerWithVM", ";", "// register all ...
Sets if converters registered with the VM PropertyEditorManager. If the new value is true, all currently registered converters are immediately registered with the VM.
[ "Sets", "if", "converters", "registered", "with", "the", "VM", "PropertyEditorManager", ".", "If", "the", "new", "value", "is", "true", "all", "currently", "registered", "converters", "are", "immediately", "registered", "with", "the", "VM", "." ]
b587c1a4672d2e4905871462fa3b38a1f7b94e90
https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-util/src/main/java/com/planet57/gshell/util/converter/Converters.java#L185-L198
train
jdillon/gshell
gshell-util/src/main/java/com/planet57/gshell/util/converter/Converters.java
Converters.findEditor
private static PropertyEditor findEditor(final Type type) { assert type != null; Class clazz = toClass(type); // try to locate this directly from the editor manager first. PropertyEditor editor = PropertyEditorManager.findEditor(clazz); // we're outta here if we got one. if (editor != null) { return editor; } // it's possible this was a request for an array class. We might not // recognize the array type directly, but the component type might be // resolvable if (clazz.isArray() && !clazz.getComponentType().isArray()) { // do a recursive lookup on the base type editor = findEditor(clazz.getComponentType()); // if we found a suitable editor for the base component type, // wrapper this in an array adaptor for real use if (editor != null) { return new ArrayConverter(clazz, editor); } } // nothing found return null; }
java
private static PropertyEditor findEditor(final Type type) { assert type != null; Class clazz = toClass(type); // try to locate this directly from the editor manager first. PropertyEditor editor = PropertyEditorManager.findEditor(clazz); // we're outta here if we got one. if (editor != null) { return editor; } // it's possible this was a request for an array class. We might not // recognize the array type directly, but the component type might be // resolvable if (clazz.isArray() && !clazz.getComponentType().isArray()) { // do a recursive lookup on the base type editor = findEditor(clazz.getComponentType()); // if we found a suitable editor for the base component type, // wrapper this in an array adaptor for real use if (editor != null) { return new ArrayConverter(clazz, editor); } } // nothing found return null; }
[ "private", "static", "PropertyEditor", "findEditor", "(", "final", "Type", "type", ")", "{", "assert", "type", "!=", "null", ";", "Class", "clazz", "=", "toClass", "(", "type", ")", ";", "// try to locate this directly from the editor manager first.", "PropertyEditor"...
Locate a property editor for given class of object. @param type The target object class of the property. @return The resolved editor, if any. Returns null if a suitable editor could not be located.
[ "Locate", "a", "property", "editor", "for", "given", "class", "of", "object", "." ]
b587c1a4672d2e4905871462fa3b38a1f7b94e90
https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-util/src/main/java/com/planet57/gshell/util/converter/Converters.java#L474-L502
train
threerings/nenya
core/src/main/java/com/threerings/media/image/Quantize.java
Quantize.quantizeImage
public static int[] quantizeImage(int pixels[][], int max_colors) { Cube cube = new Cube(pixels, max_colors); cube.classification(); cube.reduction(); cube.assignment(); return cube.colormap; }
java
public static int[] quantizeImage(int pixels[][], int max_colors) { Cube cube = new Cube(pixels, max_colors); cube.classification(); cube.reduction(); cube.assignment(); return cube.colormap; }
[ "public", "static", "int", "[", "]", "quantizeImage", "(", "int", "pixels", "[", "]", "[", "]", ",", "int", "max_colors", ")", "{", "Cube", "cube", "=", "new", "Cube", "(", "pixels", ",", "max_colors", ")", ";", "cube", ".", "classification", "(", ")...
Reduce the image to the given number of colors. @param pixels an in/out parameter that should initially contain [A]RGB values but that will contain color palette indicies upon return. @return The new color palette.
[ "Reduce", "the", "image", "to", "the", "given", "number", "of", "colors", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/Quantize.java#L310-L316
train
threerings/nenya
core/src/main/java/com/threerings/media/AbstractMediaManager.java
AbstractMediaManager.paint
public void paint (Graphics2D gfx, int layer, Shape clip) { for (int ii = 0, nn = _media.size(); ii < nn; ii++) { AbstractMedia media = _media.get(ii); int order = media.getRenderOrder(); try { if (((layer == ALL) || (layer == FRONT && order >= 0) || (layer == BACK && order < 0)) && clip.intersects(media.getBounds())) { media.paint(gfx); } } catch (Exception e) { log.warning("Failed to render media", "media", media, e); } } }
java
public void paint (Graphics2D gfx, int layer, Shape clip) { for (int ii = 0, nn = _media.size(); ii < nn; ii++) { AbstractMedia media = _media.get(ii); int order = media.getRenderOrder(); try { if (((layer == ALL) || (layer == FRONT && order >= 0) || (layer == BACK && order < 0)) && clip.intersects(media.getBounds())) { media.paint(gfx); } } catch (Exception e) { log.warning("Failed to render media", "media", media, e); } } }
[ "public", "void", "paint", "(", "Graphics2D", "gfx", ",", "int", "layer", ",", "Shape", "clip", ")", "{", "for", "(", "int", "ii", "=", "0", ",", "nn", "=", "_media", ".", "size", "(", ")", ";", "ii", "<", "nn", ";", "ii", "++", ")", "{", "Ab...
Renders all registered media in the given layer that intersect the supplied clipping rectangle to the given graphics context. @param layer the layer to render; one of {@link #FRONT}, {@link #BACK}, or {@link #ALL}. The front layer contains all animations with a positive render order; the back layer contains all animations with a negative render order; all, both.
[ "Renders", "all", "registered", "media", "in", "the", "given", "layer", "that", "intersect", "the", "supplied", "clipping", "rectangle", "to", "the", "given", "graphics", "context", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMediaManager.java#L103-L118
train
threerings/nenya
core/src/main/java/com/threerings/media/AbstractMediaManager.java
AbstractMediaManager.fastForward
public void fastForward (long timeDelta) { if (_tickStamp > 0) { log.warning("Egads! Asked to fastForward() during a tick.", new Exception()); } for (int ii = 0, nn = _media.size(); ii < nn; ii++) { _media.get(ii).fastForward(timeDelta); } }
java
public void fastForward (long timeDelta) { if (_tickStamp > 0) { log.warning("Egads! Asked to fastForward() during a tick.", new Exception()); } for (int ii = 0, nn = _media.size(); ii < nn; ii++) { _media.get(ii).fastForward(timeDelta); } }
[ "public", "void", "fastForward", "(", "long", "timeDelta", ")", "{", "if", "(", "_tickStamp", ">", "0", ")", "{", "log", ".", "warning", "(", "\"Egads! Asked to fastForward() during a tick.\"", ",", "new", "Exception", "(", ")", ")", ";", "}", "for", "(", ...
If the manager is paused for some length of time, it should be fast forwarded by the appropriate number of milliseconds. This allows media to smoothly pick up where they left off rather than abruptly jumping into the future, thinking that some outrageous amount of time passed since their last tick.
[ "If", "the", "manager", "is", "paused", "for", "some", "length", "of", "time", "it", "should", "be", "fast", "forwarded", "by", "the", "appropriate", "number", "of", "milliseconds", ".", "This", "allows", "media", "to", "smoothly", "pick", "up", "where", "...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMediaManager.java#L126-L135
train
threerings/nenya
core/src/main/java/com/threerings/media/AbstractMediaManager.java
AbstractMediaManager.insertMedia
protected boolean insertMedia (AbstractMedia media) { if (_media.contains(media)) { log.warning("Attempt to insert media more than once [media=" + media + "].", new Exception()); return false; } media.init(this); int ipos = _media.insertSorted(media, RENDER_ORDER); // if we've started our tick but have not yet painted our media, we need to take care that // this newly added media will be ticked before our upcoming render if (_tickStamp > 0L) { if (_tickpos == -1) { // if we're done with our own call to tick(), we need to tick this new media tickMedia(media, _tickStamp); } else if (ipos <= _tickpos) { // otherwise, we're in the middle of our call to tick() and we only need to tick // this guy if he's being inserted before our current tick position (if he's // inserted after our current position, we'll get to him as part of this tick // iteration) _tickpos++; tickMedia(media, _tickStamp); } } return true; }
java
protected boolean insertMedia (AbstractMedia media) { if (_media.contains(media)) { log.warning("Attempt to insert media more than once [media=" + media + "].", new Exception()); return false; } media.init(this); int ipos = _media.insertSorted(media, RENDER_ORDER); // if we've started our tick but have not yet painted our media, we need to take care that // this newly added media will be ticked before our upcoming render if (_tickStamp > 0L) { if (_tickpos == -1) { // if we're done with our own call to tick(), we need to tick this new media tickMedia(media, _tickStamp); } else if (ipos <= _tickpos) { // otherwise, we're in the middle of our call to tick() and we only need to tick // this guy if he's being inserted before our current tick position (if he's // inserted after our current position, we'll get to him as part of this tick // iteration) _tickpos++; tickMedia(media, _tickStamp); } } return true; }
[ "protected", "boolean", "insertMedia", "(", "AbstractMedia", "media", ")", "{", "if", "(", "_media", ".", "contains", "(", "media", ")", ")", "{", "log", ".", "warning", "(", "\"Attempt to insert media more than once [media=\"", "+", "media", "+", "\"].\"", ",",...
Inserts the specified media into this manager, return true on success.
[ "Inserts", "the", "specified", "media", "into", "this", "manager", "return", "true", "on", "success", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMediaManager.java#L189-L217
train
threerings/nenya
core/src/main/java/com/threerings/media/AbstractMediaManager.java
AbstractMediaManager.removeMedia
protected boolean removeMedia (AbstractMedia media) { int mpos = _media.indexOf(media); if (mpos != -1) { _media.remove(mpos); media.invalidate(); media.shutdown(); // if we're in the middle of ticking, we need to adjust the _tickpos if necessary if (mpos <= _tickpos) { _tickpos--; } return true; } log.warning("Attempt to remove media that wasn't inserted [media=" + media + "]."); return false; }
java
protected boolean removeMedia (AbstractMedia media) { int mpos = _media.indexOf(media); if (mpos != -1) { _media.remove(mpos); media.invalidate(); media.shutdown(); // if we're in the middle of ticking, we need to adjust the _tickpos if necessary if (mpos <= _tickpos) { _tickpos--; } return true; } log.warning("Attempt to remove media that wasn't inserted [media=" + media + "]."); return false; }
[ "protected", "boolean", "removeMedia", "(", "AbstractMedia", "media", ")", "{", "int", "mpos", "=", "_media", ".", "indexOf", "(", "media", ")", ";", "if", "(", "mpos", "!=", "-", "1", ")", "{", "_media", ".", "remove", "(", "mpos", ")", ";", "media"...
Removes the specified media from this manager, return true on success.
[ "Removes", "the", "specified", "media", "from", "this", "manager", "return", "true", "on", "success", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMediaManager.java#L231-L246
train
threerings/nenya
core/src/main/java/com/threerings/media/AbstractMediaManager.java
AbstractMediaManager.queueNotification
public void queueNotification (ObserverList<Object> observers, ObserverOp<Object> event) { _notify.add(new Tuple<ObserverList<Object>,ObserverOp<Object>>(observers, event)); }
java
public void queueNotification (ObserverList<Object> observers, ObserverOp<Object> event) { _notify.add(new Tuple<ObserverList<Object>,ObserverOp<Object>>(observers, event)); }
[ "public", "void", "queueNotification", "(", "ObserverList", "<", "Object", ">", "observers", ",", "ObserverOp", "<", "Object", ">", "event", ")", "{", "_notify", ".", "add", "(", "new", "Tuple", "<", "ObserverList", "<", "Object", ">", ",", "ObserverOp", "...
Queues the notification for dispatching after we've ticked all the media.
[ "Queues", "the", "notification", "for", "dispatching", "after", "we", "ve", "ticked", "all", "the", "media", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMediaManager.java#L266-L269
train
threerings/nenya
core/src/main/java/com/threerings/media/AbstractMediaManager.java
AbstractMediaManager.dispatchNotifications
protected void dispatchNotifications () { for (int ii = 0, nn = _notify.size(); ii < nn; ii++) { Tuple<ObserverList<Object>,ObserverOp<Object>> tuple = _notify.get(ii); tuple.left.apply(tuple.right); } _notify.clear(); }
java
protected void dispatchNotifications () { for (int ii = 0, nn = _notify.size(); ii < nn; ii++) { Tuple<ObserverList<Object>,ObserverOp<Object>> tuple = _notify.get(ii); tuple.left.apply(tuple.right); } _notify.clear(); }
[ "protected", "void", "dispatchNotifications", "(", ")", "{", "for", "(", "int", "ii", "=", "0", ",", "nn", "=", "_notify", ".", "size", "(", ")", ";", "ii", "<", "nn", ";", "ii", "++", ")", "{", "Tuple", "<", "ObserverList", "<", "Object", ">", "...
Dispatches all queued media notifications.
[ "Dispatches", "all", "queued", "media", "notifications", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/AbstractMediaManager.java#L277-L284
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/json/JsonOutput.java
JsonOutput.addArrayIfNotNull
public static <T> void addArrayIfNotNull(JSONWriter writer, String field, Collection<T> items, JsonObjectWriter<T> objWriter) throws JSONException { if (items == null) return; addCollection(writer, field, items, objWriter); }
java
public static <T> void addArrayIfNotNull(JSONWriter writer, String field, Collection<T> items, JsonObjectWriter<T> objWriter) throws JSONException { if (items == null) return; addCollection(writer, field, items, objWriter); }
[ "public", "static", "<", "T", ">", "void", "addArrayIfNotNull", "(", "JSONWriter", "writer", ",", "String", "field", ",", "Collection", "<", "T", ">", "items", ",", "JsonObjectWriter", "<", "T", ">", "objWriter", ")", "throws", "JSONException", "{", "if", ...
Adds a list. @param writer used writer. @param field field to write. @param items used items. @param objWriter single object writer.
[ "Adds", "a", "list", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/json/JsonOutput.java#L154-L160
train
threerings/nenya
core/src/main/java/com/threerings/media/animation/AnimationSequencer.java
AnimationSequencer.startAnimation
protected void startAnimation (Animation anim, long tickStamp) { // account for any view scrolling that happened before this animation // was actually added to the view if (_vdx != 0 || _vdy != 0) { anim.viewLocationDidChange(_vdx, _vdy); } _animmgr.registerAnimation(anim); }
java
protected void startAnimation (Animation anim, long tickStamp) { // account for any view scrolling that happened before this animation // was actually added to the view if (_vdx != 0 || _vdy != 0) { anim.viewLocationDidChange(_vdx, _vdy); } _animmgr.registerAnimation(anim); }
[ "protected", "void", "startAnimation", "(", "Animation", "anim", ",", "long", "tickStamp", ")", "{", "// account for any view scrolling that happened before this animation", "// was actually added to the view", "if", "(", "_vdx", "!=", "0", "||", "_vdy", "!=", "0", ")", ...
Called when the time comes to start an animation. Derived classes may override this method and pass the animation on to their animation manager and do whatever else they need to do with operating animations. The default implementation simply adds them to the media panel supplied when we were constructed. @param anim the animation to be displayed. @param tickStamp the timestamp at which this animation was fired.
[ "Called", "when", "the", "time", "comes", "to", "start", "an", "animation", ".", "Derived", "classes", "may", "override", "this", "method", "and", "pass", "the", "animation", "on", "to", "their", "animation", "manager", "and", "do", "whatever", "else", "they...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/animation/AnimationSequencer.java#L189-L198
train
threerings/nenya
core/src/main/java/com/threerings/media/VirtualRangeModel.java
VirtualRangeModel.setScrollableArea
public void setScrollableArea (int x, int y, int width, int height) { Rectangle vb = _panel.getViewBounds(); int hmax = x + width, vmax = y + height, value; if (width > vb.width) { value = MathUtil.bound(x, _hrange.getValue(), hmax - vb.width); _hrange.setRangeProperties(value, vb.width, x, hmax, false); } else { // Let's center it and lock it down. int newx = x - (vb.width - width)/2; _hrange.setRangeProperties(newx, 0, newx, newx, false); } if (height > vb.height) { value = MathUtil.bound(y, _vrange.getValue(), vmax - vb.height); _vrange.setRangeProperties(value, vb.height, y, vmax, false); } else { // Let's center it and lock it down. int newy = y - (vb.height - height)/2; _vrange.setRangeProperties(newy, 0, newy, newy, false); } }
java
public void setScrollableArea (int x, int y, int width, int height) { Rectangle vb = _panel.getViewBounds(); int hmax = x + width, vmax = y + height, value; if (width > vb.width) { value = MathUtil.bound(x, _hrange.getValue(), hmax - vb.width); _hrange.setRangeProperties(value, vb.width, x, hmax, false); } else { // Let's center it and lock it down. int newx = x - (vb.width - width)/2; _hrange.setRangeProperties(newx, 0, newx, newx, false); } if (height > vb.height) { value = MathUtil.bound(y, _vrange.getValue(), vmax - vb.height); _vrange.setRangeProperties(value, vb.height, y, vmax, false); } else { // Let's center it and lock it down. int newy = y - (vb.height - height)/2; _vrange.setRangeProperties(newy, 0, newy, newy, false); } }
[ "public", "void", "setScrollableArea", "(", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ")", "{", "Rectangle", "vb", "=", "_panel", ".", "getViewBounds", "(", ")", ";", "int", "hmax", "=", "x", "+", "width", ",", "vmax", ...
Informs the virtual range model the extent of the area over which we can scroll.
[ "Informs", "the", "virtual", "range", "model", "the", "extent", "of", "the", "area", "over", "which", "we", "can", "scroll", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/VirtualRangeModel.java#L56-L77
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ImageManager.java
ImageManager.createImage
public BufferedImage createImage (int width, int height, int transparency) { return _icreator.createImage(width, height, transparency); }
java
public BufferedImage createImage (int width, int height, int transparency) { return _icreator.createImage(width, height, transparency); }
[ "public", "BufferedImage", "createImage", "(", "int", "width", ",", "int", "height", ",", "int", "transparency", ")", "{", "return", "_icreator", ".", "createImage", "(", "width", ",", "height", ",", "transparency", ")", ";", "}" ]
Creates a buffered image, optimized for display on our graphics device.
[ "Creates", "a", "buffered", "image", "optimized", "for", "display", "on", "our", "graphics", "device", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageManager.java#L164-L167
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ImageManager.java
ImageManager.getImageKey
public ImageKey getImageKey (String rset, String path) { return getImageKey(getDataProvider(rset), path); }
java
public ImageKey getImageKey (String rset, String path) { return getImageKey(getDataProvider(rset), path); }
[ "public", "ImageKey", "getImageKey", "(", "String", "rset", ",", "String", "path", ")", "{", "return", "getImageKey", "(", "getDataProvider", "(", "rset", ")", ",", "path", ")", ";", "}" ]
Returns an image key that can be used to fetch the image identified by the specified resource set and image path.
[ "Returns", "an", "image", "key", "that", "can", "be", "used", "to", "fetch", "the", "image", "identified", "by", "the", "specified", "resource", "set", "and", "image", "path", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageManager.java#L262-L265
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ImageManager.java
ImageManager.getImage
public BufferedImage getImage (ImageKey key, Colorization[] zations) { CacheRecord crec = null; synchronized (_ccache) { crec = _ccache.get(key); } if (crec != null) { // log.info("Cache hit", "key", key, "crec", crec); return crec.getImage(zations, _ccache); } // log.info("Cache miss", "key", key, "crec", crec); // load up the raw image BufferedImage image = loadImage(key); if (image == null) { log.warning("Failed to load image " + key + "."); // create a blank image instead image = new BufferedImage(10, 10, BufferedImage.TYPE_BYTE_INDEXED); } // log.info("Loaded Image", "path", key.path, "image", image, // "size", ImageUtil.getEstimatedMemoryUsage(image)); // create a cache record crec = new CacheRecord(key, image); synchronized (_ccache) { _ccache.put(key, crec); } _keySet.add(key); // periodically report our image cache performance reportCachePerformance(); return crec.getImage(zations, _ccache); }
java
public BufferedImage getImage (ImageKey key, Colorization[] zations) { CacheRecord crec = null; synchronized (_ccache) { crec = _ccache.get(key); } if (crec != null) { // log.info("Cache hit", "key", key, "crec", crec); return crec.getImage(zations, _ccache); } // log.info("Cache miss", "key", key, "crec", crec); // load up the raw image BufferedImage image = loadImage(key); if (image == null) { log.warning("Failed to load image " + key + "."); // create a blank image instead image = new BufferedImage(10, 10, BufferedImage.TYPE_BYTE_INDEXED); } // log.info("Loaded Image", "path", key.path, "image", image, // "size", ImageUtil.getEstimatedMemoryUsage(image)); // create a cache record crec = new CacheRecord(key, image); synchronized (_ccache) { _ccache.put(key, crec); } _keySet.add(key); // periodically report our image cache performance reportCachePerformance(); return crec.getImage(zations, _ccache); }
[ "public", "BufferedImage", "getImage", "(", "ImageKey", "key", ",", "Colorization", "[", "]", "zations", ")", "{", "CacheRecord", "crec", "=", "null", ";", "synchronized", "(", "_ccache", ")", "{", "crec", "=", "_ccache", ".", "get", "(", "key", ")", ";"...
Obtains the image identified by the specified key, caching if possible. The image will be recolored using the supplied colorizations if requested.
[ "Obtains", "the", "image", "identified", "by", "the", "specified", "key", "caching", "if", "possible", ".", "The", "image", "will", "be", "recolored", "using", "the", "supplied", "colorizations", "if", "requested", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageManager.java#L280-L314
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ImageManager.java
ImageManager.getMirage
public Mirage getMirage (String rsrcPath) { return getMirage(getImageKey(_defaultProvider, rsrcPath), null, null); }
java
public Mirage getMirage (String rsrcPath) { return getMirage(getImageKey(_defaultProvider, rsrcPath), null, null); }
[ "public", "Mirage", "getMirage", "(", "String", "rsrcPath", ")", "{", "return", "getMirage", "(", "getImageKey", "(", "_defaultProvider", ",", "rsrcPath", ")", ",", "null", ",", "null", ")", ";", "}" ]
Creates a mirage which is an image optimized for display on our current display device and which will be stored into video memory if possible.
[ "Creates", "a", "mirage", "which", "is", "an", "image", "optimized", "for", "display", "on", "our", "current", "display", "device", "and", "which", "will", "be", "stored", "into", "video", "memory", "if", "possible", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageManager.java#L320-L323
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ImageManager.java
ImageManager.getDataProvider
protected ImageDataProvider getDataProvider (final String rset) { if (rset == null) { return _defaultProvider; } ImageDataProvider dprov = _providers.get(rset); if (dprov == null) { dprov = new ImageDataProvider() { public BufferedImage loadImage (String path) throws IOException { // first attempt to load the image from the specified resource set try { return _rmgr.getImageResource(rset, path); } catch (FileNotFoundException fnfe) { // fall back to trying the classpath return _rmgr.getImageResource(path); } } public String getIdent () { return "rmgr:" + rset; } }; _providers.put(rset, dprov); } return dprov; }
java
protected ImageDataProvider getDataProvider (final String rset) { if (rset == null) { return _defaultProvider; } ImageDataProvider dprov = _providers.get(rset); if (dprov == null) { dprov = new ImageDataProvider() { public BufferedImage loadImage (String path) throws IOException { // first attempt to load the image from the specified resource set try { return _rmgr.getImageResource(rset, path); } catch (FileNotFoundException fnfe) { // fall back to trying the classpath return _rmgr.getImageResource(path); } } public String getIdent () { return "rmgr:" + rset; } }; _providers.put(rset, dprov); } return dprov; }
[ "protected", "ImageDataProvider", "getDataProvider", "(", "final", "String", "rset", ")", "{", "if", "(", "rset", "==", "null", ")", "{", "return", "_defaultProvider", ";", "}", "ImageDataProvider", "dprov", "=", "_providers", ".", "get", "(", "rset", ")", "...
Returns the data provider configured to obtain image data from the specified resource set.
[ "Returns", "the", "data", "provider", "configured", "to", "obtain", "image", "data", "from", "the", "specified", "resource", "set", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageManager.java#L381-L409
train
threerings/nenya
core/src/main/java/com/threerings/media/image/ImageManager.java
ImageManager.loadImage
protected BufferedImage loadImage (ImageKey key) { // if (EventQueue.isDispatchThread()) { // Log.info("Loading image on AWT thread " + key + "."); // } BufferedImage image = null; try { log.debug("Loading image " + key + "."); image = key.daprov.loadImage(key.path); if (image == null) { log.warning("ImageDataProvider.loadImage(" + key + ") returned null."); } } catch (Exception e) { log.warning("Unable to load image '" + key + "'.", e); // create a blank image in its stead image = createImage(1, 1, Transparency.OPAQUE); } return image; }
java
protected BufferedImage loadImage (ImageKey key) { // if (EventQueue.isDispatchThread()) { // Log.info("Loading image on AWT thread " + key + "."); // } BufferedImage image = null; try { log.debug("Loading image " + key + "."); image = key.daprov.loadImage(key.path); if (image == null) { log.warning("ImageDataProvider.loadImage(" + key + ") returned null."); } } catch (Exception e) { log.warning("Unable to load image '" + key + "'.", e); // create a blank image in its stead image = createImage(1, 1, Transparency.OPAQUE); } return image; }
[ "protected", "BufferedImage", "loadImage", "(", "ImageKey", "key", ")", "{", "// if (EventQueue.isDispatchThread()) {", "// Log.info(\"Loading image on AWT thread \" + key + \".\");", "// }", "BufferedImage", "image", "=", "null", ";", "try", "{", "log...
Loads and returns the image with the specified key from the supplied data provider.
[ "Loads", "and", "returns", "the", "image", "with", "the", "specified", "key", "from", "the", "supplied", "data", "provider", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/ImageManager.java#L414-L436
train
threerings/nenya
core/src/main/java/com/threerings/openal/Sound.java
Sound.setPosition
public void setPosition (float x, float y, float z) { if (_source != null) { _source.setPosition(x, y, z); } _px = x; _py = y; _pz = z; }
java
public void setPosition (float x, float y, float z) { if (_source != null) { _source.setPosition(x, y, z); } _px = x; _py = y; _pz = z; }
[ "public", "void", "setPosition", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "if", "(", "_source", "!=", "null", ")", "{", "_source", ".", "setPosition", "(", "x", ",", "y", ",", "z", ")", ";", "}", "_px", "=", "x", ";", ...
Sets the position of the sound.
[ "Sets", "the", "position", "of", "the", "sound", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Sound.java#L62-L70
train
threerings/nenya
core/src/main/java/com/threerings/openal/Sound.java
Sound.setVelocity
public void setVelocity (float x, float y, float z) { if (_source != null) { _source.setVelocity(x, y, z); } _vx = x; _vy = y; _vz = z; }
java
public void setVelocity (float x, float y, float z) { if (_source != null) { _source.setVelocity(x, y, z); } _vx = x; _vy = y; _vz = z; }
[ "public", "void", "setVelocity", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "if", "(", "_source", "!=", "null", ")", "{", "_source", ".", "setVelocity", "(", "x", ",", "y", ",", "z", ")", ";", "}", "_vx", "=", "x", ";", ...
Sets the velocity of the sound.
[ "Sets", "the", "velocity", "of", "the", "sound", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Sound.java#L75-L83
train
threerings/nenya
core/src/main/java/com/threerings/openal/Sound.java
Sound.setDirection
public void setDirection (float x, float y, float z) { if (_source != null) { _source.setDirection(x, y, z); } _dx = x; _dy = y; _dz = z; }
java
public void setDirection (float x, float y, float z) { if (_source != null) { _source.setDirection(x, y, z); } _dx = x; _dy = y; _dz = z; }
[ "public", "void", "setDirection", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "if", "(", "_source", "!=", "null", ")", "{", "_source", ".", "setDirection", "(", "x", ",", "y", ",", "z", ")", ";", "}", "_dx", "=", "x", ";"...
Sets the direction of the sound.
[ "Sets", "the", "direction", "of", "the", "sound", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/Sound.java#L175-L183
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.createTimer
public static MediaTimer createTimer () { MediaTimer timer = null; for (String timerClass : PERF_TIMERS) { try { timer = (MediaTimer)Class.forName(timerClass).newInstance(); break; } catch (Throwable t) { // try the next one } } if (timer == null) { log.info("Can't use high performance timer, reverting to " + "System.currentTimeMillis() based timer."); timer = new MillisTimer(); } return timer; }
java
public static MediaTimer createTimer () { MediaTimer timer = null; for (String timerClass : PERF_TIMERS) { try { timer = (MediaTimer)Class.forName(timerClass).newInstance(); break; } catch (Throwable t) { // try the next one } } if (timer == null) { log.info("Can't use high performance timer, reverting to " + "System.currentTimeMillis() based timer."); timer = new MillisTimer(); } return timer; }
[ "public", "static", "MediaTimer", "createTimer", "(", ")", "{", "MediaTimer", "timer", "=", "null", ";", "for", "(", "String", "timerClass", ":", "PERF_TIMERS", ")", "{", "try", "{", "timer", "=", "(", "MediaTimer", ")", "Class", ".", "forName", "(", "ti...
Attempts to create a high resolution timer, but if that isn't possible, uses a System.currentTimeMillis based timer.
[ "Attempts", "to", "create", "a", "high", "resolution", "timer", "but", "if", "that", "isn", "t", "possible", "uses", "a", "System", ".", "currentTimeMillis", "based", "timer", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L136-L153
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.newInstance
public static FrameManager newInstance (ManagedRoot root, MediaTimer timer) { FrameManager fmgr = (root instanceof ManagedJFrame && _useFlip.getValue()) ? new FlipFrameManager() : new BackFrameManager(); fmgr.init(root, timer); return fmgr; }
java
public static FrameManager newInstance (ManagedRoot root, MediaTimer timer) { FrameManager fmgr = (root instanceof ManagedJFrame && _useFlip.getValue()) ? new FlipFrameManager() : new BackFrameManager(); fmgr.init(root, timer); return fmgr; }
[ "public", "static", "FrameManager", "newInstance", "(", "ManagedRoot", "root", ",", "MediaTimer", "timer", ")", "{", "FrameManager", "fmgr", "=", "(", "root", "instanceof", "ManagedJFrame", "&&", "_useFlip", ".", "getValue", "(", ")", ")", "?", "new", "FlipFra...
Constructs a frame manager that will do its rendering to the supplied root and use the supplied media timer for timing information.
[ "Constructs", "a", "frame", "manager", "that", "will", "do", "its", "rendering", "to", "the", "supplied", "root", "and", "use", "the", "supplied", "media", "timer", "for", "timing", "information", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L159-L165
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.registerFrameParticipant
public void registerFrameParticipant (FrameParticipant participant) { Object[] nparts = ListUtil.testAndAddRef(_participants, participant); if (nparts == null) { log.warning("Refusing to add duplicate frame participant! " + participant); } else { _participants = nparts; } }
java
public void registerFrameParticipant (FrameParticipant participant) { Object[] nparts = ListUtil.testAndAddRef(_participants, participant); if (nparts == null) { log.warning("Refusing to add duplicate frame participant! " + participant); } else { _participants = nparts; } }
[ "public", "void", "registerFrameParticipant", "(", "FrameParticipant", "participant", ")", "{", "Object", "[", "]", "nparts", "=", "ListUtil", ".", "testAndAddRef", "(", "_participants", ",", "participant", ")", ";", "if", "(", "nparts", "==", "null", ")", "{"...
Registers a frame participant. The participant will be given the opportunity to do processing and rendering on each frame.
[ "Registers", "a", "frame", "participant", ".", "The", "participant", "will", "be", "given", "the", "opportunity", "to", "do", "processing", "and", "rendering", "on", "each", "frame", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L184-L192
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.getPerfMetrics
public TrailingAverage[] getPerfMetrics () { if (_metrics == null) { _metrics = new TrailingAverage[] { new TrailingAverage(150), new TrailingAverage(150), new TrailingAverage(150) }; } return _metrics; }
java
public TrailingAverage[] getPerfMetrics () { if (_metrics == null) { _metrics = new TrailingAverage[] { new TrailingAverage(150), new TrailingAverage(150), new TrailingAverage(150) }; } return _metrics; }
[ "public", "TrailingAverage", "[", "]", "getPerfMetrics", "(", ")", "{", "if", "(", "_metrics", "==", "null", ")", "{", "_metrics", "=", "new", "TrailingAverage", "[", "]", "{", "new", "TrailingAverage", "(", "150", ")", ",", "new", "TrailingAverage", "(", ...
Returns debug performance metrics.
[ "Returns", "debug", "performance", "metrics", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L327-L335
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.getRoot
public static Component getRoot (Component comp, Rectangle rect) { for (Component c = comp; c != null; c = c.getParent()) { if (!c.isVisible() || !c.isDisplayable()) { return null; } if (c instanceof Window || c instanceof Applet) { return c; } rect.x += c.getX(); rect.y += c.getY(); } return null; }
java
public static Component getRoot (Component comp, Rectangle rect) { for (Component c = comp; c != null; c = c.getParent()) { if (!c.isVisible() || !c.isDisplayable()) { return null; } if (c instanceof Window || c instanceof Applet) { return c; } rect.x += c.getX(); rect.y += c.getY(); } return null; }
[ "public", "static", "Component", "getRoot", "(", "Component", "comp", ",", "Rectangle", "rect", ")", "{", "for", "(", "Component", "c", "=", "comp", ";", "c", "!=", "null", ";", "c", "=", "c", ".", "getParent", "(", ")", ")", "{", "if", "(", "!", ...
Returns the root component for the supplied component or null if it is not part of a rooted hierarchy or if any parent along the way is found to be hidden or without a peer. Along the way, it adjusts the supplied component-relative rectangle to be relative to the returned root component.
[ "Returns", "the", "root", "component", "for", "the", "supplied", "component", "or", "null", "if", "it", "is", "not", "part", "of", "a", "rooted", "hierarchy", "or", "if", "any", "parent", "along", "the", "way", "is", "found", "to", "be", "hidden", "or", ...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L343-L356
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.init
protected void init (ManagedRoot root, MediaTimer timer) { _window = root.getWindow(); _root = root; _root.init(this); _timer = timer; // set up our custom repaint manager _repainter = new ActiveRepaintManager( (_root instanceof Component) ? (Component)_root : _window); RepaintManager.setCurrentManager(_repainter); // turn off double buffering for the whole business because we handle repaints _repainter.setDoubleBufferingEnabled(false); }
java
protected void init (ManagedRoot root, MediaTimer timer) { _window = root.getWindow(); _root = root; _root.init(this); _timer = timer; // set up our custom repaint manager _repainter = new ActiveRepaintManager( (_root instanceof Component) ? (Component)_root : _window); RepaintManager.setCurrentManager(_repainter); // turn off double buffering for the whole business because we handle repaints _repainter.setDoubleBufferingEnabled(false); }
[ "protected", "void", "init", "(", "ManagedRoot", "root", ",", "MediaTimer", "timer", ")", "{", "_window", "=", "root", ".", "getWindow", "(", ")", ";", "_root", "=", "root", ";", "_root", ".", "init", "(", "this", ")", ";", "_timer", "=", "timer", ";...
Initializes this frame manager and prepares it for operation.
[ "Initializes", "this", "frame", "manager", "and", "prepares", "it", "for", "operation", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L361-L375
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.tick
protected void tick (long tickStamp) { long start = 0L, paint = 0L; if (_perfDebug.getValue()) { start = paint = _timer.getElapsedMicros(); } // if our frame is not showing (or is impossibly sized), don't try rendering anything if (_window.isShowing() && _window.getWidth() > 0 && _window.getHeight() > 0) { // tick our participants tickParticipants(tickStamp); paint = _timer.getElapsedMicros(); // repaint our participants and components paint(tickStamp); } if (_perfDebug.getValue()) { long end = _timer.getElapsedMicros(); getPerfMetrics()[1].record((int)(paint-start)/100); getPerfMetrics()[2].record((int)(end-paint)/100); } }
java
protected void tick (long tickStamp) { long start = 0L, paint = 0L; if (_perfDebug.getValue()) { start = paint = _timer.getElapsedMicros(); } // if our frame is not showing (or is impossibly sized), don't try rendering anything if (_window.isShowing() && _window.getWidth() > 0 && _window.getHeight() > 0) { // tick our participants tickParticipants(tickStamp); paint = _timer.getElapsedMicros(); // repaint our participants and components paint(tickStamp); } if (_perfDebug.getValue()) { long end = _timer.getElapsedMicros(); getPerfMetrics()[1].record((int)(paint-start)/100); getPerfMetrics()[2].record((int)(end-paint)/100); } }
[ "protected", "void", "tick", "(", "long", "tickStamp", ")", "{", "long", "start", "=", "0L", ",", "paint", "=", "0L", ";", "if", "(", "_perfDebug", ".", "getValue", "(", ")", ")", "{", "start", "=", "paint", "=", "_timer", ".", "getElapsedMicros", "(...
Called to perform the frame processing and rendering.
[ "Called", "to", "perform", "the", "frame", "processing", "and", "rendering", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L380-L401
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.paint
protected boolean paint (Graphics2D gfx) { // paint our frame participants (which want to be handled specially) int painted = 0; for (Object participant : _participants) { FrameParticipant part = (FrameParticipant)participant; if (part == null) { continue; } Component pcomp = part.getComponent(); if (pcomp == null || !part.needsPaint()) { continue; } long start = 0L; if (HANG_DEBUG) { start = System.currentTimeMillis(); } // get the bounds of this component pcomp.getBounds(_tbounds); // the bounds adjustment we're about to call will add in the components initial bounds // offsets, so we remove them here _tbounds.setLocation(0, 0); // convert them into top-level coordinates; also note that if this component does not // have a valid or visible root, we don't want to paint it either if (getRoot(pcomp, _tbounds) == null) { continue; } try { // render this participant; we don't set the clip because frame participants are // expected to handle clipping themselves; otherwise we might pointlessly set the // clip here, creating a few Rectangle objects in the process, only to have the // frame participant immediately set the clip to something more sensible gfx.translate(_tbounds.x, _tbounds.y); pcomp.paint(gfx); gfx.translate(-_tbounds.x, -_tbounds.y); painted++; } catch (Throwable t) { String ptos = StringUtil.safeToString(part); log.warning("Frame participant choked during paint [part=" + ptos + "].", t); } // render any components in our layered pane that are not in the default layer _clipped[0] = false; renderLayers(gfx, pcomp, _tbounds, _clipped, _tbounds); if (HANG_DEBUG) { long delay = (System.currentTimeMillis() - start); if (delay > HANG_GAP) { log.warning("Whoa nelly! Painter took a long time", "part", part, "time", delay + "ms"); } } } // if we have a media overlay, give that a chance to propagate its dirty regions to the // active repaint manager for areas it dirtied during this tick if (_overlay != null) { _overlay.propagateDirtyRegions(_repainter, _root.getRootPane()); } // repaint any widgets that have declared they need to be repainted since the last tick boolean pcomp = _repainter.paintComponents(gfx, this); // if we have a media overlay, give it a chance to paint on top of everything if (_overlay != null) { pcomp |= _overlay.paint(gfx); } // let the caller know if anybody painted anything return ((painted > 0) || pcomp); }
java
protected boolean paint (Graphics2D gfx) { // paint our frame participants (which want to be handled specially) int painted = 0; for (Object participant : _participants) { FrameParticipant part = (FrameParticipant)participant; if (part == null) { continue; } Component pcomp = part.getComponent(); if (pcomp == null || !part.needsPaint()) { continue; } long start = 0L; if (HANG_DEBUG) { start = System.currentTimeMillis(); } // get the bounds of this component pcomp.getBounds(_tbounds); // the bounds adjustment we're about to call will add in the components initial bounds // offsets, so we remove them here _tbounds.setLocation(0, 0); // convert them into top-level coordinates; also note that if this component does not // have a valid or visible root, we don't want to paint it either if (getRoot(pcomp, _tbounds) == null) { continue; } try { // render this participant; we don't set the clip because frame participants are // expected to handle clipping themselves; otherwise we might pointlessly set the // clip here, creating a few Rectangle objects in the process, only to have the // frame participant immediately set the clip to something more sensible gfx.translate(_tbounds.x, _tbounds.y); pcomp.paint(gfx); gfx.translate(-_tbounds.x, -_tbounds.y); painted++; } catch (Throwable t) { String ptos = StringUtil.safeToString(part); log.warning("Frame participant choked during paint [part=" + ptos + "].", t); } // render any components in our layered pane that are not in the default layer _clipped[0] = false; renderLayers(gfx, pcomp, _tbounds, _clipped, _tbounds); if (HANG_DEBUG) { long delay = (System.currentTimeMillis() - start); if (delay > HANG_GAP) { log.warning("Whoa nelly! Painter took a long time", "part", part, "time", delay + "ms"); } } } // if we have a media overlay, give that a chance to propagate its dirty regions to the // active repaint manager for areas it dirtied during this tick if (_overlay != null) { _overlay.propagateDirtyRegions(_repainter, _root.getRootPane()); } // repaint any widgets that have declared they need to be repainted since the last tick boolean pcomp = _repainter.paintComponents(gfx, this); // if we have a media overlay, give it a chance to paint on top of everything if (_overlay != null) { pcomp |= _overlay.paint(gfx); } // let the caller know if anybody painted anything return ((painted > 0) || pcomp); }
[ "protected", "boolean", "paint", "(", "Graphics2D", "gfx", ")", "{", "// paint our frame participants (which want to be handled specially)", "int", "painted", "=", "0", ";", "for", "(", "Object", "participant", ":", "_participants", ")", "{", "FrameParticipant", "part",...
Paints our frame participants and any dirty components via the repaint manager. @return true if anything was painted, false if not.
[ "Paints", "our", "frame", "participants", "and", "any", "dirty", "components", "via", "the", "repaint", "manager", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L475-L552
train
threerings/nenya
core/src/main/java/com/threerings/media/FrameManager.java
FrameManager.renderLayer
protected void renderLayer (Graphics2D g, Rectangle bounds, JLayeredPane pane, boolean[] clipped, Integer layer) { // stop now if there are no components in that layer int ccount = pane.getComponentCountInLayer(layer.intValue()); if (ccount == 0) { return; } // render them up Component[] comps = pane.getComponentsInLayer(layer.intValue()); for (int ii = 0; ii < ccount; ii++) { Component comp = comps[ii]; if (!comp.isVisible() || comp instanceof SafeLayerComponent) { continue; } // if this overlay does not intersect the component we just rendered, we don't need to // repaint it Rectangle compBounds = new Rectangle(0, 0, comp.getWidth(), comp.getHeight()); getRoot(comp, compBounds); if (!compBounds.intersects(bounds)) { continue; } // if the clipping region has not yet been set during this render pass, the time has // come to do so if (!clipped[0]) { g.setClip(bounds); clipped[0] = true; } // translate into the components coordinate system and render g.translate(compBounds.x, compBounds.y); try { comp.paint(g); } catch (Exception e) { log.warning("Component choked while rendering.", e); } g.translate(-compBounds.x, -compBounds.y); } }
java
protected void renderLayer (Graphics2D g, Rectangle bounds, JLayeredPane pane, boolean[] clipped, Integer layer) { // stop now if there are no components in that layer int ccount = pane.getComponentCountInLayer(layer.intValue()); if (ccount == 0) { return; } // render them up Component[] comps = pane.getComponentsInLayer(layer.intValue()); for (int ii = 0; ii < ccount; ii++) { Component comp = comps[ii]; if (!comp.isVisible() || comp instanceof SafeLayerComponent) { continue; } // if this overlay does not intersect the component we just rendered, we don't need to // repaint it Rectangle compBounds = new Rectangle(0, 0, comp.getWidth(), comp.getHeight()); getRoot(comp, compBounds); if (!compBounds.intersects(bounds)) { continue; } // if the clipping region has not yet been set during this render pass, the time has // come to do so if (!clipped[0]) { g.setClip(bounds); clipped[0] = true; } // translate into the components coordinate system and render g.translate(compBounds.x, compBounds.y); try { comp.paint(g); } catch (Exception e) { log.warning("Component choked while rendering.", e); } g.translate(-compBounds.x, -compBounds.y); } }
[ "protected", "void", "renderLayer", "(", "Graphics2D", "g", ",", "Rectangle", "bounds", ",", "JLayeredPane", "pane", ",", "boolean", "[", "]", "clipped", ",", "Integer", "layer", ")", "{", "// stop now if there are no components in that layer", "int", "ccount", "=",...
Renders all components in the specified layer of the supplied layered pane that intersect the supplied bounds.
[ "Renders", "all", "components", "in", "the", "specified", "layer", "of", "the", "supplied", "layered", "pane", "that", "intersect", "the", "supplied", "bounds", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/FrameManager.java#L585-L626
train
calrissian/mango
mango-core/src/main/java/org/calrissian/mango/collect/Iterators2.java
Iterators2.distinct
public static <T> Iterator<T> distinct(final Iterator<T> iterator) { requireNonNull(iterator); return new AbstractIterator<T>() { private final PeekingIterator<T> peekingIterator = peekingIterator(iterator); private T curr = null; @Override protected T computeNext() { while (peekingIterator.hasNext() && Objects.equals(curr, peekingIterator.peek())) { peekingIterator.next(); } if (!peekingIterator.hasNext()) return endOfData(); curr = peekingIterator.next(); return curr; } }; }
java
public static <T> Iterator<T> distinct(final Iterator<T> iterator) { requireNonNull(iterator); return new AbstractIterator<T>() { private final PeekingIterator<T> peekingIterator = peekingIterator(iterator); private T curr = null; @Override protected T computeNext() { while (peekingIterator.hasNext() && Objects.equals(curr, peekingIterator.peek())) { peekingIterator.next(); } if (!peekingIterator.hasNext()) return endOfData(); curr = peekingIterator.next(); return curr; } }; }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "distinct", "(", "final", "Iterator", "<", "T", ">", "iterator", ")", "{", "requireNonNull", "(", "iterator", ")", ";", "return", "new", "AbstractIterator", "<", "T", ">", "(", ")", "{", "...
If we can assume the iterator is sorted, return the distinct elements. This only works if the data provided is sorted.
[ "If", "we", "can", "assume", "the", "iterator", "is", "sorted", "return", "the", "distinct", "elements", ".", "This", "only", "works", "if", "the", "data", "provided", "is", "sorted", "." ]
a95aa5e77af9aa0e629787228d80806560023452
https://github.com/calrissian/mango/blob/a95aa5e77af9aa0e629787228d80806560023452/mango-core/src/main/java/org/calrissian/mango/collect/Iterators2.java#L42-L60
train
threerings/nenya
core/src/main/java/com/threerings/cast/CharacterComponent.java
CharacterComponent.getFrames
public ActionFrames getFrames (String action, String type) { return _frameProvider.getFrames(this, action, type); }
java
public ActionFrames getFrames (String action, String type) { return _frameProvider.getFrames(this, action, type); }
[ "public", "ActionFrames", "getFrames", "(", "String", "action", ",", "String", "type", ")", "{", "return", "_frameProvider", ".", "getFrames", "(", "this", ",", "action", ",", "type", ")", ";", "}" ]
Returns the image frames for the specified action animation or null if no animation for the specified action is available for this component. @param type null for the normal action frames or one of the custom action sub-types: {@link StandardActions#SHADOW_TYPE}, etc.
[ "Returns", "the", "image", "frames", "for", "the", "specified", "action", "animation", "or", "null", "if", "no", "animation", "for", "the", "specified", "action", "is", "available", "for", "this", "component", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/CharacterComponent.java#L74-L77
train
threerings/nenya
core/src/main/java/com/threerings/cast/CharacterComponent.java
CharacterComponent.getFramePath
public String getFramePath (String action, String type, Set<String> existentPaths) { return _frameProvider.getFramePath(this, action, type, existentPaths); }
java
public String getFramePath (String action, String type, Set<String> existentPaths) { return _frameProvider.getFramePath(this, action, type, existentPaths); }
[ "public", "String", "getFramePath", "(", "String", "action", ",", "String", "type", ",", "Set", "<", "String", ">", "existentPaths", ")", "{", "return", "_frameProvider", ".", "getFramePath", "(", "this", ",", "action", ",", "type", ",", "existentPaths", ")"...
Returns the path to the image frames for the specified action animation or null if no animation for the specified action is available for this component. @param type null for the normal action frames or one of the custom action sub-types: {@link StandardActions#SHADOW_TYPE}, etc. @param existentPaths the set of all paths for which there are valid frames.
[ "Returns", "the", "path", "to", "the", "image", "frames", "for", "the", "specified", "action", "animation", "or", "null", "if", "no", "animation", "for", "the", "specified", "action", "is", "available", "for", "this", "component", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/cast/CharacterComponent.java#L88-L91
train
threerings/nenya
tools/src/main/java/com/threerings/cast/bundle/tools/MetadataBundlerTask.java
MetadataBundlerTask.nextEntry
protected OutputStream nextEntry (OutputStream lastEntry, String path) throws IOException { ((JarOutputStream)lastEntry).putNextEntry(new JarEntry(path)); return lastEntry; }
java
protected OutputStream nextEntry (OutputStream lastEntry, String path) throws IOException { ((JarOutputStream)lastEntry).putNextEntry(new JarEntry(path)); return lastEntry; }
[ "protected", "OutputStream", "nextEntry", "(", "OutputStream", "lastEntry", ",", "String", "path", ")", "throws", "IOException", "{", "(", "(", "JarOutputStream", ")", "lastEntry", ")", ".", "putNextEntry", "(", "new", "JarEntry", "(", "path", ")", ")", ";", ...
Advances to the next named entry in the bundle and returns the stream to which to write that entry.
[ "Advances", "to", "the", "next", "named", "entry", "in", "the", "bundle", "and", "returns", "the", "stream", "to", "which", "to", "write", "that", "entry", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/tools/src/main/java/com/threerings/cast/bundle/tools/MetadataBundlerTask.java#L164-L169
train
groupon/robo-remote
RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java
QueryBuilder.map
public QueryBuilder map(String query, String method_name, Object... items) throws Exception { JSONObject op = new JSONObject(); if (query != null) op.put(Constants.REQUEST_QUERY, query); java.util.Map<String, Object> operation = new LinkedHashMap<String, Object>(); operation.put(Constants.REQUEST_METHOD_NAME, method_name); if (query != null) queryStringRepresentation += query; queryStringRepresentation += "." + method_name; operation.put(Constants.REQUEST_ARGUMENTS, buildArgsArray(items)); op.put(Constants.REQUEST_OPERATION, operation); JSONArray operations = (JSONArray) request.get(Constants.REQUEST_OPERATIONS); operations.put(op); request.remove(Constants.REQUEST_OPERATIONS); request.put(Constants.REQUEST_OPERATIONS, operations); return this; }
java
public QueryBuilder map(String query, String method_name, Object... items) throws Exception { JSONObject op = new JSONObject(); if (query != null) op.put(Constants.REQUEST_QUERY, query); java.util.Map<String, Object> operation = new LinkedHashMap<String, Object>(); operation.put(Constants.REQUEST_METHOD_NAME, method_name); if (query != null) queryStringRepresentation += query; queryStringRepresentation += "." + method_name; operation.put(Constants.REQUEST_ARGUMENTS, buildArgsArray(items)); op.put(Constants.REQUEST_OPERATION, operation); JSONArray operations = (JSONArray) request.get(Constants.REQUEST_OPERATIONS); operations.put(op); request.remove(Constants.REQUEST_OPERATIONS); request.put(Constants.REQUEST_OPERATIONS, operations); return this; }
[ "public", "QueryBuilder", "map", "(", "String", "query", ",", "String", "method_name", ",", "Object", "...", "items", ")", "throws", "Exception", "{", "JSONObject", "op", "=", "new", "JSONObject", "(", ")", ";", "if", "(", "query", "!=", "null", ")", "op...
Used to get the return from a method call @param query @param method_name @param items @return @throws Exception
[ "Used", "to", "get", "the", "return", "from", "a", "method", "call" ]
12d242faad50bf90f98657ca9a0c0c3ae1993f07
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java#L82-L104
train
groupon/robo-remote
RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java
QueryBuilder.instantiate
public QueryBuilder instantiate(String query, Object... items) throws Exception { JSONObject op = new JSONObject(); if (query != null) op.put(Constants.REQUEST_INSTANTIATE, query); if (query != null) queryStringRepresentation += query; op.put(Constants.REQUEST_ARGUMENTS, buildArgsArray(items)); JSONArray operations = (JSONArray) request.get(Constants.REQUEST_OPERATIONS); operations.put(op); request.remove(Constants.REQUEST_OPERATIONS); request.put(Constants.REQUEST_OPERATIONS, operations); return this; }
java
public QueryBuilder instantiate(String query, Object... items) throws Exception { JSONObject op = new JSONObject(); if (query != null) op.put(Constants.REQUEST_INSTANTIATE, query); if (query != null) queryStringRepresentation += query; op.put(Constants.REQUEST_ARGUMENTS, buildArgsArray(items)); JSONArray operations = (JSONArray) request.get(Constants.REQUEST_OPERATIONS); operations.put(op); request.remove(Constants.REQUEST_OPERATIONS); request.put(Constants.REQUEST_OPERATIONS, operations); return this; }
[ "public", "QueryBuilder", "instantiate", "(", "String", "query", ",", "Object", "...", "items", ")", "throws", "Exception", "{", "JSONObject", "op", "=", "new", "JSONObject", "(", ")", ";", "if", "(", "query", "!=", "null", ")", "op", ".", "put", "(", ...
Used to instantiate a class @param query @param items @return @throws Exception
[ "Used", "to", "instantiate", "a", "class" ]
12d242faad50bf90f98657ca9a0c0c3ae1993f07
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java#L113-L129
train
groupon/robo-remote
RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java
QueryBuilder.buildArgsArray
private JSONArray buildArgsArray(Object ... items) throws Exception { JSONArray args = new JSONArray(); for (int i = 0; i < items.length; i++) { if (items[i] instanceof java.lang.String) { args.put((String) items[i]); } else if (items[i] instanceof Number) { args.put((Number) items[i]); } else if (items[i] instanceof java.lang.Boolean) { args.put((Boolean) items[i]); } else if (items[i] == null) { args.put((Object)null); } else { throw new Exception("Invalid type"); } } return args; }
java
private JSONArray buildArgsArray(Object ... items) throws Exception { JSONArray args = new JSONArray(); for (int i = 0; i < items.length; i++) { if (items[i] instanceof java.lang.String) { args.put((String) items[i]); } else if (items[i] instanceof Number) { args.put((Number) items[i]); } else if (items[i] instanceof java.lang.Boolean) { args.put((Boolean) items[i]); } else if (items[i] == null) { args.put((Object)null); } else { throw new Exception("Invalid type"); } } return args; }
[ "private", "JSONArray", "buildArgsArray", "(", "Object", "...", "items", ")", "throws", "Exception", "{", "JSONArray", "args", "=", "new", "JSONArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "length", ";", "i", ...
Internal function used to build a JSON Array of arguments from a list of items @param items @return @throws Exception
[ "Internal", "function", "used", "to", "build", "a", "JSON", "Array", "of", "arguments", "from", "a", "list", "of", "items" ]
12d242faad50bf90f98657ca9a0c0c3ae1993f07
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java#L137-L163
train
groupon/robo-remote
RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java
QueryBuilder.genericRequest
private QueryBuilder genericRequest(String type, String value) throws Exception { JSONObject op = new JSONObject(); op.put(type, value); JSONArray operations = (JSONArray) request.get(Constants.REQUEST_OPERATIONS); operations.put(op); request.remove(Constants.REQUEST_OPERATIONS); request.put(Constants.REQUEST_OPERATIONS, operations); return this; }
java
private QueryBuilder genericRequest(String type, String value) throws Exception { JSONObject op = new JSONObject(); op.put(type, value); JSONArray operations = (JSONArray) request.get(Constants.REQUEST_OPERATIONS); operations.put(op); request.remove(Constants.REQUEST_OPERATIONS); request.put(Constants.REQUEST_OPERATIONS, operations); return this; }
[ "private", "QueryBuilder", "genericRequest", "(", "String", "type", ",", "String", "value", ")", "throws", "Exception", "{", "JSONObject", "op", "=", "new", "JSONObject", "(", ")", ";", "op", ".", "put", "(", "type", ",", "value", ")", ";", "JSONArray", ...
Creates a key value request @param type @param value @return @throws Exception
[ "Creates", "a", "key", "value", "request" ]
12d242faad50bf90f98657ca9a0c0c3ae1993f07
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java#L227-L235
train
groupon/robo-remote
RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java
QueryBuilder.execute
public JSONArray execute() throws Exception { try { JSONArray retVal = Client.getInstance(port).map(toString()); return retVal; } catch (Exception e) { throw new Exception(queryStringRepresentation + ": " + e.getMessage()); } }
java
public JSONArray execute() throws Exception { try { JSONArray retVal = Client.getInstance(port).map(toString()); return retVal; } catch (Exception e) { throw new Exception(queryStringRepresentation + ": " + e.getMessage()); } }
[ "public", "JSONArray", "execute", "(", ")", "throws", "Exception", "{", "try", "{", "JSONArray", "retVal", "=", "Client", ".", "getInstance", "(", "port", ")", ".", "map", "(", "toString", "(", ")", ")", ";", "return", "retVal", ";", "}", "catch", "(",...
Execute a series of commands @return @throws Exception
[ "Execute", "a", "series", "of", "commands" ]
12d242faad50bf90f98657ca9a0c0c3ae1993f07
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/RoboRemoteClientCommon/src/main/com/groupon/roboremote/roboremoteclientcommon/QueryBuilder.java#L242-L250
train
groupon/robo-remote
UIAutomatorServer/src/main/com/groupon/roboremote/uiautomatorserver/UiAutomatorServer.java
UiAutomatorServer.getInstantiatedClass
protected Object getInstantiatedClass(String query) { if (query.equals(Constants.UIAUTOMATOR_UIDEVICE)) { return device; } return null; }
java
protected Object getInstantiatedClass(String query) { if (query.equals(Constants.UIAUTOMATOR_UIDEVICE)) { return device; } return null; }
[ "protected", "Object", "getInstantiatedClass", "(", "String", "query", ")", "{", "if", "(", "query", ".", "equals", "(", "Constants", ".", "UIAUTOMATOR_UIDEVICE", ")", ")", "{", "return", "device", ";", "}", "return", "null", ";", "}" ]
Implementation of getInstantiatedClass that returns a UiDevice if one is requested @param query @return
[ "Implementation", "of", "getInstantiatedClass", "that", "returns", "a", "UiDevice", "if", "one", "is", "requested" ]
12d242faad50bf90f98657ca9a0c0c3ae1993f07
https://github.com/groupon/robo-remote/blob/12d242faad50bf90f98657ca9a0c0c3ae1993f07/UIAutomatorServer/src/main/com/groupon/roboremote/uiautomatorserver/UiAutomatorServer.java#L52-L57
train
groupon/monsoon
impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java
PushMetricRegistryInstance.setHistory
public synchronized void setHistory(CollectHistory history) { history_ = Optional.of(history); history_.ifPresent(getApi()::setHistory); data_.initWithHistoricalData(history, getDecoratorLookBack()); }
java
public synchronized void setHistory(CollectHistory history) { history_ = Optional.of(history); history_.ifPresent(getApi()::setHistory); data_.initWithHistoricalData(history, getDecoratorLookBack()); }
[ "public", "synchronized", "void", "setHistory", "(", "CollectHistory", "history", ")", "{", "history_", "=", "Optional", ".", "of", "(", "history", ")", ";", "history_", ".", "ifPresent", "(", "getApi", "(", ")", "::", "setHistory", ")", ";", "data_", ".",...
Set the history module that the push processor is to use.
[ "Set", "the", "history", "module", "that", "the", "push", "processor", "is", "to", "use", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java#L72-L76
train
groupon/monsoon
impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java
PushMetricRegistryInstance.beginCollection
@Override protected synchronized CollectionContext beginCollection(DateTime now) { data_.startNewCycle(now, getDecoratorLookBack()); return new CollectionContext() { final Map<GroupName, Alert> alerts = new HashMap<>(); @Override public Consumer<Alert> alertManager() { return (Alert alert) -> { Alert combined = combine_alert_with_past_(alert, alerts_); alerts.put(combined.getName(), combined); }; } @Override public MutableTimeSeriesCollectionPair tsdata() { return data_; } /** * Store a newly completed collection cycle. */ @Override public void commit() { alerts_ = unmodifiableMap(alerts); try { getHistory().ifPresent(history -> history.add(getCollectionData())); } catch (Exception ex) { logger.log(Level.WARNING, "unable to add collection data to history (dropped)", ex); } } }; }
java
@Override protected synchronized CollectionContext beginCollection(DateTime now) { data_.startNewCycle(now, getDecoratorLookBack()); return new CollectionContext() { final Map<GroupName, Alert> alerts = new HashMap<>(); @Override public Consumer<Alert> alertManager() { return (Alert alert) -> { Alert combined = combine_alert_with_past_(alert, alerts_); alerts.put(combined.getName(), combined); }; } @Override public MutableTimeSeriesCollectionPair tsdata() { return data_; } /** * Store a newly completed collection cycle. */ @Override public void commit() { alerts_ = unmodifiableMap(alerts); try { getHistory().ifPresent(history -> history.add(getCollectionData())); } catch (Exception ex) { logger.log(Level.WARNING, "unable to add collection data to history (dropped)", ex); } } }; }
[ "@", "Override", "protected", "synchronized", "CollectionContext", "beginCollection", "(", "DateTime", "now", ")", "{", "data_", ".", "startNewCycle", "(", "now", ",", "getDecoratorLookBack", "(", ")", ")", ";", "return", "new", "CollectionContext", "(", ")", "{...
Begin a new collection cycle. Note that the cycle isn't stored (a call to commitCollection is required). @return A new collection cycle.
[ "Begin", "a", "new", "collection", "cycle", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java#L108-L141
train
groupon/monsoon
impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java
PushMetricRegistryInstance.combine_alert_with_past_
private static Alert combine_alert_with_past_(Alert alert, Map<GroupName, Alert> previous) { Alert result = Optional.ofNullable(previous.get(alert.getName())) .map((prev) -> prev.extend(alert)) .orElse(alert); logger.log(Level.FINE, "emitting alert {0} -> {1}", new Object[]{result.getName(), result.getAlertState().name()}); return result; }
java
private static Alert combine_alert_with_past_(Alert alert, Map<GroupName, Alert> previous) { Alert result = Optional.ofNullable(previous.get(alert.getName())) .map((prev) -> prev.extend(alert)) .orElse(alert); logger.log(Level.FINE, "emitting alert {0} -> {1}", new Object[]{result.getName(), result.getAlertState().name()}); return result; }
[ "private", "static", "Alert", "combine_alert_with_past_", "(", "Alert", "alert", ",", "Map", "<", "GroupName", ",", "Alert", ">", "previous", ")", "{", "Alert", "result", "=", "Optional", ".", "ofNullable", "(", "previous", ".", "get", "(", "alert", ".", "...
Combine a new alert with its previous state. @param alert An emitted alert. @param previous A map with alerts during the previous cycle. @return An alert that its predecessor extended.
[ "Combine", "a", "new", "alert", "with", "its", "previous", "state", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java#L150-L156
train
groupon/monsoon
impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java
PushMetricRegistryInstance.create
public static synchronized PushMetricRegistryInstance create(Supplier<DateTime> now, boolean has_config, EndpointRegistration api) { return new PushMetricRegistryInstance(now, has_config, api); }
java
public static synchronized PushMetricRegistryInstance create(Supplier<DateTime> now, boolean has_config, EndpointRegistration api) { return new PushMetricRegistryInstance(now, has_config, api); }
[ "public", "static", "synchronized", "PushMetricRegistryInstance", "create", "(", "Supplier", "<", "DateTime", ">", "now", ",", "boolean", "has_config", ",", "EndpointRegistration", "api", ")", "{", "return", "new", "PushMetricRegistryInstance", "(", "now", ",", "has...
Create a plain, uninitialized metric registry. The metric registry is registered under its mbeanObjectName(package_name). @param now A function returning DateTime.now(DateTimeZone.UTC). Allowing specifying it, for the benefit of unit tests. @param has_config True if the metric registry instance should mark monsoon as being supplied with a configuration file. @param api The endpoint registration interface. @return An empty metric registry.
[ "Create", "a", "plain", "uninitialized", "metric", "registry", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/impl/src/main/java/com/groupon/lex/metrics/PushMetricRegistryInstance.java#L183-L185
train
threerings/nenya
core/src/main/java/com/threerings/media/image/NinePatchMirage.java
NinePatchMirage.newNinePatchContaining
public static Mirage newNinePatchContaining(NinePatch ninePatch, Rectangle content) { Rectangle bounds = ninePatch.getBoundsSurrounding(content); Mirage mirage = new NinePatchMirage(ninePatch, bounds.width, bounds.height); return new TransformedMirage(mirage, AffineTransform.getTranslateInstance(bounds.x, bounds.y), false); }
java
public static Mirage newNinePatchContaining(NinePatch ninePatch, Rectangle content) { Rectangle bounds = ninePatch.getBoundsSurrounding(content); Mirage mirage = new NinePatchMirage(ninePatch, bounds.width, bounds.height); return new TransformedMirage(mirage, AffineTransform.getTranslateInstance(bounds.x, bounds.y), false); }
[ "public", "static", "Mirage", "newNinePatchContaining", "(", "NinePatch", "ninePatch", ",", "Rectangle", "content", ")", "{", "Rectangle", "bounds", "=", "ninePatch", ".", "getBoundsSurrounding", "(", "content", ")", ";", "Mirage", "mirage", "=", "new", "NinePatch...
Returns a new Mirage that's a NinePatch stretched and positioned to contain the given Rectangle.
[ "Returns", "a", "new", "Mirage", "that", "s", "a", "NinePatch", "stretched", "and", "positioned", "to", "contain", "the", "given", "Rectangle", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/NinePatchMirage.java#L53-L60
train
knowitall/common-java
src/main/java/edu/washington/cs/knowitall/commonlib/Range.java
Range.isDisjoint
public static boolean isDisjoint(Collection<Range> ranges) { List<Range> rangesList = new ArrayList<Range>(ranges.size()); rangesList.addAll(ranges); Collections.sort(rangesList); for (int i = 0; i < rangesList.size() - 1; i++) { Range rCurrent = rangesList.get(i); Range rNext = rangesList.get(i+1); if (rCurrent.overlapsWith(rNext)) { return false; } } return true; }
java
public static boolean isDisjoint(Collection<Range> ranges) { List<Range> rangesList = new ArrayList<Range>(ranges.size()); rangesList.addAll(ranges); Collections.sort(rangesList); for (int i = 0; i < rangesList.size() - 1; i++) { Range rCurrent = rangesList.get(i); Range rNext = rangesList.get(i+1); if (rCurrent.overlapsWith(rNext)) { return false; } } return true; }
[ "public", "static", "boolean", "isDisjoint", "(", "Collection", "<", "Range", ">", "ranges", ")", "{", "List", "<", "Range", ">", "rangesList", "=", "new", "ArrayList", "<", "Range", ">", "(", "ranges", ".", "size", "(", ")", ")", ";", "rangesList", "....
Checks weather the given set of ranges are disjoint, i.e. none of the ranges overlap. @param ranges
[ "Checks", "weather", "the", "given", "set", "of", "ranges", "are", "disjoint", "i", ".", "e", ".", "none", "of", "the", "ranges", "overlap", "." ]
6c3e7b2f13da5afb1306e87a6c322c55b65fddfc
https://github.com/knowitall/common-java/blob/6c3e7b2f13da5afb1306e87a6c322c55b65fddfc/src/main/java/edu/washington/cs/knowitall/commonlib/Range.java#L265-L277
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java
ConfigSupport.escapeString
private static EscapeStringResult escapeString(String s, char quote) { final String[] octal_strings = { "\\0", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\016", "\\017", "\\020", "\\021", "\\022", "\\023", "\\024", "\\025", "\\026", "\\027", "\\030", "\\031", "\\032", "\\033", "\\034", "\\035", "\\036", "\\037", }; StringBuilder result = new StringBuilder(s); boolean needQuotes = s.isEmpty(); for (int i = 0, next_i; i < result.length(); i = next_i) { final int code_point = result.codePointAt(i); next_i = result.offsetByCodePoints(i, 1); if (code_point == 0) { result.replace(i, next_i, "\\0"); next_i = i + 2; needQuotes = true; } else if (code_point == (int)'\\') { result.replace(i, next_i, "\\\\"); next_i = i + 2; needQuotes = true; } else if (code_point == (int)quote) { result.replace(i, next_i, "\\" + quote); next_i = i + 2; needQuotes = true; } else if (code_point < 32) { String octal = octal_strings[code_point]; result.replace(i, next_i, octal); next_i = i + octal.length(); needQuotes = true; } else if (code_point >= 65536) { String repl = String.format("\\U%08x", code_point); result.replace(i, next_i, repl); next_i = i + repl.length(); needQuotes = true; } else if (code_point >= 128) { String repl = String.format("\\u%04x", code_point); result.replace(i, next_i, repl); next_i = i + repl.length(); needQuotes = true; } } return new EscapeStringResult(needQuotes, result); }
java
private static EscapeStringResult escapeString(String s, char quote) { final String[] octal_strings = { "\\0", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\016", "\\017", "\\020", "\\021", "\\022", "\\023", "\\024", "\\025", "\\026", "\\027", "\\030", "\\031", "\\032", "\\033", "\\034", "\\035", "\\036", "\\037", }; StringBuilder result = new StringBuilder(s); boolean needQuotes = s.isEmpty(); for (int i = 0, next_i; i < result.length(); i = next_i) { final int code_point = result.codePointAt(i); next_i = result.offsetByCodePoints(i, 1); if (code_point == 0) { result.replace(i, next_i, "\\0"); next_i = i + 2; needQuotes = true; } else if (code_point == (int)'\\') { result.replace(i, next_i, "\\\\"); next_i = i + 2; needQuotes = true; } else if (code_point == (int)quote) { result.replace(i, next_i, "\\" + quote); next_i = i + 2; needQuotes = true; } else if (code_point < 32) { String octal = octal_strings[code_point]; result.replace(i, next_i, octal); next_i = i + octal.length(); needQuotes = true; } else if (code_point >= 65536) { String repl = String.format("\\U%08x", code_point); result.replace(i, next_i, repl); next_i = i + repl.length(); needQuotes = true; } else if (code_point >= 128) { String repl = String.format("\\u%04x", code_point); result.replace(i, next_i, repl); next_i = i + repl.length(); needQuotes = true; } } return new EscapeStringResult(needQuotes, result); }
[ "private", "static", "EscapeStringResult", "escapeString", "(", "String", "s", ",", "char", "quote", ")", "{", "final", "String", "[", "]", "octal_strings", "=", "{", "\"\\\\0\"", ",", "\"\\\\001\"", ",", "\"\\\\002\"", ",", "\"\\\\003\"", ",", "\"\\\\004\"", ...
Escape a string configuration element. @param s a string. @return the string, between quotes, escaped such that the configuration parser will accept it as a string.
[ "Escape", "a", "string", "configuration", "element", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java#L103-L147
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java
ConfigSupport.quotedString
public static StringBuilder quotedString(String s) { final EscapeStringResult escapeString = escapeString(s, '\"'); final StringBuilder result = escapeString.buffer; result.insert(0, '\"'); result.append('\"'); return result; }
java
public static StringBuilder quotedString(String s) { final EscapeStringResult escapeString = escapeString(s, '\"'); final StringBuilder result = escapeString.buffer; result.insert(0, '\"'); result.append('\"'); return result; }
[ "public", "static", "StringBuilder", "quotedString", "(", "String", "s", ")", "{", "final", "EscapeStringResult", "escapeString", "=", "escapeString", "(", "s", ",", "'", "'", ")", ";", "final", "StringBuilder", "result", "=", "escapeString", ".", "buffer", ";...
Create a quoted string configuration element. @param s a string. @return the string, between quotes, escaped such that the configuration parser will accept it as a string.
[ "Create", "a", "quoted", "string", "configuration", "element", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java#L154-L161
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java
ConfigSupport.maybeQuoteIdentifier
public static StringBuilder maybeQuoteIdentifier(String s) { final EscapeStringResult escapeString = escapeString(s, '\''); final StringBuilder result = escapeString.buffer; final boolean need_quotes = s.isEmpty() || escapeString.needQuotes || KEYWORDS.contains(s) || !IDENTIFIER_MATCHER.test(s); if (need_quotes) { result.insert(0, '\''); result.append('\''); } return result; }
java
public static StringBuilder maybeQuoteIdentifier(String s) { final EscapeStringResult escapeString = escapeString(s, '\''); final StringBuilder result = escapeString.buffer; final boolean need_quotes = s.isEmpty() || escapeString.needQuotes || KEYWORDS.contains(s) || !IDENTIFIER_MATCHER.test(s); if (need_quotes) { result.insert(0, '\''); result.append('\''); } return result; }
[ "public", "static", "StringBuilder", "maybeQuoteIdentifier", "(", "String", "s", ")", "{", "final", "EscapeStringResult", "escapeString", "=", "escapeString", "(", "s", ",", "'", "'", ")", ";", "final", "StringBuilder", "result", "=", "escapeString", ".", "buffe...
Create an identifier configuration element. @param s an identifier @return the identifier as a string, which is escaped and quoted if needed.
[ "Create", "an", "identifier", "configuration", "element", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java#L168-L182
train
groupon/monsoon
intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java
ConfigSupport.durationConfigString
public static StringBuilder durationConfigString(Duration duration) { Duration remainder = duration; long days = remainder.getStandardDays(); remainder = remainder.minus(Duration.standardDays(days)); long hours = remainder.getStandardHours(); remainder = remainder.minus(Duration.standardHours(hours)); long minutes = remainder.getStandardMinutes(); remainder = remainder.minus(Duration.standardMinutes(minutes)); long seconds = remainder.getStandardSeconds(); remainder = remainder.minus(Duration.standardSeconds(seconds)); if (!remainder.isEqual(Duration.ZERO)) Logger.getLogger(ConfigSupport.class.getName()).log(Level.WARNING, "Duration is more precise than configuration will handle: {0}, dropping remainder: {1}", new Object[]{duration, remainder}); StringBuilder result = new StringBuilder(); if (days != 0) { if (result.length() != 0) result.append(' '); result.append(days).append('d'); } if (hours != 0) { if (result.length() != 0) result.append(' '); result.append(hours).append('h'); } if (minutes != 0) { if (result.length() != 0) result.append(' '); result.append(minutes).append('m'); } if (result.length() == 0 || seconds != 0) { if (result.length() != 0) result.append(' '); result.append(seconds).append('s'); } return result; }
java
public static StringBuilder durationConfigString(Duration duration) { Duration remainder = duration; long days = remainder.getStandardDays(); remainder = remainder.minus(Duration.standardDays(days)); long hours = remainder.getStandardHours(); remainder = remainder.minus(Duration.standardHours(hours)); long minutes = remainder.getStandardMinutes(); remainder = remainder.minus(Duration.standardMinutes(minutes)); long seconds = remainder.getStandardSeconds(); remainder = remainder.minus(Duration.standardSeconds(seconds)); if (!remainder.isEqual(Duration.ZERO)) Logger.getLogger(ConfigSupport.class.getName()).log(Level.WARNING, "Duration is more precise than configuration will handle: {0}, dropping remainder: {1}", new Object[]{duration, remainder}); StringBuilder result = new StringBuilder(); if (days != 0) { if (result.length() != 0) result.append(' '); result.append(days).append('d'); } if (hours != 0) { if (result.length() != 0) result.append(' '); result.append(hours).append('h'); } if (minutes != 0) { if (result.length() != 0) result.append(' '); result.append(minutes).append('m'); } if (result.length() == 0 || seconds != 0) { if (result.length() != 0) result.append(' '); result.append(seconds).append('s'); } return result; }
[ "public", "static", "StringBuilder", "durationConfigString", "(", "Duration", "duration", ")", "{", "Duration", "remainder", "=", "duration", ";", "long", "days", "=", "remainder", ".", "getStandardDays", "(", ")", ";", "remainder", "=", "remainder", ".", "minus...
Convert duration to an representation accepted by Configuration parser. @param duration A duration. @return A StringBuilder with the string representation of the duration.
[ "Convert", "duration", "to", "an", "representation", "accepted", "by", "Configuration", "parser", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/intf/src/main/java/com/groupon/lex/metrics/ConfigSupport.java#L200-L237
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/Transport.java
Transport.download
public <R> R download(String uri, ContentHandler<BasicHttpResponse, R> handler) throws RedmineException { final HttpGet request = new HttpGet(uri); return errorCheckingCommunicator.sendRequest(request, handler); }
java
public <R> R download(String uri, ContentHandler<BasicHttpResponse, R> handler) throws RedmineException { final HttpGet request = new HttpGet(uri); return errorCheckingCommunicator.sendRequest(request, handler); }
[ "public", "<", "R", ">", "R", "download", "(", "String", "uri", ",", "ContentHandler", "<", "BasicHttpResponse", ",", "R", ">", "handler", ")", "throws", "RedmineException", "{", "final", "HttpGet", "request", "=", "new", "HttpGet", "(", "uri", ")", ";", ...
Downloads a redmine content. @param uri target uri. @param handler content handler. @return handler result. @throws RedmineException if something goes wrong.
[ "Downloads", "a", "redmine", "content", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/Transport.java#L288-L293
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/Transport.java
Transport.upload
public String upload(InputStream content) throws RedmineException { final URI uploadURI = getURIConfigurator().getUploadURI(); final HttpPost request = new HttpPost(uploadURI); final AbstractHttpEntity entity = new InputStreamEntity(content, -1); /* Content type required by a Redmine */ entity.setContentType("application/octet-stream"); request.setEntity(entity); final String result = getCommunicator().sendRequest(request); return parseResponse(result, "upload", RedmineJSONParser.UPLOAD_TOKEN_PARSER); }
java
public String upload(InputStream content) throws RedmineException { final URI uploadURI = getURIConfigurator().getUploadURI(); final HttpPost request = new HttpPost(uploadURI); final AbstractHttpEntity entity = new InputStreamEntity(content, -1); /* Content type required by a Redmine */ entity.setContentType("application/octet-stream"); request.setEntity(entity); final String result = getCommunicator().sendRequest(request); return parseResponse(result, "upload", RedmineJSONParser.UPLOAD_TOKEN_PARSER); }
[ "public", "String", "upload", "(", "InputStream", "content", ")", "throws", "RedmineException", "{", "final", "URI", "uploadURI", "=", "getURIConfigurator", "(", ")", ".", "getUploadURI", "(", ")", ";", "final", "HttpPost", "request", "=", "new", "HttpPost", "...
UPloads content on a server. @param content content stream. @return uploaded item token. @throws RedmineException if something goes wrong.
[ "UPloads", "content", "on", "a", "server", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/Transport.java#L304-L315
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/internal/Transport.java
Transport.getObjectsList
public <T> List<T> getObjectsList(Class<T> objectClass, Collection<? extends NameValuePair> params) throws RedmineException { final EntityConfig<T> config = getConfig(objectClass); final List<T> result = new ArrayList<T>(); final List<NameValuePair> newParams = new ArrayList<NameValuePair>( params); newParams.add(new BasicNameValuePair("limit", String .valueOf(objectsPerPage))); int offset = 0; int totalObjectsFoundOnServer; do { List<NameValuePair> paramsList = new ArrayList<NameValuePair>( newParams); paramsList.add(new BasicNameValuePair("offset", String .valueOf(offset))); final URI uri = getURIConfigurator().getObjectsURI(objectClass, paramsList); logger.debug(uri.toString()); final HttpGet http = new HttpGet(uri); final String response = getCommunicator().sendRequest(http); logger.debug("received: " + response); final List<T> foundItems; try { final JSONObject responseObject = RedmineJSONParser .getResponse(response); foundItems = JsonInput.getListOrNull(responseObject, config.multiObjectName, config.parser); result.addAll(foundItems); /* Necessary for trackers */ if (!responseObject.has(KEY_TOTAL_COUNT)) { break; } totalObjectsFoundOnServer = JsonInput.getInt(responseObject, KEY_TOTAL_COUNT); } catch (JSONException e) { throw new RedmineFormatException(e); } if (foundItems.size() == 0) { break; } offset += foundItems.size(); } while (offset < totalObjectsFoundOnServer); return result; }
java
public <T> List<T> getObjectsList(Class<T> objectClass, Collection<? extends NameValuePair> params) throws RedmineException { final EntityConfig<T> config = getConfig(objectClass); final List<T> result = new ArrayList<T>(); final List<NameValuePair> newParams = new ArrayList<NameValuePair>( params); newParams.add(new BasicNameValuePair("limit", String .valueOf(objectsPerPage))); int offset = 0; int totalObjectsFoundOnServer; do { List<NameValuePair> paramsList = new ArrayList<NameValuePair>( newParams); paramsList.add(new BasicNameValuePair("offset", String .valueOf(offset))); final URI uri = getURIConfigurator().getObjectsURI(objectClass, paramsList); logger.debug(uri.toString()); final HttpGet http = new HttpGet(uri); final String response = getCommunicator().sendRequest(http); logger.debug("received: " + response); final List<T> foundItems; try { final JSONObject responseObject = RedmineJSONParser .getResponse(response); foundItems = JsonInput.getListOrNull(responseObject, config.multiObjectName, config.parser); result.addAll(foundItems); /* Necessary for trackers */ if (!responseObject.has(KEY_TOTAL_COUNT)) { break; } totalObjectsFoundOnServer = JsonInput.getInt(responseObject, KEY_TOTAL_COUNT); } catch (JSONException e) { throw new RedmineFormatException(e); } if (foundItems.size() == 0) { break; } offset += foundItems.size(); } while (offset < totalObjectsFoundOnServer); return result; }
[ "public", "<", "T", ">", "List", "<", "T", ">", "getObjectsList", "(", "Class", "<", "T", ">", "objectClass", ",", "Collection", "<", "?", "extends", "NameValuePair", ">", "params", ")", "throws", "RedmineException", "{", "final", "EntityConfig", "<", "T",...
Returns an object list. @return objects list, never NULL
[ "Returns", "an", "object", "list", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/internal/Transport.java#L346-L400
train
jdillon/gshell
gshell-api/src/main/java/com/planet57/gshell/command/CommandActionSupport.java
CommandActionSupport.discoverCompleter
@Nonnull protected Completer discoverCompleter() { log.debug("Discovering completer"); // TODO: Could probably use CliProcessorAware to avoid re-creating this CliProcessor cli = new CliProcessor(); cli.addBean(this); List<ArgumentDescriptor> argumentDescriptors = cli.getArgumentDescriptors(); Collections.sort(argumentDescriptors); if (log.isDebugEnabled()) { log.debug("Argument descriptors:"); argumentDescriptors.forEach(descriptor -> log.debug(" {}", descriptor)); } List<Completer> completers = new LinkedList<>(); // attempt to resolve @Complete on each argument argumentDescriptors.forEach(descriptor -> { AccessibleObject accessible = descriptor.getSetter().getAccessible(); if (accessible != null) { Complete complete = accessible.getAnnotation(Complete.class); if (complete != null) { Completer completer = namedCompleters.get(complete.value()); checkState(completer != null, "Missing named completer: %s", complete.value()); completers.add(completer); } } }); // short-circuit if no completers detected if (completers.isEmpty()) { return NullCompleter.INSTANCE; } if (log.isDebugEnabled()) { log.debug("Discovered completers:"); completers.forEach(completer -> { log.debug(" {}", completer); }); } // append terminal completer for strict completers.add(NullCompleter.INSTANCE); ArgumentCompleter completer = new ArgumentCompleter(completers); completer.setStrict(true); return completer; }
java
@Nonnull protected Completer discoverCompleter() { log.debug("Discovering completer"); // TODO: Could probably use CliProcessorAware to avoid re-creating this CliProcessor cli = new CliProcessor(); cli.addBean(this); List<ArgumentDescriptor> argumentDescriptors = cli.getArgumentDescriptors(); Collections.sort(argumentDescriptors); if (log.isDebugEnabled()) { log.debug("Argument descriptors:"); argumentDescriptors.forEach(descriptor -> log.debug(" {}", descriptor)); } List<Completer> completers = new LinkedList<>(); // attempt to resolve @Complete on each argument argumentDescriptors.forEach(descriptor -> { AccessibleObject accessible = descriptor.getSetter().getAccessible(); if (accessible != null) { Complete complete = accessible.getAnnotation(Complete.class); if (complete != null) { Completer completer = namedCompleters.get(complete.value()); checkState(completer != null, "Missing named completer: %s", complete.value()); completers.add(completer); } } }); // short-circuit if no completers detected if (completers.isEmpty()) { return NullCompleter.INSTANCE; } if (log.isDebugEnabled()) { log.debug("Discovered completers:"); completers.forEach(completer -> { log.debug(" {}", completer); }); } // append terminal completer for strict completers.add(NullCompleter.INSTANCE); ArgumentCompleter completer = new ArgumentCompleter(completers); completer.setStrict(true); return completer; }
[ "@", "Nonnull", "protected", "Completer", "discoverCompleter", "(", ")", "{", "log", ".", "debug", "(", "\"Discovering completer\"", ")", ";", "// TODO: Could probably use CliProcessorAware to avoid re-creating this", "CliProcessor", "cli", "=", "new", "CliProcessor", "(", ...
Discover the completer for the command. @since 3.0
[ "Discover", "the", "completer", "for", "the", "command", "." ]
b587c1a4672d2e4905871462fa3b38a1f7b94e90
https://github.com/jdillon/gshell/blob/b587c1a4672d2e4905871462fa3b38a1f7b94e90/gshell-api/src/main/java/com/planet57/gshell/command/CommandActionSupport.java#L105-L154
train
Systemdir/GML-Writer-for-yED
Example/src/com/github/systemdir/gml/examples/example1/Example.java
Example.getSimpleGraphFromUser
public static SimpleGraph<String, DefaultEdge> getSimpleGraphFromUser() { Scanner sc = new Scanner(System.in); SimpleGraph<String, DefaultEdge> graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); // input number of vertices int verticeAmount; do { System.out.print("Enter the number of vertices (more than one): "); verticeAmount = sc.nextInt(); } while (verticeAmount <= 1); // input vertices for (int i = 1; i <= verticeAmount; i++) { System.out.print("Enter vertex name " + i + ": "); String input = sc.next(); if (graph.vertexSet().contains(input)) { System.err.println("vertex with that name already exists"); i--; } else { graph.addVertex(input); } } // input edges System.out.println("\nEnter edge (name => name)"); String userWantsToContinue; do { String e1, e2; do { System.out.print("Edge from: "); e1 = sc.next(); } while (!graph.vertexSet().contains(e1)); do { System.out.print("Edge to: "); e2 = sc.next(); } while (!graph.vertexSet().contains(e2)); graph.addEdge(e1, e2); // add another edge? System.out.print("Add more edges? (y/n): "); userWantsToContinue = sc.next(); }while (userWantsToContinue.equals("y") || userWantsToContinue.equals("yes") || userWantsToContinue.equals("1")); return graph; }
java
public static SimpleGraph<String, DefaultEdge> getSimpleGraphFromUser() { Scanner sc = new Scanner(System.in); SimpleGraph<String, DefaultEdge> graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); // input number of vertices int verticeAmount; do { System.out.print("Enter the number of vertices (more than one): "); verticeAmount = sc.nextInt(); } while (verticeAmount <= 1); // input vertices for (int i = 1; i <= verticeAmount; i++) { System.out.print("Enter vertex name " + i + ": "); String input = sc.next(); if (graph.vertexSet().contains(input)) { System.err.println("vertex with that name already exists"); i--; } else { graph.addVertex(input); } } // input edges System.out.println("\nEnter edge (name => name)"); String userWantsToContinue; do { String e1, e2; do { System.out.print("Edge from: "); e1 = sc.next(); } while (!graph.vertexSet().contains(e1)); do { System.out.print("Edge to: "); e2 = sc.next(); } while (!graph.vertexSet().contains(e2)); graph.addEdge(e1, e2); // add another edge? System.out.print("Add more edges? (y/n): "); userWantsToContinue = sc.next(); }while (userWantsToContinue.equals("y") || userWantsToContinue.equals("yes") || userWantsToContinue.equals("1")); return graph; }
[ "public", "static", "SimpleGraph", "<", "String", ",", "DefaultEdge", ">", "getSimpleGraphFromUser", "(", ")", "{", "Scanner", "sc", "=", "new", "Scanner", "(", "System", ".", "in", ")", ";", "SimpleGraph", "<", "String", ",", "DefaultEdge", ">", "graph", ...
Asks the user to input an graph @return graph inputted by the user
[ "Asks", "the", "user", "to", "input", "an", "graph" ]
353ecf132929889cb15968865283ee511f7c8d87
https://github.com/Systemdir/GML-Writer-for-yED/blob/353ecf132929889cb15968865283ee511f7c8d87/Example/src/com/github/systemdir/gml/examples/example1/Example.java#L43-L89
train
threerings/nenya
core/src/main/java/com/threerings/media/tile/TrimmedTile.java
TrimmedTile.getTrimmedBounds
public void getTrimmedBounds (Rectangle tbounds) { tbounds.setBounds(_tbounds.x, _tbounds.y, _mirage.getWidth(), _mirage.getHeight()); }
java
public void getTrimmedBounds (Rectangle tbounds) { tbounds.setBounds(_tbounds.x, _tbounds.y, _mirage.getWidth(), _mirage.getHeight()); }
[ "public", "void", "getTrimmedBounds", "(", "Rectangle", "tbounds", ")", "{", "tbounds", ".", "setBounds", "(", "_tbounds", ".", "x", ",", "_tbounds", ".", "y", ",", "_mirage", ".", "getWidth", "(", ")", ",", "_mirage", ".", "getHeight", "(", ")", ")", ...
Fills in the bounds of the trimmed image within the coordinate system defined by the complete virtual tile.
[ "Fills", "in", "the", "bounds", "of", "the", "trimmed", "image", "within", "the", "coordinate", "system", "defined", "by", "the", "complete", "virtual", "tile", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/tile/TrimmedTile.java#L67-L70
train
threerings/nenya
core/src/main/java/com/threerings/media/image/NinePatch.java
NinePatch.getBoundsSurrounding
public Rectangle getBoundsSurrounding (Rectangle content) { Rectangle bounds = new Rectangle(content); bounds.width += _leftPad + _rightPad; bounds.height += _topPad + _bottomPad; bounds.x -= _leftPad; bounds.y -= _topPad; return bounds; }
java
public Rectangle getBoundsSurrounding (Rectangle content) { Rectangle bounds = new Rectangle(content); bounds.width += _leftPad + _rightPad; bounds.height += _topPad + _bottomPad; bounds.x -= _leftPad; bounds.y -= _topPad; return bounds; }
[ "public", "Rectangle", "getBoundsSurrounding", "(", "Rectangle", "content", ")", "{", "Rectangle", "bounds", "=", "new", "Rectangle", "(", "content", ")", ";", "bounds", ".", "width", "+=", "_leftPad", "+", "_rightPad", ";", "bounds", ".", "height", "+=", "_...
Returns a rectangle describing the bounds of this NinePatch when drawn such that it frames the given content rectangle.
[ "Returns", "a", "rectangle", "describing", "the", "bounds", "of", "this", "NinePatch", "when", "drawn", "such", "that", "it", "frames", "the", "given", "content", "rectangle", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/NinePatch.java#L206-L216
train
threerings/nenya
core/src/main/java/com/threerings/media/image/NinePatch.java
NinePatch.getRectangle
protected static Rectangle getRectangle (BufferedImage img, boolean stretch) { Rectangle rect = new Rectangle(0, 0, img.getWidth() - 2, img.getHeight() - 2); for (int xx = 1; xx < rect.width + 1; xx++) { if (ImageUtil.hitTest(img, xx, stretch ? 0 : img.getHeight() - 1)) { rect.x = xx - 1; rect.width -= rect.x; break; } } for (int xx = img.getWidth() - 1; xx >= rect.x + 1; xx--) { if (ImageUtil.hitTest(img, xx, stretch ? 0 : img.getHeight() - 1)) { rect.width = xx - rect.x; break; } } for (int yy = 1; yy < rect.height + 1; yy++) { if (ImageUtil.hitTest(img, stretch ? 0 : img.getWidth() - 1, yy)) { rect.y = yy - 1; rect.height -= rect.y; break; } } for (int yy = img.getHeight() - 1; yy >= rect.y + 1; yy--) { if (ImageUtil.hitTest(img, stretch ? 0 : img.getWidth() - 1, yy)) { rect.height = yy - rect.y; break; } } return rect; }
java
protected static Rectangle getRectangle (BufferedImage img, boolean stretch) { Rectangle rect = new Rectangle(0, 0, img.getWidth() - 2, img.getHeight() - 2); for (int xx = 1; xx < rect.width + 1; xx++) { if (ImageUtil.hitTest(img, xx, stretch ? 0 : img.getHeight() - 1)) { rect.x = xx - 1; rect.width -= rect.x; break; } } for (int xx = img.getWidth() - 1; xx >= rect.x + 1; xx--) { if (ImageUtil.hitTest(img, xx, stretch ? 0 : img.getHeight() - 1)) { rect.width = xx - rect.x; break; } } for (int yy = 1; yy < rect.height + 1; yy++) { if (ImageUtil.hitTest(img, stretch ? 0 : img.getWidth() - 1, yy)) { rect.y = yy - 1; rect.height -= rect.y; break; } } for (int yy = img.getHeight() - 1; yy >= rect.y + 1; yy--) { if (ImageUtil.hitTest(img, stretch ? 0 : img.getWidth() - 1, yy)) { rect.height = yy - rect.y; break; } } return rect; }
[ "protected", "static", "Rectangle", "getRectangle", "(", "BufferedImage", "img", ",", "boolean", "stretch", ")", "{", "Rectangle", "rect", "=", "new", "Rectangle", "(", "0", ",", "0", ",", "img", ".", "getWidth", "(", ")", "-", "2", ",", "img", ".", "g...
Parses the image to find the bounds of the rectangle defined by pixels on the outside.
[ "Parses", "the", "image", "to", "find", "the", "bounds", "of", "the", "rectangle", "defined", "by", "pixels", "on", "the", "outside", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/media/image/NinePatch.java#L221-L256
train
threerings/nenya
core/src/main/java/com/threerings/miso/client/DirtyItemList.java
DirtyItemList.appendDirtySprite
public void appendDirtySprite (Sprite sprite, int tx, int ty) { DirtyItem item = getDirtyItem(); item.init(sprite, tx, ty); _items.add(item); }
java
public void appendDirtySprite (Sprite sprite, int tx, int ty) { DirtyItem item = getDirtyItem(); item.init(sprite, tx, ty); _items.add(item); }
[ "public", "void", "appendDirtySprite", "(", "Sprite", "sprite", ",", "int", "tx", ",", "int", "ty", ")", "{", "DirtyItem", "item", "=", "getDirtyItem", "(", ")", ";", "item", ".", "init", "(", "sprite", ",", "tx", ",", "ty", ")", ";", "_items", ".", ...
Appends the dirty sprite at the given coordinates to the dirty item list. @param sprite the dirty sprite itself. @param tx the sprite's x tile position. @param ty the sprite's y tile position.
[ "Appends", "the", "dirty", "sprite", "at", "the", "given", "coordinates", "to", "the", "dirty", "item", "list", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/DirtyItemList.java#L56-L61
train
threerings/nenya
core/src/main/java/com/threerings/miso/client/DirtyItemList.java
DirtyItemList.appendDirtyObject
public void appendDirtyObject (SceneObject scobj) { DirtyItem item = getDirtyItem(); item.init(scobj, scobj.info.x, scobj.info.y); _items.add(item); }
java
public void appendDirtyObject (SceneObject scobj) { DirtyItem item = getDirtyItem(); item.init(scobj, scobj.info.x, scobj.info.y); _items.add(item); }
[ "public", "void", "appendDirtyObject", "(", "SceneObject", "scobj", ")", "{", "DirtyItem", "item", "=", "getDirtyItem", "(", ")", ";", "item", ".", "init", "(", "scobj", ",", "scobj", ".", "info", ".", "x", ",", "scobj", ".", "info", ".", "y", ")", "...
Appends the dirty object tile at the given coordinates to the dirty item list. @param scobj the scene object that is dirty.
[ "Appends", "the", "dirty", "object", "tile", "at", "the", "given", "coordinates", "to", "the", "dirty", "item", "list", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/DirtyItemList.java#L68-L73
train
threerings/nenya
core/src/main/java/com/threerings/miso/client/DirtyItemList.java
DirtyItemList.paintAndClear
public void paintAndClear (Graphics2D gfx) { int icount = _items.size(); for (int ii = 0; ii < icount; ii++) { DirtyItem item = _items.get(ii); item.paint(gfx); item.clear(); _freelist.add(item); } _items.clear(); }
java
public void paintAndClear (Graphics2D gfx) { int icount = _items.size(); for (int ii = 0; ii < icount; ii++) { DirtyItem item = _items.get(ii); item.paint(gfx); item.clear(); _freelist.add(item); } _items.clear(); }
[ "public", "void", "paintAndClear", "(", "Graphics2D", "gfx", ")", "{", "int", "icount", "=", "_items", ".", "size", "(", ")", ";", "for", "(", "int", "ii", "=", "0", ";", "ii", "<", "icount", ";", "ii", "++", ")", "{", "DirtyItem", "item", "=", "...
Paints all the dirty items in this list using the supplied graphics context. The items are removed from the dirty list after being painted and the dirty list ends up empty.
[ "Paints", "all", "the", "dirty", "items", "in", "this", "list", "using", "the", "supplied", "graphics", "context", ".", "The", "items", "are", "removed", "from", "the", "dirty", "list", "after", "being", "painted", "and", "the", "dirty", "list", "ends", "u...
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/DirtyItemList.java#L158-L168
train
threerings/nenya
core/src/main/java/com/threerings/miso/client/DirtyItemList.java
DirtyItemList.clear
public void clear () { for (int icount = _items.size(); icount > 0; icount--) { DirtyItem item = _items.remove(0); item.clear(); _freelist.add(item); } }
java
public void clear () { for (int icount = _items.size(); icount > 0; icount--) { DirtyItem item = _items.remove(0); item.clear(); _freelist.add(item); } }
[ "public", "void", "clear", "(", ")", "{", "for", "(", "int", "icount", "=", "_items", ".", "size", "(", ")", ";", "icount", ">", "0", ";", "icount", "--", ")", "{", "DirtyItem", "item", "=", "_items", ".", "remove", "(", "0", ")", ";", "item", ...
Clears out any items that were in this list.
[ "Clears", "out", "any", "items", "that", "were", "in", "this", "list", "." ]
3165a012fd859009db3367f87bd2a5b820cc760a
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/miso/client/DirtyItemList.java#L173-L180
train
groupon/monsoon
expr/src/main/java/com/groupon/lex/metrics/timeseries/TimeSeriesMetricAggregate.java
TimeSeriesMetricAggregate.mapAndReduce
private Intermediate mapAndReduce(Context ctx) { /* Fetch each metric wildcard and add it to the to-be-processed list. */ final List<Map.Entry<Tags, MetricValue>> matcher_tsvs = matchers_.stream() .flatMap(m -> m.filter(ctx)) .map(named_entry -> SimpleMapEntry.create(named_entry.getKey().getTags(), named_entry.getValue())) .collect(Collectors.toList()); /* Resolve each expression. */ final Map<Boolean, List<TimeSeriesMetricDeltaSet>> expr_tsvs_map = exprs_.stream() .map(expr -> expr.apply(ctx)) .collect(Collectors.partitioningBy(TimeSeriesMetricDeltaSet::isVector)); final List<TimeSeriesMetricDeltaSet> expr_tsvs = expr_tsvs_map.getOrDefault(true, Collections.emptyList()); final Optional<T> scalar = expr_tsvs_map.getOrDefault(false, Collections.emptyList()) .stream() .map(tsv_set -> map_(tsv_set.asScalar().get())) .reduce(this::reducer_); /* * Reduce everything using the reducer (in the derived class). */ return new Intermediate(scalar, unmodifiableMap(aggregation_.apply( matcher_tsvs.stream(), expr_tsvs.stream().flatMap(TimeSeriesMetricDeltaSet::streamAsMap), Map.Entry::getKey, Map.Entry::getKey, Map.Entry::getValue, Map.Entry::getValue) .entrySet().stream() .map(entry -> { return entry.getValue().stream().map(this::map_) .reduce(this::reducer_) .map(v -> SimpleMapEntry.create(entry.getKey(), v)); }) .flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue())))); }
java
private Intermediate mapAndReduce(Context ctx) { /* Fetch each metric wildcard and add it to the to-be-processed list. */ final List<Map.Entry<Tags, MetricValue>> matcher_tsvs = matchers_.stream() .flatMap(m -> m.filter(ctx)) .map(named_entry -> SimpleMapEntry.create(named_entry.getKey().getTags(), named_entry.getValue())) .collect(Collectors.toList()); /* Resolve each expression. */ final Map<Boolean, List<TimeSeriesMetricDeltaSet>> expr_tsvs_map = exprs_.stream() .map(expr -> expr.apply(ctx)) .collect(Collectors.partitioningBy(TimeSeriesMetricDeltaSet::isVector)); final List<TimeSeriesMetricDeltaSet> expr_tsvs = expr_tsvs_map.getOrDefault(true, Collections.emptyList()); final Optional<T> scalar = expr_tsvs_map.getOrDefault(false, Collections.emptyList()) .stream() .map(tsv_set -> map_(tsv_set.asScalar().get())) .reduce(this::reducer_); /* * Reduce everything using the reducer (in the derived class). */ return new Intermediate(scalar, unmodifiableMap(aggregation_.apply( matcher_tsvs.stream(), expr_tsvs.stream().flatMap(TimeSeriesMetricDeltaSet::streamAsMap), Map.Entry::getKey, Map.Entry::getKey, Map.Entry::getValue, Map.Entry::getValue) .entrySet().stream() .map(entry -> { return entry.getValue().stream().map(this::map_) .reduce(this::reducer_) .map(v -> SimpleMapEntry.create(entry.getKey(), v)); }) .flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty)) .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue())))); }
[ "private", "Intermediate", "mapAndReduce", "(", "Context", "ctx", ")", "{", "/* Fetch each metric wildcard and add it to the to-be-processed list. */", "final", "List", "<", "Map", ".", "Entry", "<", "Tags", ",", "MetricValue", ">", ">", "matcher_tsvs", "=", "matchers_"...
Create a reduction of the matchers and expressions for a given context. @param ctx The context on which to apply the reduction. @return A reduction.
[ "Create", "a", "reduction", "of", "the", "matchers", "and", "expressions", "for", "a", "given", "context", "." ]
eb68d72ba4c01fe018dc981097dbee033908f5c7
https://github.com/groupon/monsoon/blob/eb68d72ba4c01fe018dc981097dbee033908f5c7/expr/src/main/java/com/groupon/lex/metrics/timeseries/TimeSeriesMetricAggregate.java#L130-L161
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/RedmineManager.java
RedmineManager.getIssues
public List<Issue> getIssues(Map<String, String> pParameters) throws RedmineException { Set<NameValuePair> params = new HashSet<NameValuePair>(); for (final Entry<String, String> param : pParameters.entrySet()) { params.add(new BasicNameValuePair(param.getKey(), param.getValue())); } return transport.getObjectsList(Issue.class, params); }
java
public List<Issue> getIssues(Map<String, String> pParameters) throws RedmineException { Set<NameValuePair> params = new HashSet<NameValuePair>(); for (final Entry<String, String> param : pParameters.entrySet()) { params.add(new BasicNameValuePair(param.getKey(), param.getValue())); } return transport.getObjectsList(Issue.class, params); }
[ "public", "List", "<", "Issue", ">", "getIssues", "(", "Map", "<", "String", ",", "String", ">", "pParameters", ")", "throws", "RedmineException", "{", "Set", "<", "NameValuePair", ">", "params", "=", "new", "HashSet", "<", "NameValuePair", ">", "(", ")", ...
Generic method to search for issues. @param pParameters the http parameters key/value pairs to append to the rest api request @return empty list if not issues with this summary field exist, never NULL @throws RedmineAuthenticationException invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments. @throws NotFoundException @throws RedmineException
[ "Generic", "method", "to", "search", "for", "issues", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/RedmineManager.java#L194-L202
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/RedmineManager.java
RedmineManager.deleteRelation
public void deleteRelation(Integer id) throws RedmineException { transport.deleteObject(IssueRelation.class, Integer.toString(id)); }
java
public void deleteRelation(Integer id) throws RedmineException { transport.deleteObject(IssueRelation.class, Integer.toString(id)); }
[ "public", "void", "deleteRelation", "(", "Integer", "id", ")", "throws", "RedmineException", "{", "transport", ".", "deleteObject", "(", "IssueRelation", ".", "class", ",", "Integer", ".", "toString", "(", "id", ")", ")", ";", "}" ]
Delete Issue Relation with the given ID.
[ "Delete", "Issue", "Relation", "with", "the", "given", "ID", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/RedmineManager.java#L459-L461
train
stephenc/redmine-java-api
src/main/java/org/redmine/ta/RedmineManager.java
RedmineManager.uploadAttachment
public Attachment uploadAttachment(String fileName, String contentType, InputStream content) throws RedmineException, IOException { final InputStream wrapper = new MarkedInputStream(content, "uploadStream"); final String token; try { token = transport.upload(wrapper); final Attachment result = new Attachment(); result.setToken(token); result.setContentType(contentType); result.setFileName(fileName); return result; } catch (RedmineException e) { unwrapIO(e, "uploadStream"); throw e; } }
java
public Attachment uploadAttachment(String fileName, String contentType, InputStream content) throws RedmineException, IOException { final InputStream wrapper = new MarkedInputStream(content, "uploadStream"); final String token; try { token = transport.upload(wrapper); final Attachment result = new Attachment(); result.setToken(token); result.setContentType(contentType); result.setFileName(fileName); return result; } catch (RedmineException e) { unwrapIO(e, "uploadStream"); throw e; } }
[ "public", "Attachment", "uploadAttachment", "(", "String", "fileName", ",", "String", "contentType", ",", "InputStream", "content", ")", "throws", "RedmineException", ",", "IOException", "{", "final", "InputStream", "wrapper", "=", "new", "MarkedInputStream", "(", "...
Uploads an attachement. @param fileName file name of the attachement. @param contentType content type of the attachement. @param content attachement content stream. @return attachement content. @throws RedmineException if something goes wrong. @throws IOException if input cannot be read. This exception cannot be thrown yet (I am not sure if http client can distinguish "network" errors and local errors) but is will be good to distinguish reading errors and transport errors.
[ "Uploads", "an", "attachement", "." ]
7e5270c84aba32d74a506260ec47ff86ab6c9d84
https://github.com/stephenc/redmine-java-api/blob/7e5270c84aba32d74a506260ec47ff86ab6c9d84/src/main/java/org/redmine/ta/RedmineManager.java#L693-L709
train